]> git.pld-linux.org Git - packages/kernel.git/blob - 2.2.21-ppc_11.patch
- obsolete
[packages/kernel.git] / 2.2.21-ppc_11.patch
1 diff -urN linux.orig/arch/ppc/boot/Makefile linux/arch/ppc/boot/Makefile
2 --- linux.orig/arch/ppc/boot/Makefile   Sun Mar 25 18:31:49 2001
3 +++ linux/arch/ppc/boot/Makefile        Fri Jul 12 19:00:55 2002
4 @@ -69,7 +69,7 @@
5  zvmlinux.initrd: zvmlinux
6         $(LD) $(ZLINKFLAGS) -o zvmlinux.initrd.tmp $(OBJECTS)
7         $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \
8 -               --add-section=initrd=../coffboot/ramdisk.image.gz \
9 +               --add-section=initrd=ramdisk.image.gz \
10                 --add-section=image=../coffboot/vmlinux.gz \
11                 zvmlinux.initrd.tmp zvmlinux.initrd
12         $(CC) $(CFLAGS) -DINITRD_OFFSET=`sh offset $(OBJDUMP) zvmlinux.initrd initrd` \
13 @@ -79,7 +79,7 @@
14                 -c -o misc.o misc.c
15         $(LD) $(ZLINKFLAGS) -o zvmlinux.initrd.tmp $(OBJECTS)
16         $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \
17 -               --add-section=initrd=../coffboot/ramdisk.image.gz \
18 +               --add-section=initrd=ramdisk.image.gz \
19                 --add-section=image=../coffboot/vmlinux.gz \
20                 zvmlinux.initrd.tmp $@
21         rm zvmlinux.initrd.tmp
22 diff -urN linux.orig/arch/ppc/coffboot/Makefile linux/arch/ppc/coffboot/Makefile
23 --- linux.orig/arch/ppc/coffboot/Makefile       Sun Mar 25 18:31:49 2001
24 +++ linux/arch/ppc/coffboot/Makefile    Thu Jul 11 15:43:29 2002
25 @@ -9,13 +9,12 @@
26  LD     = $(CROSS_COMPILE)ld
27  CFLAGS = $(CPPFLAGS) -O -fno-builtin -I$(HPATH)
28  OBJCOPY = $(CROSS_COMPILE)objcopy
29 -OBJCOPY_ARGS = -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
30 -COFF_LD_ARGS = -e _start -T ld.script -Ttext 500000 -Tdata 510000 -Bstatic
31 -CHRP_LD_ARGS = -Ttext 0x01000000
32 +OBJCOPY_ARGS = -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment \
33 +       --add-section=image=vmlinux.gz
34 +LD_ARGS = -e _start -T ld.script -Ttext 500000 -Tdata 510000 -Bstatic
35  GZ = gzip -9
36  
37 -COFFOBJS = coffcrt0.o start.o coffmain.o misc.o string.o zlib.o image.o
38 -CHRPOBJS = crt0.o start.o chrpmain.o misc.o string.o zlib.o image.o
39 +OBJS = crt0.o start.o main.o misc.o string.o zlib.o
40  LIBS = $(TOPDIR)/lib/lib.a
41  
42  ifeq ($(CONFIG_PPC64),y)
43 @@ -34,81 +33,39 @@
44  hack-coff: hack-coff.c
45         $(HOSTCC) $(HOSTCFLAGS) -o hack-coff hack-coff.c
46  
47 -znetboot: vmlinux.coff zImage vmlinux.elf
48 -       cp vmlinux.coff $(TFTPIMAGE)
49 -       cp vmlinux.elf $(TFTPIMAGE).elf
50 -
51 -znetboot.initrd: vmlinux.coff.initrd vmlinux.elf.initrd
52 -       cp vmlinux.coff.initrd $(TFTPIMAGE)
53 -       cp vmlinux.elf.initrd $(TFTPIMAGE).elf
54 -
55  floppy: zImage
56  #      mount -t hfs /dev/fd0 /mnt
57  #      cp vmlinux.coff /mnt
58  #      umount /mnt
59  
60 -coffboot: $(COFFOBJS) no_initrd.o ld.script
61 -       $(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) no_initrd.o $(LIBS)
62 -
63 -coffboot.initrd: $(COFFOBJS) initrd.o ld.script
64 -       $(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) initrd.o $(LIBS)
65 +znetboot: vmlinux.coff
66 +       cp vmlinux.coff $(TFTPIMAGE)
67  
68 -piggyback: piggyback.c
69 -       $(HOSTCC) $(HOSTCFLAGS) -DKERNELBASE=$(KERNELBASE) -o piggyback piggyback.c
70 +znetboot.initrd: vmlinux.coff.initrd
71 +       cp vmlinux.coff.initrd $(TFTPIMAGE)
72  
73 -mknote: mknote.c
74 -       $(HOSTCC) $(HOSTCFLAGS) -o mknote mknote.c
75 +coffboot: $(OBJS) ld.script
76 +       $(LD) -o coffboot $(LD_ARGS) $(OBJS) $(LIBS)
77  
78 -image.o: piggyback vmlinux.gz
79 -       ./piggyback image < vmlinux.gz | $(AS) -o image.o
80 +zImage: vmlinux.coff
81  
82 -initrd.o: ramdisk.image.gz piggyback
83 -       ./piggyback initrd < ramdisk.image.gz | $(AS) -o initrd.o
84 +zImage.initrd: vmlinux.coff.initrd
85  
86 -vmlinux.coff: coffboot hack-coff
87 +vmlinux.coff: coffboot hack-coff vmlinux.gz
88         $(OBJCOPY) $(OBJCOPY_ARGS) coffboot $@
89         ./hack-coff $@
90         ln -sf vmlinux.coff zImage
91  
92 -vmlinux.coff.initrd: coffboot.initrd hack-coff
93 -       $(OBJCOPY) $(OBJCOPY_ARGS) coffboot.initrd $@
94 +vmlinux.coff.initrd: coffboot hack-coff vmlinux.gz ramdisk.image.gz
95 +       $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=initrd=ramdisk.image.gz \
96 +               coffboot $@
97         ./hack-coff $@
98  
99 -vmlinux.elf: $(CHRPOBJS) no_initrd.o mknote
100 -       $(LD) $(CHRP_LD_ARGS) -o $@ $(CHRPOBJS) no_initrd.o $(LIBS)
101 -       ./mknote > note
102 -       $(OBJCOPY) $@ $@ --add-section=.note=note -R .comment
103 -
104 -vmlinux.elf.initrd: $(CHRPOBJS) initrd.o mknote
105 -       $(LD) $(CHRP_LD_ARGS) -o $@ $(CHRPOBJS) initrd.o $(LIBS)
106 -       ./mknote > note
107 -       $(OBJCOPY) $@ $@ --add-section=.note=note -R .comment
108 -
109 -micoffboot: dummy.o
110 -       $(LD) -o $@ $(COFF_LD_ARGS) dummy.o $(LIBS)
111 -
112 -miboot.image: micoffboot hack-coff vmlinux.gz
113 -       $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=image=vmlinux.gz micoffboot $@
114 -       ./hack-coff $@
115 -
116 -miboot.image.initrd: micoffboot hack-coff vmlinux.gz ramdisk.image.gz
117 -       $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=image=vmlinux.gz \
118 -       --add-section=initrd=ramdisk.image.gz micoffboot $@
119 -       ./hack-coff $@
120 -
121 -zImage: vmlinux.coff vmlinux.elf miboot.image
122 -
123 -zImage.initrd: vmlinux.coff.initrd vmlinux.elf.initrd miboot.image.initrd
124 -
125  else
126  znetboot: vmlinux.gz
127  
128  znetboot.initrd: vmlinux.gz
129  
130 -miboot.image: vmlinux.gz
131 -
132 -miboot.image.initrd: vmlinux.gz
133 -
134  coffboot: vmlinux.gz
135  
136  zImage: vmlinux.gz
137 @@ -129,7 +86,5 @@
138  
139  clean:
140         rm -f hack-coff coffboot zImage vmlinux.coff vmlinux.gz
141 -       rm -f mknote piggyback vmlinux.elf note
142 -       rm -f micoffboot miboot.image
143  
144  fastdep:
145 diff -urN linux.orig/arch/ppc/coffboot/chrpmain.c linux/arch/ppc/coffboot/chrpmain.c
146 --- linux.orig/arch/ppc/coffboot/chrpmain.c     Sun Mar 25 18:31:49 2001
147 +++ linux/arch/ppc/coffboot/chrpmain.c  Thu Jan  1 01:00:00 1970
148 @@ -1,252 +0,0 @@
149 -/*
150 - * Copyright (C) Paul Mackerras 1997.
151 - *
152 - * This program is free software; you can redistribute it and/or
153 - * modify it under the terms of the GNU General Public License
154 - * as published by the Free Software Foundation; either version
155 - * 2 of the License, or (at your option) any later version.
156 - */
157 -#include "nonstdio.h"
158 -#include "zlib.h"
159 -
160 -extern void *finddevice(const char *);
161 -extern int getprop(void *, const char *, void *, int);
162 -void gunzip(void *, int, unsigned char *, int *);
163 -void stop_imac_ethernet(void);
164 -void stop_imac_usb(void);
165 -
166 -#define get_16be(x)    (*(unsigned short *)(x))
167 -#define get_32be(x)    (*(unsigned *)(x))
168 -
169 -#define RAM_END                (16 << 20)
170 -
171 -#define PROG_START     0x00010000
172 -#define PROG_SIZE      0x003f0000
173 -
174 -#define SCRATCH_SIZE   (128 << 10)
175 -
176 -char *avail_ram;
177 -char *begin_avail, *end_avail;
178 -char *avail_high;
179 -unsigned int heap_use;
180 -unsigned int heap_max;
181 -
182 -extern char _end[];
183 -extern char image_data[];
184 -extern int image_len;
185 -extern char initrd_data[];
186 -extern int initrd_len;
187 -
188 -
189 -boot(int a1, int a2, void *prom)
190 -{
191 -    int ns, oh, i;
192 -    unsigned sa, len;
193 -    void *dst;
194 -    unsigned char *im;
195 -    unsigned initrd_start, initrd_size;
196 -    extern char _start;
197 -    
198 -    printf("chrpboot starting: loaded at 0x%x\n", &_start);
199 -    if (initrd_len) {
200 -       initrd_size = initrd_len;
201 -       initrd_start = (RAM_END - initrd_size) & ~0xFFF;
202 -       a1 = initrd_start;
203 -       a2 = initrd_size;
204 -       claim(initrd_start, RAM_END - initrd_start, 0);
205 -       printf("initial ramdisk moving 0x%x <- 0x%x (%x bytes)\n",
206 -              initrd_start, initrd_data, initrd_size);
207 -       memcpy((char *)initrd_start, initrd_data, initrd_size);
208 -    }
209 -    im = image_data;
210 -    len = image_len;
211 -    /* claim 3MB starting at PROG_START */
212 -    claim(PROG_START, PROG_SIZE, 0);
213 -    dst = (void *) PROG_START;
214 -    if (im[0] == 0x1f && im[1] == 0x8b) {
215 -       /* claim some memory for scratch space */
216 -       avail_ram = (char *) claim(0, SCRATCH_SIZE, 0x10);
217 -       begin_avail = avail_high = avail_ram;
218 -       end_avail = avail_ram + SCRATCH_SIZE;
219 -       printf("heap at 0x%x\n", avail_ram);
220 -       printf("gunzipping (0x%x <- 0x%x:0x%0x)...", dst, im, im+len);
221 -       gunzip(dst, PROG_SIZE, im, &len);
222 -       printf("done %u bytes\n", len);
223 -       printf("%u bytes of heap consumed, max in use %u\n",
224 -              avail_high - begin_avail, heap_max);
225 -    } else {
226 -       memmove(dst, im, len);
227 -    }
228 -
229 -    flush_cache(dst, len);
230 -#if 0
231 -    stop_imac_ethernet();
232 -    stop_imac_usb();
233 -#endif
234 -
235 -    sa = (unsigned long)PROG_START;
236 -    printf("start address = 0x%x\n", sa);
237 -
238 -    (*(void (*)())sa)(a1, a2, prom);
239 -
240 -    printf("returned?\n");
241 -
242 -    pause();
243 -}
244 -
245 -#if 0
246 -#define eieio()        asm volatile("eieio");
247 -
248 -void stop_imac_ethernet(void)
249 -{
250 -    void *macio, *enet;
251 -    unsigned int macio_addr[5], enet_reg[6];
252 -    int len;
253 -    volatile unsigned int *dbdma;
254 -
255 -    macio = finddevice("/pci/mac-io");
256 -    enet = finddevice("/pci/mac-io/ethernet");
257 -    if (macio == NULL || enet == NULL)
258 -       return;
259 -    len = getprop(macio, "assigned-addresses", macio_addr, sizeof(macio_addr));
260 -    if (len != sizeof(macio_addr))
261 -       return;
262 -    len = getprop(enet, "reg", enet_reg, sizeof(enet_reg));
263 -    if (len != sizeof(enet_reg))
264 -       return;
265 -    printf("macio base %x, dma at %x & %x\n",
266 -          macio_addr[2], enet_reg[2], enet_reg[4]);
267 -
268 -    /* hope this is mapped... */
269 -    dbdma = (volatile unsigned int *) (macio_addr[2] + enet_reg[2]);
270 -    *dbdma = 0x80;     /* clear the RUN bit */
271 -    eieio();
272 -    dbdma = (volatile unsigned int *) (macio_addr[2] + enet_reg[4]);
273 -    *dbdma = 0x80;     /* clear the RUN bit */
274 -    eieio();
275 -}
276 -
277 -void stop_imac_usb(void)
278 -{
279 -    void *usb;
280 -    unsigned int usb_addr[5];
281 -    int len;
282 -    volatile unsigned int *usb_ctrl;
283 -
284 -    usb = finddevice("/pci/usb");
285 -    if (usb == NULL)
286 -       return;
287 -    len = getprop(usb, "assigned-addresses", usb_addr, sizeof(usb_addr));
288 -    if (len != sizeof(usb_addr))
289 -       return;
290 -    printf("usb base %x\n", usb_addr[2]);
291 -
292 -    usb_ctrl = (volatile unsigned int *) (usb_addr[2] + 8);
293 -    *usb_ctrl = 0x01000000;    /* cpu_to_le32(1) */
294 -    eieio();
295 -}
296 -#endif
297 -
298 -struct memchunk {
299 -    unsigned int size;
300 -    struct memchunk *next;
301 -};
302 -
303 -static struct memchunk *freechunks;
304 -
305 -void *zalloc(void *x, unsigned items, unsigned size)
306 -{
307 -    void *p;
308 -    struct memchunk **mpp, *mp;
309 -
310 -    size *= items;
311 -    size = (size + 7) & -8;
312 -    heap_use += size;
313 -    if (heap_use > heap_max)
314 -       heap_max = heap_use;
315 -    for (mpp = &freechunks; (mp = *mpp) != 0; mpp = &mp->next) {
316 -       if (mp->size == size) {
317 -           *mpp = mp->next;
318 -           return mp;
319 -       }
320 -    }
321 -    p = avail_ram;
322 -    avail_ram += size;
323 -    if (avail_ram > avail_high)
324 -       avail_high = avail_ram;
325 -    if (avail_ram > end_avail) {
326 -       printf("oops... out of memory\n");
327 -       pause();
328 -    }
329 -    return p;
330 -}
331 -
332 -void zfree(void *x, void *addr, unsigned nb)
333 -{
334 -    struct memchunk *mp = addr;
335 -
336 -    nb = (nb + 7) & -8;
337 -    heap_use -= nb;
338 -    if (avail_ram == addr + nb) {
339 -       avail_ram = addr;
340 -       return;
341 -    }
342 -    mp->size = nb;
343 -    mp->next = freechunks;
344 -    freechunks = mp;
345 -}
346 -
347 -#define HEAD_CRC       2
348 -#define EXTRA_FIELD    4
349 -#define ORIG_NAME      8
350 -#define COMMENT                0x10
351 -#define RESERVED       0xe0
352 -
353 -#define DEFLATED       8
354 -
355 -void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
356 -{
357 -    z_stream s;
358 -    int r, i, flags;
359 -
360 -    /* skip header */
361 -    i = 10;
362 -    flags = src[3];
363 -    if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
364 -       printf("bad gzipped data\n");
365 -       exit();
366 -    }
367 -    if ((flags & EXTRA_FIELD) != 0)
368 -       i = 12 + src[10] + (src[11] << 8);
369 -    if ((flags & ORIG_NAME) != 0)
370 -       while (src[i++] != 0)
371 -           ;
372 -    if ((flags & COMMENT) != 0)
373 -       while (src[i++] != 0)
374 -           ;
375 -    if ((flags & HEAD_CRC) != 0)
376 -       i += 2;
377 -    if (i >= *lenp) {
378 -       printf("gunzip: ran out of data in header\n");
379 -       exit();
380 -    }
381 -
382 -    s.zalloc = zalloc;
383 -    s.zfree = zfree;
384 -    r = inflateInit2(&s, -MAX_WBITS);
385 -    if (r != Z_OK) {
386 -       printf("inflateInit2 returned %d\n", r);
387 -       exit();
388 -    }
389 -    s.next_in = src + i;
390 -    s.avail_in = *lenp - i;
391 -    s.next_out = dst;
392 -    s.avail_out = dstlen;
393 -    r = inflate(&s, Z_FINISH);
394 -    if (r != Z_OK && r != Z_STREAM_END) {
395 -       printf("inflate returned %d msg: %s\n", r, s.msg);
396 -       exit();
397 -    }
398 -    *lenp = s.next_out - (unsigned char *) dst;
399 -    inflateEnd(&s);
400 -}
401 diff -urN linux.orig/arch/ppc/coffboot/coffcrt0.S linux/arch/ppc/coffboot/coffcrt0.S
402 --- linux.orig/arch/ppc/coffboot/coffcrt0.S     Sun Mar 25 18:31:49 2001
403 +++ linux/arch/ppc/coffboot/coffcrt0.S  Thu Jan  1 01:00:00 1970
404 @@ -1,24 +0,0 @@
405 -/*
406 - * Copyright (C) Paul Mackerras 1997.
407 - *
408 - * This program is free software; you can redistribute it and/or
409 - * modify it under the terms of the GNU General Public License
410 - * as published by the Free Software Foundation; either version
411 - * 2 of the License, or (at your option) any later version.
412 - */
413 -       .text
414 -       .globl  _start
415 -_start:
416 -       .long   __start,0,0
417 -
418 -       .globl  __start
419 -__start:
420 -       lis     9,_start@h
421 -       lis     8,_etext@ha
422 -       addi    8,8,_etext@l
423 -1:     dcbf    0,9
424 -       icbi    0,9
425 -       addi    9,9,0x20
426 -       cmplwi  0,9,8
427 -       blt     1b
428 -       b       start
429 diff -urN linux.orig/arch/ppc/coffboot/coffmain.c linux/arch/ppc/coffboot/coffmain.c
430 --- linux.orig/arch/ppc/coffboot/coffmain.c     Sun Mar 25 18:31:49 2001
431 +++ linux/arch/ppc/coffboot/coffmain.c  Thu Jan  1 01:00:00 1970
432 @@ -1,157 +0,0 @@
433 -/*
434 - * Copyright (C) Paul Mackerras 1997.
435 - *
436 - * This program is free software; you can redistribute it and/or
437 - * modify it under the terms of the GNU General Public License
438 - * as published by the Free Software Foundation; either version
439 - * 2 of the License, or (at your option) any later version.
440 - */
441 -#include "nonstdio.h"
442 -#include "zlib.h"
443 -
444 -extern void *finddevice(const char *);
445 -extern int getprop(void *, const char *, void *, int);
446 -extern char *claim(unsigned, unsigned, unsigned);
447 -void gunzip(void *, int, unsigned char *, int *);
448 -
449 -#define get_16be(x)    (*(unsigned short *)(x))
450 -#define get_32be(x)    (*(unsigned *)(x))
451 -
452 -#define RAM_START      0xc0000000
453 -#define PROG_START     RAM_START
454 -#define RAM_END                (RAM_START + 0x800000)  /* only 8M mapped with BATs */
455 -
456 -char *avail_ram;
457 -char *end_avail;
458 -
459 -extern char _start[], _end[];
460 -extern char image_data[];
461 -extern int image_len;
462 -extern char initrd_data[];
463 -extern int initrd_len;
464 -
465 -
466 -boot(int a1, int a2, void *prom)
467 -{
468 -    int ns, oh, i;
469 -    unsigned sa, len;
470 -    void *dst;
471 -    unsigned char *im;
472 -    unsigned initrd_start, initrd_size;
473 -    
474 -    printf("coffboot starting: loaded at 0x%x\n", _start);
475 -    setup_bats(RAM_START);
476 -    if (initrd_len) {
477 -       initrd_size = initrd_len;
478 -       initrd_start = (RAM_END - initrd_size) & ~0xFFF;
479 -       a1 = initrd_start;
480 -       a2 = initrd_size;
481 -       claim(initrd_start - RAM_START, RAM_END - initrd_start, 0);
482 -       printf("initial ramdisk moving 0x%x <- 0x%x (%x bytes)\n",
483 -              initrd_start, initrd_data, initrd_size);
484 -       memcpy((char *)initrd_start, initrd_data, initrd_size);
485 -    }
486 -    im = image_data;
487 -    len = image_len;
488 -    /* claim 3MB starting at 0 */
489 -    claim(0, 3 << 20, 0);
490 -    dst = (void *) RAM_START;
491 -    if (im[0] == 0x1f && im[1] == 0x8b) {
492 -       /* claim 512kB for scratch space */
493 -       avail_ram = claim(0, 512 << 10, 0x10) + RAM_START;
494 -       end_avail = avail_ram + (512 << 10);
495 -       printf("avail_ram = %x\n", avail_ram);
496 -       printf("gunzipping (0x%x <- 0x%x:0x%0x)...", dst, im, im+len);
497 -       gunzip(dst, 3 << 20, im, &len);
498 -       printf("done %u bytes\n", len);
499 -    } else {
500 -       memmove(dst, im, len);
501 -    }
502 -
503 -    flush_cache(dst, len);
504 -    
505 -    sa = (unsigned long)PROG_START;
506 -    printf("start address = 0x%x\n", sa);
507 -
508 -#if 0
509 -    pause();
510 -#endif
511 -    (*(void (*)())sa)(a1, a2, prom);
512 -
513 -    printf("returned?\n");
514 -
515 -    pause();
516 -}
517 -
518 -void *zalloc(void *x, unsigned items, unsigned size)
519 -{
520 -    void *p = avail_ram;
521 -
522 -    size *= items;
523 -    size = (size + 7) & -8;
524 -    avail_ram += size;
525 -    if (avail_ram > end_avail) {
526 -       printf("oops... out of memory\n");
527 -       pause();
528 -    }
529 -    return p;
530 -}
531 -
532 -void zfree(void *x, void *addr, unsigned nb)
533 -{
534 -}
535 -
536 -#define HEAD_CRC       2
537 -#define EXTRA_FIELD    4
538 -#define ORIG_NAME      8
539 -#define COMMENT                0x10
540 -#define RESERVED       0xe0
541 -
542 -#define DEFLATED       8
543 -
544 -void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp)
545 -{
546 -    z_stream s;
547 -    int r, i, flags;
548 -
549 -    /* skip header */
550 -    i = 10;
551 -    flags = src[3];
552 -    if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
553 -       printf("bad gzipped data\n");
554 -       exit();
555 -    }
556 -    if ((flags & EXTRA_FIELD) != 0)
557 -       i = 12 + src[10] + (src[11] << 8);
558 -    if ((flags & ORIG_NAME) != 0)
559 -       while (src[i++] != 0)
560 -           ;
561 -    if ((flags & COMMENT) != 0)
562 -       while (src[i++] != 0)
563 -           ;
564 -    if ((flags & HEAD_CRC) != 0)
565 -       i += 2;
566 -    if (i >= *lenp) {
567 -       printf("gunzip: ran out of data in header\n");
568 -       exit();
569 -    }
570 -
571 -    s.zalloc = zalloc;
572 -    s.zfree = zfree;
573 -    r = inflateInit2(&s, -MAX_WBITS);
574 -    if (r != Z_OK) {
575 -       printf("inflateInit2 returned %d\n", r);
576 -       exit();
577 -    }
578 -    s.next_in = src + i;
579 -    s.avail_in = *lenp - i;
580 -    s.next_out = dst;
581 -    s.avail_out = dstlen;
582 -    r = inflate(&s, Z_FINISH);
583 -    if (r != Z_OK && r != Z_STREAM_END) {
584 -       printf("inflate returned %d msg: %s\n", r, s.msg);
585 -       exit();
586 -    }
587 -    *lenp = s.next_out - (unsigned char *) dst;
588 -    inflateEnd(&s);
589 -}
590 diff -urN linux.orig/arch/ppc/coffboot/crt0.S linux/arch/ppc/coffboot/crt0.S
591 --- linux.orig/arch/ppc/coffboot/crt0.S Sun Mar 25 18:31:49 2001
592 +++ linux/arch/ppc/coffboot/crt0.S      Thu Jul 11 15:43:29 2002
593 @@ -9,6 +9,10 @@
594         .text
595         .globl  _start
596  _start:
597 +       .long   __start,0,0
598 +
599 +       .globl  __start
600 +__start:
601         lis     9,_start@h
602         lis     8,_etext@ha
603         addi    8,8,_etext@l
604 diff -urN linux.orig/arch/ppc/coffboot/dummy.c linux/arch/ppc/coffboot/dummy.c
605 --- linux.orig/arch/ppc/coffboot/dummy.c        Sun Mar 25 18:31:49 2001
606 +++ linux/arch/ppc/coffboot/dummy.c     Thu Jan  1 01:00:00 1970
607 @@ -1,4 +0,0 @@
608 -int main(void)
609 -{
610 -       return 0;
611 -}
612 diff -urN linux.orig/arch/ppc/coffboot/misc.S linux/arch/ppc/coffboot/misc.S
613 --- linux.orig/arch/ppc/coffboot/misc.S Sun Mar 25 18:31:49 2001
614 +++ linux/arch/ppc/coffboot/misc.S      Thu Jul 11 15:43:29 2002
615 @@ -14,26 +14,23 @@
616   */
617         .globl  setup_bats
618  setup_bats:
619 -       mfpvr   5
620 -       rlwinm  5,5,16,16,31            /* r3 = 1 for 601, 4 for 604 */
621 -       cmpi    0,5,1
622 -       li      0,0
623 +       mr      4,3
624 +       mfpvr   3
625 +       rlwinm  3,3,16,16,31            /* r3 = 1 for 601, 4 for 604 */
626 +       cmpi    0,3,1
627         bne     4f
628 -       mtibatl 3,0                     /* invalidate BAT first */
629 -       ori     3,3,4                   /* set up BAT registers for 601 */
630 -       li      4,0x7f
631 -       mtibatu 3,3
632 -       mtibatl 3,4
633 -       b       5f
634 -4:     mtdbatu 3,0                     /* invalidate BATs first */
635 -       mtibatu 3,0
636 -       ori     3,3,0xff                /* set up BAT registers for 604 */
637 -       li      4,2
638 -       mtdbatl 3,4
639 -       mtdbatu 3,3
640 -       mtibatl 3,4
641 -       mtibatu 3,3
642 -5:     sync
643 +       ori     4,4,4                   /* set up BAT registers for 601 */
644 +       li      5,0x7f
645 +       mtibatu 3,4
646 +       mtibatl 3,5
647 +       isync
648 +       blr
649 +4:     ori     4,4,0xfe                /* set up BAT registers for 604 */
650 +       li      5,2
651 +       mtdbatl 3,5
652 +       mtdbatu 3,4
653 +       mtibatl 3,5
654 +       mtibatu 3,4
655         isync
656         blr
657  
658 diff -urN linux.orig/arch/ppc/coffboot/mknote.c linux/arch/ppc/coffboot/mknote.c
659 --- linux.orig/arch/ppc/coffboot/mknote.c       Sun Mar 25 18:31:49 2001
660 +++ linux/arch/ppc/coffboot/mknote.c    Thu Jan  1 01:00:00 1970
661 @@ -1,43 +0,0 @@
662 -/*
663 - * Copyright (C) Cort Dougan 1999.
664 - *
665 - * This program is free software; you can redistribute it and/or
666 - * modify it under the terms of the GNU General Public License
667 - * as published by the Free Software Foundation; either version
668 - * 2 of the License, or (at your option) any later version.
669 - *
670 - * Generate a note section as per the CHRP specification.
671 - *
672 - */
673 -
674 -#include <stdio.h>
675 -
676 -#define PL(x) printf("%c%c%c%c", ((x)>>24)&0xff, ((x)>>16)&0xff, ((x)>>8)&0xff, (x)&0xff );
677 -
678 -int main(void)
679 -{
680 -/* header */
681 -       /* namesz */
682 -       PL(strlen("PowerPC")+1);
683 -       /* descrsz */
684 -       PL(6*4);
685 -       /* type */
686 -       PL(0x1275);
687 -       /* name */
688 -       printf("PowerPC"); printf("%c", 0);
689 -       
690 -/* descriptor */
691 -       /* real-mode */
692 -       PL(0xffffffff);
693 -       /* real-base */
694 -       PL(0x00c00000);
695 -       /* real-size */
696 -       PL(0xffffffff);
697 -       /* virt-base */
698 -       PL(0xffffffff);
699 -       /* virt-size */
700 -       PL(0xffffffff);
701 -       /* load-base */
702 -       PL(0x4000);
703 -       return 0;
704 -}
705 diff -urN linux.orig/arch/ppc/coffboot/no_initrd.c linux/arch/ppc/coffboot/no_initrd.c
706 --- linux.orig/arch/ppc/coffboot/no_initrd.c    Sun Mar 25 18:31:49 2001
707 +++ linux/arch/ppc/coffboot/no_initrd.c Thu Jan  1 01:00:00 1970
708 @@ -1,2 +0,0 @@
709 -char initrd_data[1];
710 -int initrd_len = 0;
711 diff -urN linux.orig/arch/ppc/coffboot/piggyback.c linux/arch/ppc/coffboot/piggyback.c
712 --- linux.orig/arch/ppc/coffboot/piggyback.c    Sun Mar 25 18:31:49 2001
713 +++ linux/arch/ppc/coffboot/piggyback.c Thu Jan  1 01:00:00 1970
714 @@ -1,65 +0,0 @@
715 -#include <stdio.h>
716 -
717 -extern long ce_exec_config[];
718 -
719 -main(int argc, char *argv[])
720 -{
721 -       int i, cnt, pos, len;
722 -       unsigned int cksum, val;
723 -       unsigned char *lp;
724 -       unsigned char buf[8192];
725 -       if (argc != 2)
726 -       {
727 -               fprintf(stderr, "usage: %s name <in-file >out-file\n",
728 -                       argv[0]);
729 -               exit(1);
730 -       }
731 -       fprintf(stdout, "#\n");
732 -       fprintf(stdout, "# Miscellaneous data structures:\n");
733 -       fprintf(stdout, "# WARNING - this file is automatically generated!\n");
734 -       fprintf(stdout, "#\n");
735 -       fprintf(stdout, "\n");
736 -       fprintf(stdout, "\t.data\n");
737 -       fprintf(stdout, "\t.globl %s_data\n", argv[1]);
738 -       fprintf(stdout, "%s_data:\n", argv[1]);
739 -       pos = 0;
740 -       cksum = 0;
741 -       while ((len = read(0, buf, sizeof(buf))) > 0)
742 -       {
743 -               cnt = 0;
744 -               lp = (unsigned char *)buf;
745 -               len = (len + 3) & ~3;  /* Round up to longwords */
746 -               for (i = 0;  i < len;  i += 4)
747 -               {
748 -                       if (cnt == 0)
749 -                       {
750 -                               fprintf(stdout, "\t.long\t");
751 -                       }
752 -                       fprintf(stdout, "0x%02X%02X%02X%02X", lp[0], lp[1], lp[2], lp[3]);
753 -                       val = *(unsigned long *)lp;
754 -                       cksum ^= val;
755 -                       lp += 4;
756 -                       if (++cnt == 4)
757 -                       {
758 -                               cnt = 0;
759 -                               fprintf(stdout, " # %x \n", pos+i-12);
760 -                               fflush(stdout);
761 -                       } else
762 -                       {
763 -                               fprintf(stdout, ",");
764 -                       }
765 -               }
766 -               if (cnt)
767 -               {
768 -                       fprintf(stdout, "0\n");
769 -               }
770 -               pos += len;
771 -       }
772 -       fprintf(stdout, "\t.globl %s_len\n", argv[1]);
773 -       fprintf(stdout, "%s_len:\t.long\t0x%x\n", argv[1], pos);
774 -       fflush(stdout);
775 -       fclose(stdout);
776 -       fprintf(stderr, "cksum = %x\n", cksum);
777 -       exit(0);
778 -}
779 -
780 diff -urN linux.orig/arch/ppc/coffboot/start.c linux/arch/ppc/coffboot/start.c
781 --- linux.orig/arch/ppc/coffboot/start.c        Sun Mar 25 18:31:49 2001
782 +++ linux/arch/ppc/coffboot/start.c     Thu Jul 11 15:43:29 2002
783 @@ -33,7 +33,7 @@
784      if (getprop(chosen_handle, "stdin", &stdin, sizeof(stdin)) != 4)
785         exit();
786  
787 -    boot(a1, a2, promptr);
788 +    coffboot(a1, a2, promptr);
789      for (;;)
790         exit();
791  }
792 @@ -62,25 +62,6 @@
793      return args.actual;
794  }
795  
796 -int writestring(void *f, char *ptr, int nb)
797 -{
798 -       int w = 0, i;
799 -       char *ret = "\r";
800 -
801 -       for (i = 0; i < nb; ++i) {
802 -               if (ptr[i] == '\n') {
803 -                       if (i > w) {
804 -                               write(f, ptr + w, i - w);
805 -                               w = i;
806 -                       }
807 -                       write(f, ret, 1);
808 -               }
809 -       }
810 -       if (w < nb)
811 -               write(f, ptr + w, nb - w);
812 -       return nb;
813 -}
814 -
815  int
816  read(void *handle, void *ptr, int nb)
817  {
818 @@ -149,29 +130,6 @@
819      return args.phandle;
820  }
821  
822 -void *
823 -claim(unsigned int virt, unsigned int size, unsigned int align)
824 -{
825 -    struct prom_args {
826 -       char *service;
827 -       int nargs;
828 -       int nret;
829 -       unsigned int virt;
830 -       unsigned int size;
831 -       unsigned int align;
832 -       void *ret;
833 -    } args;
834 -
835 -    args.service = "claim";
836 -    args.nargs = 3;
837 -    args.nret = 1;
838 -    args.virt = virt;
839 -    args.size = size;
840 -    args.align = align;
841 -    (*prom)(&args);
842 -    return args.ret;
843 -}
844 -
845  int
846  getprop(void *phandle, const char *name, void *buf, int buflen)
847  {
848 @@ -203,7 +161,9 @@
849  {
850      char ch = c;
851  
852 -    return writestring(f, &ch, 1) == 1? c: -1;
853 +    if (c == '\n')
854 +       putc('\r', f);
855 +    return write(f, &ch, 1) == 1? c: -1;
856  }
857  
858  int
859 @@ -217,7 +177,7 @@
860  {
861      int n = strlen(str);
862  
863 -    return writestring(f, str, n) == n? 0: -1;
864 +    return write(f, str, n) == n? 0: -1;
865  }
866  
867  int
868 @@ -230,7 +190,7 @@
869         case 1:
870             return ch;
871         case -1:
872 -           printk("read(stdin) returned -1\n");
873 +           printk("read(stdin) returned -1\r\n");
874             return -1;
875         }
876      }
877 @@ -304,7 +264,7 @@
878         va_start(args, fmt);
879         n = vsprintf(sprint_buf, fmt, args);
880         va_end(args);
881 -       writestring(stdout, sprint_buf, n);
882 +       write(stdout, sprint_buf, n);
883  }
884  
885  int
886 @@ -316,6 +276,6 @@
887         va_start(args, fmt);
888         n = vsprintf(sprint_buf, fmt, args);
889         va_end(args);
890 -       writestring(stdout, sprint_buf, n);
891 +       write(stdout, sprint_buf, n);
892         return n;
893  }
894 diff -urN linux.orig/arch/ppc/common_defconfig linux/arch/ppc/common_defconfig
895 --- linux.orig/arch/ppc/common_defconfig        Sun Mar 25 18:31:50 2001
896 +++ linux/arch/ppc/common_defconfig     Fri Jul 12 18:54:54 2002
897 @@ -16,7 +16,6 @@
898  # CONFIG_GEMINI is not set
899  # CONFIG_MBX is not set
900  # CONFIG_SMP is not set
901 -CONFIG_ALTIVEC=y
902  CONFIG_6xx=y
903  
904  #
905 diff -urN linux.orig/arch/ppc/config.in linux/arch/ppc/config.in
906 --- linux.orig/arch/ppc/config.in       Fri Nov  2 17:39:05 2001
907 +++ linux/arch/ppc/config.in    Thu Jul 11 15:43:29 2002
908 @@ -22,10 +22,6 @@
909  
910  bool 'Symmetric multi-processing support' CONFIG_SMP
911  
912 -if [ "$CONFIG_6xx" = "y" ]; then
913 -  bool 'Altivec (G4) support' CONFIG_ALTIVEC
914 -fi
915 -
916  if [ "$CONFIG_ALL_PPC" != "y" ]; then
917    define_bool CONFIG_MACH_SPECIFIC y
918  fi
919 diff -urN linux.orig/arch/ppc/kernel/Makefile linux/arch/ppc/kernel/Makefile
920 --- linux.orig/arch/ppc/kernel/Makefile Sun Mar 25 18:31:48 2001
921 +++ linux/arch/ppc/kernel/Makefile      Fri Jul 12 19:09:44 2002
922 @@ -7,13 +7,8 @@
923  #
924  # Note 2! The CFLAGS definitions are now in the main makefile...
925  
926 -# Once a gas that groks -mvec is generally available, we'll use it...
927  .S.o:
928 -#ifdef CONFIG_ALTIVEC
929 -#      $(CC) $(CFLAGS) -D__ASSEMBLY__ -Wa,-mvec -c $< -o $*.o
930 -#else
931         $(CC) $(CFLAGS) -D__ASSEMBLY__ -c $< -o $*.o
932 -#endif
933  
934  O_TARGET := kernel.o
935  OX_OBJS := ppc_ksyms.o setup.o
936 @@ -36,40 +31,20 @@
937  
938  ifeq ($(CONFIG_MBX),y)
939  O_OBJS += mbx_setup.o mbx_pci.o softemu8xx.o i8259.o ppc8xx_pic.o
940 -endif
941 +else
942  ifeq ($(CONFIG_APUS),y)
943  O_OBJS += apus_setup.o prom.o openpic.o
944 +else
945 +ifneq ($(CONFIG_MBX),y)
946 +O_OBJS += prep_time.o pmac_time.o chrp_time.o \
947 +         pmac_setup.o pmac_support.o \
948 +         prep_pci.o pmac_pci.o chrp_pci.o \
949 +         residual.o prom.o openpic.o feature.o \
950 +         prep_nvram.o open_pic.o i8259.o pmac_pic.o indirect_pci.o \
951 +         gemini_pci.o gemini_prom.o gemini_setup.o
952 +OX_OBJS += chrp_setup.o prep_setup.o
953 +endif
954  endif
955 -
956 -PMAC_OBJS = pmac_time.o pmac_setup.o pmac_support.o pmac_pci.o pmac_pic.o \
957 -       feature.o openpic.o open_pic.o prom.o
958 -CHRP_OBJS = $(PMAC_OBJS) chrp_time.o chrp_pci.o i8259.o indirect_pci.o
959 -CHRPX_OBJS = chrp_setup.o
960 -PREP_OBJS = prep_time.o prep_pci.o residual.o prep_nvram.o i8259.o \
961 -       indirect_pci.o openpic.o open_pic.o prom.o
962 -PREPX_OBJS = prep_setup.o
963 -
964 -ifeq ($(CONFIG_ALL_PPC),y)
965 -O_OBJS += $(sort $(PMAC_OBJS) $(PREP_OBJS) $(CHRP_OBJS))
966 -OX_OBJS += $(PMACX_OBJS) $(PREPX_OBJS) $(CHRPX_OBJS)
967 -endif
968 -ifeq ($(CONFIG_PMAC),y)
969 -O_OBJS += $(PMAC_OBJS)
970 -OX_OBJS += $(PMACX_OBJS)
971 -endif
972 -ifeq ($(CONFIG_PREP),y)
973 -O_OBJS += $(PREP_OBJS)
974 -OX_OBJS += $(PREPX_OBJS)
975 -endif
976 -ifeq ($(CONFIG_CHRP),y)
977 -O_OBJS += $(CHRP_OBJS)
978 -OX_OBJS += $(CHRPX_OBJS)
979 -endif
980 -
981 -GEMINI_OBJS = $(PREP_OBJS) gemini_pci.o gemini_prom.o gemini_setup.o
982 -ifeq ($(CONFIG_GEMINI),y)
983 -O_OBJS += $(GEMINI_OBJS)
984 -OX_OBJS += $(PREPX_OBJS)
985  endif
986  
987  ifdef CONFIG_SMP
988 diff -urN linux.orig/arch/ppc/kernel/apus_setup.c linux/arch/ppc/kernel/apus_setup.c
989 --- linux.orig/arch/ppc/kernel/apus_setup.c     Sun Mar 25 18:31:49 2001
990 +++ linux/arch/ppc/kernel/apus_setup.c  Fri Jul 12 17:02:19 2002
991 @@ -42,7 +42,7 @@
992  #include <asm/machdep.h>
993  #include <asm/ide.h>
994  
995 -#include <asm/time.h>
996 +#include "time.h"
997  #include "local_irq.h"
998  
999  unsigned long apus_get_rtc_time(void);
1000 diff -urN linux.orig/arch/ppc/kernel/chrp_pci.c linux/arch/ppc/kernel/chrp_pci.c
1001 --- linux.orig/arch/ppc/kernel/chrp_pci.c       Sun Mar 25 18:31:48 2001
1002 +++ linux/arch/ppc/kernel/chrp_pci.c    Thu Jul 11 15:43:29 2002
1003 @@ -12,6 +12,7 @@
1004  #include <asm/io.h>
1005  #include <asm/pgtable.h>
1006  #include <asm/irq.h>
1007 +#include <asm/irq-compat.h>
1008  #include <asm/hydra.h>
1009  #include <asm/prom.h>
1010  #include <asm/gg2.h>
1011 @@ -19,7 +20,6 @@
1012  #include <asm/machdep.h>
1013  
1014  #include "pci.h"
1015 -#include "open_pic.h"
1016  
1017  /* LongTrail */
1018  #define pci_config_addr(bus, dev, offset) \
1019 @@ -287,7 +287,7 @@
1020         for( dev=pci_devices ; dev; dev=dev->next )
1021         {
1022                 if ( dev->irq )
1023 -                       dev->irq = dev->irq + open_pic.irq_offset;
1024 +                       dev->irq = openpic_to_irq( dev->irq );
1025                 /* these need to be absolute addrs for OF and Matrox FB -- Cort */
1026                 if ( dev->vendor == PCI_VENDOR_ID_MATROX )
1027                 {
1028 diff -urN linux.orig/arch/ppc/kernel/chrp_setup.c linux/arch/ppc/kernel/chrp_setup.c
1029 --- linux.orig/arch/ppc/kernel/chrp_setup.c     Sun Mar 25 18:31:49 2001
1030 +++ linux/arch/ppc/kernel/chrp_setup.c  Thu Jul 11 16:22:09 2002
1031 @@ -33,7 +33,6 @@
1032  #include <linux/pci.h>
1033  #include <linux/openpic.h>
1034  #include <linux/version.h>
1035 -#include <linux/delay.h>
1036  
1037  #include <asm/mmu.h>
1038  #include <asm/processor.h>
1039 @@ -46,11 +45,12 @@
1040  #include <asm/dma.h>
1041  #include <asm/machdep.h>
1042  #include <asm/irq.h>
1043 +#include <asm/irq-compat.h>
1044  #include <asm/adb.h>
1045  #include <asm/hydra.h>
1046  #include <asm/keyboard.h>
1047  
1048 -#include <asm/time.h>
1049 +#include "time.h"
1050  #include "local_irq.h"
1051  #include "i8259.h"
1052  #include "open_pic.h"
1053 @@ -69,7 +69,7 @@
1054  int chrp_set_rtc_time(unsigned long nowtime);
1055  unsigned long rtas_event_scan_rate = 0, rtas_event_scan_ct = 0;
1056  void chrp_calibrate_decr(void);
1057 -long chrp_time_init(void);
1058 +void chrp_time_init(void);
1059  
1060  void chrp_setup_pci_ptrs(void);
1061  
1062 @@ -359,6 +359,81 @@
1063         }
1064  }
1065  
1066 +void
1067 +chrp_do_IRQ(struct pt_regs *regs,
1068 +           int            cpu,
1069 +            int            isfake)
1070 +{
1071 +        int irq;
1072 +        unsigned long bits = 0;
1073 +        int openpic_eoi_done = 0;
1074 +
1075 +#ifdef __SMP__
1076 +        {
1077 +                unsigned int loops = 1000000;
1078 +                while (test_bit(0, &global_irq_lock)) {
1079 +                        if (smp_processor_id() == global_irq_holder) {
1080 +                                printk("uh oh, interrupt while we hold global irq lock!\n");
1081 +#ifdef CONFIG_XMON
1082 +                                xmon(0);
1083 +#endif
1084 +                                break;
1085 +                        }
1086 +                        if (loops-- == 0) {
1087 +                                printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder);
1088 +#ifdef CONFIG_XMON
1089 +                                xmon(0);
1090 +#endif
1091 +                        }
1092 +                }
1093 +        }
1094 +#endif /* __SMP__ */
1095 +       
1096 +        irq = openpic_irq(smp_processor_id());
1097 +        if (irq == IRQ_8259_CASCADE)
1098 +        {
1099 +                /*
1100 +                 * This magic address generates a PCI IACK cycle.
1101 +                 *
1102 +                 * This should go in the above mask/ack code soon. -- Cort
1103 +                 */
1104 +               if ( chrp_int_ack_special )
1105 +                       irq = *chrp_int_ack_special;
1106 +               else
1107 +                       irq = i8259_irq(0);
1108 +                /*
1109 +                 * Acknowledge as soon as possible to allow i8259
1110 +                 * interrupt nesting                         */
1111 +                openpic_eoi(smp_processor_id());
1112 +                openpic_eoi_done = 1;
1113 +        }
1114 +        if (irq == OPENPIC_VEC_SPURIOUS)
1115 +        {
1116 +                /*
1117 +                 * Spurious interrupts should never be
1118 +                 * acknowledged
1119 +                 */
1120 +                ppc_spurious_interrupts++;
1121 +                openpic_eoi_done = 1;
1122 +               goto out;
1123 +        }
1124 +        bits = 1UL << irq;
1125 +
1126 +        if (irq < 0)
1127 +        {
1128 +                printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n",
1129 +                       irq, regs->nip);
1130 +                ppc_spurious_interrupts++;
1131 +        }
1132 +       else
1133 +        {
1134 +               ppc_irq_dispatch_handler( regs, irq );
1135 +       }
1136 +out:
1137 +        if (!openpic_eoi_done)
1138 +                openpic_eoi(smp_processor_id());
1139 +}
1140 +
1141  __initfunc(void
1142            chrp_init_IRQ(void))
1143  {
1144 @@ -373,7 +448,7 @@
1145                         (*(unsigned long *)get_property(np,
1146                                                         "8259-interrupt-acknowledge", NULL));
1147         }
1148 -       open_pic.irq_offset = NUM_8259_INTERRUPTS;
1149 +       open_pic.irq_offset = 16;
1150         for ( i = 16 ; i < NR_IRQS ; i++ )
1151                 irq_desc[i].ctl = &open_pic;
1152         openpic_init(1);
1153 @@ -381,7 +456,7 @@
1154                 irq_desc[i].ctl = &i8259_pic;
1155         i8259_init();
1156  #ifdef CONFIG_XMON
1157 -       request_irq(HYDRA_INT_ADB_NMI+open_pic.irq_offset,
1158 +       request_irq(openpic_to_irq(HYDRA_INT_ADB_NMI),
1159                     xmon_irq, 0, "NMI", 0);
1160  #endif /* CONFIG_XMON */
1161  #ifdef __SMP__
1162 @@ -570,7 +645,7 @@
1163         ppc_md.get_cpuinfo    = chrp_get_cpuinfo;
1164         ppc_md.irq_cannonicalize = chrp_irq_cannonicalize;
1165         ppc_md.init_IRQ       = chrp_init_IRQ;
1166 -       ppc_md.do_IRQ         = open_pic_do_IRQ;
1167 +       ppc_md.do_IRQ         = chrp_do_IRQ;
1168                 
1169         ppc_md.init           = chrp_init2;
1170  
1171 @@ -612,8 +687,3 @@
1172         while ( *s )
1173                 call_rtas( "display-character", 1, 1, NULL, *s++ );
1174  }
1175 -
1176 -void chrp_indicator(int x)
1177 -{
1178 -       call_rtas("set-indicator", 3, 1, NULL, 6, 0, x);
1179 -}
1180 diff -urN linux.orig/arch/ppc/kernel/chrp_time.c linux/arch/ppc/kernel/chrp_time.c
1181 --- linux.orig/arch/ppc/kernel/chrp_time.c      Sun Mar 25 18:31:49 2001
1182 +++ linux/arch/ppc/kernel/chrp_time.c   Thu Jul 11 15:43:29 2002
1183 @@ -25,25 +25,24 @@
1184  #include <asm/processor.h>
1185  #include <asm/nvram.h>
1186  #include <asm/prom.h>
1187 -#include <asm/time.h>
1188 +#include "time.h"
1189  
1190  static int nvram_as1 = NVRAM_AS1;
1191  static int nvram_as0 = NVRAM_AS0;
1192  static int nvram_data = NVRAM_DATA;
1193  
1194 -__initfunc(long chrp_time_init(void))
1195 +__initfunc(void chrp_time_init(void))
1196  {
1197         struct device_node *rtcs;
1198         int base;
1199  
1200         rtcs = find_compatible_devices("rtc", "pnpPNP,b00");
1201         if (rtcs == NULL || rtcs->addrs == NULL)
1202 -               return 0;
1203 +               return;
1204         base = rtcs->addrs[0].address;
1205         nvram_as1 = 0;
1206         nvram_as0 = base;
1207         nvram_data = base + 1;
1208 -       return 0;
1209  }
1210  
1211  int chrp_cmos_clock_read(int addr)
1212 diff -urN linux.orig/arch/ppc/kernel/gemini_setup.c linux/arch/ppc/kernel/gemini_setup.c
1213 --- linux.orig/arch/ppc/kernel/gemini_setup.c   Sun Mar 25 18:31:49 2001
1214 +++ linux/arch/ppc/kernel/gemini_setup.c        Thu Jul 11 15:45:25 2002
1215 @@ -21,7 +21,6 @@
1216  #include <linux/blk.h>
1217  #include <linux/console.h>
1218  #include <linux/openpic.h>
1219 -#include <linux/delay.h>
1220  
1221  #include <asm/system.h>
1222  #include <asm/pgtable.h>
1223 @@ -30,9 +29,8 @@
1224  #include <asm/io.h>
1225  #include <asm/m48t35.h>
1226  #include <asm/gemini.h>
1227 -#include <asm/processor.h>
1228  
1229 -#include <asm/time.h>
1230 +#include "time.h"
1231  #include "local_irq.h"
1232  #include "open_pic.h"
1233  
1234 @@ -168,6 +166,8 @@
1235         ioremap( GEMINI_MPIC_ADDR, sizeof( struct OpenPIC ));
1236  }
1237  
1238 +
1239 +extern unsigned long loops_per_jiffy;
1240  extern int root_mountflags;
1241  extern char cmd_line[];
1242  
1243 @@ -258,6 +258,14 @@
1244         return clock;
1245  }
1246  
1247 +
1248 +#define L2CR_PIPE_LATEWR   (0x01800000)   /* late-write SRAM */
1249 +#define L2CR_L2CTL         (0x00100000)   /* RAM control */
1250 +#define L2CR_INST_DISABLE  (0x00400000)   /* disable for insn's */
1251 +#define L2CR_L2I           (0x00200000)   /* global invalidate */
1252 +#define L2CR_L2E           (0x80000000)   /* enable */
1253 +#define L2CR_L2WT          (0x00080000)   /* write-through */
1254 +
1255  void __init gemini_init_l2(void)
1256  {
1257         unsigned char reg;
1258 @@ -331,7 +339,8 @@
1259                         cache |= L2CR_L2WT;
1260  #endif
1261                 cache |= L2CR_PIPE_LATEWR|L2CR_L2CTL|L2CR_INST_DISABLE;
1262 -               _set_L2CR(cache|L2CR_L2E);
1263 +               _set_L2CR(0);
1264 +               _set_L2CR(cache|L2CR_L2I|L2CR_L2E);
1265         }
1266  }
1267  
1268 @@ -381,7 +390,7 @@
1269  #define gemini_rtc_write(val,x)  (writeb((val),(GEMINI_RTC+(x))))
1270  
1271  /* ensure that the RTC is up and running */
1272 -long __init gemini_time_init(void)
1273 +void __init gemini_time_init(void)
1274  {
1275         unsigned char reg;
1276  
1277 @@ -392,7 +401,6 @@
1278                 gemini_rtc_write((reg & ~(M48T35_RTC_STOPPED)), M48T35_RTC_CONTROL);
1279                 gemini_rtc_write((reg | M48T35_RTC_SET), M48T35_RTC_CONTROL);
1280         }
1281 -       return 0;
1282  }
1283  
1284  #undef DEBUG_RTC
1285 diff -urN linux.orig/arch/ppc/kernel/head.S linux/arch/ppc/kernel/head.S
1286 --- linux.orig/arch/ppc/kernel/head.S   Fri Nov  2 17:39:05 2001
1287 +++ linux/arch/ppc/kernel/head.S        Thu Jul 11 15:43:29 2002
1288 @@ -13,7 +13,6 @@
1289   *    Copyright (C) 1996 Paul Mackerras.
1290   *  MPC8xx modifications Copyright (C) 1997 Dan Malek (dmalek@jlc.net).
1291   *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
1292 - *  AltiVec additions by Kumar Gala (kumar.gala@motorola.com).
1293   *
1294   *  This file contains the low-level support and setup for the
1295   *  PowerPC platform, including trap and interrupt dispatch.
1296 @@ -23,10 +22,6 @@
1297   *  modify it under the terms of the GNU General Public License
1298   *  as published by the Free Software Foundation; either version
1299   *  2 of the License, or (at your option) any later version.
1300 - *
1301 - *  2000-04-10.
1302 - *  Add sys_rt_sigreturn in DoSyscall Handler.
1303 - *  Giovanna Ambrosini (ambrosini@lightning.ch).
1304   *     
1305   */
1306  
1307 @@ -87,28 +82,6 @@
1308  #define REST_16FPRS(n, base)   REST_8FPRS(n, base); REST_8FPRS(n+8, base)
1309  #define REST_32FPRS(n, base)   REST_16FPRS(n, base); REST_16FPRS(n+16, base)
1310  
1311 -/*
1312 - * Once a version of gas that understands the AltiVec instructions
1313 - * is freely available, we can do this the normal way...  - paulus
1314 - */
1315 -#define LVX(r,a,b)     .long   (31<<26)+((r)<<21)+((a)<<16)+((b)<<11)+(103<<1)
1316 -#define STVX(r,a,b)    .long   (31<<26)+((r)<<21)+((a)<<16)+((b)<<11)+(231<<1)
1317 -#define MFVSCR(r)      .long   (4<<26)+((r)<<11)+(770<<1)
1318 -#define MTVSCR(r)      .long   (4<<26)+((r)<<11)+(802<<1)
1319 -
1320 -#define SAVE_VR(n,b,base)      li b,TSS_VR0+(16*(n)); STVX(n,b,base)
1321 -#define SAVE_2VR(n,b,base)     SAVE_VR(n,b,base); SAVE_VR(n+1,b,base) 
1322 -#define SAVE_4VR(n,b,base)     SAVE_2VR(n,b,base); SAVE_2VR(n+2,b,base) 
1323 -#define SAVE_8VR(n,b,base)     SAVE_4VR(n,b,base); SAVE_4VR(n+4,b,base) 
1324 -#define SAVE_16VR(n,b,base)    SAVE_8VR(n,b,base); SAVE_8VR(n+8,b,base)
1325 -#define SAVE_32VR(n,b,base)    SAVE_16VR(n,b,base); SAVE_16VR(n+16,b,base)
1326 -#define REST_VR(n,b,base)      li b,TSS_VR0+(16*(n)); LVX(n,b,base)
1327 -#define REST_2VR(n,b,base)     REST_VR(n,b,base); REST_VR(n+1,b,base) 
1328 -#define REST_4VR(n,b,base)     REST_2VR(n,b,base); REST_2VR(n+2,b,base) 
1329 -#define REST_8VR(n,b,base)     REST_4VR(n,b,base); REST_4VR(n+4,b,base) 
1330 -#define REST_16VR(n,b,base)    REST_8VR(n,b,base); REST_8VR(n+8,b,base) 
1331 -#define REST_32VR(n,b,base)    REST_16VR(n,b,base); REST_16VR(n+16,b,base)
1332 -
1333  #define SYNC \
1334         sync; \
1335         isync
1336 @@ -262,15 +235,66 @@
1337  __secondary_start:
1338  /* Switch MMU off, clear BATs and flush TLB */
1339         bl      mmu_off
1340 -mmu_off_return:
1341         bl      clear_bats
1342         bl      flush_tlbs
1343 -       bl      setup_init_bats
1344 -#ifndef CONFIG_APUS
1345 -#ifdef CONFIG_BOOTX_TEXT
1346 -       bl      setup_disp_bat
1347 -#endif
1348 +
1349 +/* Use the first pair of BAT registers to map the 1st 16MB
1350 + * of RAM to KERNELBASE.  From this point on we can't safely
1351 + * call OF any more.
1352 + */
1353 +       lis     r11,KERNELBASE@h
1354 +       mfspr   r9,PVR
1355 +       rlwinm  r9,r9,16,16,31          /* r9 = 1 for 601, 4 for 604 */
1356 +       cmpi    0,r9,1
1357 +       bne     4f
1358 +       ori     r11,r11,4               /* set up BAT registers for 601 */
1359 +       li      r8,0x7f                 /* valid, block length = 8MB */
1360 +       oris    r9,r11,0x800000@h       /* set up BAT reg for 2nd 8M */
1361 +       oris    r10,r8,0x800000@h       /* set up BAT reg for 2nd 8M */
1362 +       mtspr   IBAT0U,r11              /* N.B. 601 has valid bit in */
1363 +       mtspr   IBAT0L,r8               /* lower BAT register */
1364 +       mtspr   IBAT1U,r9
1365 +       mtspr   IBAT1L,r10
1366 +       b       5f
1367 +4:
1368 +#ifdef CONFIG_APUS
1369 +       ori     r11,r11,BL_8M<<2|0x2    /* set up an 8MB mapping */
1370 +       ori     r11,r11,0xfe            /* set up an 8MB mapping */
1371 +       lis     r8,CYBERBASEp@h
1372 +       lwz     r8,0(r8)
1373 +       addis   r8,r8,KERNELBASE@h
1374 +       addi    r8,r8,2
1375 +#else  
1376 +       ori     r11,r11,BL_256M<<2|0x2  /* set up BAT registers for 604 */
1377 +       li      r8,2                    /* R/W access */
1378 +       /*
1379 +        * If the MMU is off clear the bats.  See clear_bat() -- Cort
1380 +        */
1381 +#ifndef CONFIG_GEMINI  
1382 +       /* 
1383 +        * allow secondary cpus to get at all of ram in early bootup
1384 +        * since their init_task may be up there -- Cort
1385 +        */
1386 +       oris    r18,r8,0x10000000@h
1387 +       oris    r21,r11,(KERNELBASE+0x10000000)@h
1388 +       mtspr   DBAT1L,r18              /* N.B. 6xx (not 601) have valid */
1389 +       mtspr   DBAT1U,r21              /* bit in upper BAT register */
1390 +       mtspr   IBAT1L,r18
1391 +       mtspr   IBAT1U,r21
1392 +       
1393 +       oris    r18,r8,0x20000000@h
1394 +       oris    r21,r11,(KERNELBASE+0x20000000)@h
1395 +       mtspr   DBAT2L,r18              /* N.B. 6xx (not 601) have valid */
1396 +       mtspr   DBAT2U,r21              /* bit in upper BAT register */
1397 +       mtspr   IBAT2L,r18
1398 +       mtspr   IBAT2U,r21
1399 +#endif /* ndef CONFIG_GEMINI */        
1400  #endif
1401 +       mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
1402 +       mtspr   DBAT0U,r11              /* bit in upper BAT register */
1403 +       mtspr   IBAT0L,r8
1404 +       mtspr   IBAT0U,r11
1405 +5:     isync
1406  #ifdef CONFIG_APUS
1407         /* Unfortunately the APUS specific instructions bloat the
1408          * code so it cannot fit in the 0x100 bytes available. We have
1409 @@ -396,15 +420,6 @@
1410  #endif /* CONFIG_8xx */
1411         b       turn_on_mmu
1412  
1413 -/* Hack for sleep on Core99 machines
1414 - */
1415 -#ifdef CONFIG_POWERMAC
1416 -       . = 0x80
1417 -SleepVector:
1418 -       .long   0
1419 -       .long   0       
1420 -#endif /* CONFIG_POWERMAC */
1421 -
1422  /*
1423   * GCC sometimes accesses words at negative offsets from the stack
1424   * pointer, although the SysV ABI says it shouldn't.  To cope with
1425 @@ -477,7 +492,7 @@
1426  #endif /* CONFIG_GEMINI */
1427  #else
1428         STD_EXCEPTION(0x100, Reset, UnknownException)
1429 -#endif
1430 +#endif 
1431  
1432  /* Machine check */
1433         STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
1434 @@ -636,26 +651,7 @@
1435         STD_EXCEPTION(0xd00, SingleStep, SingleStepException)
1436  
1437         STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
1438 -
1439 -#ifndef CONFIG_ALTIVEC
1440         STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
1441 -#else
1442 -/*
1443 - * The Altivec unavailable trap is at 0x0f20.  Foo.
1444 - * We effectively remap it to 0x3000.
1445 - */
1446 -       . = 0xf00
1447 -       b       Trap_0f
1448 -trap_0f_cont:
1449 -       addi    r3,r1,STACK_FRAME_OVERHEAD
1450 -       li      r20,MSR_KERNEL
1451 -       bl      transfer_to_handler
1452 -       .long   UnknownException
1453 -       .long   int_return
1454 -
1455 -       . = 0xf20
1456 -       b       AltiVecUnavailable
1457 -#endif /* CONFIG_ALTIVEC */
1458  
1459  #ifndef CONFIG_8xx
1460  /*
1461 @@ -1173,24 +1169,9 @@
1462         STD_EXCEPTION(0x2f00, Trap_2f, UnknownException)
1463  
1464         . = 0x3000
1465 -#ifdef CONFIG_ALTIVEC
1466 -AltiVecUnavailable:
1467 -       EXCEPTION_PROLOG
1468 -       bne     load_up_altivec         /* if from user, just load it up */
1469 -       li      r20,MSR_KERNEL
1470 -       bl      transfer_to_handler     /* if from kernel, take a trap */
1471 -       .long   KernelAltiVec
1472 -       .long   int_return
1473 -
1474 -/* here are the bits of trap 0xf00 which got displaced */
1475 -Trap_0f:
1476 -       EXCEPTION_PROLOG
1477 -       b       trap_0f_cont
1478 -#endif /* CONFIG_ALTIVEC */
1479 -
1480 -#else /* CONFIG_8xx */
1481 +#else
1482         . = 0x2000
1483 -#endif /* CONFIG_8xx */
1484 +#endif
1485  
1486  /*
1487   * This code finishes saving the registers to the exception frame
1488 @@ -1345,7 +1326,11 @@
1489         /* Construct the high word of the PPC-style PTE */
1490         mfsrin  r5,r3                   /* get segment reg for segment */
1491         rlwinm  r5,r5,7,1,24            /* put VSID in 0x7fffff80 bits */
1492 +       
1493 +#ifndef __SMP__                                /* do this later for SMP */
1494         oris    r5,r5,0x8000            /* set V (valid) bit */
1495 +#endif
1496 +       
1497         rlwimi  r5,r3,10,26,31          /* put in API (abbrev page index) */
1498         /* Get the address of the primary PTE group in the hash table */
1499         .globl  hash_page_patch_A
1500 @@ -1457,7 +1442,6 @@
1501   */
1502  found_empty:
1503  found_slot:
1504 -       clrlwi  r5,r5,1         /* clear valid bit (0x80000000) */
1505         stw     r5,0(r3)        /* clear V (valid) bit in PTE */
1506         sync
1507         tlbsync
1508 @@ -1509,7 +1493,6 @@
1509         REST_GPR(20, r21)
1510         REST_2GPRS(22, r21)
1511         lwz     r21,GPR21(r21)
1512 -       sync
1513         rfi
1514         
1515  #ifdef __SMP__
1516 @@ -1649,145 +1632,24 @@
1517  #endif /* __SMP__ */
1518         blr
1519  
1520 -#ifdef CONFIG_ALTIVEC
1521 -/* Note that the AltiVec support is closely modeled after the FP
1522 - * support.  Changes to one are likely to be applicable to the
1523 - * other!  */
1524 -load_up_altivec:
1525 -/*
1526 - * Disable AltiVec for the task which had AltiVec previously,
1527 - * and save its AltiVec registers in its thread_struct.
1528 - * Enables AltiVec for use in the kernel on return.
1529 - * On SMP we know the AltiVec units are free, since we give it up every
1530 - * switch.  -- Kumar
1531 - */
1532 -       mfmsr   r5
1533 -       oris    r5,r5,MSR_VEC@h
1534 -       SYNC
1535 -       mtmsr   r5                      /* enable use of AltiVec now */
1536 -       SYNC
1537 -/*
1538 - * For SMP, we don't do lazy AltiVec switching because it just gets too
1539 - * horrendously complex, especially when a task switches from one CPU
1540 - * to another.  Instead we call giveup_altivec in switch_to.
1541 - */
1542 -#ifndef __SMP__
1543 -#ifndef CONFIG_APUS
1544 -       lis     r6,-KERNELBASE@h
1545 -#else
1546 -       lis     r6,CYBERBASEp@h
1547 -       lwz     r6,0(r6)
1548 -#endif
1549 -       addis   r3,r6,last_task_used_altivec@ha
1550 -       lwz     r4,last_task_used_altivec@l(r3)
1551 -       cmpi    0,r4,0
1552 -       beq     1f
1553 -       add     r4,r4,r6
1554 -       addi    r4,r4,TSS       /* want TSS of last_task_used_altivec */
1555 -       SAVE_32VR(0,r20,r4)
1556 -       MFVSCR(vr0)
1557 -       li      r20,TSS_VSCR
1558 -       STVX(vr0,r20,r4)
1559 -       lwz     r5,PT_REGS(r4)
1560 -       add     r5,r5,r6
1561 -       lwz     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1562 -       lis     r20,MSR_VEC@h
1563 -       andc    r4,r4,r20       /* disable altivec for previous task */
1564 -       stw     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1565 -1:
1566 -#endif /* __SMP__ */
1567 -       /* enable use of AltiVec after return */
1568 -       oris    r23,r23,MSR_VEC@h
1569 -       mfspr   r5,SPRG3                /* current task's TSS (phys) */
1570 -       li      r20,TSS_VSCR
1571 -       LVX(vr0,r20,r5)
1572 -       MTVSCR(vr0)
1573 -       REST_32VR(0,r20,r5)
1574 -#ifndef __SMP__
1575 -       subi    r4,r5,TSS
1576 -       sub     r4,r4,r6
1577 -       stw     r4,last_task_used_altivec@l(r3)
1578 -#endif /* __SMP__ */
1579 -       /* restore registers and return */
1580 -       lwz     r3,_CCR(r21)
1581 -       lwz     r4,_LINK(r21)
1582 -       mtcrf   0xff,r3
1583 -       mtlr    r4
1584 -       REST_GPR(1, r21)
1585 -       REST_4GPRS(3, r21)
1586 -       /* we haven't used ctr or xer */
1587 -       mtspr   SRR1,r23
1588 -       mtspr   SRR0,r22
1589 -       REST_GPR(20, r21)
1590 -       REST_2GPRS(22, r21)
1591 -       lwz     r21,GPR21(r21)
1592 -       SYNC
1593 -       rfi
1594 -
1595 -/*
1596 - * AltiVec unavailable trap from kernel - print a message, but let
1597 - * the task use AltiVec in the kernel until it returns to user mode.
1598 - */
1599 -KernelAltiVec:
1600 -       lwz     r3,_MSR(r1)
1601 -       oris    r3,r3,MSR_VEC@h
1602 -       stw     r3,_MSR(r1)     /* enable use of AltiVec after return */
1603 -       lis     r3,87f@h
1604 -       ori     r3,r3,87f@l
1605 -       mr      r4,r2           /* current */
1606 -       lwz     r5,_NIP(r1)
1607 -       bl      printk
1608 -       b       int_return
1609 -87:    .string "AltiVec used in kernel  (task=%p, pc=%x)  \n"
1610 -       .align  4
1611 -
1612 -/*
1613 - * giveup_altivec(tsk)
1614 - * Disable AltiVec for the task given as the argument,
1615 - * and save the AltiVec registers in its thread_struct.
1616 - * Enables AltiVec for use in the kernel on return.
1617 - */
1618 -
1619 -       .globl  giveup_altivec
1620 -giveup_altivec:
1621 -       mfmsr   r5
1622 -       oris    r5,r5,MSR_VEC@h
1623 -       SYNC
1624 -       mtmsr   r5                      /* enable use of AltiVec now */
1625 -       SYNC
1626 -       cmpi    0,r3,0
1627 -       beqlr-                          /* if no previous owner, done */
1628 -       addi    r3,r3,TSS               /* want TSS of task */
1629 -       lwz     r5,PT_REGS(r3)
1630 -       cmpi    0,r5,0
1631 -       SAVE_32VR(0, r4, r3)
1632 -       MFVSCR(vr0)
1633 -       li      r4,TSS_VSCR
1634 -       STVX(vr0, r4, r3)
1635 -       beq     1f
1636 -       lwz     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1637 -       lis     r3,MSR_VEC@h
1638 -       andc    r4,r4,r3                /* disable AltiVec for previous task */
1639 -       stw     r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1640 -1:
1641 -#ifndef __SMP__
1642 -       li      r5,0
1643 -       lis     r4,last_task_used_altivec@ha
1644 -       stw     r5,last_task_used_altivec@l(r4)
1645 -#endif /* __SMP__ */
1646 +#else  /* CONFIG_8xx */
1647 +       .globl  giveup_fpu
1648 +giveup_fpu:
1649         blr
1650 -#endif /* CONFIG_ALTIVEC */
1651 +#endif /* CONFIG_8xx */
1652  
1653  mmu_off:
1654 -       addi    r4, r3, mmu_off_return - _start
1655 +       addi    r4, r3, __secondary_start - _start
1656         mfmsr   r3
1657         andi.   r0,r3,MSR_DR|MSR_IR             /* MMU enabled? */
1658 -       beqlr
1659 -       andc    r3,r3,r0
1660 +       beq     1f
1661 +       ori     r3,r3,MSR_DR|MSR_IR
1662 +       xori    r3,r3,MSR_DR|MSR_IR
1663         mtspr   SRR0,r4
1664         mtspr   SRR1,r3
1665 -       SYNC
1666 +       sync
1667         rfi
1668 +1:     blr
1669  
1670  /*
1671   * This code is jumped to from the startup code to copy
1672 @@ -1798,6 +1660,10 @@
1673         addi    r9,r9,0x6f58            /* translate source addr */
1674         cmpw    r31,r9                  /* (we have to on chrp) */
1675         beq     7f
1676 +#if 0 // still needed ? breaks on me if I don't disable this
1677 +       rlwinm  r4,r4,0,8,31            /* translate source address */
1678 +       add     r4,r4,r3                /* to region mapped with BATs */
1679 +#endif 
1680  7:     addis   r9,r26,klimit@ha        /* fetch klimit */
1681         lwz     r25,klimit@l(r9)
1682         addis   r25,r25,-KERNELBASE@h
1683 @@ -1845,12 +1711,6 @@
1684         . = 0x4000
1685  #endif
1686  
1687 -#else  /* CONFIG_8xx */
1688 -       .globl  giveup_fpu
1689 -giveup_fpu:
1690 -       blr
1691 -#endif /* CONFIG_8xx */
1692 -
1693  turn_on_mmu:
1694         mfmsr   r0
1695         ori     r1,r0,MSR_DR|MSR_IR
1696 @@ -1913,7 +1773,7 @@
1697         mfspr   r9,PVR
1698         rlwinm  r9,r9,16,16,31
1699         cmpi    0,r9,1
1700 -       beq     6f                      /* not needed for 601 */
1701 +       beq     4f                      /* not needed for 601 */
1702         mfspr   r11,HID0
1703         andi.   r0,r11,HID0_DCE
1704         ori     r11,r11,HID0_ICE|HID0_DCE
1705 @@ -1930,24 +1790,14 @@
1706         cmpi    0,r9,4                  /* check for 604 */
1707         cmpi    1,r9,9                  /* or 604e */
1708         cmpi    2,r9,10                 /* or mach5 */
1709 -       cmpi    3,r9,8                  /* check for 750 (G3) */
1710 -       cmpi    4,r9,12                 /* or 7400 (G4) */
1711         cror    2,2,6
1712         cror    2,2,10
1713         bne     4f
1714         ori     r11,r11,HID0_SIED|HID0_BHTE /* for 604[e], enable */
1715         bne     2,5f
1716         ori     r11,r11,HID0_BTCD
1717 -       b       5f
1718 -4:
1719 -       cror    14,14,18
1720 -       bne     3,6f
1721 -       ori     r11,r11,HID0_SGE|HID0_BHTE|HID0_BTIC|HID0_ABE /* for g3/g4, enable */
1722 -       rlwinm  r11,r11,0,23,21         /* clear HID0_SPD */
1723 -       li      r3,0
1724 -       mtspr   ICTC,r3
1725  5:     mtspr   HID0,r11                /* superscalar exec & br history tbl */
1726 -6:
1727 +4:
1728  #endif /* CONFIG_8xx */
1729  #ifdef __SMP__
1730         /* if we're the second cpu stack and r2 are different
1731 @@ -2028,10 +1878,10 @@
1732         li      r3,MSR_KERNEL & ~(MSR_IR|MSR_DR)
1733         mtspr   SRR0,r4
1734         mtspr   SRR1,r3
1735 -       SYNC
1736         rfi
1737  /* Load up the kernel context */
1738  2:
1739 +       SYNC                    /* Force all PTE updates to finish */
1740         tlbia                   /* Clear all TLB entries */
1741         sync                    /* wait for tlbia/tlbie to finish */
1742  #ifdef __SMP__
1743 @@ -2088,7 +1938,6 @@
1744  #endif /* __SMP__ */
1745         mtspr   SRR0,r3
1746         mtspr   SRR1,r4
1747 -       SYNC
1748         rfi                     /* enable MMU and jump to start_kernel */
1749  
1750  /*
1751 @@ -2126,11 +1975,9 @@
1752  1:
1753  #endif /* SHOW_SYSCALLS */
1754         cmpi    0,r0,0x7777     /* Special case for 'sys_sigreturn' */
1755 -        cmpi    1,r0,0x6666     /* Special case for 'sys_rt_sigreturn' */
1756         beq-    10f
1757 -        beq-    cr1,16f
1758 -       lwz     r10,TASK_PTRACE(r2)
1759 -       andi.   r10,r10,PT_TRACESYS
1760 +       lwz     r10,TASK_FLAGS(r2)
1761 +       andi.   r10,r10,PF_TRACESYS
1762         bne-    50f
1763         cmpli   0,r0,NR_syscalls
1764         bge-    66f
1765 @@ -2175,12 +2022,6 @@
1766  /* sys_sigreturn */
1767  10:    addi    r3,r1,STACK_FRAME_OVERHEAD
1768         bl      sys_sigreturn
1769 -        cmpi    0,r3,0          /* Check for restarted system call */
1770 -        bge     int_return
1771 -        b       20b
1772 -/* sys_rt_sigreturn */
1773 -16:     addi    r3,r1,STACK_FRAME_OVERHEAD
1774 -        bl      sys_rt_sigreturn
1775         cmpi    0,r3,0          /* Check for restarted system call */
1776         bge     int_return
1777         b       20b
1778 @@ -2273,9 +2114,6 @@
1779         mflr    r20             /* Return to switch caller */
1780         mfmsr   r22
1781         li      r0,MSR_FP       /* Disable floating-point */
1782 -#ifdef CONFIG_ALTIVEC
1783 -       oris    r0,r0,MSR_VEC@h
1784 -#endif /* CONFIG_ALTIVEC */
1785         andc    r22,r22,r0
1786         stw     r20,_NIP(r1)
1787         stw     r22,_MSR(r1)
1788 @@ -2589,38 +2427,6 @@
1789         blr
1790  
1791  /*
1792 - * Copy a whole page.  We use the dcbz instruction on the destination
1793 - * to reduce memory traffic (it eliminates the unnecessary reads of
1794 - * the destination into cache).  This requires that the destination
1795 - * is cacheable.
1796 - */
1797 -_GLOBAL(copy_page)
1798 -       li      r0,4096/CACHE_LINE_SIZE
1799 -       mtctr   r0
1800 -       addi    r3,r3,-4
1801 -       addi    r4,r4,-4
1802 -       li      r5,4
1803 -1:     dcbz    r5,r3
1804 -       lwz     r6,4(r4)
1805 -       lwz     r7,8(r4)
1806 -       lwz     r8,12(r4)
1807 -       lwzu    r9,16(r4)
1808 -       stw     r6,4(r3)
1809 -       stw     r7,8(r3)
1810 -       stw     r8,12(r3)
1811 -       stwu    r9,16(r3)
1812 -       lwz     r6,4(r4)
1813 -       lwz     r7,8(r4)
1814 -       lwz     r8,12(r4)
1815 -       lwzu    r9,16(r4)
1816 -       stw     r6,4(r3)
1817 -       stw     r7,8(r3)
1818 -       stw     r8,12(r3)
1819 -       stwu    r9,16(r3)
1820 -       bdnz    1b
1821 -       blr
1822 -
1823 -/*
1824   * Flush entries from the hash table with VSIDs in the range
1825   * given.
1826   */
1827 @@ -2798,6 +2604,7 @@
1828         stw     r0,20(r1)
1829         lis     r4,rtas_data@ha
1830         lwz     r4,rtas_data@l(r4)
1831 +       addis   r4,r4,-KERNELBASE@h
1832         lis     r6,1f@ha        /* physical return address for rtas */
1833         addi    r6,r6,1f@l
1834         addis   r6,r6,-KERNELBASE@h
1835 @@ -2817,7 +2624,6 @@
1836         mtspr   SPRG2,r7
1837         mtspr   SRR0,r8
1838         mtspr   SRR1,r9
1839 -       SYNC
1840         rfi
1841  1:     addis   r9,r1,-KERNELBASE@h
1842         lwz     r8,20(r9)       /* get return address */
1843 @@ -2826,7 +2632,6 @@
1844         mtspr   SPRG2,r0
1845         mtspr   SRR0,r8
1846         mtspr   SRR1,r9
1847 -       SYNC
1848         rfi                     /* return to caller */
1849  #endif /* CONFIG_8xx */
1850  
1851 @@ -2851,6 +2656,30 @@
1852         mtlr    r4
1853         blr
1854  #endif /* CONFIG_8xx */
1855 +       
1856 +/*
1857 + * We put a few things here that have to be page-aligned.
1858 + * This stuff goes at the beginning of the data segment,
1859 + * which is page-aligned.
1860 + */
1861 +       .data
1862 +       .globl  sdata
1863 +sdata:
1864 +       .globl  empty_zero_page
1865 +empty_zero_page:
1866 +       .space  4096
1867 +
1868 +       .globl  swapper_pg_dir
1869 +swapper_pg_dir:
1870 +       .space  4096    
1871 +
1872 +/*
1873 + * This space gets a copy of optional info passed to us by the bootstrap
1874 + * Used to pass parameters into the kernel like root=/dev/sda1, etc.
1875 + */    
1876 +       .globl  cmd_line
1877 +cmd_line:
1878 +       .space  512
1879  
1880  /* 
1881   * An undocumented "feature" of 604e requires that the v bit
1882 @@ -2895,117 +2724,4 @@
1883         blt     1b
1884         sync
1885         blr
1886 -
1887 -/* Use the first pair of BAT registers to map the 1st 16MB
1888 - * of RAM to KERNELBASE.  From this point on we can't safely
1889 - * call OF any more.
1890 - */
1891 -setup_init_bats:
1892 -       lis     r11,KERNELBASE@h
1893 -       mfspr   r9,PVR
1894 -       rlwinm  r9,r9,16,16,31          /* r9 = 1 for 601, 4 for 604 */
1895 -       cmpi    0,r9,1
1896 -       bne     4f
1897 -       ori     r11,r11,4               /* set up BAT registers for 601 */
1898 -       li      r8,0x7f                 /* valid, block length = 8MB */
1899 -       oris    r9,r11,0x800000@h       /* set up BAT reg for 2nd 8M */
1900 -       oris    r10,r8,0x800000@h       /* set up BAT reg for 2nd 8M */
1901 -       mtspr   IBAT0U,r11              /* N.B. 601 has valid bit in */
1902 -       mtspr   IBAT0L,r8               /* lower BAT register */
1903 -       mtspr   IBAT1U,r9
1904 -       mtspr   IBAT1L,r10
1905 -       b       5f
1906 -4:
1907 -#ifdef CONFIG_APUS
1908 -       ori     r11,r11,BL_8M<<2|0x2    /* set up an 8MB mapping */
1909 -       ori     r11,r11,0xfe            /* set up an 8MB mapping */
1910 -       lis     r8,CYBERBASEp@h
1911 -       lwz     r8,0(r8)
1912 -       addis   r8,r8,KERNELBASE@h
1913 -       addi    r8,r8,2
1914 -#else  
1915 -       ori     r11,r11,BL_256M<<2|0x2  /* set up BAT registers for 604 */
1916 -       li      r8,2                    /* R/W access */
1917 -       /*
1918 -        * If the MMU is off clear the bats.  See clear_bat() -- Cort
1919 -        */
1920 -#ifndef CONFIG_GEMINI  
1921 -       /* 
1922 -        * allow secondary cpus to get at all of ram in early bootup
1923 -        * since their init_task may be up there -- Cort
1924 -        */
1925 -       oris    r18,r8,0x10000000@h
1926 -       oris    r21,r11,(KERNELBASE+0x10000000)@h
1927 -       mtspr   DBAT1L,r18              /* N.B. 6xx (not 601) have valid */
1928 -       mtspr   DBAT1U,r21              /* bit in upper BAT register */
1929 -       mtspr   IBAT1L,r18
1930 -       mtspr   IBAT1U,r21
1931         
1932 -       oris    r18,r8,0x20000000@h
1933 -       oris    r21,r11,(KERNELBASE+0x20000000)@h
1934 -       mtspr   DBAT2L,r18              /* N.B. 6xx (not 601) have valid */
1935 -       mtspr   DBAT2U,r21              /* bit in upper BAT register */
1936 -       mtspr   IBAT2L,r18
1937 -       mtspr   IBAT2U,r21
1938 -#endif /* ndef CONFIG_GEMINI */        
1939 -#endif
1940 -       mtspr   DBAT0L,r8               /* N.B. 6xx (not 601) have valid */
1941 -       mtspr   DBAT0U,r11              /* bit in upper BAT register */
1942 -       mtspr   IBAT0L,r8
1943 -       mtspr   IBAT0U,r11
1944 -5:     isync
1945 -       blr
1946 -       
1947 -#ifdef CONFIG_BOOTX_TEXT
1948 -setup_disp_bat:
1949 -       /*
1950 -        * setup the display bat prepared for us in prom.c
1951 -        */
1952 -       mflr    r8
1953 -       bl      reloc_offset
1954 -       mtlr    r8
1955 -       lis     r8, disp_BATL@h
1956 -       ori     r8, r8, disp_BATL@l
1957 -       add     r8, r3, r8
1958 -       lwz     r8, 0(r8)
1959 -       lis     r11, disp_BATU@h
1960 -       ori     r11, r11, disp_BATU@l
1961 -       add     r11, r3, r11
1962 -       lwz     r11, 0(r11)
1963 -       mtspr   IBAT3L,r8
1964 -       mtspr   IBAT3U,r11
1965 -       mfspr   r9,PVR
1966 -       rlwinm  r9,r9,16,16,31          /* r9 = 1 for 601, 4 for 604 */
1967 -       cmpi    0,r9,1
1968 -       beq     1f
1969 -       mtspr   DBAT3L,r8
1970 -       mtspr   DBAT3U,r11
1971 -1:             
1972 -       blr
1973 -#endif
1974 -       
1975 -/*
1976 - * We put a few things here that have to be page-aligned.
1977 - * This stuff goes at the beginning of the data segment,
1978 - * which is page-aligned.
1979 - */
1980 -       .data
1981 -       .globl  sdata
1982 -sdata:
1983 -       .globl  empty_zero_page
1984 -empty_zero_page:
1985 -       .space  4096
1986 -
1987 -       .globl  swapper_pg_dir
1988 -swapper_pg_dir:
1989 -       .space  4096    
1990 -
1991 -/*
1992 - * This space gets a copy of optional info passed to us by the bootstrap
1993 - * Used to pass parameters into the kernel like root=/dev/sda1, etc.
1994 - */    
1995 -       .globl  cmd_line
1996 -cmd_line:
1997 -       .space  512
1998 -
1999 -
2000 diff -urN linux.orig/arch/ppc/kernel/irq.c linux/arch/ppc/kernel/irq.c
2001 --- linux.orig/arch/ppc/kernel/irq.c    Sun Mar 25 18:31:48 2001
2002 +++ linux/arch/ppc/kernel/irq.c Thu Jul 11 15:43:29 2002
2003 @@ -61,9 +61,7 @@
2004  
2005  #include "local_irq.h"
2006  
2007 -extern atomic_t ipi_recv;
2008 -extern atomic_t ipi_sent;
2009 -void enable_irq(unsigned int irq_nr);
2010 +extern volatile unsigned long ipi_count;
2011  void enable_irq(unsigned int irq_nr);
2012  void disable_irq(unsigned int irq_nr);
2013  
2014 @@ -139,21 +137,20 @@
2015         if (!handler)
2016         {
2017                 /* Free */
2018 -               p = &irq_desc[irq].action;
2019 -               while ((action = *p) != NULL && action->dev_id != dev_id)
2020 -                       p = &action->next;
2021 -               if (action == NULL)
2022 -                       return -ENOENT;
2023 -
2024 -               /* Found it - now free it */
2025 -               save_flags(flags);
2026 -               cli();
2027 -               *p = action->next;
2028 -               if (irq_desc[irq].action == NULL)
2029 -                       disable_irq(irq);
2030 -               restore_flags(flags);
2031 -               irq_kfree(action);
2032 -               return 0;
2033 +               for (p = &irq_desc[irq].action; (action = *p) != NULL; p = &action->next)
2034 +               {
2035 +                       if (action->dev_id == dev_id)
2036 +                       {
2037 +                               /* Found it - now free it */
2038 +                               save_flags(flags);
2039 +                               cli();
2040 +                               *p = action->next;
2041 +                               restore_flags(flags);
2042 +                               irq_kfree(action);
2043 +                               return 0;
2044 +                       }
2045 +               }
2046 +               return -ENOENT;
2047         }
2048         
2049         action = (struct irqaction *)
2050 @@ -244,10 +241,8 @@
2051         }
2052  #ifdef __SMP__
2053         /* should this be per processor send/receive? */
2054 -       /* should this be per processor send/receive? */
2055 -       len += sprintf(buf+len, "IPI: (recv/sent) %10lu/%lu\n",
2056 -                       atomic_read(&ipi_recv), atomic_read(&ipi_sent));
2057 -#endif /* __SMP__ */           
2058 +       len += sprintf(buf+len, "IPI: %10lu\n", ipi_count);
2059 +#endif         
2060         len += sprintf(buf+len, "BAD: %10u\n", ppc_spurious_interrupts);
2061         return len;
2062  }
2063 @@ -322,14 +317,10 @@
2064  atomic_t global_bh_count;
2065  atomic_t global_bh_lock;
2066  
2067 -extern unsigned long *_get_SP(void);
2068 -
2069  static void show(char * str)
2070  {
2071 -#if 0
2072         int i;
2073         unsigned long *stack;
2074 -#endif
2075         int cpu = smp_processor_id();
2076  
2077         printk("\n%s, CPU %d:\n", str, cpu);
2078 @@ -341,10 +332,6 @@
2079                atomic_read(&global_bh_count),
2080                ppc_local_bh_count[0],
2081                ppc_local_bh_count[1]);
2082 -#if 1
2083 -       printk(" CPU: %d last CPU: %d\n", current->processor,current->last_processor);
2084 -       print_backtrace (_get_SP());
2085 -#else
2086         stack = (unsigned long *) &str;
2087         for (i = 40; i ; i--) {
2088                 unsigned long x = *++stack;
2089 @@ -352,7 +339,6 @@
2090                         printk("<[%08lx]> ", x);
2091                 }
2092         }
2093 -#endif
2094  }
2095  
2096  static inline void wait_on_bh(void)
2097 diff -urN linux.orig/arch/ppc/kernel/local_irq.h linux/arch/ppc/kernel/local_irq.h
2098 --- linux.orig/arch/ppc/kernel/local_irq.h      Sun Mar 25 18:31:49 2001
2099 +++ linux/arch/ppc/kernel/local_irq.h   Thu Jul 11 15:43:29 2002
2100 @@ -26,7 +26,6 @@
2101  struct irqdesc {
2102         struct irqaction *action;
2103         struct hw_interrupt_type *ctl;
2104 -       int level;
2105  };
2106  
2107  extern struct irqdesc irq_desc[NR_IRQS];
2108 diff -urN linux.orig/arch/ppc/kernel/mbx_pci.c linux/arch/ppc/kernel/mbx_pci.c
2109 --- linux.orig/arch/ppc/kernel/mbx_pci.c        Sun Mar 25 18:31:49 2001
2110 +++ linux/arch/ppc/kernel/mbx_pci.c     Thu Jul 11 15:43:29 2002
2111 @@ -17,9 +17,7 @@
2112  
2113  #include <asm/io.h>
2114  #include <asm/mbx.h>
2115 -#include <asm/machdep.h>
2116  
2117 -#include "pci.h"
2118  
2119  /*
2120   * This blows......The MBX uses the Tundra QSpan PCI bridge.  When
2121 diff -urN linux.orig/arch/ppc/kernel/mbx_setup.c linux/arch/ppc/kernel/mbx_setup.c
2122 --- linux.orig/arch/ppc/kernel/mbx_setup.c      Sun Mar 25 18:31:49 2001
2123 +++ linux/arch/ppc/kernel/mbx_setup.c   Thu Jul 11 15:43:29 2002
2124 @@ -31,7 +31,6 @@
2125  #include <linux/init.h>
2126  #include <linux/blk.h>
2127  #include <linux/ioport.h>
2128 -#include <linux/delay.h>
2129  
2130  #include <asm/mmu.h>
2131  #include <asm/processor.h>
2132 @@ -41,25 +40,14 @@
2133  #include <asm/ide.h>
2134  #include <asm/mbx.h>
2135  #include <asm/machdep.h>
2136 -#include <asm/keyboard.h>
2137 -#include <asm/8xx_immap.h>
2138 -#include <asm/time.h>
2139  
2140 +#include "time.h"
2141  #include "local_irq.h"
2142  
2143  static int mbx_set_rtc_time(unsigned long time);
2144  unsigned long mbx_get_rtc_time(void);
2145  void mbx_calibrate_decr(void);
2146  
2147 -extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
2148 -extern int pckbd_getkeycode(unsigned int scancode);
2149 -extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
2150 -                          char raw_mode);
2151 -extern char pckbd_unexpected_up(unsigned char keycode);
2152 -extern void pckbd_leds(unsigned char leds);
2153 -extern void pckbd_init_hw(void);
2154 -extern unsigned char pckbd_sysrq_xlate[128];
2155 -
2156  extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode);
2157  extern int mackbd_getkeycode(unsigned int scancode);
2158  extern int mackbd_translate(unsigned char scancode, unsigned char *keycode,
2159 @@ -68,6 +56,8 @@
2160  extern void mackbd_leds(unsigned char leds);
2161  extern void mackbd_init_hw(void);
2162  
2163 +extern unsigned long loops_per_jiffy;
2164 +
2165  unsigned long empty_zero_page[1024];
2166  
2167  #ifdef CONFIG_BLK_DEV_RAM
2168 @@ -463,7 +453,7 @@
2169         ppc_md.kbd_leds          = pckbd_leds;
2170         ppc_md.kbd_init_hw       = pckbd_init_hw;
2171  #ifdef CONFIG_MAGIC_SYSRQ
2172 -       ppc_md.sysrq_xlate       = pckbd_sysrq_xlate;
2173 +       ppc_md.kbd_sysrq_xlate   = pckbd_sysrq_xlate;
2174         SYSRQ_KEY                = 0x54;
2175  #endif
2176  
2177 diff -urN linux.orig/arch/ppc/kernel/misc.S linux/arch/ppc/kernel/misc.S
2178 --- linux.orig/arch/ppc/kernel/misc.S   Sun Mar 25 18:37:30 2001
2179 +++ linux/arch/ppc/kernel/misc.S        Thu Jul 11 15:43:29 2002
2180 @@ -125,33 +125,12 @@
2181   * Flush MMU TLB
2182   */
2183  _GLOBAL(_tlbia)
2184 -#if defined(CONFIG_SMP)
2185 -       mfmsr   r10
2186 -       sync
2187 -       rlwinm  r0,r10,0,17,15          /* clear bit 16 (MSR_EE) */
2188 -       mtmsr   r0
2189 -       SYNC
2190 -       lis     r9,hash_table_lock@h
2191 -       ori     r9,r9,hash_table_lock@l
2192 -       lwz     r8,PROCESSOR(r2)
2193 -       oris    r8,r8,10
2194 -10:    lwarx   r7,0,r9
2195 -       cmpi    0,r7,0
2196 -       bne-    10b
2197 -       stwcx.  r8,0,r9
2198 -       bne-    10b
2199 -       eieio
2200 -#endif /* CONFIG_SMP */
2201         sync
2202         tlbia
2203         sync
2204  #ifdef __SMP__
2205         tlbsync
2206         sync
2207 -       li      r0,0
2208 -       stw     r0,0(r9)                /* clear hash_table_lock */
2209 -       mtmsr   r10
2210 -       SYNC
2211  #endif
2212         blr     
2213  
2214 @@ -159,32 +138,11 @@
2215   * Flush MMU TLB for a particular address
2216   */
2217  _GLOBAL(_tlbie)
2218 -#if defined(CONFIG_SMP)
2219 -       mfmsr   r10
2220 -       sync
2221 -       rlwinm  r0,r10,0,17,15          /* clear bit 16 (MSR_EE) */
2222 -       mtmsr   r0
2223 -       SYNC
2224 -       lis     r9,hash_table_lock@h
2225 -       ori     r9,r9,hash_table_lock@l
2226 -       lwz     r8,PROCESSOR(r2)
2227 -       oris    r8,r8,11
2228 -10:    lwarx   r7,0,r9
2229 -       cmpi    0,r7,0
2230 -       bne-    10b
2231 -       stwcx.  r8,0,r9
2232 -       bne-    10b
2233 -       eieio
2234 -#endif /* CONFIG_SMP */
2235         tlbie   r3
2236         sync
2237 -#ifdef CONFIG_SMP
2238 +#ifdef __SMP__
2239         tlbsync
2240         sync
2241 -       li      r0,0
2242 -       stw     r0,0(r9)                /* clear hash_table_lock */
2243 -       mtmsr   r10
2244 -       SYNC
2245  #endif
2246         blr
2247  
2248 @@ -317,8 +275,10 @@
2249         stwcx.  r5,0,r3         /* Update with new value */
2250         bne-    10b             /* Retry if "reservation" (i.e. lock) lost */
2251         SMP_MB
2252 -       cntlzw  r3,r5
2253 -       srwi    r3,r3,5
2254 +       cmpi    0,r5,0          /* Return 'true' IFF 0 */
2255 +       li      r3,1
2256 +       beqlr
2257 +       li      r3,0
2258         blr
2259  _GLOBAL(atomic_clear_mask)
2260         SMP_WMB                 /* wmb() */
2261 @@ -354,10 +314,8 @@
2262   * The *_ns versions don't do byte-swapping.
2263   */
2264  _GLOBAL(_insb)
2265 -       cmpwi   0,r5,0
2266         mtctr   r5
2267         subi    r4,r4,1
2268 -       blelr-
2269  00:    lbz     r5,0(r3)
2270         eieio
2271         stbu    r5,1(r4)
2272 @@ -365,10 +323,8 @@
2273         blr
2274  
2275  _GLOBAL(_outsb)
2276 -       cmpwi   0,r5,0
2277         mtctr   r5
2278         subi    r4,r4,1
2279 -       blelr-
2280  00:    lbzu    r5,1(r4)
2281         stb     r5,0(r3)
2282         eieio
2283 @@ -376,10 +332,8 @@
2284         blr     
2285  
2286  _GLOBAL(_insw)
2287 -       cmpwi   0,r5,0
2288         mtctr   r5
2289         subi    r4,r4,2
2290 -       blelr-
2291  00:    lhbrx   r5,0,r3
2292         eieio
2293         sthu    r5,2(r4)
2294 @@ -387,10 +341,8 @@
2295         blr
2296  
2297  _GLOBAL(_outsw)
2298 -       cmpwi   0,r5,0
2299         mtctr   r5
2300         subi    r4,r4,2
2301 -       blelr-
2302  00:    lhzu    r5,2(r4)
2303         eieio
2304         sthbrx  r5,0,r3 
2305 @@ -398,10 +350,8 @@
2306         blr     
2307  
2308  _GLOBAL(_insl)
2309 -       cmpwi   0,r5,0
2310         mtctr   r5
2311         subi    r4,r4,4
2312 -       blelr-
2313  00:    lwbrx   r5,0,r3
2314         eieio
2315         stwu    r5,4(r4)
2316 @@ -409,10 +359,8 @@
2317         blr
2318  
2319  _GLOBAL(_outsl)
2320 -       cmpwi   0,r5,0
2321         mtctr   r5
2322         subi    r4,r4,4
2323 -       blelr-
2324  00:    lwzu    r5,4(r4)
2325         stwbrx  r5,0,r3
2326         eieio
2327 @@ -421,10 +369,8 @@
2328  
2329  _GLOBAL(ide_insw)
2330  _GLOBAL(_insw_ns)
2331 -       cmpwi   0,r5,0
2332         mtctr   r5
2333         subi    r4,r4,2
2334 -       blelr-
2335  00:    lhz     r5,0(r3)
2336         eieio
2337         sthu    r5,2(r4)
2338 @@ -433,10 +379,8 @@
2339  
2340  _GLOBAL(ide_outsw)
2341  _GLOBAL(_outsw_ns)
2342 -       cmpwi   0,r5,0
2343         mtctr   r5
2344         subi    r4,r4,2
2345 -       blelr-
2346  00:    lhzu    r5,2(r4)
2347         sth     r5,0(r3)
2348         eieio
2349 @@ -444,10 +388,8 @@
2350         blr     
2351  
2352  _GLOBAL(_insl_ns)
2353 -       cmpwi   0,r5,0
2354         mtctr   r5
2355         subi    r4,r4,4
2356 -       blelr-
2357  00:    lwz     r5,0(r3)
2358         eieio
2359         stwu    r5,4(r4)
2360 @@ -455,10 +397,8 @@
2361         blr
2362  
2363  _GLOBAL(_outsl_ns)
2364 -       cmpwi   0,r5,0
2365         mtctr   r5
2366         subi    r4,r4,4
2367 -       blelr-
2368  00:    lwzu    r5,4(r4)
2369         stw     r5,0(r3)
2370         eieio
2371 @@ -466,59 +406,48 @@
2372         blr     
2373  
2374  /*
2375 - * Extended precision shifts.
2376 - * 
2377 - * Updated to be valid for shift counts from 0 to 63 inclusive.
2378 - * -- Gabriel
2379 + * Extended precision shifts
2380   *
2381   * R3/R4 has 64 bit value
2382   * R5    has shift count
2383   * result in R3/R4
2384   *
2385 - *  ashrdi3: arithmetic right shift (sign propagation)     
2386 - *  lshrdi3: logical right shift       
2387 - *  ashldi3: left shift
2388 + *  ashrdi3:     XXXYYY/ZZZAAA -> SSSXXX/YYYZZZ
2389 + *  ashldi3:     XXXYYY/ZZZAAA -> YYYZZZ/AAA000
2390 + *  lshrdi3:     XXXYYY/ZZZAAA -> 000XXX/YYYZZZ
2391   */
2392  _GLOBAL(__ashrdi3)
2393 -       subfic  r6,r5,32        
2394 -       srw     r4,r4,r5        # LSW = count > 31 ? 0 : LSW >> count
2395 -       addi    r7,r5,32        # could be xori, or addi with -32
2396 -       slw     r6,r3,r6        # t1 = count > 31 ? 0 : MSW << (32-count)
2397 -       rlwinm  r8,r7,0,32      # t3 = (count < 32) ? 32 : 0
2398 -       sraw    r7,r3,r7        # t2 = MSW >> (count-32)
2399 -       or      r4,r4,r6        # LSW |= t1
2400 -       slw     r7,r7,r8        # t2 = (count < 32) ? 0 : t2
2401 -       sraw    r3,r3,r5        # MSW = MSW >> count
2402 -       or      r4,r4,r7        # LSW |= t2
2403 +       li      r6,32
2404 +       sub     r6,r6,r5
2405 +       slw     r7,r3,r6        /* isolate YYY */
2406 +       srw     r4,r4,r5        /* isolate ZZZ */
2407 +       or      r4,r4,r7        /* YYYZZZ */
2408 +       sraw    r3,r3,r5        /* SSSXXX */
2409         blr
2410  
2411  _GLOBAL(__ashldi3)
2412 -       subfic  r6,r5,32        
2413 -       slw     r3,r3,r5        # MSW = count > 31 ? 0 : MSW << count
2414 -       addi    r7,r5,32        # could be xori, or addi with -32
2415 -       srw     r6,r4,r6        # t1 = count > 31 ? 0 : LSW >> (32-count)
2416 -       slw     r7,r4,r7        # t2 = count < 32 ? 0 : LSW << (count-32)
2417 -       or      r3,r3,r6        # MSW |= t1
2418 -       slw     r4,r4,r5        # LSW = LSW << count
2419 -       or      r3,r3,r7        # MSW |= t2
2420 +       li      r6,32
2421 +       sub     r6,r6,r5
2422 +       srw     r7,r4,r6        /* isolate ZZZ */
2423 +       slw     r4,r4,r5        /* AAA000 */
2424 +       slw     r3,r3,r5        /* YYY--- */
2425 +       or      r3,r3,r7        /* YYYZZZ */
2426         blr
2427  
2428  _GLOBAL(__lshrdi3)
2429 -       subfic  r6,r5,32        
2430 -       srw     r4,r4,r5        # LSW = count > 31 ? 0 : LSW >> count
2431 -       addi    r7,r5,32        # could be xori, or addi with -32
2432 -       slw     r6,r3,r6        # t1 = count > 31 ? 0 : MSW << (32-count)
2433 -       srw     r7,r3,r7        # t2 = count < 32 ? 0 : MSW >> (count-32)
2434 -       or      r4,r4,r6        # LSW |= t1
2435 -       srw     r3,r3,r5        # MSW = MSW >> count
2436 -       or      r4,r4,r7        # LSW |= t2 
2437 +       li      r6,32
2438 +       sub     r6,r6,r5
2439 +       slw     r7,r3,r6        /* isolate YYY */
2440 +       srw     r4,r4,r5        /* isolate ZZZ */
2441 +       or      r4,r4,r7        /* YYYZZZ */
2442 +       srw     r3,r3,r5        /* 000XXX */
2443         blr
2444  
2445  _GLOBAL(abs)
2446 -       srawi   r4,r3,31
2447 -       xor     r3,r3,r4
2448 -       sub     r3,r3,r4
2449 -       blr
2450 +       cmpi    0,r3,0
2451 +       bge     10f
2452 +       neg     r3,r3
2453 +10:    blr
2454  
2455  _GLOBAL(_get_SP)
2456         mr      r3,r1           /* Close enough */
2457 @@ -563,14 +492,6 @@
2458         isync /* Handle erratas in some cases */
2459         blr
2460  
2461 -_GLOBAL(_get_ICTC)
2462 -       mfspr   r3,ICTC
2463 -       blr
2464 -
2465 -_GLOBAL(_set_ICTC)
2466 -       mtspr   ICTC,r3
2467 -       blr
2468 -
2469  /*
2470         L2CR functions
2471         Copyright Â© 1997-1998 by PowerLogix R & D, Inc.
2472 @@ -592,17 +513,6 @@
2473  /*
2474         Thur, Dec. 12, 1998.
2475         - First public release, contributed by PowerLogix.
2476 -       ***********
2477 -       Sat, Aug. 7, 1999.
2478 -       - Terry: Made sure code disabled interrupts before running. (Previously
2479 -                       it was assumed interrupts were already disabled).
2480 -       - Terry: Updated for tentative G4 support.  4MB of memory is now flushed
2481 -                       instead of 2MB.  (Prob. only 3 is necessary).
2482 -       - Terry: Updated for workaround to HID0[DPM] processor bug
2483 -                       during global invalidates.
2484 -       ***********
2485 -       Thu, July 13, 2000.
2486 -       - Terry: Added isync to correct for an errata.
2487         
2488         Author: Terry Greeniaus (tgree@phys.ualberta.ca)
2489         Please e-mail updates to this file to me, thanks!
2490 @@ -641,94 +551,80 @@
2491         causes cache pushes from the L1 cache to go to the L2 cache
2492         instead of to main memory.
2493  */
2494 -/*
2495 - * Summary: this procedure ignores the L2I bit in the value passed in,
2496 - * flushes the cache if it was already enabled, always invalidates the
2497 - * cache, then enables the cache if the L2E bit is set in the value
2498 - * passed in.
2499 - *   -- paulus.
2500 - */
2501 +
2502  _GLOBAL(_set_L2CR)
2503 -       /* Make sure this is a 750 or 7400 chip */
2504 +       /* Make sure this is a 750 chip */
2505         mfspr   r4,PVR
2506         rlwinm  r4,r4,16,16,31
2507 -       cmpwi   r4,0x0008
2508 -       cmpwi   cr1,r4,0x000c
2509 -       cror    2,2,4*cr1+2
2510 -       bne     99f
2511 -
2512 -       /* Turn off interrupts and data relocation. */
2513 -       mfmsr   r7              /* Save MSR in r7 */
2514 -       rlwinm  r4,r7,0,17,15
2515 -       rlwinm  r4,r4,0,28,26   /* Turn off DR bit */
2516 +       cmplwi  r4,0x0008
2517 +       beq     thisIs750
2518 +       li      r3,-1
2519 +       blr
2520 +       
2521 +thisIs750:
2522 +       /* Get the current enable bit of the L2CR into r4 */
2523 +       mfspr   r4,L2CR
2524 +       mfmsr   r7
2525 +       
2526 +       /* See if we want to perform a global inval this time. */
2527 +       rlwinm  r6,r3,0,10,10   /* r6 contains the new invalidate bit */
2528 +       rlwinm. r5,r3,0,0,0     /* r5 contains the new enable bit */
2529 +       rlwinm  r3,r3,0,11,9    /* Turn off the invalidate bit */
2530 +       rlwimi  r3,r4,0,0,0     /* Keep the enable bit the same as it was. */
2531 +       bne     dontDisableCache /* Only disable the cache if L2CRApply
2532 +                                   has the enable bit off */
2533 +
2534 +disableCache:
2535 +       /* Disable the cache.  First, we turn off interrupts.
2536 +          An interrupt while we are flushing the cache could bring
2537 +          in data which may not get properly flushed. */
2538 +       rlwinm  r4,r7,0,17,15   /* Turn off EE bit */
2539         sync
2540         mtmsr   r4
2541         sync
2542 -
2543 -       /* Get the current enable bit of the L2CR into r4 */
2544 -       mfspr   r4,L2CR
2545         
2546 -       /* Tweak some bits */
2547 -       rlwinm  r5,r3,0,0,0             /* r5 contains the new enable bit */
2548 -       rlwinm  r3,r3,0,11,9            /* Turn off the invalidate bit */
2549 -       rlwinm  r3,r3,0,1,31            /* Turn off the enable bit */
2550 -
2551 -       /* Check to see if we need to flush */
2552 -       rlwinm. r4,r4,0,0,0
2553 -       beq     2f
2554 -
2555 -       /* Flush the cache. First, read the first 4MB of memory (physical) to
2556 -        * put new data in the cache.  (Actually we only need
2557 -        * the size of the L2 cache plus the size of the L1 cache, but 4MB will
2558 -        * cover everything just to be safe).
2559 -        */
2560 -               
2561 -        /**** Might be a good idea to set L2DO here - to prevent instructions
2562 -              from getting into the cache.  But since we invalidate
2563 -              the next time we enable the cache it doesn't really matter.
2564 -         ****/
2565 -
2566 -       lis     r4,0x0002
2567 +/*
2568 +       Now, read the first 2MB of memory to put new data in the cache.
2569 +       (Actually we only need the size of the L2 cache plus the size
2570 +       of the L1 cache, but 2MB will cover everything just to be safe).
2571 +*/
2572 +       lis     r4,0x0001
2573         mtctr   r4
2574 -       li      r4,0
2575 -1:
2576 -       lwzx    r0,r0,r4
2577 -       addi    r4,r4,32                /* Go to start of next cache line */
2578 +       lis     r4,KERNELBASE@h
2579 +1:     lwzx    r0,r0,r4
2580 +       addi    r4,r4,0x0020            /* Go to start of next cache line */
2581         bdnz    1b
2582         
2583 -       /* Now, flush the first 4MB of memory */
2584 -       lis     r4,0x0002
2585 +       /* Now, flush the first 2MB of memory */
2586 +       lis     r4,0x0001
2587         mtctr   r4
2588 -       li      r4,0
2589 +       lis     r4,KERNELBASE@h
2590         sync
2591 -1:
2592 -       dcbf    r0,r4
2593 -       addi    r4,r4,32                /* Go to start of next cache line */
2594 -       bdnz    1b
2595 -
2596 -2:
2597 -       /* Set up the L2CR configuration bits (and switch L2 off) */
2598 +2:     dcbf    r0,r4
2599 +       addi    r4,r4,0x0020    /* Go to start of next cache line */
2600 +       bdnz    2b
2601 +       
2602 +       /* Turn off the L2CR enable bit. */
2603 +       rlwinm  r3,r3,0,1,31
2604 +       
2605 +dontDisableCache:
2606 +       /* Set up the L2CR configuration bits */
2607         sync
2608         mtspr   L2CR,r3
2609         sync
2610  
2611 -       /* Before we perform the global invalidation, we must disable dynamic
2612 -        * power management via HID0[DPM] to work around a processor bug where
2613 -        * DPM can possibly interfere with the state machine in the processor
2614 -        * that invalidates the L2 cache tags.
2615 -        */
2616 -       mfspr   r8,HID0                 /* Save HID0 in r8 */
2617 -       rlwinm  r4,r8,0,12,10           /* Turn off HID0[DPM] */
2618 -       sync
2619 -       mtspr   HID0,r4                 /* Disable DPM */
2620 +       /* Reenable interrupts if necessary. */
2621 +       mtmsr   r7
2622         sync
2623 -
2624 +       
2625 +       cmplwi  r6,0
2626 +       beq     noInval
2627 +       
2628         /* Perform a global invalidation */
2629         oris    r3,r3,0x0020
2630         sync
2631         mtspr   L2CR,r3
2632         sync
2633 -       isync                           /* For errata */
2634  
2635         /* Wait for the invalidation to complete */
2636  3:     mfspr   r3,L2CR
2637 @@ -740,38 +636,25 @@
2638         mtspr   L2CR,r3
2639         sync
2640         
2641 -       /* Restore HID0[DPM] to whatever it was before */
2642 -       sync
2643 -       mtspr   1008,r8
2644 -       sync
2645 -
2646 +noInval:
2647         /* See if we need to enable the cache */
2648         cmplwi  r5,0
2649 -       beq     4f
2650 +       beqlr
2651  
2652         /* Enable the cache */
2653         oris    r3,r3,0x8000
2654         mtspr   L2CR,r3
2655         sync
2656 -
2657 -       /* Restore MSR (restores EE and DR bits to original state) */
2658 -4:     sync
2659 -       mtmsr   r7
2660 -       sync
2661 -       blr
2662 -
2663 -99:    li      r3,-1
2664         blr
2665  
2666  _GLOBAL(_get_L2CR)
2667         /* Make sure this is a 750 chip */
2668         mfspr   r3,PVR
2669 -       srwi    r3,r3,16
2670 -       cmpwi   r3,0x0008
2671 -       cmpwi   cr1,r3,0x000c
2672 +       rlwinm  r3,r3,16,16,31
2673 +       cmplwi  r3,0x0008
2674         li      r3,0
2675 -       cror    2,2,4*cr1+2
2676         bnelr
2677 +       
2678         /* Return the L2CR contents */
2679         mfspr   r3,L2CR
2680         blr
2681 @@ -779,6 +662,16 @@
2682  /* --- End of PowerLogix code ---
2683   */
2684  
2685 +/*
2686 +_GLOBAL(_get_L2CR)
2687 +       mfspr   r3,L2CR
2688 +       blr
2689 +
2690 +_GLOBAL(_set_L2CR)
2691 +       mtspr   L2CR,r3
2692 +       blr
2693 +               
2694 +*/
2695  
2696  /*
2697   * These are used in the alignment trap handler when emulating
2698 @@ -1036,7 +929,11 @@
2699         .long sys_getresuid     /* 165 */
2700         .long sys_query_module
2701         .long sys_poll
2702 +#ifdef CONFIG_NFSD
2703         .long sys_nfsservctl
2704 +#else
2705 +       .long sys_ni_syscall
2706 +#endif         
2707         .long sys_setresgid
2708         .long sys_getresgid     /* 170 */
2709         .long sys_prctl
2710 @@ -1058,18 +955,4 @@
2711         .long sys_ni_syscall            /* streams1 */
2712         .long sys_ni_syscall            /* streams2 */
2713         .long sys_vfork
2714 -       .long sys_ni_syscall            /* 190 */       /* MacOnLinux - old */
2715 -       .long sys_ni_syscall            /* 191 */       /* Unused */
2716 -       .long sys_ni_syscall            /* 192 - reserved - mmap2 */
2717 -       .long sys_ni_syscall            /* 193 - reserved - truncate64 */
2718 -       .long sys_ni_syscall            /* 194 - reserved - ftruncate64 */
2719 -       .long sys_ni_syscall            /* 195 - reserved - stat64 */
2720 -       .long sys_ni_syscall            /* 196 - reserved - lstat64 */
2721 -       .long sys_ni_syscall            /* 197 - reserved - fstat64 */
2722 -       .long sys_pciconfig_read        /* 198 */
2723 -       .long sys_pciconfig_write       /* 199 */
2724 -       .long sys_pciconfig_iobase      /* 200 */
2725 -       .long sys_ni_syscall            /* 201 - reserved - MacOnLinux - new */
2726 -       .rept NR_syscalls-201
2727 -               .long sys_ni_syscall
2728 -       .endr
2729 +       .space (NR_syscalls-183)*4
2730 diff -urN linux.orig/arch/ppc/kernel/mk_defs.c linux/arch/ppc/kernel/mk_defs.c
2731 --- linux.orig/arch/ppc/kernel/mk_defs.c        Fri Nov  2 17:39:05 2001
2732 +++ linux/arch/ppc/kernel/mk_defs.c     Thu Jul 11 15:43:29 2002
2733 @@ -8,7 +8,7 @@
2734   * #defines from the assembly-language output.
2735   */
2736  
2737 -#include <linux/config.h>
2738 +#include <stddef.h>
2739  #include <linux/signal.h>
2740  #include <linux/sched.h>
2741  #include <linux/kernel.h>
2742 @@ -22,6 +22,7 @@
2743  #include <asm/page.h>
2744  #include <asm/pgtable.h>
2745  #include <asm/processor.h>
2746 +#include <asm/pf-compat.h>
2747  
2748  #define DEFINE(sym, val) \
2749         asm volatile("\n#define\t" #sym "\t%0" : : "i" (val))
2750 @@ -43,18 +44,11 @@
2751         DEFINE(PGD, offsetof(struct mm_struct, pgd));
2752         DEFINE(LAST_SYSCALL, offsetof(struct thread_struct, last_syscall));
2753         DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
2754 -       DEFINE(PT_TRACESYS, PT_TRACESYS);
2755 +       DEFINE(PF_TRACESYS, PF_TRACESYS);
2756         DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
2757 -       DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
2758         DEFINE(NEED_RESCHED, offsetof(struct task_struct, need_resched));
2759         DEFINE(TSS_FPR0, offsetof(struct thread_struct, fpr[0]));
2760         DEFINE(TSS_FPSCR, offsetof(struct thread_struct, fpscr));
2761 -#ifdef CONFIG_ALTIVEC
2762 -       DEFINE(TSS_VR0, offsetof(struct thread_struct, vr[0]));
2763 -       DEFINE(TSS_VRSAVE, offsetof(struct thread_struct, vrsave));
2764 -       DEFINE(TSS_VSCR, offsetof(struct thread_struct, vscr));
2765 -#endif /* CONFIG_ALTIVEC */
2766 -
2767         /* Interrupt register frame */
2768         DEFINE(TASK_UNION_SIZE, sizeof(union task_union));
2769         DEFINE(STACK_FRAME_OVERHEAD, STACK_FRAME_OVERHEAD);
2770 diff -urN linux.orig/arch/ppc/kernel/open_pic.c linux/arch/ppc/kernel/open_pic.c
2771 --- linux.orig/arch/ppc/kernel/open_pic.c       Sun Mar 25 18:31:49 2001
2772 +++ linux/arch/ppc/kernel/open_pic.c    Thu Jul 11 15:43:29 2002
2773 @@ -1,126 +1,48 @@
2774 -/*
2775 - * open_pic.c
2776 - *
2777 - * Common support routines for platforms with an OpenPIC interrupt controller
2778 - *
2779 - */
2780 -
2781  #include <linux/stddef.h>
2782  #include <linux/init.h>
2783  #include <linux/sched.h>
2784  #include <linux/signal.h>
2785  #include <linux/openpic.h>
2786  #include <asm/irq.h>
2787 -#include <asm/processor.h>
2788  #include "open_pic.h"
2789  #include "i8259.h"
2790  
2791 -extern volatile unsigned char *chrp_int_ack_special;
2792 -
2793 -void open_pic_do_IRQ(struct pt_regs *regs, int cpu, int isfake)
2794 -{
2795 -       int irq;
2796 -        int openpic_eoi_done = 0;
2797 -
2798  #ifdef __SMP__
2799 -        {
2800 -                unsigned int loops = 1000000;
2801 -                while (test_bit(0, &global_irq_lock)) {
2802 -                        if (smp_processor_id() == global_irq_holder) {
2803 -                                printk("uh oh, interrupt while we hold global irq lock!\n");
2804 -#ifdef CONFIG_XMON
2805 -                                xmon(0);
2806 -#endif
2807 -                                break;
2808 -                        }
2809 -                        if (loops-- == 0) {
2810 -                                printk("do_IRQ waiting for irq lock (holder=%d)\n", global_irq_holder);
2811 -#ifdef CONFIG_XMON
2812 -                                xmon(0);
2813 -#endif
2814 -                        }
2815 -                }
2816 -        }
2817 +void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs)
2818 +{
2819 +       smp_message_recv(cpl-OPENPIC_VEC_IPI);
2820 +}
2821  #endif /* __SMP__ */
2822 -       
2823 -        irq = openpic_irq(smp_processor_id());
2824 -       /* make sure open_pic.irq_offset is set to something!
2825 -        * do we really need the _MACH_Pmac test??
2826 -        */
2827 -        if (!(_machine == _MACH_Pmac) && (irq == open_pic.irq_offset))
2828 -        {
2829 -                /*
2830 -                 * This magic address generates a PCI IACK cycle.
2831 -                 *
2832 -                 * This should go in the above mask/ack code soon. -- Cort
2833 -                 */
2834 -               if ( chrp_int_ack_special )
2835 -                       irq = *chrp_int_ack_special;
2836 -#ifndef CONFIG_PMAC
2837 -               else
2838 -                       irq = i8259_irq(0);
2839 -#endif
2840 -                /*
2841 -                 * Acknowledge as soon as possible to allow i8259
2842 -                 * interrupt nesting                         */
2843 -                openpic_eoi(smp_processor_id());
2844 -                openpic_eoi_done = 1;
2845 -        }
2846 -        if (irq == OPENPIC_VEC_SPURIOUS)
2847 -        {
2848 -                /*
2849 -                 * Spurious interrupts should never be
2850 -                 * acknowledged
2851 -                 */
2852 -                ppc_spurious_interrupts++;
2853 -                openpic_eoi_done = 1;
2854 -               goto out;
2855 -        }
2856  
2857 -        if (irq < 0)
2858 -        {
2859 -                printk(KERN_DEBUG "Bogus interrupt %d from PC = %lx\n",
2860 -                       irq, regs->nip);
2861 -                ppc_spurious_interrupts++;
2862 -        }
2863 -       else
2864 -        {
2865 -               ppc_irq_dispatch_handler( regs, irq );
2866 -       }
2867 -out:
2868 -        if (!openpic_eoi_done)
2869 -                openpic_eoi(smp_processor_id());
2870 +void chrp_mask_and_ack_irq(unsigned int irq_nr)
2871 +{
2872 +       if ((_machine != _MACH_gemini) && is_8259_irq(irq_nr))
2873 +               i8259_pic.mask_and_ack(irq_nr);
2874  }
2875  
2876 -#ifdef __SMP__
2877 -void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs)
2878 +static void chrp_mask_irq(unsigned int irq_nr)
2879  {
2880 -       smp_message_recv(cpl-OPENPIC_VEC_IPI);
2881 +       if ((_machine != _MACH_gemini) && is_8259_irq(irq_nr))
2882 +               i8259_pic.disable(irq_nr);
2883 +       else
2884 +               openpic_disable_irq(irq_nr-open_pic.irq_offset);
2885  }
2886 -#endif /* __SMP__ */
2887  
2888 +static void chrp_unmask_irq(unsigned int irq_nr)
2889 +{
2890 +       if ((_machine != _MACH_gemini) && is_8259_irq(irq_nr))
2891 +               i8259_pic.enable(irq_nr);
2892 +       else
2893 +               openpic_enable_irq(irq_nr-open_pic.irq_offset);
2894 +}
2895  
2896  struct hw_interrupt_type open_pic = {
2897         " OpenPIC  ",
2898         NULL,
2899         NULL,
2900         NULL,
2901 -       openpic_enable_irq,
2902 -       openpic_disable_irq,
2903 -       /* Theorically, the mask&ack should be NULL for OpenPIC. However, doing
2904 -        * so shows tons of bogus interrupts coming in.
2905 -        * This problem is apparently due to the common code always calling
2906 -        * unmask(). I apparently (need more test) fixed it in the 2.4 new IRQ
2907 -        * management by cleanly implementing the handler's end() function, so
2908 -        * neither mask nor unmask are needed. In the meantime, the fix below will
2909 -        * work for 2.2 -Benh
2910 -        *
2911 -        * Hopefully this will fix my bogus interrups on MTX
2912 -        * I merged everthing together so we don't have the same code in three
2913 -        * places. This might cause stability problems, but I'd rather
2914 -        * get it right once than three different times because someone forgot
2915 -        * to make the same change to PReP or something --Troy
2916 -        */
2917 -       openpic_disable_irq,
2918 +       chrp_unmask_irq,
2919 +       chrp_mask_irq,
2920 +       chrp_mask_and_ack_irq,
2921         0
2922  };
2923 diff -urN linux.orig/arch/ppc/kernel/open_pic.h linux/arch/ppc/kernel/open_pic.h
2924 --- linux.orig/arch/ppc/kernel/open_pic.h       Sun Mar 25 18:31:49 2001
2925 +++ linux/arch/ppc/kernel/open_pic.h    Thu Jul 11 15:43:29 2002
2926 @@ -6,7 +6,6 @@
2927  
2928  extern struct hw_interrupt_type open_pic;
2929  
2930 -void open_pic_do_IRQ(struct pt_regs *regs, int cpu, int isfake);
2931  void openpic_ipi_action(int cpl, void *dev_id, struct pt_regs *regs);
2932  void openpic_enable_IPI(u_int ipi);
2933  void do_openpic_setup_cpu(void);
2934 diff -urN linux.orig/arch/ppc/kernel/openpic.c linux/arch/ppc/kernel/openpic.c
2935 --- linux.orig/arch/ppc/kernel/openpic.c        Fri Nov  2 17:39:05 2001
2936 +++ linux/arch/ppc/kernel/openpic.c     Thu Jul 11 15:43:29 2002
2937 @@ -5,11 +5,6 @@
2938   *
2939   *  Fixed up IPI and restructured a bit
2940   *    Cort Dougan <cort@ppc.kernel.org>
2941 - *
2942 - *  Added initialisation code for Apple Core99 machines, tweaked a few things
2943 - *  to avoid bogus interrupts and to make sure the disable function exits with
2944 - *  the interrupt actually masked. --BenH
2945 - *  Todo: map interrupts to all available CPUs after the ack round
2946   * 
2947   *  This file is subject to the terms and conditions of the GNU General Public
2948   *  License.  See the file COPYING in the main directory of this archive
2949 @@ -26,16 +21,11 @@
2950  #include <asm/io.h>
2951  #include <asm/irq.h>
2952  #include "open_pic.h"
2953 -#ifdef __powerpc__
2954 -#include <asm/prom.h>
2955 -#endif
2956  
2957  #define REGISTER_DEBUG
2958  #undef REGISTER_DEBUG
2959  
2960 -#ifdef __powerpc__
2961 -extern int use_of_interrupt_tree;
2962 -#endif
2963 +#define OPENPIC_SENSE_POLARITY                 0x00800000      /* Undoc'd */
2964  
2965  volatile struct OpenPIC *OpenPIC = NULL;
2966  u_int OpenPIC_NumInitSenses __initdata = 0;
2967 @@ -92,7 +82,7 @@
2968   *  I/O functions
2969   */
2970  #ifdef __i386__
2971 -static inline u_int in_le32(volatile u_int *addr)
2972 +static inline u_int ld_le32(volatile u_int *addr)
2973  {
2974         return *addr;
2975  }
2976 @@ -107,7 +97,7 @@
2977  {
2978         u_int val;
2979  
2980 -       val = in_le32(addr);
2981 +       val = ld_le32(addr);
2982  #ifdef REGISTER_DEBUG
2983         printk("openpic_read(0x%08x) = 0x%08x\n", (u_int)addr, val);
2984  #endif
2985 @@ -154,9 +144,6 @@
2986  {
2987         openpic_setfield(addr, OPENPIC_MASK);
2988         /* wait until it's not in use */
2989 -       /* BenH: Is this code really enough ? I would rather check the result
2990 -        *       and eventually retry ...
2991 -        */
2992         while (openpic_read(addr) & OPENPIC_ACTIVITY);
2993         openpic_writefield(addr, mask | OPENPIC_MASK, field | OPENPIC_MASK);
2994  }
2995 @@ -164,20 +151,7 @@
2996  /*
2997   *  Initialize the OpenPIC
2998   */
2999 -
3000 -/* PoweMac note:
3001 - *
3002 - * With BootX, we consider the controller as beeing already initialized by MacOS
3003 - * and we only mask out interrupts.
3004 - * With OF booting, we initialize the interrupts that we find in the device tree,
3005 - * other ones are just masked out.
3006 - * Note: We might want to adjust priorities too.
3007 - */
3008 -
3009 -/* Not an init func, called on pbook wakeup --BenH */
3010 -void
3011 -__init
3012 -openpic_init(int main_pic)
3013 +__initfunc(void openpic_init(int main_pic))
3014  {
3015         u_int t, i;
3016         u_int timerfreq;
3017 @@ -207,16 +181,13 @@
3018                       OPENPIC_FEATURE_LAST_SOURCE_SHIFT) + 1;
3019         printk("OpenPIC Version %s (%d CPUs and %d IRQ sources) at %p\n", version,
3020                NumProcessors, NumSources, OpenPIC);
3021 -       /* Apple's OpenPIC is an IBM MPIC without the timer. */
3022 -       if (_machine != _MACH_Pmac) {
3023 -               timerfreq = openpic_read(&OpenPIC->Global.Timer_Frequency);
3024 -               printk("OpenPIC timer frequency is ");
3025 -               if (timerfreq)
3026 -                       printk("%d Hz\n", timerfreq);
3027 -               else
3028 -                       printk("not set\n");
3029 -       }
3030 -       
3031 +       timerfreq = openpic_read(&OpenPIC->Global.Timer_Frequency);
3032 +       printk("OpenPIC timer frequency is ");
3033 +       if (timerfreq)
3034 +               printk("%d Hz\n", timerfreq);
3035 +       else
3036 +               printk("not set\n");
3037 +
3038         if ( main_pic )
3039         {
3040                 /* Initialize timer interrupts */
3041 @@ -229,60 +200,24 @@
3042             
3043                 /* Initialize IPI interrupts */
3044                 for (i = 0; i < OPENPIC_NUM_IPI; i++) {
3045 -                       openpic_initipi(i, 10+i, OPENPIC_VEC_IPI+i);
3046 +                       openpic_initipi(i, 10, OPENPIC_VEC_IPI+i);
3047                 }
3048             
3049 -               if (_machine != _MACH_Pmac) {
3050 -                       /* Initialize external interrupts */
3051 -                       for (i = 0; i < NumSources; i++) {
3052 -                           /* Enabled, Priority 8 */
3053 -                           openpic_initirq(i, 8, open_pic.irq_offset+i, 0,
3054 -                               i < OpenPIC_NumInitSenses ? OpenPIC_InitSenses[i] : 1);
3055 -                           /* Processor 0 */
3056 -                           openpic_mapirq(i, 1<<0);
3057 -                       }
3058 -               } else {
3059 -                       /* Prevent any interrupt from occurring during initialisation.
3060 -                        * Hum... I believe this is not necessary, Apple does that in
3061 -                        * Darwin's PowerExpress code.
3062 -                        */
3063 -                       openpic_set_priority(0, 0xf);
3064 -
3065 -                       /* First disable all interrupts and map them to CPU 0 */
3066 -                       for (i = 0; i < NumSources; i++) {
3067 -                               openpic_disable_irq(i);
3068 -                               openpic_mapirq(i, 1<<0);
3069 -                       }
3070 -                       
3071 -                       /* If we use the device tree, then lookup all interrupts and
3072 -                        * initialize them according to sense infos found in the tree
3073 -                        */
3074 -                       if (use_of_interrupt_tree) {
3075 -                               struct device_node* np = find_all_nodes();
3076 -                               while(np) {
3077 -                                   int j, pri;
3078 -                                   pri = strcmp(np->name, "programmer-switch") ? 2 : 7;
3079 -                                   for (j=0;j<np->n_intrs;j++) {
3080 -                                       openpic_initirq(        np->intrs[j].line,
3081 -                                                               pri,
3082 -                                                               np->intrs[j].line,
3083 -                                                               0,
3084 -                                                               np->intrs[j].sense);
3085 -                                       irq_desc[np->intrs[j].line].level = np->intrs[j].sense;
3086 -                                   }
3087 -                                   np = np->next;
3088 -                               }
3089 -                       } else {
3090 -                               /* Fixme: read level value from controller */
3091 -                               printk("openpic: WARNING, openpic running without interrupt tree\n");
3092 -                       }
3093 +               /* Initialize external interrupts */
3094 +               for (i = 0; i < NumSources; i++) {
3095 +                       /* Enabled, Priority 8 */
3096 +                       openpic_initirq(i, 8, open_pic.irq_offset+i, 0,
3097 +                                       i < OpenPIC_NumInitSenses ? OpenPIC_InitSenses[i] : 1);
3098 +                       /* Processor 0 */
3099 +                       openpic_mapirq(i, 1<<0);
3100                 }
3101 -
3102 +           
3103                 /* Initialize the spurious interrupt */
3104                 openpic_set_spurious(OPENPIC_VEC_SPURIOUS);
3105  
3106                 /* Gemini has no i8259 */
3107 -               if (( _machine != _MACH_gemini ) && (_machine != _MACH_Pmac)) {
3108 +               if ( _machine != _MACH_gemini )
3109 +               {
3110                         /* SIOint (8259 cascade) is special */
3111                         openpic_initirq(0, 8, open_pic.irq_offset, 1, 1);
3112                         openpic_mapirq(0, 1<<0);
3113 @@ -292,14 +227,6 @@
3114                 }
3115                 openpic_set_priority(0, 0);
3116                 openpic_disable_8259_pass_through();
3117 -
3118 -               /* We ack pending interrupts to avoid blocking them */
3119 -               if (_machine == _MACH_Pmac) {
3120 -                       for (i = 0; i < NumSources; i++) {
3121 -                               (void)openpic_irq(0);
3122 -                               openpic_eoi(0);
3123 -                       }
3124 -               }
3125         }
3126  }
3127  
3128 @@ -311,10 +238,6 @@
3129  {
3130         openpic_setfield(&OpenPIC->Global.Global_Configuration0,
3131                          OPENPIC_CONFIG_RESET);
3132 -       /* Wait for reset to complete */
3133 -       while(openpic_readfield(&OpenPIC->Global.Global_Configuration0,
3134 -                       OPENPIC_CONFIG_RESET))
3135 -               ;
3136  }
3137  
3138  
3139 @@ -360,7 +283,6 @@
3140  {
3141         check_arg_cpu(cpu);
3142         openpic_write(&OpenPIC->THIS_CPU.EOI, 0);
3143 -       (void)openpic_read(&OpenPIC->THIS_CPU.EOI);
3144  }
3145  
3146  
3147 @@ -465,12 +387,12 @@
3148         
3149         for ( i = 0; i < OPENPIC_NUM_IPI ; i++ )
3150                   openpic_enable_IPI(i);
3151 -
3152 +#if 0  
3153         /* let the openpic know we want intrs */
3154         for ( i = 0; i < NumSources ; i++ )
3155                 openpic_mapirq(i, openpic_read(&OpenPIC->Source[i].Destination)
3156                                | (1<<smp_processor_id()) );
3157 -
3158 +#endif 
3159         openpic_set_priority(smp_processor_id(), 0);
3160  }    
3161  
3162 @@ -506,43 +428,14 @@
3163   */
3164  void openpic_enable_irq(u_int irq)
3165  {
3166 -       /* on SMP, we get IPI vector numbers here, we should handle them
3167 -        * or at least ignore them.
3168 -        */
3169 -       if (irq < 0 || irq >= NumSources)
3170 -               return;
3171 +       check_arg_irq(irq);
3172         openpic_clearfield(&OpenPIC->Source[irq].Vector_Priority, OPENPIC_MASK);
3173 -       /* make sure mask gets to controller before we return to user */
3174 -       do {
3175 -               mb();
3176 -       } while(openpic_readfield(&OpenPIC->Source[irq].Vector_Priority,
3177 -                       OPENPIC_MASK));
3178 -}
3179 -
3180 -u_int openpic_get_enable(u_int irq)
3181 -{
3182 -       if (irq < 0 || irq >= NumSources)
3183 -               return 0;
3184 -       return !openpic_readfield(&OpenPIC->Source[irq].Vector_Priority,
3185 -                       OPENPIC_MASK);
3186  }
3187  
3188  void openpic_disable_irq(u_int irq)
3189  {
3190 -       u32 vp;
3191 -       
3192 -       /* on SMP, we get IPI vector numbers here, we should handle them
3193 -        * or at least ignore them.
3194 -        */
3195 -       if (irq < 0 || irq >= NumSources)
3196 -               return;
3197 +       check_arg_irq(irq);
3198         openpic_setfield(&OpenPIC->Source[irq].Vector_Priority, OPENPIC_MASK);
3199 -       /* make sure mask gets to controller before we return to user */
3200 -       do {
3201 -               mb();  /* sync is probably useless here */
3202 -               vp = openpic_readfield(&OpenPIC->Source[irq].Vector_Priority,
3203 -                       OPENPIC_MASK | OPENPIC_ACTIVITY);
3204 -       } while((vp & OPENPIC_ACTIVITY) && !(vp & OPENPIC_MASK));
3205  }
3206  
3207  /*
3208 @@ -561,11 +454,10 @@
3209         check_arg_vec(vec);
3210         openpic_safe_writefield(&OpenPIC->Source[irq].Vector_Priority,
3211                                 OPENPIC_PRIORITY_MASK | OPENPIC_VECTOR_MASK |
3212 -                               OPENPIC_POLARITY_MASK | OPENPIC_SENSE_MASK,
3213 +                               OPENPIC_SENSE_POLARITY | OPENPIC_SENSE_LEVEL,
3214                                 (pri << OPENPIC_PRIORITY_SHIFT) | vec |
3215 -                               (pol ? OPENPIC_POLARITY_POSITIVE :
3216 -                                       OPENPIC_POLARITY_NEGATIVE) |
3217 -                               (sense ? OPENPIC_SENSE_LEVEL : OPENPIC_SENSE_EDGE));
3218 +                               (pol ? OPENPIC_SENSE_POLARITY : 0) |
3219 +                               (sense ? OPENPIC_SENSE_LEVEL : 0));
3220  }
3221  
3222  /*
3223 @@ -589,7 +481,6 @@
3224                                 OPENPIC_SENSE_LEVEL,
3225                                 (sense ? OPENPIC_SENSE_LEVEL : 0));
3226  }
3227 -
3228  #ifdef CONFIG_PMAC_PBOOK
3229  static u32 save_ipi_vp[OPENPIC_NUM_IPI];
3230  static u32 save_irq_src_vp[OPENPIC_MAX_SOURCES];
3231 diff -urN linux.orig/arch/ppc/kernel/pci.c linux/arch/ppc/kernel/pci.c
3232 --- linux.orig/arch/ppc/kernel/pci.c    Sun Mar 25 18:31:48 2001
3233 +++ linux/arch/ppc/kernel/pci.c Thu Jul 11 15:43:29 2002
3234 @@ -10,20 +10,15 @@
3235  #include <linux/init.h>
3236  #include <linux/config.h>
3237  #include <linux/openpic.h>
3238 -#include <linux/capability.h>
3239 -#include <linux/sched.h>
3240 -#include <linux/errno.h>
3241  
3242  #include <asm/processor.h>
3243  #include <asm/io.h>
3244  #include <asm/prom.h>
3245  #include <asm/pci-bridge.h>
3246 -#include <asm/pci.h>
3247  #include <asm/residual.h>
3248  #include <asm/byteorder.h>
3249  #include <asm/irq.h>
3250  #include <asm/gg2.h>
3251 -#include <asm/uaccess.h>
3252  
3253  #include "pci.h"
3254  
3255 @@ -98,7 +93,7 @@
3256  
3257         for (; node != 0;node = node->sibling) {
3258                 class_code = (unsigned int *) get_property(node, "class-code", 0);
3259 -               if(class_code && (*class_code >> 8) == PCI_CLASS_BRIDGE_PCI)
3260 +               if((*class_code >> 8) == PCI_CLASS_BRIDGE_PCI)
3261                         fix_intr(node->child, dev);
3262                 reg = (unsigned int *) get_property(node, "reg", 0);
3263                 if (reg == 0 || ((reg[0] >> 8) & 0xff) != dev->devfn)
3264 @@ -110,156 +105,3 @@
3265         }
3266  }
3267  #endif
3268 -
3269 -
3270 -void *
3271 -pci_dev_io_base(unsigned char bus, unsigned char devfn, int physical)
3272 -{
3273 -       if (!ppc_md.pci_dev_io_base) {
3274 -               /* Please, someone fix this for non-pmac machines, we
3275 -                * need either the virtual or physical PCI IO base
3276 -                */
3277 -               return 0;
3278 -       }
3279 -       return ppc_md.pci_dev_io_base(bus, devfn, physical);
3280 -}
3281 -
3282 -void *
3283 -pci_dev_mem_base(unsigned char bus, unsigned char devfn)
3284 -{
3285 -       /* Default memory base is 0 (1:1 mapping) */
3286 -       if (!ppc_md.pci_dev_mem_base) {
3287 -               /* Please, someone fix this for non-pmac machines.*/
3288 -               return 0;
3289 -       }
3290 -       return ppc_md.pci_dev_mem_base(bus, devfn);
3291 -}
3292 -
3293 -/* Returns the root-bridge number (Uni-N number) of a device */
3294 -int
3295 -pci_dev_root_bridge(unsigned char bus, unsigned char devfn)
3296 -{
3297 -       /* Defaults to 0 */
3298 -       if (!ppc_md.pci_dev_root_bridge)
3299 -               return 0;
3300 -       return ppc_md.pci_dev_root_bridge(bus, devfn);
3301 -}
3302 -
3303 -/*
3304 - * Those syscalls are derived from the Alpha versions, they
3305 - * allow userland apps to retreive the per-device iobase and
3306 - * mem-base. They also provide wrapper for userland to do
3307 - * config space accesses.
3308 - * The "host_number" returns the number of the Uni-N sub bridge
3309 - */
3310 -
3311 -asmlinkage int
3312 -sys_pciconfig_read(unsigned long bus, unsigned long dfn,
3313 -                  unsigned long off, unsigned long len,
3314 -                  unsigned char *buf)
3315 -{
3316 -       unsigned char ubyte;
3317 -       unsigned short ushort;
3318 -       unsigned int uint;
3319 -       long err = 0;
3320 -
3321 -       if (!capable(CAP_SYS_ADMIN))
3322 -               return -EPERM;
3323 -       if (!pcibios_present())
3324 -               return -ENOSYS;
3325 -       
3326 -       switch (len) {
3327 -       case 1:
3328 -               err = pcibios_read_config_byte(bus, dfn, off, &ubyte);
3329 -               put_user(ubyte, buf);
3330 -               break;
3331 -       case 2:
3332 -               err = pcibios_read_config_word(bus, dfn, off, &ushort);
3333 -               put_user(ushort, (unsigned short *)buf);
3334 -               break;
3335 -       case 4:
3336 -               err = pcibios_read_config_dword(bus, dfn, off, &uint);
3337 -               put_user(uint, (unsigned int *)buf);
3338 -               break;
3339 -       default:
3340 -               err = -EINVAL;
3341 -               break;
3342 -       }
3343 -       return err;
3344 -}
3345 -
3346 -asmlinkage int
3347 -sys_pciconfig_write(unsigned long bus, unsigned long dfn,
3348 -                   unsigned long off, unsigned long len,
3349 -                   unsigned char *buf)
3350 -{
3351 -       unsigned char ubyte;
3352 -       unsigned short ushort;
3353 -       unsigned int uint;
3354 -       long err = 0;
3355 -
3356 -       if (!capable(CAP_SYS_ADMIN))
3357 -               return -EPERM;
3358 -       if (!pcibios_present())
3359 -               return -ENOSYS;
3360 -
3361 -       switch (len) {
3362 -       case 1:
3363 -               err = get_user(ubyte, buf);
3364 -               if (err)
3365 -                       break;
3366 -               err = pcibios_write_config_byte(bus, dfn, off, ubyte);
3367 -               if (err != PCIBIOS_SUCCESSFUL) {
3368 -                       err = -EFAULT;
3369 -               }
3370 -               break;
3371 -       case 2:
3372 -               err = get_user(ushort, (unsigned short *)buf);
3373 -               if (err)
3374 -                       break;
3375 -               err = pcibios_write_config_word(bus, dfn, off, ushort);
3376 -               if (err != PCIBIOS_SUCCESSFUL) {
3377 -                       err = -EFAULT;
3378 -               }
3379 -               break;
3380 -       case 4:
3381 -               err = get_user(uint, (unsigned int *)buf);
3382 -               if (err)
3383 -                       break;
3384 -               err = pcibios_write_config_dword(bus, dfn, off, uint);
3385 -               if (err != PCIBIOS_SUCCESSFUL) {
3386 -                       err = -EFAULT;
3387 -               }
3388 -               break;
3389 -       default:
3390 -               err = -EINVAL;
3391 -               break;
3392 -       }
3393 -       return err;
3394 -}
3395 -
3396 -/* Provide information on locations of various I/O regions in physical
3397 - * memory.  Do this on a per-card basis so that we choose the right
3398 - * root bridge.
3399 - * Note that the returned IO or memory base is a physical address
3400 - */
3401 -
3402 -asmlinkage long
3403 -sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn)
3404 -{
3405 -       long result = -EOPNOTSUPP;
3406 -       
3407 -       switch (which) {
3408 -       case IOBASE_BRIDGE_NUMBER:
3409 -               return (long)pci_dev_root_bridge(bus, devfn);
3410 -       case IOBASE_MEMORY:
3411 -               return (long)pci_dev_mem_base(bus, devfn);
3412 -       case IOBASE_IO:
3413 -               result = (long)pci_dev_io_base(bus, devfn, 1);
3414 -               if (result == 0)
3415 -                       result = -EOPNOTSUPP;
3416 -               break;
3417 -       }
3418 -
3419 -       return result;
3420 -}
3421 diff -urN linux.orig/arch/ppc/kernel/pmac_pci.c linux/arch/ppc/kernel/pmac_pci.c
3422 --- linux.orig/arch/ppc/kernel/pmac_pci.c       Fri Nov  2 17:39:05 2001
3423 +++ linux/arch/ppc/kernel/pmac_pci.c    Thu Jul 11 15:43:29 2002
3424 @@ -28,20 +28,6 @@
3425  struct bridge_data **bridges, *bridge_list;
3426  static int max_bus;
3427  
3428 -struct uninorth_data {
3429 -       struct device_node*     node;
3430 -       volatile unsigned int*  cfg_addr;
3431 -       volatile unsigned int*  cfg_data;
3432 -       void*                   iobase;
3433 -       void*                   iobase_phys;
3434 -};
3435 -
3436 -static struct uninorth_data uninorth_bridges[3];
3437 -static int uninorth_count;
3438 -static int uninorth_default = -1;
3439
3440 -
3441 -
3442  static void add_bridges(struct device_node *dev, unsigned long *mem_ptr);
3443  
3444  /*
3445 @@ -85,208 +71,6 @@
3446         return 0;
3447  }
3448  
3449 -/* This routines figures out on which root bridge a given PCI device
3450 - * is attached.
3451 - * 
3452 - * WARNING: When passed the address of the bridge itself (11), it must
3453 - *          return the AGP bus. Currently, it returns 0, which is by
3454 - *          chance the AGP one. We may have to improve that however...
3455 - */
3456 -__pmac
3457 -int
3458 -pmac_pci_dev_root_bridge(unsigned char bus, unsigned char dev_fn)
3459 -{
3460 -       struct device_node *node, *bridge_node;
3461 -       int bridge = uninorth_default;
3462 -
3463 -       if (uninorth_count == 0)
3464 -               return 0;
3465 -       if (bus == 0 && PCI_SLOT(dev_fn) < 11)
3466 -               return 0;
3467 -       
3468 -       /* We look for the OF device corresponding to this bus/devfn pair. If we
3469 -        * don't find it, we default to the external PCI */
3470 -       bridge_node = NULL;
3471 -       node = find_pci_device_OFnode(bus, dev_fn & 0xf8);
3472 -       if (node) {
3473 -           /* note: we don't stop on the first occurrence since we need to go
3474 -             * up to the root bridge */
3475 -           do {
3476 -               if (node->type && !strcmp(node->type, "pci") 
3477 -                       && device_is_compatible(node, "uni-north"))
3478 -                       bridge_node = node;
3479 -               node=node->parent;
3480 -           } while (node);
3481 -       }
3482 -       if (bridge_node) {
3483 -           int i;
3484 -           for (i=0;i<uninorth_count;i++)
3485 -               if (uninorth_bridges[i].node == bridge_node) {
3486 -                   bridge = i;
3487 -                   break;
3488 -               }
3489 -       }
3490 -
3491 -       if (bridge == -1) {
3492 -               printk(KERN_WARNING "pmac_pci: no default bridge !\n");
3493 -               return 0;
3494 -       }
3495 -
3496 -       return bridge;  
3497 -}
3498 -
3499 -__pmac
3500 -void *
3501 -pmac_pci_dev_io_base(unsigned char bus, unsigned char devfn, int physical)
3502 -{
3503 -       int bridge = -1;
3504 -       if (uninorth_count != 0)
3505 -               bridge = pmac_pci_dev_root_bridge(bus, devfn);
3506 -       if (bridge == -1) {
3507 -               struct bridge_data *bp;
3508 -
3509 -               if (bus > max_bus || (bp = bridges[bus]) == 0)
3510 -                       return 0;
3511 -               return physical ? bp->io_base_phys : bp->io_base;
3512 -       }
3513 -       return physical ? uninorth_bridges[bridge].iobase_phys
3514 -               : uninorth_bridges[bridge].iobase;
3515 -}
3516 -
3517 -__pmac
3518 -void *
3519 -pmac_pci_dev_mem_base(unsigned char bus, unsigned char devfn)
3520 -{
3521 -       return 0;
3522 -}
3523 -
3524 -/* This function only works for bus 0, uni-N uses a different mecanism for
3525 - * other busses (see below)
3526 - */
3527 -#define UNI_N_CFA0(devfn, off) \
3528 -       ((1 << (unsigned long)PCI_SLOT(dev_fn)) \
3529 -       | (((unsigned long)PCI_FUNC(dev_fn)) << 8) \
3530 -       | (((unsigned long)(off)) & 0xFCUL))
3531 -
3532 -/* This one is for type 1 config accesses */
3533 -#define UNI_N_CFA1(bus, devfn, off)    \
3534 -       ((((unsigned long)(bus)) << 16) \
3535 -       |(((unsigned long)(devfn)) << 8) \
3536 -       |(((unsigned long)(off)) & 0xFCUL) \
3537 -       |1UL)
3538 -       
3539 -
3540 -__pmac static
3541 -unsigned int
3542 -uni_north_access_data(unsigned char bus, unsigned char dev_fn,
3543 -                               unsigned char offset)
3544 -{
3545 -       int bridge;
3546 -       unsigned int caddr;
3547 -
3548 -       bridge = pmac_pci_dev_root_bridge(bus, dev_fn);
3549 -       if (bus == 0)
3550 -               caddr = UNI_N_CFA0(dev_fn, offset);
3551 -       else
3552 -               caddr = UNI_N_CFA1(bus, dev_fn, offset);
3553 -       
3554 -       if (bridge == -1) {
3555 -               printk(KERN_WARNING "pmac_pci: no default bridge !\n");
3556 -               return 0;
3557 -       }
3558 -               
3559 -       /* Uninorth will return garbage if we don't read back the value ! */
3560 -       out_le32(uninorth_bridges[bridge].cfg_addr, caddr);
3561 -       (void)in_le32(uninorth_bridges[bridge].cfg_addr);
3562 -       /* Yes, offset is & 7, not & 3 ! */
3563 -       return (unsigned int)(uninorth_bridges[bridge].cfg_data) + (offset & 0x07);
3564 -}
3565 -
3566 -__pmac
3567 -int uni_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
3568 -                                 unsigned char offset, unsigned char *val)
3569 -{
3570 -       unsigned int addr;
3571 -       
3572 -       *val = 0xff;
3573 -       addr = uni_north_access_data(bus, dev_fn, offset);
3574 -       if (!addr)
3575 -               return PCIBIOS_DEVICE_NOT_FOUND;
3576 -       *val = in_8((volatile unsigned char*)addr);
3577 -       return PCIBIOS_SUCCESSFUL;
3578 -}
3579 -
3580 -__pmac
3581 -int uni_pcibios_read_config_word(unsigned char bus, unsigned char dev_fn,
3582 -                                 unsigned char offset, unsigned short *val)
3583 -{
3584 -       unsigned int addr;
3585 -       
3586 -       *val = 0xffff;
3587 -       addr = uni_north_access_data(bus, dev_fn, offset);
3588 -       if (!addr)
3589 -               return PCIBIOS_DEVICE_NOT_FOUND;
3590 -       *val = in_le16((volatile unsigned short*)addr);
3591 -       return PCIBIOS_SUCCESSFUL;
3592 -}
3593 -
3594 -__pmac
3595 -int uni_pcibios_read_config_dword(unsigned char bus, unsigned char dev_fn,
3596 -                                  unsigned char offset, unsigned int *val)
3597 -{
3598 -       unsigned int addr;
3599 -       
3600 -       *val = 0xffff;
3601 -       addr = uni_north_access_data(bus, dev_fn, offset);
3602 -       if (!addr)
3603 -               return PCIBIOS_DEVICE_NOT_FOUND;
3604 -       *val = in_le32((volatile unsigned int*)addr);
3605 -       return PCIBIOS_SUCCESSFUL;
3606 -}
3607 -
3608 -__pmac
3609 -int uni_pcibios_write_config_byte(unsigned char bus, unsigned char dev_fn,
3610 -                                  unsigned char offset, unsigned char val)
3611 -{
3612 -       unsigned int addr;
3613 -       
3614 -       addr = uni_north_access_data(bus, dev_fn, offset);
3615 -       if (!addr)
3616 -               return PCIBIOS_DEVICE_NOT_FOUND;
3617 -       out_8((volatile unsigned char *)addr, val);
3618 -       (void)in_8((volatile unsigned char *)addr);
3619 -       return PCIBIOS_SUCCESSFUL;
3620 -}
3621 -
3622 -__pmac
3623 -int uni_pcibios_write_config_word(unsigned char bus, unsigned char dev_fn,
3624 -                                  unsigned char offset, unsigned short val)
3625 -{
3626 -       unsigned int addr;
3627 -       
3628 -       addr = uni_north_access_data(bus, dev_fn, offset);
3629 -       if (!addr)
3630 -               return PCIBIOS_DEVICE_NOT_FOUND;
3631 -       out_le16((volatile unsigned short *)addr, val);
3632 -       (void)in_le16((volatile unsigned short *)addr);
3633 -       return PCIBIOS_SUCCESSFUL;
3634 -}
3635 -
3636 -__pmac
3637 -int uni_pcibios_write_config_dword(unsigned char bus, unsigned char dev_fn,
3638 -                                   unsigned char offset, unsigned int val)
3639 -{
3640 -       unsigned int addr;
3641 -       
3642 -       addr = uni_north_access_data(bus, dev_fn, offset);
3643 -       if (!addr)
3644 -               return PCIBIOS_DEVICE_NOT_FOUND;
3645 -       out_le32((volatile unsigned int *)addr, val);
3646 -       (void)in_le32((volatile unsigned int *)addr);
3647 -       return PCIBIOS_SUCCESSFUL;
3648 -}
3649 -
3650 -
3651  __pmac
3652  int pmac_pcibios_read_config_byte(unsigned char bus, unsigned char dev_fn,
3653                                   unsigned char offset, unsigned char *val)
3654 @@ -576,80 +360,6 @@
3655                bp->io_base);
3656  }
3657  
3658 -#define GRACKLE_PICR1_STG              0x00000040
3659 -#define GRACKLE_PICR1_LOOPSNOOP                0x00000010
3660 -
3661 -/* N.B. this is called before bridges is initialized, so we can't
3662 -   use grackle_pcibios_{read,write}_config_dword. */
3663 -static inline void grackle_set_stg(struct bridge_data *bp, int enable)
3664 -{
3665 -       unsigned int val;
3666 -
3667 -       out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
3668 -       val = in_le32((volatile unsigned int *)bp->cfg_data);
3669 -       val = enable? (val | GRACKLE_PICR1_STG) :
3670 -               (val & ~GRACKLE_PICR1_STG);
3671 -       out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
3672 -       out_le32((volatile unsigned int *)bp->cfg_data, val);
3673 -}
3674 -
3675 -static inline void grackle_set_loop_snoop(struct bridge_data *bp, int enable)
3676 -{
3677 -       unsigned int val;
3678 -
3679 -       out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
3680 -       val = in_le32((volatile unsigned int *)bp->cfg_data);
3681 -       val = enable? (val | GRACKLE_PICR1_LOOPSNOOP) :
3682 -               (val & ~GRACKLE_PICR1_LOOPSNOOP);
3683 -       out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
3684 -       out_le32((volatile unsigned int *)bp->cfg_data, val);
3685 -}
3686 -
3687 -static int __init
3688 -fixup_one_level_bus_range(struct device_node *node, int higher)
3689 -{
3690 -       for (; node != 0;node = node->sibling) {
3691 -               int * bus_range;
3692 -               unsigned int *class_code;                       
3693 -               int len;
3694 -
3695 -               /* For PCI<->PCI bridges or CardBus bridges, we go down */
3696 -               class_code = (unsigned int *) get_property(node, "class-code", 0);
3697 -               if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
3698 -                       (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
3699 -                       continue;
3700 -               bus_range = (int *) get_property(node, "bus-range", &len);
3701 -               if (bus_range != NULL && len > 2 * sizeof(int)) {
3702 -                       if (bus_range[1] > higher)
3703 -                               higher = bus_range[1];
3704 -               }
3705 -               higher = fixup_one_level_bus_range(node->child, higher);
3706 -       }
3707 -       return higher;
3708 -}
3709 -
3710 -/* This routine fixes the "bus-range" property of all bridges in the
3711 - * system since they tend to have their "last" member wrong on macs
3712 - * 
3713 - * Note that the bus numbers manipulated here are OF bus numbers, they
3714 - * are not Linux bus numbers.
3715 - */
3716 -static void __init
3717 -fixup_bus_range(struct device_node *bridge)
3718 -{
3719 -       int * bus_range;
3720 -       int len;
3721 -       
3722 -       /* Lookup the "bus-range" property for the hose */              
3723 -       bus_range = (int *) get_property(bridge, "bus-range", &len);
3724 -       if (bus_range == NULL || len < 2 * sizeof(int)) {
3725 -               printk(KERN_WARNING "Can't get bus-range for %s\n",
3726 -                              bridge->full_name);
3727 -               return;
3728 -       }
3729 -       bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]);
3730 -}
3731 -
3732  __initfunc(unsigned long pmac_find_bridges(unsigned long mem_start, unsigned long mem_end))
3733  {
3734         int bus;
3735 @@ -689,7 +399,6 @@
3736                                dev->full_name);
3737                         continue;
3738                 }
3739 -               fixup_bus_range(dev);
3740                 bus_range = (int *) get_property(dev, "bus-range", &len);
3741                 if (bus_range == NULL || len < 2 * sizeof(int)) {
3742                         printk(KERN_WARNING "Can't get bus-range for %s\n",
3743 @@ -702,54 +411,21 @@
3744                         printk(KERN_INFO "PCI buses %d..%d", bus_range[0],
3745                                bus_range[1]);
3746                 printk(" controlled by %s at %x\n", dev->name, addr->address);
3747 -               if (device_is_compatible(dev, "uni-north")) {
3748 -                       int i = uninorth_count++;
3749 -                       uninorth_bridges[i].cfg_addr = ioremap(addr->address + 0x800000, 0x1000);
3750 -                       uninorth_bridges[i].cfg_data = ioremap(addr->address + 0xc00000, 0x1000);
3751 -                       uninorth_bridges[i].node = dev;
3752 -                       uninorth_bridges[i].iobase_phys = (void *)addr->address;
3753 -                       /* is 0x10000 enough for io space ? */
3754 -                       uninorth_bridges[i].iobase = (void *)ioremap(addr->address, 0x10000);
3755 -                       /* XXX This is the bridge with the PCI expansion bus. This is also the
3756 -                        * address of the bus that will receive type 1 config accesses and io
3757 -                        * accesses. Appears to be correct for iMac DV and G4 Sawtooth too.
3758 -                        * That means that we cannot do io cycles on the AGP bus nor the internal
3759 -                        * ethernet/fw bus. Fortunately, they appear not to be needed on iMac DV
3760 -                        * and G4 neither.
3761 -                        */
3762 -                       if (addr->address == 0xf2000000)
3763 -                               uninorth_default = i;
3764 -                       else
3765 -                               continue;
3766 -               }
3767                 bp = (struct bridge_data *) *mem_ptr;
3768                 *mem_ptr += sizeof(struct bridge_data);
3769 -               if (device_is_compatible(dev, "uni-north")) {
3770 -                       bp->cfg_addr = 0;
3771 -                       bp->cfg_data = 0;
3772 -                       bp->io_base = uninorth_bridges[uninorth_count-1].iobase;
3773 -                       bp->io_base_phys = uninorth_bridges[uninorth_count-1].iobase_phys;
3774 -               } else if (strcmp(dev->name, "pci") == 0) {
3775 -                       /* XXX assume this is a mpc106 (grackle) */
3776 -                       bp->cfg_addr = (volatile unsigned int *)
3777 -                               ioremap(0xfec00000, 0x1000);
3778 -                       bp->cfg_data = (volatile unsigned char *)
3779 -                               ioremap(0xfee00000, 0x1000);
3780 -                        bp->io_base = (void *) ioremap(0xfe000000, 0x20000);
3781 -                        bp->io_base_phys = (void *)0xfe000000;
3782 -                        if (machine_is_compatible("AAPL,PowerBook1998"))
3783 -                               grackle_set_loop_snoop(bp, 1);
3784 -#if 0                  /* Disabled for now, HW problems ??? */
3785 -                       grackle_set_stg(bp, 1);
3786 -#endif
3787 -               } else {
3788 -                       /* a `bandit' or `chaos' bridge */
3789 +               if (strcmp(dev->name, "pci") != 0) {
3790                         bp->cfg_addr = (volatile unsigned int *)
3791                                 ioremap(addr->address + 0x800000, 0x1000);
3792                         bp->cfg_data = (volatile unsigned char *)
3793                                 ioremap(addr->address + 0xc00000, 0x1000);
3794                         bp->io_base = (void *) ioremap(addr->address, 0x10000);
3795 -                       bp->io_base_phys = (void *)addr->address;
3796 +               } else {
3797 +                       /* XXX */
3798 +                       bp->cfg_addr = (volatile unsigned int *)
3799 +                               ioremap(0xfec00000, 0x1000);
3800 +                       bp->cfg_data = (volatile unsigned char *)
3801 +                               ioremap(0xfee00000, 0x1000);
3802 +                        bp->io_base = (void *) ioremap(0xfe000000, 0x20000);
3803                 }
3804                 if (isa_io_base == 0)
3805                         isa_io_base = (unsigned long) bp->io_base;
3806 @@ -792,13 +468,7 @@
3807                 if (pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin) ||
3808                     !pin)
3809                         continue; /* No interrupt generated -> no fixup */
3810 -               /* We iterate all instances of uninorth for now */      
3811 -               if (uninorth_count && dev->bus->number == 0) {
3812 -                       int i;
3813 -                       for (i=0;i<uninorth_count;i++)
3814 -                               fix_intr(uninorth_bridges[i].node->child, dev);
3815 -               } else
3816 -                       fix_intr(bp->node->child, dev);
3817 +                fix_intr(bp->node->child, dev);
3818         }
3819  }
3820  
3821 @@ -806,17 +476,9 @@
3822  void
3823  pmac_setup_pci_ptrs(void))
3824  {
3825 -       struct device_node* np;
3826 -
3827 -       np = find_devices("pci");
3828 -       if (np != 0) {
3829 -               if (device_is_compatible(np, "uni-north")) {
3830 -                       /* looks like an Core99 powermac */
3831 -                       set_config_access_method(uni);
3832 -               } else {
3833 -                       /* looks like a G3 powermac */
3834 -                       set_config_access_method(grackle);
3835 -               }
3836 +       if (find_devices("pci") != 0) {
3837 +               /* looks like a G3 powermac */
3838 +               set_config_access_method(grackle);
3839         } else {
3840                 set_config_access_method(pmac);
3841         }
3842 diff -urN linux.orig/arch/ppc/kernel/pmac_pic.c linux/arch/ppc/kernel/pmac_pic.c
3843 --- linux.orig/arch/ppc/kernel/pmac_pic.c       Sun Mar 25 18:31:49 2001
3844 +++ linux/arch/ppc/kernel/pmac_pic.c    Thu Jul 11 15:43:29 2002
3845 @@ -4,13 +4,11 @@
3846  #include <linux/sched.h>
3847  #include <linux/signal.h>
3848  #include <linux/pci.h>
3849 -#include <linux/openpic.h>
3850  #include <asm/pci-bridge.h>
3851  #include <asm/io.h>
3852  #include <asm/smp.h>
3853  #include <asm/prom.h>
3854  #include "pmac_pic.h"
3855 -#include "open_pic.h"
3856  
3857  struct pmac_irq_hw {
3858          unsigned int    flag;
3859 @@ -30,8 +28,6 @@
3860  static int max_irqs;
3861  static int max_real_irqs;
3862  
3863 -extern u_int openpic_read(volatile u_int *addr);
3864 -
3865  #define MAXCOUNT 10000000
3866  
3867  #define GATWICK_IRQ_POOL_SIZE        10
3868 @@ -158,8 +154,6 @@
3869             int            cpu,
3870              int            isfake)
3871  {
3872 -       extern void psurge_smp_message_recv(void);
3873 -
3874         int irq;
3875         unsigned long bits = 0;
3876  
3877 @@ -174,7 +168,7 @@
3878                          if (xmon_2nd)
3879                                  xmon(regs);
3880  #endif
3881 -                        psurge_smp_message_recv();
3882 +                        pmac_smp_message_recv();
3883                          goto out;
3884                  }
3885                  /* could be here due to a do_fake_interrupt call but we don't
3886 @@ -356,58 +350,6 @@
3887          struct device_node *irqctrler;
3888          volatile struct pmac_irq_hw *addr;
3889         int second_irq;
3890 -       u_int t;
3891 -       int nr_irq;
3892 -
3893 -       /* We first try to detect Apple's new Core99 chipset, since mac-io
3894 -        * is quite different on those machines and contains an IBM MPIC2.
3895 -        */
3896 -       irqctrler = find_type_devices("open-pic");
3897 -       if (irqctrler != NULL) {
3898 -           printk("PowerMac using OpenPIC irq controller\n");
3899 -           if (irqctrler->n_addrs > 0) {
3900 -#ifdef CONFIG_XMON
3901 -               struct device_node* pswitch;
3902 -#endif /* CONFIG_XMON */       
3903 -               OpenPIC = (volatile struct OpenPIC *)
3904 -                       ioremap(irqctrler->addrs[0].address,
3905 -                       irqctrler->addrs[0].size);
3906 -               /* from openpic.c code... --Troy
3907 -                * dynamically figure out how many interrupts 
3908 -                * We should really do something like panic
3909 -                * if nr_irq >= OPENPIC_VEC_IPI
3910 -                */
3911 -               t = openpic_read(&OpenPIC->Global.Feature_Reporting0);
3912 -                nr_irq = ((t & OPENPIC_FEATURE_LAST_SOURCE_MASK) >>
3913 -                                OPENPIC_FEATURE_LAST_SOURCE_SHIFT) + 1;
3914 -               
3915 -               for ( i = 0 ; i < nr_irq ; i++ ) {
3916 -                   irq_desc[i].ctl = &open_pic;
3917 -                   irq_desc[i].level = 0;
3918 -               }
3919 -               ppc_md.do_IRQ = open_pic_do_IRQ;
3920 -               open_pic.irq_offset = 0;
3921 -               openpic_init(1);
3922 -#ifdef CONFIG_XMON
3923 -               pswitch = find_devices("programmer-switch");
3924 -               if (pswitch && pswitch->n_intrs)
3925 -                       request_irq(pswitch->intrs[0].line, xmon_irq, 0,        
3926 -                               "NMI - XMON", 0);
3927 -#endif /* CONFIG_XMON */
3928 -#ifdef __SMP__
3929 -               request_irq(OPENPIC_VEC_IPI, openpic_ipi_action,
3930 -                           0, "IPI0", 0);
3931 -               request_irq(OPENPIC_VEC_IPI+1, openpic_ipi_action,
3932 -                           0, "IPI1 (invalidate TLB)", 0);
3933 -               request_irq(OPENPIC_VEC_IPI+2, openpic_ipi_action,
3934 -                           0, "IPI2 (stop CPU)", 0);
3935 -               request_irq(OPENPIC_VEC_IPI+3, openpic_ipi_action,
3936 -                           0, "IPI3 (reschedule)", 0);
3937 -#endif /* __SMP__ */
3938 -               return;
3939 -           }
3940 -           irqctrler = NULL;
3941 -       }
3942  
3943         /*
3944          * G3 powermacs and 1999 G3 PowerBooks have 64 interrupts,
3945 @@ -487,8 +429,6 @@
3946   * sleep_save_intrs() saves the states of all interrupt enables
3947   * and disables all interupts except for the nominated one.
3948   * sleep_restore_intrs() restores the states of all interrupt enables.
3949 - * 
3950 - * TODO: Those should be sleep notifiers with high priority.
3951   */
3952  unsigned int sleep_save_mask[2];
3953  
3954 @@ -499,8 +439,7 @@
3955         sleep_save_mask[1] = ppc_cached_irq_mask[1];
3956         ppc_cached_irq_mask[0] = 0;
3957         ppc_cached_irq_mask[1] = 0;
3958 -       if (viaint > 0)
3959 -               set_bit(viaint, ppc_cached_irq_mask);
3960 +       set_bit(viaint, ppc_cached_irq_mask);
3961         out_le32(&pmac_irq_hw[0]->enable, ppc_cached_irq_mask[0]);
3962         if (max_real_irqs > 32)
3963                 out_le32(&pmac_irq_hw[1]->enable, ppc_cached_irq_mask[1]);
3964 @@ -513,7 +452,6 @@
3965  {
3966         int i;
3967  
3968 -
3969         out_le32(&pmac_irq_hw[0]->enable, 0);
3970         if (max_real_irqs > 32)
3971                 out_le32(&pmac_irq_hw[1]->enable, 0);
3972 diff -urN linux.orig/arch/ppc/kernel/pmac_setup.c linux/arch/ppc/kernel/pmac_setup.c
3973 --- linux.orig/arch/ppc/kernel/pmac_setup.c     Sun Mar 25 18:37:30 2001
3974 +++ linux/arch/ppc/kernel/pmac_setup.c  Tue Jul 16 16:43:35 2002
3975 @@ -58,19 +58,18 @@
3976  #include <asm/ide.h>
3977  #include <asm/machdep.h>
3978  #include <asm/keyboard.h>
3979 -#include <asm/time.h>
3980  
3981 +#include "time.h"
3982  #include "local_irq.h"
3983  #include "pmac_pic.h"
3984  
3985  #undef SHOW_GATWICK_IRQS
3986  
3987 -extern long pmac_time_init(void);
3988 -extern unsigned long pmac_get_rtc_time(void);
3989 -extern int pmac_set_rtc_time(unsigned long nowtime);
3990 -extern void pmac_read_rtc_time(void);
3991 -extern void pmac_calibrate_decr(void);
3992 -extern void pmac_setup_pci_ptrs(void);
3993 +unsigned long pmac_get_rtc_time(void);
3994 +int pmac_set_rtc_time(unsigned long nowtime);
3995 +void pmac_read_rtc_time(void);
3996 +void pmac_calibrate_decr(void);
3997 +void pmac_setup_pci_ptrs(void);
3998  
3999  extern int mackbd_setkeycode(unsigned int scancode, unsigned int keycode);
4000  extern int mackbd_getkeycode(unsigned int scancode);
4001 @@ -80,9 +79,9 @@
4002  extern void mackbd_leds(unsigned char leds);
4003  extern void mackbd_init_hw(void);
4004  #ifdef CONFIG_MAGIC_SYSRQ
4005 -extern unsigned char mackbd_sysrq_xlate[128];
4006  extern unsigned char mac_hid_kbd_sysrq_xlate[128];
4007  extern unsigned char pckbd_sysrq_xlate[128];
4008 +unsigned char mackbd_sysrq_xlate[128];
4009  #endif /* CONFIG_MAGIC_SYSRQ */
4010  extern int keyboard_sends_linux_keycodes;
4011  extern int mac_hid_kbd_translate(unsigned char scancode,
4012 @@ -90,49 +89,27 @@
4013  extern char mac_hid_kbd_unexpected_up(unsigned char keycode);
4014  extern void mac_hid_init_hw(void);
4015  
4016 -extern void pmac_nvram_update(void);
4017 -
4018 -extern void *pmac_pci_dev_io_base(unsigned char bus, unsigned char devfn);
4019 -extern void *pmac_pci_dev_mem_base(unsigned char bus, unsigned char devfn);
4020 -extern int pmac_pci_dev_root_bridge(unsigned char bus, unsigned char devfn);
4021 +extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
4022 +extern int pckbd_getkeycode(unsigned int scancode);
4023 +extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
4024 +                          char raw_mode);
4025 +extern char pckbd_unexpected_up(unsigned char keycode);
4026 +extern void pckbd_leds(unsigned char leds);
4027 +extern void pckbd_init_hw(void);
4028  
4029  unsigned char drive_info;
4030  
4031  int ppc_override_l2cr = 0;
4032  int ppc_override_l2cr_value;
4033  
4034 -static int current_root_goodness = -1;
4035 -
4036  extern char saved_command_line[];
4037  
4038 -extern int pmac_newworld;
4039 -
4040  #define DEFAULT_ROOT_DEVICE 0x0801     /* sda1 - slightly silly choice */
4041  
4042  extern void zs_kgdb_hook(int tty_num);
4043  static void ohare_init(void);
4044  static void init_p2pbridge(void);
4045  
4046 -#ifdef CONFIG_SMP
4047 -volatile static long int core99_l2_cache;
4048 -void core99_init_l2(void)
4049 -{
4050 -       int cpu = smp_processor_id();
4051
4052 -       if ( (_get_PVR() >> 16) != 8 && (_get_PVR() >> 16) != 12 )
4053 -               return;
4054 -
4055 -       if (cpu == 0){
4056 -               core99_l2_cache = _get_L2CR();
4057 -               printk("CPU0: L2CR is %lx\n", core99_l2_cache);
4058 -       } else {
4059 -               printk("CPU%d: L2CR was %lx\n", cpu, _get_L2CR());
4060 -               _set_L2CR(core99_l2_cache);
4061 -               printk("CPU%d: L2CR set to %lx\n", cpu, core99_l2_cache);
4062 -       }
4063 -}
4064 -#endif /* CONFIG_SMP */
4065 -
4066  __pmac
4067  int
4068  pmac_get_cpuinfo(char *buffer)
4069 @@ -219,10 +196,6 @@
4070                         len += sprintf(buffer+len, "l2cr override\t: 0x%x\n", *l2cr);
4071                 }
4072         }
4073 -
4074 -       /* Indicate newworld/oldworld */
4075 -       len += sprintf(buffer+len, "pmac-generation\t: %s\n",
4076 -               pmac_newworld ? "NewWorld" : "OldWorld");               
4077         
4078         return len;
4079  }
4080 @@ -282,10 +255,8 @@
4081                 if (fp != 0) {
4082                         switch (_get_PVR() >> 16) {
4083                         case 4:         /* 604 */
4084 -                       case 8:         /* G3 */
4085                         case 9:         /* 604e */
4086                         case 10:        /* mach V (604ev5) */
4087 -                       case 12:        /* G4 */
4088                         case 20:        /* 620 */
4089                                 loops_per_jiffy = *fp / HZ;
4090                                 break;
4091 @@ -304,11 +275,9 @@
4092  
4093         *memory_start_p = pmac_find_bridges(*memory_start_p, *memory_end_p);
4094         init_p2pbridge();
4095 -       
4096 -       /* Checks "l2cr-value" property in the registry
4097 -        * And enable G3/G4 Dynamic Power Management
4098 -        */
4099 -       if ( (_get_PVR() >> 16) == 8 || (_get_PVR() >> 16) == 12 ) {
4100 +
4101 +       /* Checks "l2cr-value" property in the registry */
4102 +       if ( (_get_PVR() >> 16) == 8) {
4103                 struct device_node *np = find_devices("cpus");          
4104                 if (np == 0)
4105                         np = find_type_devices("cpu");          
4106 @@ -319,22 +288,17 @@
4107                                 ppc_override_l2cr = 1;
4108                                 ppc_override_l2cr_value = *l2cr;
4109                                 _set_L2CR(0);
4110 -                               if (ppc_override_l2cr_value)
4111 -                                       _set_L2CR(ppc_override_l2cr_value);
4112 +                               _set_L2CR(ppc_override_l2cr_value);
4113                         }
4114                 }
4115 -               _set_HID0(_get_HID0() | HID0_DPM);
4116         }
4117  
4118         if (ppc_override_l2cr)
4119                 printk(KERN_INFO "L2CR overriden (0x%x), backside cache is %s\n",
4120                         ppc_override_l2cr_value, (ppc_override_l2cr_value & 0x80000000)
4121                                 ? "enabled" : "disabled");
4122 -       feature_init();
4123  
4124 -#ifdef CONFIG_SMP
4125 -       core99_init_l2();
4126 -#endif
4127 +       feature_init();
4128  
4129  #ifdef CONFIG_KGDB
4130         zs_kgdb_hook(0);
4131 @@ -343,8 +307,6 @@
4132         find_via_cuda();
4133         find_via_pmu();
4134  
4135 -       pmac_nvram_init();
4136 -
4137  #ifdef CONFIG_DUMMY_CONSOLE
4138         conswitchp = &dummy_con;
4139  #endif
4140 @@ -413,6 +375,7 @@
4141  pmac_init2(void))
4142  {
4143         adb_init();
4144 +       pmac_nvram_init();
4145         media_bay_init();
4146  }
4147  
4148 @@ -493,14 +456,13 @@
4149  
4150  /* can't be initfunc - can be called whenever a disk is first accessed */
4151  __pmac
4152 -void note_bootable_part(kdev_t dev, int part, int goodness)
4153 +void note_bootable_part(kdev_t dev, int part)
4154  {
4155         static int found_boot = 0;
4156         char *p;
4157  
4158         /* Do nothing if the root has been set already. */
4159 -       if ((goodness < current_root_goodness) &&
4160 -               (ROOT_DEV != to_kdev_t(DEFAULT_ROOT_DEVICE)))
4161 +       if (ROOT_DEV != to_kdev_t(DEFAULT_ROOT_DEVICE))
4162                 return;
4163         p = strstr(saved_command_line, "root=");
4164         if (p != NULL && (p == saved_command_line || p[-1] == ' '))
4165 @@ -513,7 +475,7 @@
4166         if (boot_dev == 0 || dev == boot_dev) {
4167                 ROOT_DEV = MKDEV(MAJOR(dev), MINOR(dev) + part);
4168                 boot_dev = NODEV;
4169 -               current_root_goodness = goodness;
4170 +               printk(" (root)");
4171         }
4172  }
4173  
4174 @@ -522,8 +484,6 @@
4175  {
4176         struct adb_request req;
4177  
4178 -       pmac_nvram_update();
4179 -       
4180         switch (adb_hardware) {
4181         case ADB_VIACUDA:
4182                 cuda_request(&req, NULL, 2, CUDA_PACKET,
4183 @@ -544,8 +504,6 @@
4184  {
4185         struct adb_request req;
4186  
4187 -       pmac_nvram_update();
4188 -       
4189         switch (adb_hardware) {
4190         case ADB_VIACUDA:
4191                 cuda_request(&req, NULL, 2, CUDA_PACKET,
4192 @@ -564,6 +522,7 @@
4193  void
4194  pmac_halt(void)
4195  {
4196 +   pmac_power_off();
4197  }
4198  
4199  
4200 @@ -663,15 +622,11 @@
4201         ppc_md.power_off      = pmac_power_off;
4202         ppc_md.halt           = pmac_halt;
4203  
4204 -       ppc_md.time_init      = pmac_time_init;
4205 +       ppc_md.time_init      = NULL;
4206         ppc_md.set_rtc_time   = pmac_set_rtc_time;
4207         ppc_md.get_rtc_time   = pmac_get_rtc_time;
4208         ppc_md.calibrate_decr = pmac_calibrate_decr;
4209  
4210 -       ppc_md.pci_dev_root_bridge      = pmac_pci_dev_root_bridge;
4211 -       ppc_md.pci_dev_mem_base         = pmac_pci_dev_mem_base;
4212 -       ppc_md.pci_dev_io_base          = pmac_pci_dev_io_base;
4213 -
4214  #ifdef CONFIG_VT
4215  #ifdef CONFIG_MAC_KEYBOARD
4216         ppc_md.kbd_setkeycode    = mackbd_setkeycode;
4217 diff -urN linux.orig/arch/ppc/kernel/pmac_support.c linux/arch/ppc/kernel/pmac_support.c
4218 --- linux.orig/arch/ppc/kernel/pmac_support.c   Sun Mar 25 18:31:49 2001
4219 +++ linux/arch/ppc/kernel/pmac_support.c        Thu Jul 11 15:43:29 2002
4220 @@ -1,19 +1,10 @@
4221  /*
4222   * Miscellaneous procedures for dealing with the PowerMac hardware.
4223 - * Contains support for the nvram.
4224 - * 
4225 - *   Copyright (C) 2000 Paul Mackerras
4226 - *   Copyright (C) 2000 Benjamin Herrenschmidt
4227 - *
4228 - * ToDo: Handle type 0 and type 1 "NameRegistry" NVRAM properties. Those
4229 - *       contain, among other things, the brightness, video mode, etc...
4230   */
4231  #include <linux/kernel.h>
4232  #include <linux/stddef.h>
4233  #include <linux/reboot.h>
4234  #include <linux/nvram.h>
4235 -#include <linux/slab.h>
4236 -#include <linux/delay.h>
4237  #include <asm/init.h>
4238  #include <asm/ptrace.h>
4239  #include <asm/io.h>
4240 @@ -22,49 +13,16 @@
4241  #include <asm/prom.h>
4242  #include <asm/adb.h>
4243  #include <asm/pmu.h>
4244 -#include <asm/machdep.h>
4245  #include <asm/nvram.h>
4246  #include <asm/backlight.h>
4247  
4248 -#undef DEBUG
4249 -
4250 -#define NVRAM_SIZE             0x2000  /* 8kB of non-volatile RAM */
4251 -
4252 -#define CORE99_SIGNATURE       0x5a
4253 -#define CORE99_ADLER_START     0x14
4254 -
4255 -/* Core99 nvram is a flash */
4256 -#define CORE99_FLASH_STATUS_DONE       0x80
4257 -#define CORE99_FLASH_STATUS_ERR                0x38
4258 -#define CORE99_FLASH_CMD_ERASE_CONFIRM 0xd0
4259 -#define CORE99_FLASH_CMD_ERASE_SETUP   0x20
4260 -#define CORE99_FLASH_CMD_RESET         0xff
4261 -#define CORE99_FLASH_CMD_WRITE_SETUP   0x40
4262 -
4263 -/* CHRP NVRAM header */
4264 -struct chrp_header {
4265 -       u8      signature;
4266 -       u8      cksum;
4267 -       u16     len;
4268 -       char    name[12];
4269 -       u8      data[0];
4270 -};
4271 -
4272 -struct core99_header {
4273 -       struct chrp_header hdr;
4274 -       u32     adler;
4275 -       u32     generation;
4276 -       u32     reserved[2];
4277 -};
4278 -
4279  /*
4280   * Read and write the non-volatile RAM on PowerMacs and CHRP machines.
4281   */
4282  static int nvram_naddrs;
4283  static volatile unsigned char *nvram_addr;
4284  static volatile unsigned char *nvram_data;
4285 -static int nvram_mult, is_core_99;
4286 -static int core99_bank = 0;
4287 +static int nvram_mult;
4288  static int nvram_partitions[3];
4289  
4290  static struct backlight_controller *backlighter = NULL;
4291 @@ -73,213 +31,22 @@
4292  static int backlight_level = BACKLIGHT_MAX;
4293  static int backlight_enabled = 1;
4294  
4295 -/* FIXME: kmalloc fails to allocate the image now that I had to move it
4296 - *        before time_init(). For now, I allocate a static buffer here
4297 - *        but it's a waste of space on all but core99 machines
4298 - */
4299 -#if 0
4300 -static char* nvram_image;
4301 -#else
4302 -static char nvram_image[NVRAM_SIZE];
4303 -#endif
4304 -
4305 -extern int pmac_newworld;
4306 -
4307 -static u8 __pmac
4308 -chrp_checksum(struct chrp_header* hdr)
4309 -{
4310 -       u8 *ptr;
4311 -       u16 sum = hdr->signature;
4312 -       for (ptr = (u8 *)&hdr->len; ptr < hdr->data; ptr++)
4313 -               sum += *ptr;
4314 -       while (sum > 0xFF)
4315 -               sum = (sum & 0xFF) + (sum>>8);
4316 -       return sum;
4317 -}
4318 -
4319 -static u32 __pmac
4320 -core99_calc_adler(u8 *buffer)
4321 -{
4322 -       int cnt;
4323 -       u32 low, high;
4324 -
4325 -       buffer += CORE99_ADLER_START;
4326 -       low = 1;
4327 -       high = 0;
4328 -       for (cnt=0; cnt<(NVRAM_SIZE-CORE99_ADLER_START); cnt++) {
4329 -               if ((cnt % 5000) == 0) {
4330 -                       high  %= 65521UL;
4331 -                       high %= 65521UL;
4332 -               }
4333 -               low += buffer[cnt];
4334 -               high += low;
4335 -       }
4336 -       low  %= 65521UL;
4337 -       high %= 65521UL;
4338 -  
4339 -       return (high << 16) | low;
4340 -}
4341 -
4342 -static u32 __pmac
4343 -core99_check(u8* datas)
4344 -{
4345 -       struct core99_header* hdr99 = (struct core99_header*)datas;
4346 +#define NVRAM_SIZE     0x2000  /* 8kB of non-volatile RAM */
4347  
4348 -       if (hdr99->hdr.signature != CORE99_SIGNATURE) {
4349 -#ifdef DEBUG
4350 -               printk("Invalid signature\n");
4351 -#endif         
4352 -               return 0;
4353 -       }
4354 -       if (hdr99->hdr.cksum != chrp_checksum(&hdr99->hdr)) {
4355 -#ifdef DEBUG
4356 -               printk("Invalid checksum\n");
4357 -#endif
4358 -               return 0;
4359 -       }
4360 -       if (hdr99->adler != core99_calc_adler(datas)) {
4361 -#ifdef DEBUG
4362 -               printk("Invalid adler\n");
4363 -#endif
4364 -               return 0;
4365 -       }
4366 -       return hdr99->generation;
4367 -}
4368 -
4369 -static int __pmac
4370 -core99_erase_bank(int bank)
4371 -{
4372 -       int stat, i;
4373 -       
4374 -       u8* base = (u8 *)nvram_data + core99_bank*NVRAM_SIZE;
4375 -       
4376 -       out_8(base, CORE99_FLASH_CMD_ERASE_SETUP);
4377 -       out_8(base, CORE99_FLASH_CMD_ERASE_CONFIRM);
4378 -       do { stat = in_8(base); }
4379 -       while(!(stat & CORE99_FLASH_STATUS_DONE));
4380 -       out_8(base, CORE99_FLASH_CMD_RESET);
4381 -       if (stat & CORE99_FLASH_STATUS_ERR) {
4382 -               printk("nvram: flash error 0x%02x on erase !\n", stat);
4383 -               return -ENXIO;
4384 -       }
4385 -       for (i=0; i<NVRAM_SIZE; i++)
4386 -               if (base[i] != 0xff) {
4387 -                       printk("nvram: flash erase failed !\n");
4388 -                       return -ENXIO;
4389 -               }
4390 -       return 0;
4391 -}
4392 -
4393 -static int __pmac
4394 -core99_write_bank(int bank, u8* datas)
4395 -{
4396 -       int i, stat = 0;
4397 -       
4398 -       u8* base = (u8 *)nvram_data + core99_bank*NVRAM_SIZE;
4399 -       
4400 -       for (i=0; i<NVRAM_SIZE; i++) {
4401 -               out_8(base+i, CORE99_FLASH_CMD_WRITE_SETUP);
4402 -               out_8(base+i, datas[i]);
4403 -               do { stat = in_8(base); }
4404 -               while(!(stat & CORE99_FLASH_STATUS_DONE));
4405 -               if (stat & CORE99_FLASH_STATUS_ERR)
4406 -                       break;
4407 -       }
4408 -       out_8(base, CORE99_FLASH_CMD_RESET);
4409 -       if (stat & CORE99_FLASH_STATUS_ERR) {
4410 -               printk("nvram: flash error 0x%02x on write !\n", stat);
4411 -               return -ENXIO;
4412 -       }
4413 -       for (i=0; i<NVRAM_SIZE; i++)
4414 -               if (base[i] != datas[i]) {
4415 -                       printk("nvram: flash write failed !\n");
4416 -                       return -ENXIO;
4417 -               }
4418 -       return 0;       
4419 -}
4420 -
4421 -static void __pmac
4422 -lookup_partitions(void)
4423 -{
4424 -       u8 buffer[17];
4425 -       int i, offset;
4426 -       struct chrp_header* hdr;
4427 -
4428 -       if (pmac_newworld) {
4429 -               nvram_partitions[pmac_nvram_OF] = -1;
4430 -               nvram_partitions[pmac_nvram_XPRAM] = -1;
4431 -               nvram_partitions[pmac_nvram_NR] = -1;
4432 -               hdr = (struct chrp_header *)buffer;
4433 -       
4434 -               offset = 0;
4435 -               buffer[16] = 0;
4436 -               do {
4437 -                       for (i=0;i<16;i++)
4438 -                               buffer[i] = nvram_read_byte(offset+i);
4439 -                       if (!strcmp(hdr->name, "common"))
4440 -                               nvram_partitions[pmac_nvram_OF] = offset + 0x10;
4441 -                       if (!strcmp(hdr->name, "APL,MacOS75")) {
4442 -                               nvram_partitions[pmac_nvram_XPRAM] = offset + 0x10;
4443 -                               nvram_partitions[pmac_nvram_NR] = offset + 0x110;
4444 -                       }
4445 -                       offset += (hdr->len * 0x10);
4446 -               } while(offset < NVRAM_SIZE);
4447 -       } else {
4448 -               nvram_partitions[pmac_nvram_OF] = 0x1800;
4449 -               nvram_partitions[pmac_nvram_XPRAM] = 0x1300;
4450 -               nvram_partitions[pmac_nvram_NR] = 0x1400;
4451 -       }       
4452 -#ifdef DEBUG
4453 -       printk("nvram: OF partition at 0x%x\n", nvram_partitions[pmac_nvram_OF]);
4454 -       printk("nvram: XP partition at 0x%x\n", nvram_partitions[pmac_nvram_XPRAM]);
4455 -       printk("nvram: NR partition at 0x%x\n", nvram_partitions[pmac_nvram_NR]);
4456 -#endif 
4457 -}
4458  
4459  __init
4460  void pmac_nvram_init(void)
4461  {
4462         struct device_node *dp;
4463  
4464 -       nvram_naddrs = 0;
4465 -
4466         dp = find_devices("nvram");
4467         if (dp == NULL) {
4468                 printk(KERN_ERR "Can't find NVRAM device\n");
4469 +               nvram_naddrs = 0;
4470                 return;
4471         }
4472         nvram_naddrs = dp->n_addrs;
4473 -       is_core_99 = device_is_compatible(dp, "nvram,flash");
4474 -       printk("pmac nvram is core99: %d\n", is_core_99);
4475 -       if (is_core_99) {
4476 -               int i;
4477 -               u32 gen_bank0, gen_bank1;
4478 -               
4479 -               if (nvram_naddrs < 1) {
4480 -                       printk(KERN_ERR "nvram: no address\n");
4481 -                       return;
4482 -               }
4483 -#if 0
4484 -               nvram_image = kmalloc(NVRAM_SIZE, GFP_KERNEL);
4485 -               if (!nvram_image) {
4486 -                       printk(KERN_ERR "nvram: can't allocate image\n");
4487 -                       return;
4488 -               }
4489 -#endif         
4490 -               nvram_data = ioremap(dp->addrs[0].address, NVRAM_SIZE*2);
4491 -#ifdef DEBUG
4492 -               printk("nvram: Checking bank 0...\n");
4493 -#endif
4494 -               gen_bank0 = core99_check((u8 *)nvram_data);
4495 -               gen_bank1 = core99_check((u8 *)nvram_data + NVRAM_SIZE);
4496 -               core99_bank = (gen_bank0 < gen_bank1) ? 1 : 0;
4497 -#ifdef DEBUG
4498 -               printk("nvram: gen0=%d, gen1=%d\n", gen_bank0, gen_bank1);
4499 -               printk("nvram: Active bank is: %d\n", core99_bank);
4500 -#endif
4501 -               for (i=0; i<NVRAM_SIZE; i++)
4502 -                       nvram_image[i] = nvram_data[i + core99_bank*NVRAM_SIZE];
4503 -       } else if (_machine == _MACH_chrp && nvram_naddrs == 1) {
4504 +       if (_machine == _MACH_chrp && nvram_naddrs == 1) {
4505                 nvram_data = ioremap(dp->addrs[0].address, dp->addrs[0].size);
4506                 nvram_mult = 1;
4507         } else if (nvram_naddrs == 1) {
4508 @@ -288,45 +55,15 @@
4509         } else if (nvram_naddrs == 2) {
4510                 nvram_addr = ioremap(dp->addrs[0].address, dp->addrs[0].size);
4511                 nvram_data = ioremap(dp->addrs[1].address, dp->addrs[1].size);
4512 -       } else if (nvram_naddrs == 0 && adb_controller &&
4513 -               adb_controller->kind == ADB_VIAPMU) {
4514 +       } else if (nvram_naddrs == 0 && adb_hardware == ADB_VIAPMU) {
4515                 nvram_naddrs = -1;
4516         } else {
4517                 printk(KERN_ERR "Don't know how to access NVRAM with %d addresses\n",
4518                        nvram_naddrs);
4519         }
4520 -       lookup_partitions();
4521  }
4522  
4523 -void __pmac
4524 -pmac_nvram_update(void)
4525 -{
4526 -       struct core99_header* hdr99;
4527 -       
4528 -       if (!is_core_99 || !nvram_data || !nvram_image)
4529 -               return;
4530 -       if (!memcmp(nvram_image, (u8*)nvram_data + core99_bank*NVRAM_SIZE,
4531 -               NVRAM_SIZE))
4532 -               return;
4533 -#ifdef DEBUG
4534 -       printk("Updating nvram...\n");
4535 -#endif
4536 -       hdr99 = (struct core99_header*)nvram_image;
4537 -       hdr99->generation++;
4538 -       hdr99->hdr.signature = CORE99_SIGNATURE;
4539 -       hdr99->hdr.cksum = chrp_checksum(&hdr99->hdr);
4540 -       hdr99->adler = core99_calc_adler(nvram_image);
4541 -       core99_bank = core99_bank ? 0 : 1;
4542 -       if (core99_erase_bank(core99_bank)) {
4543 -               printk("nvram: Error erasing bank %d\n", core99_bank);
4544 -               return;
4545 -       }
4546 -       if (core99_write_bank(core99_bank, nvram_image))
4547 -               printk("nvram: Error writing bank %d\n", core99_bank);
4548 -}
4549 -
4550 -unsigned char __pmac
4551 -nvram_read_byte(int addr)
4552 +unsigned char nvram_read_byte(int addr)
4553  {
4554         struct adb_request req;
4555  
4556 @@ -339,8 +76,6 @@
4557                         pmu_poll();
4558                 return req.reply[1];
4559         case 1:
4560 -               if (is_core_99)
4561 -                       return nvram_image ? nvram_image[addr] : 0;
4562                 return nvram_data[(addr & (NVRAM_SIZE - 1)) * nvram_mult];
4563         case 2:
4564                 *nvram_addr = addr >> 5;
4565 @@ -350,8 +85,7 @@
4566         return 0;
4567  }
4568  
4569 -void __pmac
4570 -nvram_write_byte(unsigned char val, int addr)
4571 +void nvram_write_byte(unsigned char val, int addr)
4572  {
4573         struct adb_request req;
4574  
4575 @@ -364,12 +98,6 @@
4576                         pmu_poll();
4577                 break;
4578         case 1:
4579 -               if (is_core_99) {
4580 -                       if (!nvram_image)
4581 -                               return;
4582 -                       nvram_image[addr] = val;
4583 -                       break;
4584 -               }
4585                 nvram_data[(addr & (NVRAM_SIZE - 1)) * nvram_mult] = val;
4586                 break;
4587         case 2:
4588 diff -urN linux.orig/arch/ppc/kernel/pmac_time.c linux/arch/ppc/kernel/pmac_time.c
4589 --- linux.orig/arch/ppc/kernel/pmac_time.c      Sun Mar 25 18:31:49 2001
4590 +++ linux/arch/ppc/kernel/pmac_time.c   Thu Jul 11 15:43:29 2002
4591 @@ -22,9 +22,8 @@
4592  #include <asm/system.h>
4593  #include <asm/io.h>
4594  #include <asm/pgtable.h>
4595 -#include <asm/nvram.h>
4596  
4597 -#include <asm/time.h>
4598 +#include "time.h"
4599  
4600  /* Apparently the RTC stores seconds since 1 Jan 1904 */
4601  #define RTC_OFFSET     2082844800
4602 @@ -50,26 +49,8 @@
4603  /* Bits in IFR and IER */
4604  #define T1_INT         0x40            /* Timer 1 interrupt */
4605  
4606 -extern struct timezone sys_tz;
4607 -
4608 -__init
4609 -long pmac_time_init(void)
4610 -{
4611 -       s32 delta = 0;
4612 -       int dst;
4613 -       
4614 -       delta = ((s32)pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0x9)) << 16;
4615 -       delta |= ((s32)pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0xa)) << 8;
4616 -       delta |= pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0xb);
4617 -       if (delta & 0x00800000UL)
4618 -               delta |= 0xFF000000UL;
4619 -       dst = ((pmac_xpram_read(PMAC_XPRAM_MACHINE_LOC + 0x8) & 0x80) != 0);
4620 -       printk("GMT Delta read from XPRAM: %d minutes, DST: %s\n", delta/60,
4621 -               dst ? "on" : "off");
4622 -       return -delta;
4623 -}
4624 -
4625  __pmac
4626 +
4627  unsigned long pmac_get_rtc_time(void)
4628  {
4629         struct adb_request req;
4630 @@ -109,42 +90,7 @@
4631  
4632  int pmac_set_rtc_time(unsigned long nowtime)
4633  {
4634 -       struct adb_request req;
4635 -       int dst, delta;
4636 -
4637 -       nowtime += RTC_OFFSET;
4638 -
4639 -       /* Set the time in the RTC */
4640 -       if (adb_controller == 0)
4641 -               return 0;
4642 -       /* adb_controller->kind, not adb_hardware, since that doesn't
4643 -          get set until we call adb_init - paulus. */
4644 -       switch (adb_controller->kind) {
4645 -       case ADB_VIACUDA:
4646 -               if (cuda_request(&req, NULL, 6, CUDA_PACKET, CUDA_SET_TIME,
4647 -                                nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0)
4648 -                       return 0;
4649 -               while (!req.complete)
4650 -                       cuda_poll();
4651 -//             if (req.reply_len != 7)
4652 -                       printk(KERN_ERR "pmac_set_rtc_time: got %d byte reply\n",
4653 -                              req.reply_len);
4654 -               break;
4655 -       case ADB_VIAPMU:
4656 -               if (pmu_request(&req, NULL, 5, PMU_SET_RTC,
4657 -                               nowtime >> 24, nowtime >> 16, nowtime >> 8, nowtime) < 0)
4658 -                       return 0;
4659 -               while (!req.complete)
4660 -                       pmu_poll();
4661 -               if (req.reply_len != 5)
4662 -                       printk(KERN_ERR "pmac_set_rtc_time: got %d byte reply\n",
4663 -                              req.reply_len);
4664 -               break;
4665 -       default:
4666 -               return 0;
4667 -       }
4668 -
4669 -       return 1;
4670 +       return 0;
4671  }
4672  
4673  /*
4674 diff -urN linux.orig/arch/ppc/kernel/ppc-stub.c linux/arch/ppc/kernel/ppc-stub.c
4675 --- linux.orig/arch/ppc/kernel/ppc-stub.c       Sun Mar 25 18:31:49 2001
4676 +++ linux/arch/ppc/kernel/ppc-stub.c    Thu Jul 11 15:43:29 2002
4677 @@ -351,7 +351,7 @@
4678  
4679  static inline void set_msr(int msr)
4680  {
4681 -       asm volatile("mtmsr %0" : : "r" (msr));
4682 +       asm volatile("mfmsr %0" : : "r" (msr));
4683  }
4684  
4685  /* Set up exception handlers for tracing and breakpoints
4686 diff -urN linux.orig/arch/ppc/kernel/ppc_asm.tmpl linux/arch/ppc/kernel/ppc_asm.tmpl
4687 --- linux.orig/arch/ppc/kernel/ppc_asm.tmpl     Sun Mar 25 18:31:48 2001
4688 +++ linux/arch/ppc/kernel/ppc_asm.tmpl  Thu Jul 11 15:43:29 2002
4689 @@ -64,36 +64,3 @@
4690  #define        fr29    29
4691  #define        fr30    30
4692  #define        fr31    31
4693 -
4694 -#define        vr0     0
4695 -#define        vr1     1
4696 -#define        vr2     2
4697 -#define        vr3     3
4698 -#define        vr4     4
4699 -#define        vr5     5
4700 -#define        vr6     6
4701 -#define        vr7     7
4702 -#define        vr8     8
4703 -#define        vr9     9
4704 -#define        vr10    10
4705 -#define        vr11    11
4706 -#define        vr12    12
4707 -#define        vr13    13
4708 -#define        vr14    14
4709 -#define        vr15    15
4710 -#define        vr16    16
4711 -#define        vr17    17
4712 -#define        vr18    18
4713 -#define        vr19    19
4714 -#define        vr20    20
4715 -#define        vr21    21
4716 -#define        vr22    22
4717 -#define        vr23    23
4718 -#define        vr24    24
4719 -#define        vr25    25
4720 -#define        vr26    26
4721 -#define        vr27    27
4722 -#define        vr28    28
4723 -#define        vr29    29
4724 -#define        vr30    30
4725 -#define        vr31    31
4726 diff -urN linux.orig/arch/ppc/kernel/ppc_htab.c linux/arch/ppc/kernel/ppc_htab.c
4727 --- linux.orig/arch/ppc/kernel/ppc_htab.c       Sun Mar 25 18:31:49 2001
4728 +++ linux/arch/ppc/kernel/ppc_htab.c    Thu Jul 11 15:43:29 2002
4729 @@ -547,8 +547,7 @@
4730                 "0.5", "1.0", "(reserved2)", "(reserved3)"
4731         };
4732  
4733 -       if ( ((_get_PVR() >> 16) != 8) && ((_get_PVR() >> 16) != 12))
4734 -               return -EFAULT;
4735 +       if ( (_get_PVR() >> 16) != 8) return -EFAULT;
4736         
4737         if ( /*!table->maxlen ||*/ (filp->f_pos && !write)) {
4738                 *lenp = 0;
4739 @@ -587,8 +586,9 @@
4740                         buffer += len;
4741                         left -= len;
4742                         _set_L2CR(0);
4743 -                       if (val)
4744 -                               _set_L2CR(val);
4745 +                       _set_L2CR(val);
4746 +                       while ( _get_L2CR() & 0x1 )
4747 +                               /* wait for invalidate to finish */;
4748                           
4749                 } else {
4750                         p = buf;
4751 diff -urN linux.orig/arch/ppc/kernel/ppc_ksyms.c linux/arch/ppc/kernel/ppc_ksyms.c
4752 --- linux.orig/arch/ppc/kernel/ppc_ksyms.c      Tue Jun 11 19:39:18 2002
4753 +++ linux/arch/ppc/kernel/ppc_ksyms.c   Fri Jul 12 18:41:29 2002
4754 @@ -5,26 +5,30 @@
4755  #include <linux/sched.h>
4756  #include <linux/string.h>
4757  #include <linux/interrupt.h>
4758 -#include <linux/smp_lock.h>
4759  #include <linux/vt_kern.h>
4760  #include <linux/nvram.h>
4761  
4762 +#include <asm/page.h>
4763  #include <asm/semaphore.h>
4764  #include <asm/processor.h>
4765  #include <asm/uaccess.h>
4766 +#include <asm/io.h>
4767  #include <asm/ide.h>
4768 +#include <asm/atomic.h>
4769 +#include <asm/bitops.h>
4770  #include <asm/checksum.h>
4771  #include <asm/pgtable.h>
4772  #include <asm/adb.h>
4773  #include <asm/cuda.h>
4774  #include <asm/pmu.h>
4775  #include <asm/prom.h>
4776 +#include <asm/system.h>
4777  #include <asm/pci-bridge.h>
4778  #include <asm/irq.h>
4779  #include <asm/feature.h>
4780 +#include <asm/spinlock.h>
4781  #include <asm/dma.h>
4782 -#include <asm/nvram.h>
4783 -#include <asm/time.h>
4784 +#include <asm/machdep.h>
4785  
4786  /* Tell string.h we don't want memcpy etc. as cpp defines */
4787  #define EXPORT_SYMTAB_STROPS
4788 @@ -45,10 +49,10 @@
4789                              unsigned int, unsigned int, unsigned int);
4790  extern void to_tm(int tim, struct rtc_time * tm);
4791  
4792 -long long __ashrdi3(long long, int);
4793 -long long __ashldi3(long long, int);
4794 -long long __lshrdi3(long long, int);
4795 -int abs(int);
4796 +asmlinkage long long __ashrdi3(long long, int);
4797 +asmlinkage long long __ashldi3(long long, int);
4798 +asmlinkage long long __lshrdi3(long long, int);
4799 +asmlinkage int abs(int);
4800  
4801  EXPORT_SYMBOL(clear_page);
4802  EXPORT_SYMBOL(do_signal);
4803 @@ -73,12 +77,10 @@
4804  EXPORT_SYMBOL(isa_mem_base);
4805  EXPORT_SYMBOL(pci_dram_offset);
4806  EXPORT_SYMBOL(ISA_DMA_THRESHOLD);
4807 -EXPORT_SYMBOL_NOVERS(DMA_MODE_READ);
4808 +EXPORT_SYMBOL(DMA_MODE_READ);
4809  EXPORT_SYMBOL(DMA_MODE_WRITE);
4810 -#if defined(CONFIG_PREP) || defined(CONFIG_ALL_PPC)
4811  EXPORT_SYMBOL(_prep_type);
4812  EXPORT_SYMBOL(ucSystemType);
4813 -#endif
4814  
4815  EXPORT_SYMBOL(atomic_add);
4816  EXPORT_SYMBOL(atomic_sub);
4817 @@ -167,16 +169,11 @@
4818  EXPORT_SYMBOL(enable_kernel_fp);
4819  EXPORT_SYMBOL(flush_icache_range);
4820  EXPORT_SYMBOL(xchg_u32);
4821 -
4822 -#ifdef CONFIG_ALTIVEC
4823 -EXPORT_SYMBOL(giveup_altivec);
4824 -#endif
4825 -
4826  #ifdef __SMP__
4827 -EXPORT_SYMBOL(cpu_data);
4828 -EXPORT_SYMBOL(kernel_flag);
4829 -EXPORT_SYMBOL(cpu_number_map);
4830 -EXPORT_SYMBOL(smp_num_cpus);
4831 +EXPORT_SYMBOL(__global_cli);
4832 +EXPORT_SYMBOL(__global_sti);
4833 +EXPORT_SYMBOL(__global_save_flags);
4834 +EXPORT_SYMBOL(__global_restore_flags);
4835  EXPORT_SYMBOL(_spin_lock);
4836  EXPORT_SYMBOL(_spin_unlock);
4837  EXPORT_SYMBOL(spin_trylock);
4838 @@ -184,35 +181,11 @@
4839  EXPORT_SYMBOL(_read_unlock);
4840  EXPORT_SYMBOL(_write_lock);
4841  EXPORT_SYMBOL(_write_unlock);
4842 -
4843 -/* Global SMP irq stuff */
4844 -EXPORT_SYMBOL(synchronize_irq);
4845 -EXPORT_SYMBOL(synchronize_bh);
4846 -EXPORT_SYMBOL(global_bh_count);
4847 -EXPORT_SYMBOL(global_bh_lock);
4848 -EXPORT_SYMBOL(global_irq_holder);
4849 -EXPORT_SYMBOL(__global_cli);
4850 -EXPORT_SYMBOL(__global_sti);
4851 -EXPORT_SYMBOL(__global_save_flags);
4852 -EXPORT_SYMBOL(__global_restore_flags);
4853 -#endif /* __SMP__ */
4854 +#endif
4855  
4856  EXPORT_SYMBOL(_machine);
4857  EXPORT_SYMBOL(ppc_md);
4858 -EXPORT_SYMBOL(abort);
4859  
4860 -#ifndef CONFIG_MBX
4861 -EXPORT_SYMBOL(find_devices);
4862 -EXPORT_SYMBOL(find_type_devices);
4863 -EXPORT_SYMBOL(find_compatible_devices);
4864 -EXPORT_SYMBOL(find_path_device);
4865 -EXPORT_SYMBOL(find_phandle);
4866 -EXPORT_SYMBOL(device_is_compatible);
4867 -EXPORT_SYMBOL(machine_is_compatible);
4868 -EXPORT_SYMBOL(find_pci_device_OFnode);
4869 -EXPORT_SYMBOL(find_all_nodes);
4870 -EXPORT_SYMBOL(get_property);
4871 -#endif /* CONFIG_MBX */
4872  #ifdef CONFIG_POWERMAC
4873  EXPORT_SYMBOL(adb_request);
4874  EXPORT_SYMBOL(adb_register);
4875 @@ -227,21 +200,25 @@
4876  EXPORT_SYMBOL(pmu_enable_irled);
4877  #endif /* CONFIG_PMAC_PBOOK */
4878  #ifdef CONFIG_POWERMAC
4879 +EXPORT_SYMBOL(abort);
4880 +EXPORT_SYMBOL(find_devices);
4881 +EXPORT_SYMBOL(find_type_devices);
4882 +EXPORT_SYMBOL(find_compatible_devices);
4883 +EXPORT_SYMBOL(find_path_device);
4884 +EXPORT_SYMBOL(find_phandle);
4885 +EXPORT_SYMBOL(device_is_compatible);
4886 +EXPORT_SYMBOL(machine_is_compatible);
4887 +EXPORT_SYMBOL(find_pci_device_OFnode);
4888 +EXPORT_SYMBOL(get_property);
4889  EXPORT_SYMBOL(pci_io_base);
4890 -EXPORT_SYMBOL(pci_dev_io_base);
4891 -EXPORT_SYMBOL(pci_dev_mem_base);
4892  EXPORT_SYMBOL(pci_device_loc);
4893  EXPORT_SYMBOL(feature_set);
4894  EXPORT_SYMBOL(feature_clear);
4895  EXPORT_SYMBOL(feature_test);
4896  EXPORT_SYMBOL(feature_set_gmac_power);
4897  EXPORT_SYMBOL(feature_set_gmac_phy_reset);
4898 -EXPORT_SYMBOL(feature_set_usb_power);
4899 -EXPORT_SYMBOL(feature_set_firewire_power);
4900  EXPORT_SYMBOL(nvram_read_byte);
4901  EXPORT_SYMBOL(nvram_write_byte);
4902 -EXPORT_SYMBOL(pmac_xpram_read);
4903 -EXPORT_SYMBOL(pmac_xpram_write);
4904  #ifdef CONFIG_SCSI
4905  EXPORT_SYMBOL(note_scsi_host);
4906  #endif /* CONFIG_SCSI */
4907 diff -urN linux.orig/arch/ppc/kernel/prep_pci.c linux/arch/ppc/kernel/prep_pci.c
4908 --- linux.orig/arch/ppc/kernel/prep_pci.c       Sun Mar 25 18:31:49 2001
4909 +++ linux/arch/ppc/kernel/prep_pci.c    Thu Jul 11 15:43:29 2002
4910 @@ -8,7 +8,6 @@
4911   */
4912  
4913  #include <linux/types.h>
4914 -#include <linux/string.h>
4915  #include <linux/pci.h>
4916  #include <linux/kernel.h>
4917  #include <linux/init.h>
4918 @@ -22,10 +21,10 @@
4919  #include <asm/residual.h>
4920  #include <asm/processor.h>
4921  #include <asm/irq.h>
4922 +#include <asm/irq-compat.h>
4923  #include <asm/machdep.h>
4924  
4925  #include "pci.h"
4926 -#include "open_pic.h"
4927  
4928  #define MAX_DEVNR 22
4929  
4930 @@ -38,11 +37,13 @@
4931  unsigned char *Motherboard_routes;
4932  void (*Motherboard_non0)(struct pci_dev *);
4933  
4934 -void Powerplus_Map_Non0(struct pci_dev *);
4935 +void Mesquite_Map_Non0(struct pci_dev *);
4936  
4937  /* Used for Motorola to store system config register */
4938  static unsigned long   *ProcInfo;
4939  
4940 +extern void chrp_do_IRQ(struct pt_regs *,int , int);
4941 +
4942  /* Tables for known hardware */   
4943  
4944  /* Motorola PowerStackII - Utah */
4945 @@ -508,51 +509,6 @@
4946          13      /* Line 4 */
4947  };
4948  
4949 -/* Motorola PowerPlus architecture PCI IRQ tables */
4950 -/* Interrupt line values for INTA-D on primary/secondary MPIC inputs */
4951 -
4952 -struct powerplus_irq_list
4953 -{
4954 -       unsigned char primary[4];       /* INT A-D */
4955 -       unsigned char secondary[4];     /* INT A-D */
4956 -};
4957 -
4958 -/*
4959 - * For standard PowerPlus boards, bus 0 PCI INTs A-D are routed to
4960 - * OpenPIC inputs 9-12.  PCI INTs A-D from the on board P2P bridge
4961 - * are routed to OpenPIC inputs 5-8.  These values are offset by 
4962 - * 16 in the table to reflect the Linux kernel interrupt value.
4963 - */
4964 -struct powerplus_irq_list Powerplus_pci_IRQ_list =
4965 -{
4966 -       {25, 26, 27, 28},
4967 -       {21, 22, 23, 24}
4968 -};
4969 -
4970 -/* 
4971 - * For the MCP750 (system slot board), bus 0 PCI INTs A-D are routed
4972 - * to OpenPIC inputs 8-11.  PCI INTs A-D from the on board P2P bridge
4973 - * are routed to OpenPIC inputs 12-15.  These values are offset by 16
4974 - * in the table to reflect the Linux kernel interrupt value.
4975 - */
4976 -struct powerplus_irq_list Mesquite_pci_IRQ_list =
4977 -{
4978 -       {24, 25, 26, 27},
4979 -       {28, 29, 30, 31}
4980 -};
4981 -
4982 -/*
4983 - * This table represents the standard PCI swizzle defined in the
4984 - * PCI bus specification.
4985 - */ 
4986 -static unsigned char prep_pci_intpins[4][4] =
4987 -{
4988 -        { 1, 2, 3, 4},  /* Buses 0, 4, 8, ... */
4989 -        { 2, 3, 4, 1},  /* Buses 1, 5, 9, ... */
4990 -        { 3, 4, 1, 2},  /* Buses 2, 6, 10 ... */
4991 -        { 4, 1, 2, 3},  /* Buses 3, 7, 11 ... */
4992 -};
4993 -
4994  /* We have to turn on LEVEL mode for changed IRQ's */
4995  /* All PCI IRQ's need to be level mode, so this should be something
4996   * other than hard-coded as well... IRQ's are individually mappable
4997 @@ -730,7 +686,8 @@
4998  #define MOT_RAVEN_PRESENT      0x1
4999  #define MOT_HAWK_PRESENT       0x2
5000  
5001 -int mot_entry = -1;
5002 +/* Keyboard present flag */
5003 +int prep_kbd_present = 1;   /* Keyboard present by default */
5004  
5005  int MotMPIC = 0;
5006  int mot_multi = 0;
5007 @@ -783,7 +740,7 @@
5008         OpenPIC_InitSenses = mvme2600_openpic_initsenses;
5009         OpenPIC_NumInitSenses = sizeof(mvme2600_openpic_initsenses);
5010  
5011 -       ppc_md.do_IRQ = open_pic_do_IRQ;
5012 +       ppc_md.do_IRQ = chrp_do_IRQ;
5013         
5014         /* If raven is present on Motorola store the system config register
5015          * for later use.
5016 @@ -795,17 +752,13 @@
5017                 mot_multi = 1;
5018         }
5019  
5020 -       /*
5021 -        * If a Motorola MVME2300, 2400, or MCPN750 board is detected
5022 -        * disable keyboard controller initialization to avoid system
5023 -        * hangs.
5024 +       /* This is a hack.  If this is a 2300 or 2400 mot board then there is
5025 +        * no keyboard controller and we have to indicate that.
5026          */
5027         base_mod = inb(MOTOROLA_BASETYPE_REG);
5028         if ((MotMPIC == MOT_HAWK_PRESENT) || (base_mod == 0xF9) ||
5029 -           (base_mod == 0xFA) || (base_mod == 0xE1)) {
5030 -               ppc_md.kbd_leds = NULL; 
5031 -               ppc_md.kbd_init_hw = NULL; 
5032 -       }
5033 +           (base_mod == 0xFA) || (base_mod == 0xE1))
5034 +               prep_kbd_present = 0;
5035  
5036         return 1;
5037  }
5038 @@ -819,35 +772,33 @@
5039         unsigned char   *map;
5040         unsigned char   *routes;
5041         void            (*map_non0_bus)(struct pci_dev *);      /* For boards with more than bus 0 devices. */
5042 -       struct powerplus_irq_list *pci_irq_list; /* List of PCI MPIC inputs */
5043 -       unsigned char   secondary_bridge_devfn; /* devfn of secondary bus transparent bridge */
5044  } mot_info[] = {
5045 -       {0x300, 0x00, 0x00, "MVME 2400",                        Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5046 -       {0x010, 0x00, 0x00, "Genesis",                          Genesis_pci_IRQ_map,    Genesis_pci_IRQ_routes, Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5047 -       {0x020, 0x00, 0x00, "Powerstack (Series E)",            Comet_pci_IRQ_map,      Comet_pci_IRQ_routes,   NULL, NULL, 0x00},
5048 -       {0x040, 0x00, 0x00, "Blackhawk (Powerstack)",           Blackhawk_pci_IRQ_map,  Blackhawk_pci_IRQ_routes, NULL, NULL, 0x00},
5049 -       {0x050, 0x00, 0x00, "Omaha (PowerStack II Pro3000)",    Omaha_pci_IRQ_map,      Omaha_pci_IRQ_routes,   NULL, NULL, 0x00},
5050 -       {0x060, 0x00, 0x00, "Utah (Powerstack II Pro4000)",     Utah_pci_IRQ_map,       Utah_pci_IRQ_routes,    NULL, NULL, 0x00},
5051 -       {0x0A0, 0x00, 0x00, "Powerstack (Series EX)",           Comet2_pci_IRQ_map,     Comet2_pci_IRQ_routes,  NULL, NULL, 0x00},
5052 -       {0x1E0, 0xE0, 0x00, "Mesquite cPCI (MCP750)",           Mesquite_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Mesquite_pci_IRQ_list, 0x00},
5053 -       {0x1E0, 0xE1, 0x00, "Sitka cPCI (MCPN750)",             Sitka_pci_IRQ_map,      Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5054 -       {0x1E0, 0xE2, 0x00, "Mesquite cPCI (MCP750) w/ HAC",    Mesquite_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Mesquite_pci_IRQ_list, 0xC0},
5055 -       {0x1E0, 0xF6, 0x80, "MTX Plus",                         MTXplus_pci_IRQ_map,    Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xA0},
5056 -       {0x1E0, 0xF6, 0x81, "Dual MTX Plus",                    MTXplus_pci_IRQ_map,    Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0xA0},
5057 -       {0x1E0, 0xF7, 0x80, "MTX wo/ Parallel Port",            MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5058 -       {0x1E0, 0xF7, 0x81, "Dual MTX wo/ Parallel Port",       MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5059 -       {0x1E0, 0xF8, 0x80, "MTX w/ Parallel Port",             MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5060 -       {0x1E0, 0xF8, 0x81, "Dual MTX w/ Parallel Port",        MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5061 -       {0x1E0, 0xF9, 0x00, "MVME 2300",                        Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5062 -       {0x1E0, 0xFA, 0x00, "MVME 2300SC/2600",                 Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5063 -       {0x1E0, 0xFB, 0x00, "MVME 2600 with MVME712M",          Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5064 -       {0x1E0, 0xFC, 0x00, "MVME 2600/2700 with MVME761",      Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5065 -       {0x1E0, 0xFD, 0x80, "MVME 3600 with MVME712M",          Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5066 -       {0x1E0, 0xFD, 0x81, "MVME 4600 with MVME712M",          Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5067 -       {0x1E0, 0xFE, 0x80, "MVME 3600 with MVME761",           Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5068 -       {0x1E0, 0xFE, 0x81, "MVME 4600 with MVME761",           Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   Powerplus_Map_Non0, &Powerplus_pci_IRQ_list, 0x00},
5069 -       {0x1E0, 0xFF, 0x00, "MVME 1600-001 or 1600-011",        Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL, NULL, 0x00},
5070 -       {0x000, 0x00, 0x00, "",                                 NULL,                   NULL,   NULL, 0x00}
5071 +       {0x300, 0x00, 0x00, "MVME 2400",                        Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5072 +       {0x010, 0x00, 0x00, "Genesis",                          Genesis_pci_IRQ_map,    Genesis_pci_IRQ_routes, NULL},
5073 +       {0x020, 0x00, 0x00, "Powerstack (Series E)",            Comet_pci_IRQ_map,      Comet_pci_IRQ_routes,   NULL},
5074 +       {0x040, 0x00, 0x00, "Blackhawk (Powerstack)",           Blackhawk_pci_IRQ_map,  Blackhawk_pci_IRQ_routes, NULL},
5075 +       {0x050, 0x00, 0x00, "Omaha (PowerStack II Pro3000)",    Omaha_pci_IRQ_map,      Omaha_pci_IRQ_routes,   NULL},
5076 +       {0x060, 0x00, 0x00, "Utah (Powerstack II Pro4000)",     Utah_pci_IRQ_map,       Utah_pci_IRQ_routes,    NULL},
5077 +       {0x0A0, 0x00, 0x00, "Powerstack (Series EX)",           Comet2_pci_IRQ_map,     Comet2_pci_IRQ_routes,  NULL},
5078 +       {0x1E0, 0xE0, 0x00, "Mesquite cPCI (MCP750)",           Mesquite_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5079 +       {0x1E0, 0xE1, 0x00, "Sitka cPCI (MCPN750)",             Sitka_pci_IRQ_map,      Raven_pci_IRQ_routes,   NULL},
5080 +       {0x1E0, 0xE2, 0x00, "Mesquite cPCI (MCP750) w/ HAC",    Mesquite_pci_IRQ_map,   Raven_pci_IRQ_routes,   Mesquite_Map_Non0},
5081 +       {0x1E0, 0xF6, 0x80, "MTX Plus",                         MTXplus_pci_IRQ_map,    Raven_pci_IRQ_routes,   NULL},
5082 +       {0x1E0, 0xF6, 0x81, "Dual MTX Plus",                    MTXplus_pci_IRQ_map,    Raven_pci_IRQ_routes,   NULL},
5083 +       {0x1E0, 0xF7, 0x80, "MTX wo/ Parallel Port",            MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   NULL},
5084 +       {0x1E0, 0xF7, 0x81, "Dual MTX wo/ Parallel Port",       MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   NULL},
5085 +       {0x1E0, 0xF8, 0x80, "MTX w/ Parallel Port",             MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   NULL},
5086 +       {0x1E0, 0xF8, 0x81, "Dual MTX w/ Parallel Port",        MTX_pci_IRQ_map,        Raven_pci_IRQ_routes,   NULL},
5087 +       {0x1E0, 0xF9, 0x00, "MVME 2300",                        Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5088 +       {0x1E0, 0xFA, 0x00, "MVME 2300SC/2600",                 Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5089 +       {0x1E0, 0xFB, 0x00, "MVME 2600 with MVME712M",          Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5090 +       {0x1E0, 0xFC, 0x00, "MVME 2600/2700 with MVME761",      Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5091 +       {0x1E0, 0xFD, 0x80, "MVME 3600 with MVME712M",          Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5092 +       {0x1E0, 0xFD, 0x81, "MVME 4600 with MVME712M",          Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5093 +       {0x1E0, 0xFE, 0x80, "MVME 3600 with MVME761",           Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5094 +       {0x1E0, 0xFE, 0x81, "MVME 4600 with MVME761",           Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5095 +       {0x1E0, 0xFF, 0x00, "MVME 1600-001 or 1600-011",        Genesis2_pci_IRQ_map,   Raven_pci_IRQ_routes,   NULL},
5096 +       {0x000, 0x00, 0x00, "",                                 NULL,                   NULL,   NULL}
5097  };
5098  
5099  __initfunc(unsigned long prep_route_pci_interrupts(void))
5100 @@ -862,6 +813,7 @@
5101                 unsigned char  cpu_type;
5102                 unsigned char  base_mod;
5103                 int            entry;
5104 +               int            mot_entry = -1;
5105  
5106                 cpu_type = inb(MOTOROLA_CPUTYPE_REG) & 0xF0;
5107                 base_mod = inb(MOTOROLA_BASETYPE_REG);
5108 @@ -1038,91 +990,91 @@
5109         return 0;
5110  }
5111  
5112 -/*
5113 - * Remove a device from the kernel PCI device list based on its 
5114 - * devfn identifier.
5115 - */
5116 -__initfunc(
5117 -void
5118 -prep_exclude_pci_device(unsigned char devfn)
5119 -)
5120 +static unsigned int pci_localpirqs[4] =
5121  {
5122 -       struct pci_dev *dev, *pdev = NULL;
5123 +       24,
5124 +       25,
5125 +       26,
5126 +       27
5127 +};
5128  
5129 -       /* Walk the pci device list */
5130 -       for(dev=pci_devices; dev; dev=dev->next) {
5131 -               if (dev->devfn == devfn)
5132 -               {
5133 -                       /*
5134 -                        * If we find a matching device, adjust
5135 -                        * the list to remove the device.
5136 -                        */
5137 -                       if (pdev != NULL)
5138 -                               pdev->next = dev->next;
5139 -                       else
5140 -                               pci_devices = dev->next;
5141 +static unsigned int pci_remotepirqs[4] =
5142 +{
5143 +       28,
5144 +       29,
5145 +       30,
5146 +       31
5147 +};
5148  
5149 -                       break;
5150 -               }
5151 -               pdev = dev;
5152 -       }
5153 -}
5154 +static unsigned int pci_remotedev = 0xc0;
5155  
5156  void
5157 -Powerplus_Map_Non0(struct pci_dev *dev)
5158 +Mesquite_Map_Non0(struct pci_dev *pdev)
5159  {
5160 -       struct pci_bus  *pbus;          /* Parent bus structure pointer */
5161 -       struct pci_dev  *tdev;          /* Temporary device structure */
5162 -        unsigned int    devnum;         /* Accumulated device number */
5163 -        unsigned char   intline;        /* Linux interrupt value */
5164 -       unsigned char   intpin;         /* PCI interrupt pin */
5165
5166 -       /* Check for valid PCI dev pointer */
5167 -       if (dev == NULL) return;
5168 -
5169 -       /* Fill our temporary device, and get the device number */
5170 -       *tdev = *dev;
5171 -       devnum = PCI_SLOT(tdev->devfn);
5172 -
5173 -       /* Read the interrupt pin of the device and adjust for indexing */
5174 -       pcibios_read_config_byte(tdev->bus->number, tdev->devfn,
5175 -                               PCI_INTERRUPT_PIN, &intpin);
5176 +       struct pci_bus  *pbus;          /* Parent Bus Structure Pointer */
5177 +       unsigned int    devnum;         /* Accumulated Device Number */
5178 +       unsigned int    irq;            /* IRQ Value */
5179  
5180 -       /* If device doesn't request an interrupt, return */
5181 -       if ( (intpin < 1) || (intpin > 4) )
5182 -               return;
5183 +       /*
5184 +       **    Device Interrupt Line register initialization.
5185 +       **    The IRQ line number will be generated after
5186 +       **    taking into account all the PCI-2-PCI bridge
5187 +       **    devices between the device and the Host Bridge.
5188 +       */
5189 +       devnum = PCI_SLOT(pdev->devfn);
5190 +       pbus = pdev->bus;
5191 +
5192 +       while ((pbus->parent)->primary != (pbus->parent)->secondary)
5193 +       {
5194 +           devnum += PCI_SLOT((pbus->self)->devfn);
5195 +
5196 +           pbus = pbus->parent;
5197 +       }
5198 +
5199 +       devnum &= 0x03;
5200 +
5201 +       /*
5202 +       **    By default, get the PCI local domain IRQ value.
5203 +       */
5204 +       irq = pci_localpirqs[devnum];
5205 +
5206 +       /*
5207 +       **    Determine if the device is located in the
5208 +       **    remote domain or not. We must find the
5209 +       **    domain's bridge device located on bus 0.
5210 +       */
5211 +       pbus = pdev->bus;
5212 +
5213 +       while (pbus->primary != 0)
5214 +           pbus = pbus->parent;
5215  
5216 -       intpin--;
5217 +       /*
5218 +       **    Check the device/function of domain's bridge
5219 +       **    device against the remote device/function.
5220 +       **    If the same, then the device is located in
5221 +       **    the remote domain. Thus, get the PCI remote
5222 +       **    domain IRQ value.
5223 +       */
5224 +       if ((pbus->self)->devfn == pci_remotedev)
5225 +        irq = pci_remotepirqs[devnum];
5226  
5227 -       /* Walk up to bus 0, adjusting the interrupt pin for the standard
5228 -          PCI bus swizzle. */
5229 -       do {
5230 -               intpin = (prep_pci_intpins[devnum % 4][intpin]) - 1;
5231 -               pbus = tdev->bus;        /* up one level */
5232 -               tdev = pbus->self;
5233 -               devnum = PCI_SLOT(tdev->devfn);
5234 -       } while(tdev->bus->number);
5235 -
5236 -       /* Use the primary interrupt inputs by default */
5237 -       intline = mot_info[mot_entry].pci_irq_list->primary[intpin];
5238 -
5239 -       /* If the board has secondary interrupt inputs, walk the bus and
5240 -          note the devfn of the bridge from bus 0.  If it is the same as
5241 -          the devfn of the bus bridge with secondary inputs, use those. */
5242 -       if (mot_info[mot_entry].secondary_bridge_devfn)
5243 +       /*
5244 +       **    Validate the IRQ number.
5245 +       */
5246 +       if (irq <= 255)
5247         {
5248 -               pbus = dev->bus;
5249
5250 -               while (pbus->primary != 0)
5251 -                       pbus = pbus->parent;
5252
5253 -               if ((pbus->self)->devfn == mot_info[mot_entry].secondary_bridge_devfn)
5254 -                       intline = mot_info[mot_entry].pci_irq_list->secondary[intpin];
5255 +           /*
5256 +           **    Set the device's Interrupt Line register
5257 +           **    to the IRQ number and save it in the
5258 +           **    device's structure.
5259 +           */
5260 +
5261 +           pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, (u8)irq);
5262 +
5263 +           pdev->irq = irq;
5264 +
5265         }
5266 -       
5267 -       /* Write calculated interrupt value to header and device list */
5268 -       pci_write_config_byte(dev, PCI_INTERRUPT_LINE, (u8)intline);
5269 -       dev->irq = intline;
5270 +       return;
5271  }
5272  
5273  int motopenpic_to_irq(int n)
5274 @@ -1130,7 +1082,7 @@
5275         if (n & 0xF0) {
5276                 return (n & 0x0F);
5277         } else {
5278 -               return(n+open_pic.irq_offset);
5279 +               return(openpic_to_irq(n));
5280         }
5281  }
5282  
5283 @@ -1169,17 +1121,6 @@
5284                                         dev->devfn, 0x44, short_reg);
5285                 }
5286         }
5287 -       if ((dev = pci_find_device(PCI_VENDOR_ID_WINBOND,
5288 -                                  PCI_DEVICE_ID_WINBOND_82C105, dev))){
5289 -               if (OpenPIC){
5290 -                       /* Disable LEGIRQ mode so PCI INTs are routed to
5291 -                          the 8259 */
5292 -                       pci_write_config_dword(dev, 0x40, 0x10ff00a1);
5293 -               } else {
5294 -                       /* Enable LEGIRQ for PCI INT -> 8259 IRQ routing */
5295 -                       pci_write_config_dword(dev, 0x40, 0x10ff08a1);
5296 -               }
5297 -       }
5298  }
5299  __initfunc(
5300  void
5301 @@ -1197,15 +1138,6 @@
5302  
5303         prep_route_pci_interrupts();
5304  
5305 -       /*
5306 -        * If MTX+, exclude the SL82C105 IDE controller so the driver
5307 -        * doesn't hang.
5308 -        */
5309 -       if ( _prep_type == _PREP_Motorola )
5310 -               if ( strstr(mot_info[mot_entry].name, "MTX Plus") )
5311 -                       /* On MTX+, SL82C105 is at IDSEL 0xb function 0x1 */
5312 -                       prep_exclude_pci_device(PCI_DEVFN(0xb, 0x1));
5313 -
5314         prep_pib_init();
5315  
5316         printk("Setting PCI interrupts for a \"%s\"\n", Motherboard_map_name);
5317 @@ -1219,7 +1151,7 @@
5318                        motopenpic_to_irq(Motherboard_map[PCI_SLOT(dev->devfn)]);
5319  
5320                     pcibios_write_config_byte(dev->bus->number, dev->devfn, 
5321 -                                             PCI_INTERRUPT_LINE, dev->irq);
5322 +                                             PCI_INTERRUPT_PIN, dev->irq);
5323                 } else {
5324                         if (Motherboard_non0 != NULL)
5325                                 Motherboard_non0(dev);
5326 diff -urN linux.orig/arch/ppc/kernel/prep_setup.c linux/arch/ppc/kernel/prep_setup.c
5327 --- linux.orig/arch/ppc/kernel/prep_setup.c     Sun Mar 25 18:31:49 2001
5328 +++ linux/arch/ppc/kernel/prep_setup.c  Thu Jul 11 15:46:34 2002
5329 @@ -33,12 +33,12 @@
5330  #include <linux/timex.h>
5331  #include <linux/pci.h>
5332  #include <linux/openpic.h>
5333 -#include <linux/delay.h>
5334  
5335  #include <asm/mmu.h>
5336  #include <asm/processor.h>
5337  #include <asm/residual.h>
5338  #include <asm/io.h>
5339 +#include <asm/irq-compat.h>
5340  #include <asm/pgtable.h>
5341  #include <asm/ide.h>
5342  #include <asm/cache.h>
5343 @@ -48,9 +48,9 @@
5344  #include <asm/prep_nvram.h>
5345  #include <asm/raven.h>
5346  #include <asm/keyboard.h>
5347 -#include <asm/time.h>
5348 -#include <asm/vga.h>
5349  
5350 +
5351 +#include "time.h"
5352  #include "local_irq.h"
5353  #include "i8259.h"
5354  #include "open_pic.h"
5355 @@ -102,12 +102,16 @@
5356  extern PTE *Hash, *Hash_end;
5357  extern unsigned long Hash_size, Hash_mask;
5358  extern int probingmem;
5359 +extern unsigned long loops_per_jiffy;
5360  
5361  #ifdef CONFIG_BLK_DEV_RAM
5362  extern int rd_doload;          /* 1 = load ramdisk, 0 = don't load */
5363  extern int rd_prompt;          /* 1 = prompt for ramdisk, 0 = don't prompt */
5364  extern int rd_image_start;     /* starting block # of image */
5365  #endif
5366 +#ifdef CONFIG_VGA_CONSOLE
5367 +unsigned long vgacon_remap_base;
5368 +#endif
5369  
5370  __prep
5371  int
5372 @@ -605,7 +609,6 @@
5373         int i;
5374  
5375         if (OpenPIC != NULL) {
5376 -               open_pic.irq_offset = 16;
5377                 for ( i = 16 ; i < 36 ; i++ )
5378                         irq_desc[i].ctl = &open_pic;
5379                 openpic_init(1);
5380 @@ -615,14 +618,8 @@
5381                  irq_desc[i].ctl = &i8259_pic;
5382          i8259_init();
5383  #ifdef __SMP__
5384 -       request_irq(OPENPIC_VEC_IPI, openpic_ipi_action,
5385 +       request_irq(openpic_to_irq(OPENPIC_VEC_SPURIOUS), openpic_ipi_action,
5386                     0, "IPI0", 0);
5387 -       request_irq(OPENPIC_VEC_IPI+1, openpic_ipi_action,
5388 -                   0, "IPI1 (invalidate TLB)", 0);
5389 -       request_irq(OPENPIC_VEC_IPI+2, openpic_ipi_action,
5390 -                   0, "IPI2 (stop CPU)", 0);
5391 -       request_irq(OPENPIC_VEC_IPI+3, openpic_ipi_action,
5392 -                   0, "IPI3 (reschedule)", 0);
5393  #endif /* __SMP__ */
5394  }
5395  
5396 diff -urN linux.orig/arch/ppc/kernel/prep_time.c linux/arch/ppc/kernel/prep_time.c
5397 --- linux.orig/arch/ppc/kernel/prep_time.c      Sun Mar 25 18:31:49 2001
5398 +++ linux/arch/ppc/kernel/prep_time.c   Thu Jul 11 15:43:29 2002
5399 @@ -26,7 +26,7 @@
5400  #include <asm/prep_nvram.h>
5401  #include <asm/mk48t59.h>
5402  
5403 -#include <asm/time.h>
5404 +#include "time.h"
5405  
5406  /*
5407   * The motorola uses the m48t18 rtc (includes DS1643) whose registers
5408 diff -urN linux.orig/arch/ppc/kernel/process.c linux/arch/ppc/kernel/process.c
5409 --- linux.orig/arch/ppc/kernel/process.c        Sun Mar 25 18:31:49 2001
5410 +++ linux/arch/ppc/kernel/process.c     Thu Jul 11 15:43:29 2002
5411 @@ -43,11 +43,9 @@
5412  #include <asm/mmu_context.h>
5413  
5414  int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs);
5415 -int dump_altivec(struct pt_regs *regs, elf_vrregset_t *vrregs);
5416  extern unsigned long _get_SP(void);
5417  
5418  struct task_struct *last_task_used_math = NULL;
5419 -struct task_struct *last_task_used_altivec = NULL;
5420  static struct vm_area_struct init_mmap = INIT_MMAP;
5421  static struct fs_struct init_fs = INIT_FS;
5422  static struct files_struct init_files = INIT_FILES;
5423 @@ -81,31 +79,6 @@
5424         return 1;
5425  }
5426  
5427 -#ifdef CONFIG_ALTIVEC
5428 -int
5429 -dump_altivec(struct pt_regs *regs, elf_vrregset_t *vrregs)
5430 -{
5431 -       if (regs->msr & MSR_VEC)
5432 -               giveup_altivec(current);
5433 -       memcpy(vrregs, &current->tss.vr[0], sizeof(*vrregs));
5434 -       return 1;
5435 -}
5436 -
5437 -void 
5438 -enable_kernel_altivec(void)
5439 -{
5440 -#ifdef __SMP__
5441 -       if (current->tss.regs && (current->tss.regs->msr & MSR_VEC))
5442 -               giveup_altivec(current);
5443 -       else
5444 -               giveup_altivec(NULL);   /* just enable AltiVec for kernel - force */
5445 -#else
5446 -       giveup_altivec(last_task_used_altivec);
5447 -#endif /* __SMP __ */
5448 -       printk("MSR_VEC in enable_altivec_kernel\n");
5449 -}
5450 -#endif /* CONFIG_ALTIVEC */
5451 -
5452  void
5453  enable_kernel_fp(void)
5454  {
5455 @@ -221,53 +194,22 @@
5456         _enable_interrupts(s);
5457  }
5458  
5459 -struct bits {
5460 -       const char *name;
5461 -       unsigned int bit;
5462 -};
5463 -
5464 -void print_bits(unsigned int val, struct bits *bits)
5465 -{
5466 -       const char *sep = "";
5467 -
5468 -       printk("[");
5469 -       for (; bits->bit != 0; ++bits) {
5470 -               if (val & bits->bit) {
5471 -                       printk("%s%s", sep, bits->name);
5472 -                       sep = ", ";
5473 -               }
5474 -       }
5475 -       printk("]");
5476 -}
5477 -
5478 -struct bits msr_bits[] = {
5479 -       {"VEC", MSR_VEC},
5480 -       {"EE", MSR_EE},
5481 -       {"PR", MSR_PR},
5482 -       {"FP", MSR_FP},
5483 -       {"IR", MSR_IR},
5484 -       {"DR", MSR_DR},
5485 -       {"ME", MSR_ME},
5486 -       {0, 0}
5487 -};
5488 -
5489 -void show_regs(struct pt_regs *regs)
5490 +void show_regs(struct pt_regs * regs)
5491  {
5492         int i;
5493  
5494         printk("NIP: %08lX XER: %08lX LR: %08lX REGS: %p TRAP: %04lx\n",
5495                regs->nip, regs->xer, regs->link, regs,regs->trap);
5496 -       printk("MSR: %08lx ", regs->msr);
5497 -       print_bits(regs->msr, msr_bits);
5498 -       printk("\n");
5499 +       printk("MSR: %08lx EE: %01x PR: %01x FP: %01x ME: %01x IR/DR: %01x%01x\n",
5500 +              regs->msr, regs->msr&MSR_EE ? 1 : 0, regs->msr&MSR_PR ? 1 : 0,
5501 +              regs->msr & MSR_FP ? 1 : 0,regs->msr&MSR_ME ? 1 : 0,
5502 +              regs->msr&MSR_IR ? 1 : 0,
5503 +              regs->msr&MSR_DR ? 1 : 0);
5504         printk("TASK = %p[%d] '%s' mm->pgd %p ",
5505                current, current->pid, current->comm, current->mm->pgd);
5506         printk("Last syscall: %ld ", current->tss.last_syscall);
5507 -       if (last_task_used_math)
5508 -               printk("\nlast math %p", last_task_used_math);
5509 -       if (last_task_used_altivec)
5510 -               printk("\nlast altivec %p", last_task_used_altivec);
5511 -
5512 +       printk("\nlast math %p", last_task_used_math);
5513 +       
5514  #ifdef __SMP__ 
5515         printk(" CPU: %d last CPU: %d", current->processor,current->last_processor);
5516  #endif /* __SMP__ */
5517 @@ -314,16 +256,12 @@
5518  {
5519         if (last_task_used_math == current)
5520                 last_task_used_math = NULL;
5521 -       if (last_task_used_altivec == current)
5522 -               last_task_used_altivec = NULL;
5523  }
5524  
5525  void flush_thread(void)
5526  {
5527         if (last_task_used_math == current)
5528                 last_task_used_math = NULL;
5529 -       if (last_task_used_altivec == current)
5530 -               last_task_used_altivec = NULL;
5531  }
5532  
5533  void
5534 @@ -381,19 +319,6 @@
5535         if (regs->msr & MSR_FP)
5536                 giveup_fpu(current);
5537  
5538 -#ifdef CONFIG_ALTIVEC
5539 -       /*
5540 -        * copy altiVec info - assume lazy altiVec switch
5541 -        * - kumar
5542 -        */
5543 -       if (regs->msr & MSR_VEC)
5544 -               giveup_altivec(current);
5545 -
5546 -       memcpy(&p->tss.vr, &current->tss.vr, sizeof(p->tss.vr));
5547 -       p->tss.vscr = current->tss.vscr;
5548 -       childregs->msr &= ~MSR_VEC;
5549 -#endif /* CONFIG_ALTIVEC */
5550 -
5551         memcpy(&p->tss.fpr, &current->tss.fpr, sizeof(p->tss.fpr));
5552         p->tss.fpscr = current->tss.fpscr;
5553         childregs->msr &= ~MSR_FP;
5554 @@ -455,8 +380,6 @@
5555         shove_aux_table(sp);
5556         if (last_task_used_math == current)
5557                 last_task_used_math = 0;
5558 -       if (last_task_used_altivec == current)
5559 -               last_task_used_altivec = 0;
5560         current->tss.fpscr = 0;
5561  }
5562  
5563 @@ -516,10 +439,6 @@
5564                 goto out;
5565         if (regs->msr & MSR_FP)
5566                 giveup_fpu(current);
5567 -#ifdef CONFIG_ALTIVEC
5568 -       if (regs->msr & MSR_VEC)
5569 -               giveup_altivec(current);
5570 -#endif /* CONFIG_ALTIVEC */ 
5571         error = do_execve(filename, (char **) a1, (char **) a2, regs);
5572         putname(filename);
5573  out:
5574 diff -urN linux.orig/arch/ppc/kernel/prom.c linux/arch/ppc/kernel/prom.c
5575 --- linux.orig/arch/ppc/kernel/prom.c   Sun Mar 25 18:37:30 2001
5576 +++ linux/arch/ppc/kernel/prom.c        Thu Jul 11 15:43:29 2002
5577 @@ -16,29 +16,24 @@
5578  #include <linux/string.h>
5579  #include <linux/init.h>
5580  #include <linux/version.h>
5581 -#include <linux/fs.h>
5582 -#include <linux/console.h>
5583  #include <asm/spinlock.h>
5584  #include <asm/prom.h>
5585  #include <asm/page.h>
5586  #include <asm/processor.h>
5587  #include <asm/irq.h>
5588 +#include <asm/irq-compat.h>
5589  #include <asm/io.h>
5590  #include <asm/smp.h>
5591  #include <asm/bootx.h>
5592  #include <asm/system.h>
5593  #include <asm/gemini.h>
5594 -#include <asm/linux_logo.h>
5595 -#include <asm/mmu.h>
5596 -#include <asm/pgtable.h>
5597 -#include <asm/adb.h>
5598 -#include <asm/pmu.h>
5599  
5600  /*
5601   * Properties whose value is longer than this get excluded from our
5602   * copy of the device tree.  This way we don't waste space storing
5603   * things like "driver,AAPL,MacOS,PowerPC" properties.
5604   */
5605 +
5606  #define MAX_PROPERTY_LENGTH    1024
5607  
5608  struct prom_args {
5609 @@ -95,77 +90,45 @@
5610  char *of_stdout_device = 0;
5611  
5612  prom_entry prom = 0;
5613 -ihandle prom_chosen = 0, prom_stdout = 0, prom_disp_node = 0;
5614 +ihandle prom_chosen = 0, prom_stdout = 0;
5615  int prom_version = 0;
5616  
5617  extern char *klimit;
5618  char *bootpath = 0;
5619  char *bootdevice = 0;
5620  
5621 -unsigned int rtas_data = 0;   /* physical pointer */
5622 +unsigned int rtas_data = 0;   /* virtual pointer */
5623  unsigned int rtas_entry = 0;  /* physical pointer */
5624  unsigned int rtas_size = 0;
5625  unsigned int old_rtas = 0;
5626  
5627 -/* Set for a newworld machine */
5628 -int use_of_interrupt_tree = 0;
5629 -int pmac_newworld = 0;
5630 -
5631  static struct device_node *allnodes = 0;
5632  
5633 -#ifdef CONFIG_BOOTX_TEXT
5634 -
5635 -/*
5636 - * The VGA font is in the _pmac section. Can't this cause problems with CHRP
5637 - * using some of the prom_xxxx functions ?
5638 - * All this need to be moved in a separate source file anyway
5639 - */
5640 -
5641  static void clearscreen(void);
5642  static void flushscreen(void);
5643  
5644 +#ifdef CONFIG_BOOTX_TEXT
5645 +
5646  void drawchar(char c);
5647  void drawstring(const char *c);
5648 -void drawhex(unsigned long v);
5649 +static void drawhex(unsigned long v);
5650  static void scrollscreen(void);
5651 -static void prepare_disp_BAT(void);
5652 -static void boot_console_write(struct console *co, const char *s,
5653 -                                unsigned count);
5654  
5655  static void draw_byte(unsigned char c, long locX, long locY);
5656 -static void draw_byte_32(unsigned char *bits, unsigned long *base, int rb);
5657 -static void draw_byte_16(unsigned char *bits, unsigned long *base, int rb);
5658 -static void draw_byte_8(unsigned char *bits, unsigned long *base, int rb);
5659 -
5660 -/* We want those in the data section */
5661 -static long                            g_loc_X = 0;
5662 -static long                            g_loc_Y = 0;
5663 -static long                            g_max_loc_X = 0;
5664 -static long                            g_max_loc_Y = 0; 
5665 -
5666 -unsigned long disp_BATL = 0;
5667 -unsigned long disp_BATU = 0;
5668 +static void draw_byte_32(unsigned char *bits, unsigned long *base);
5669 +static void draw_byte_16(unsigned char *bits, unsigned long *base);
5670 +static void draw_byte_8(unsigned char *bits, unsigned long *base);
5671 +
5672 +static long                            g_loc_X;
5673 +static long                            g_loc_Y;
5674 +static long                            g_max_loc_X;
5675 +static long                            g_max_loc_Y;
5676  
5677  #define cmapsz (16*256)
5678  
5679  static unsigned char vga_font[cmapsz];
5680  
5681 -static struct console boot_cons = {
5682 -       "boot",
5683 -       boot_console_write,
5684 -       NULL,
5685 -       NULL,
5686 -       NULL,
5687 -       NULL,
5688 -       NULL,
5689 -       CON_PRINTBUFFER,
5690 -       0,
5691 -       0,
5692 -       NULL
5693 -};
5694 -static int boot_cons_registered = 0;
5695 -
5696 -#endif /* CONFIG_BOOTX_TEXT */
5697 +#endif
5698  
5699  
5700  static void *call_prom(const char *service, int nargs, int nret, ...);
5701 @@ -175,25 +138,15 @@
5702                                   unsigned long, struct device_node ***);
5703  static unsigned long finish_node(struct device_node *, unsigned long,
5704                                  interpret_func *);
5705 -static unsigned long finish_node_interrupts(struct device_node *, unsigned long);
5706  static unsigned long check_display(unsigned long);
5707  static int prom_next_node(phandle *);
5708  static void *early_get_property(unsigned long, unsigned long, char *);
5709  
5710 -#ifdef CONFIG_BOOTX_TEXT
5711 -static void setup_disp_fake_bi(ihandle dp);
5712 -static void prom_welcome(boot_infos_t* bi, unsigned long phys);
5713 -#endif
5714 -
5715  extern void enter_rtas(void *);
5716  extern unsigned long reloc_offset(void);
5717  
5718  extern char cmd_line[512];     /* XXX */
5719  boot_infos_t *boot_infos = 0;  /* init it so it's in data segment not bss */
5720 -#ifdef CONFIG_BOOTX_TEXT
5721 -boot_infos_t *disp_bi = 0;
5722 -boot_infos_t fake_bi = {0,};
5723 -#endif
5724  
5725  /*
5726   * prom_init() is called very early on, before the kernel text
5727 @@ -276,7 +229,7 @@
5728         return prom_args.args[nargs];
5729  }
5730  
5731 -/*__init*/
5732 +__init
5733  void
5734  prom_print(const char *msg)
5735  {
5736 @@ -286,7 +239,7 @@
5737         if (RELOC(prom_stdout) == 0)
5738         {
5739  #ifdef CONFIG_BOOTX_TEXT
5740 -               if (RELOC(disp_bi) != 0)
5741 +               if (RELOC(boot_infos) != 0)
5742                         drawstring(msg);
5743  #endif
5744                 return;
5745 @@ -307,22 +260,6 @@
5746         }
5747  }
5748  
5749 -void
5750 -prom_print_hex(unsigned int v)
5751 -{
5752 -       char buf[16];
5753 -       int i, c;
5754 -
5755 -       for (i = 0; i < 8; ++i) {
5756 -               c = (v >> ((7-i)*4)) & 0xf;
5757 -               c += (c >= 10)? ('a' - 10): '0';
5758 -               buf[i] = c;
5759 -       }
5760 -       buf[i] = ' ';
5761 -       buf[i+1] = 0;
5762 -       prom_print(buf);
5763 -}
5764 -
5765  unsigned long smp_ibm_chrp_hack __initdata = 0;
5766  
5767  /*
5768 @@ -338,7 +275,6 @@
5769         phandle node;
5770         char type[16], *path;
5771  #endif 
5772 -       int chrp = 0;
5773         unsigned long mem;
5774         ihandle prom_rtas, prom_mmu, prom_op;
5775         unsigned long offset = reloc_offset();
5776 @@ -365,19 +301,22 @@
5777                 unsigned long space;
5778                 unsigned long ptr, x;
5779                 char *model;
5780 +#ifdef CONFIG_BOOTX_TEXT
5781 +               unsigned long flags;
5782 +#endif         
5783  
5784                 RELOC(boot_infos) = PTRUNRELOC(bi);
5785                 if (!BOOT_INFO_IS_V2_COMPATIBLE(bi))
5786                         bi->logicalDisplayBase = 0;
5787 +
5788 +               clearscreen();
5789 +
5790  #ifdef CONFIG_BOOTX_TEXT
5791                 RELOC(g_loc_X) = 0;
5792                 RELOC(g_loc_Y) = 0;
5793                 RELOC(g_max_loc_X) = (bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) / 8;
5794                 RELOC(g_max_loc_Y) = (bi->dispDeviceRect[3] - bi->dispDeviceRect[1]) / 16;
5795 -               RELOC(disp_bi) = PTRUNRELOC(bi);
5796                 
5797 -               clearscreen();
5798 -
5799                 /* Test if boot-info is compatible. Done only in config CONFIG_BOOTX_TEXT since
5800                    there is nothing much we can do with an incompatible version, except display
5801                    a message and eventually hang the processor...
5802 @@ -388,10 +327,24 @@
5803                 if (!BOOT_INFO_IS_COMPATIBLE(bi))
5804                         prom_print(RELOC(" !!! WARNING - Incompatible version of BootX !!!\n\n\n"));
5805                 
5806 -               prom_welcome(bi, phys);
5807 +               prom_print(RELOC("Welcome to Linux, kernel " UTS_RELEASE "\n"));
5808 +               prom_print(RELOC("\nstarted at       : 0x"));
5809 +               drawhex(reloc_offset() + KERNELBASE);
5810 +               prom_print(RELOC("\nlinked at        : 0x"));
5811 +               drawhex(KERNELBASE);
5812 +               prom_print(RELOC("\nframe buffer at  : 0x"));
5813 +               drawhex((unsigned long)bi->dispDeviceBase);
5814 +               prom_print(RELOC(" (phys), 0x"));
5815 +               drawhex((unsigned long)bi->logicalDisplayBase);
5816 +               prom_print(RELOC(" (log)"));
5817 +               prom_print(RELOC("\nMSR              : 0x"));
5818 +               __asm__ __volatile__ ("mfmsr %0" : "=r" ((flags)) : : "memory");
5819 +               drawhex(flags);
5820 +               prom_print(RELOC("\n\n"));
5821 +#endif
5822 +               /* Out of the #if/#endif since it flushes the clearscreen too */
5823                 flushscreen();
5824 -#endif /* CONFIG_BOOTX_TEXT */
5825 -
5826 +               
5827                 /* New BootX enters kernel with MMU off, i/os are not allowed
5828                    here. This hack will have been done by the boostrap anyway.
5829                  */
5830 @@ -432,7 +385,6 @@
5831                 }
5832                 
5833  #ifdef CONFIG_BOOTX_TEXT
5834 -               prepare_disp_BAT();
5835                 prom_print(RELOC("booting...\n"));
5836                 flushscreen();
5837  #endif
5838 @@ -470,15 +422,12 @@
5839             int sz;
5840             sz = (int)call_prom(RELOC("getprop"), 4, 1, prom_op, RELOC("model"), model, 64);
5841             if (sz > 0) {
5842 -               if ( strncmp(model,RELOC("IBM"),3) ) {
5843 -                   char *c;
5844 -                   for (c = model; *c; c++)
5845 -                       if (*c >= '0' && *c <= '9') {
5846 -                           RELOC(prom_version) = *c - '0';
5847 -                           break;
5848 -                       }
5849 -               } else
5850 -                   chrp = 1;
5851 +               char *c;
5852 +               for (c = model; *c; c++)
5853 +                   if (*c >= '0' && *c <= '9') {
5854 +                       RELOC(prom_version) = *c - '0';
5855 +                       break;
5856 +                   }
5857             }
5858         }
5859         if (RELOC(prom_version) >= 3)
5860 @@ -498,6 +447,15 @@
5861                 RELOC(bootdevice) = PTRUNRELOC(d);
5862                 mem = ALIGN(mem + strlen(d) + 1);
5863         }
5864 +
5865 +       mem = check_display(mem);
5866 +
5867 +       prom_print(RELOC("copying OF device tree..."));
5868 +       mem = copy_device_tree(mem, mem + (1<<20));
5869 +       prom_print(RELOC("done\n"));
5870 +
5871 +
5872 +       RELOC(klimit) = (char *) (mem - offset);
5873         
5874         prom_rtas = call_prom(RELOC("finddevice"), 1, 1, RELOC("/rtas"));
5875         if (prom_rtas != (void *) -1) {
5876 @@ -509,14 +467,18 @@
5877                         RELOC(rtas_data) = 0;
5878                 } else {
5879                         /*
5880 -                        * Ask OF for some space for RTAS.
5881 +                        * We do _not_ want the rtas_data inside the klimit
5882 +                        * boundry since it'll be squashed when we do the
5883 +                        * relocate of the kernel on chrp right after prom_init()
5884 +                        * in head.S.  So, we just pick a spot in memory.
5885 +                        * -- Cort
5886                          */
5887 -                       RELOC(rtas_data) = (unsigned int)
5888 -                               call_prom(RELOC("claim"), 3, 1, 0,
5889 -                                         RELOC(rtas_size), 0x1000);
5890 -                       prom_print(RELOC("rtas at "));
5891 -                       prom_print_hex(RELOC(rtas_data));
5892 -                       prom_print(RELOC("\n"));
5893 +#if 0
5894 +                       mem = (mem + 4095) & -4096;
5895 +                       RELOC(rtas_data) = mem + KERNELBASE;
5896 +                       mem += RELOC(rtas_size);
5897 +#endif
5898 +                       RELOC(rtas_data) = (6<<20) + KERNELBASE;
5899                 }
5900                 prom_rtas = call_prom(RELOC("open"), 1, 1, RELOC("/rtas"));
5901                 {
5902 @@ -528,7 +490,7 @@
5903                         prom_args.nret = 2;
5904                         prom_args.args[0] = RELOC("instantiate-rtas");
5905                         prom_args.args[1] = prom_rtas;
5906 -                       prom_args.args[2] = (void *) RELOC(rtas_data);
5907 +                       prom_args.args[2] = ((void *)(RELOC(rtas_data)-KERNELBASE));
5908                         RELOC(prom)(&prom_args);
5909                         if (prom_args.args[nargs] != 0)
5910                                 i = 0;
5911 @@ -542,15 +504,6 @@
5912                         prom_print(RELOC(" done\n"));
5913         }
5914  
5915 -       mem = check_display(mem);
5916 -
5917 -       prom_print(RELOC("copying OF device tree..."));
5918 -       /* N.B. do this *after* any claims */
5919 -       mem = copy_device_tree(mem, mem + (1<<20));
5920 -       prom_print(RELOC("done\n"));
5921 -
5922 -       RELOC(klimit) = (char *) (mem - offset);
5923 -
5924         /* If we are already running at 0xc0000000, we assume we were loaded by
5925          * an OF bootloader which did set a BAT for us. This breaks OF translate
5926          * so we force phys to be 0
5927 @@ -582,11 +535,6 @@
5928             }
5929         }
5930             
5931 -#ifdef CONFIG_BOOTX_TEXT
5932 -       if (RELOC(prom_disp_node) != 0)
5933 -               setup_disp_fake_bi(RELOC(prom_disp_node));
5934 -#endif
5935 -
5936  #ifdef CONFIG_SMP
5937         /*
5938          * With CHRP SMP we need to use the OF to start the other
5939 @@ -607,11 +555,7 @@
5940          * is in its holding pattern code.
5941          *
5942          * -- Cort
5943 -        * 
5944 -        * This code crashes on some pmacs since the memory at 8M is not
5945 -        * claim'ed and so can be unmapped. -- BenH
5946          */
5947 -       if (chrp)
5948         {
5949                 extern void __secondary_hold(void);
5950                 unsigned long i;
5951 @@ -637,7 +581,7 @@
5952         }
5953  
5954         /* look for cpus */
5955 -       for (node = 0; chrp && prom_next_node(&node);)
5956 +       for (node = 0; prom_next_node(&node);)
5957         {
5958                 type[0] = 0;
5959                 call_prom(RELOC("getprop"), 4, 1, node, RELOC("device_type"),
5960 @@ -666,132 +610,19 @@
5961                 else
5962                         prom_print(RELOC("...failed\n"));
5963         }
5964 +#endif /* CONFIG_SMP */
5965         
5966 -#endif 
5967 -       /* If PowerMac, then use quiesce call */
5968 -       if (!chrp) {
5969 +       /* If OpenFirmware version >= 3, then use quiesce call */
5970 +       if (RELOC(prom_version) >= 3) {
5971             prom_print(RELOC("Calling quiesce ...\n"));
5972             call_prom(RELOC("quiesce"), 0, 0);
5973             offset = reloc_offset();
5974             phys = offset + KERNELBASE;
5975         }
5976  
5977 -#ifdef CONFIG_BOOTX_TEXT
5978 -       if (!chrp && RELOC(disp_bi)) {
5979 -               RELOC(prom_stdout) = 0;
5980 -               clearscreen();
5981 -               prepare_disp_BAT();
5982 -               prom_welcome(PTRRELOC(RELOC(disp_bi)), phys);
5983 -       }
5984 -#endif
5985 -
5986 -       prom_print(RELOC("booting...\n"));
5987         return phys;
5988  }
5989  
5990 -#ifdef CONFIG_BOOTX_TEXT
5991 -__init static void
5992 -prom_welcome(boot_infos_t* bi, unsigned long phys)
5993 -{
5994 -       unsigned long offset = reloc_offset();
5995 -       unsigned long flags;
5996 -       unsigned long pvr;
5997 -       
5998 -       prom_print(RELOC("Welcome to Linux, kernel " UTS_RELEASE "\n"));
5999 -       prom_print(RELOC("\nstarted at       : 0x"));
6000 -       drawhex(phys);
6001 -       prom_print(RELOC("\nlinked at        : 0x"));
6002 -       drawhex(KERNELBASE);
6003 -       prom_print(RELOC("\nframe buffer at  : 0x"));
6004 -       drawhex((unsigned long)bi->dispDeviceBase);
6005 -       prom_print(RELOC(" (phys), 0x"));
6006 -       drawhex((unsigned long)bi->logicalDisplayBase);
6007 -       prom_print(RELOC(" (log)"));
6008 -       prom_print(RELOC("\nMSR              : 0x"));
6009 -       __asm__ __volatile__ ("mfmsr %0" : "=r" (flags));
6010 -       drawhex(flags);
6011 -       __asm__ __volatile__ ("mfspr %0, 287" : "=r" (pvr));
6012 -       pvr >>= 16;
6013 -       if (pvr > 1) {
6014 -           prom_print(RELOC("\nHID0             : 0x"));
6015 -           __asm__ __volatile__ ("mfspr %0, 1008" : "=r" (flags));
6016 -           drawhex(flags);
6017 -       }
6018 -       if (pvr == 8 || pvr == 12) {
6019 -           prom_print(RELOC("\nICTC             : 0x"));
6020 -           __asm__ __volatile__ ("mfspr %0, 1019" : "=r" (flags));
6021 -           drawhex(flags);
6022 -       }
6023 -       prom_print(RELOC("\n\n"));
6024 -}
6025 -
6026 -void showvalue(char *str, unsigned long val)
6027 -{
6028 -       drawstring(str);
6029 -       drawhex(val);
6030 -       drawstring("\n");
6031 -}
6032 -
6033 -/* Calc BAT values for mapping the display and store them
6034 - * in disp_BATH and disp_BATL. Those values are then used
6035 - * from head.S to map the display during identify_machine()
6036 - * and MMU_Init()
6037 - * 
6038 - * For now, the display is mapped in place (1:1). This should
6039 - * be changed if the display physical address overlaps
6040 - * KERNELBASE, which is fortunately not the case on any machine
6041 - * I know of. This mapping is temporary and will disappear as
6042 - * soon as the setup done by MMU_Init() is applied
6043 - * 
6044 - * For now, we align the BAT and then map 8Mb on 601 and 16Mb
6045 - * on other PPCs. This may cause trouble if the framebuffer
6046 - * is really badly aligned, but I didn't encounter this case
6047 - * yet.
6048 - */
6049 -__init
6050 -static void
6051 -prepare_disp_BAT(void)
6052 -{
6053 -       unsigned long offset = reloc_offset();
6054 -       boot_infos_t* bi = PTRRELOC(RELOC(disp_bi));
6055 -       unsigned long addr = (unsigned long)bi->dispDeviceBase;
6056 -       
6057 -       if ((_get_PVR() >> 16) != 1) {
6058 -               /* 603, 604, G3, G4, ... */
6059 -               addr &= 0xFF000000UL;
6060 -               RELOC(disp_BATU) = addr | (BL_16M<<2) | 2;
6061 -               RELOC(disp_BATL) = addr | (_PAGE_NO_CACHE | _PAGE_GUARDED | BPP_RW);            
6062 -       } else {
6063 -               /* 601 */
6064 -               addr &= 0xFF800000UL;
6065 -               RELOC(disp_BATU) = addr | (_PAGE_NO_CACHE | PP_RWXX) | 4;
6066 -               RELOC(disp_BATL) = addr | BL_8M | 0x40;
6067 -       }
6068 -       bi->logicalDisplayBase = bi->dispDeviceBase;
6069 -}
6070 -
6071 -#endif
6072 -
6073 -__init
6074 -static int
6075 -prom_set_color(ihandle ih, int i, int r, int g, int b)
6076 -{
6077 -       struct prom_args prom_args;
6078 -       unsigned long offset = reloc_offset();
6079 -
6080 -       prom_args.service = RELOC("call-method");
6081 -       prom_args.nargs = 6;
6082 -       prom_args.nret = 1;
6083 -       prom_args.args[0] = RELOC("color!");
6084 -       prom_args.args[1] = ih;
6085 -       prom_args.args[2] = (void *) i;
6086 -       prom_args.args[3] = (void *) b;
6087 -       prom_args.args[4] = (void *) g;
6088 -       prom_args.args[5] = (void *) r;
6089 -       RELOC(prom)(&prom_args);
6090 -       return (int) prom_args.args[6];
6091 -}
6092 -
6093  /*
6094   * If we have a display that we don't know how to drive,
6095   * we will want to try to execute OF's open method for it
6096 @@ -804,32 +635,11 @@
6097  static unsigned long
6098  check_display(unsigned long mem)
6099  {
6100 -#ifdef CONFIG_FB
6101         phandle node;
6102         ihandle ih;
6103         int i;
6104         unsigned long offset = reloc_offset();
6105 -       char type[16], *path, name[32];
6106 -       static unsigned char default_colors[] = {
6107 -               0x00, 0x00, 0x00,
6108 -               0x00, 0x00, 0xaa,
6109 -               0x00, 0xaa, 0x00,
6110 -               0x00, 0xaa, 0xaa,
6111 -               0xaa, 0x00, 0x00,
6112 -               0xaa, 0x00, 0xaa,
6113 -               0xaa, 0xaa, 0x00,
6114 -               0xaa, 0xaa, 0xaa,
6115 -               0x55, 0x55, 0x55,
6116 -               0x55, 0x55, 0xff,
6117 -               0x55, 0xff, 0x55,
6118 -               0x55, 0xff, 0xff,
6119 -               0xff, 0x55, 0x55,
6120 -               0xff, 0x55, 0xff,
6121 -               0xff, 0xff, 0x55,
6122 -               0xff, 0xff, 0xff
6123 -       };
6124 -
6125 -       RELOC(prom_disp_node) = 0;
6126 +       char type[16], *path;
6127  
6128         for (node = 0; prom_next_node(&node); ) {
6129                 type[0] = 0;
6130 @@ -837,12 +647,6 @@
6131                           type, sizeof(type));
6132                 if (strcmp(type, RELOC("display")) != 0)
6133                         continue;
6134 -               name[0] = 0;
6135 -               call_prom(RELOC("getprop"), 4, 1, node, RELOC("name"),
6136 -                         name, sizeof(name));
6137 -               if (!strcmp(name, RELOC("offscreen-display")))
6138 -                       continue;
6139 -
6140                 /* It seems OF doesn't null-terminate the path :-( */
6141                 path = (char *) mem;
6142                 memset(path, 0, 256);
6143 @@ -858,24 +662,6 @@
6144                 }
6145                 prom_print(RELOC("... ok\n"));
6146  
6147 -               if (RELOC(prom_disp_node) == 0)
6148 -                       RELOC(prom_disp_node) = node;
6149 -
6150 -               /* Setup a useable color table when the appropriate
6151 -                * method is available. Should update this to set-colors */
6152 -               for (i = 0; i < 32; i++)
6153 -                       if (prom_set_color(ih, i, RELOC(default_colors)[i*3],
6154 -                                          RELOC(default_colors)[i*3+1],
6155 -                                          RELOC(default_colors)[i*3+2]) != 0)
6156 -                               break;
6157 -
6158 -               for (i = 0; i < LINUX_LOGO_COLORS; i++)
6159 -                       if (prom_set_color(ih, i + 32,
6160 -                                          RELOC(linux_logo_red)[i],
6161 -                                          RELOC(linux_logo_green)[i],
6162 -                                          RELOC(linux_logo_blue)[i]) != 0)
6163 -                               break;
6164 -
6165                 /*
6166                  * If this display is the device that OF is using for stdout,
6167                  * move it to the front of the list.
6168 @@ -892,85 +678,9 @@
6169                 if (RELOC(prom_num_displays) >= FB_MAX)
6170                         break;
6171         }
6172 -#endif /* CONFIG_FB */
6173         return ALIGN(mem);
6174  }
6175  
6176 -/* This function will enable the early boot text when doing OF booting. This
6177 - * way, xmon output should work too
6178 - */
6179 -#ifdef CONFIG_BOOTX_TEXT
6180 -__init
6181 -static void
6182 -setup_disp_fake_bi(ihandle dp)
6183 -{
6184 -       unsigned int len;
6185 -       int width = 640, height = 480, depth = 8, pitch;
6186 -       unsigned  address;
6187 -       boot_infos_t* bi;
6188 -       unsigned long offset = reloc_offset();
6189 -       
6190 -       prom_print(RELOC("Initing fake screen\n"));
6191 -
6192 -       len = 0;
6193 -       call_prom(RELOC("getprop"), 4, 1, dp, RELOC("depth"), &len, sizeof(len));
6194 -       if (len == 0)
6195 -               prom_print(RELOC("Warning: assuming display depth = 8\n"));
6196 -       else
6197 -               depth = len;
6198 -       width = len = 0;
6199 -       call_prom(RELOC("getprop"), 4, 1, dp, RELOC("width"), &len, sizeof(len));
6200 -       width = len;
6201 -       if (width == 0) {
6202 -               prom_print(RELOC("Failed to get width\n"));
6203 -               return;
6204 -       }
6205 -       height = len = 0;
6206 -       call_prom(RELOC("getprop"), 4, 1, dp, RELOC("height"), &len, sizeof(len));
6207 -       height = len;
6208 -       if (height == 0) {
6209 -               prom_print(RELOC("Failed to get height\n"));
6210 -               return;
6211 -       }
6212 -       pitch = len = 0;
6213 -       call_prom(RELOC("getprop"), 4, 1, dp, RELOC("linebytes"), &len, sizeof(len));
6214 -       pitch = len;
6215 -       if (pitch == 0) {
6216 -               prom_print(RELOC("Failed to get pitch\n"));
6217 -               return;
6218 -       }
6219 -       if (pitch == 1)
6220 -               pitch = 0x1000;
6221 -       address = len = 0;
6222 -       len = 0xfa000000;
6223 -       call_prom(RELOC("getprop"), 4, 1, dp, RELOC("address"), &len, sizeof(len));
6224 -       address = len;
6225 -       if (address == 0) {
6226 -               prom_print(RELOC("Failed to get address\n"));
6227 -               return;
6228 -       }
6229 -#if 0
6230 -       /* kludge for valkyrie */
6231 -       if (strcmp(dp->name, "valkyrie") == 0) 
6232 -           address += 0x1000;
6233 -#endif
6234
6235 -       RELOC(disp_bi) = &fake_bi;
6236 -       bi = PTRRELOC((&fake_bi));
6237 -       RELOC(g_loc_X) = 0;
6238 -       RELOC(g_loc_Y) = 0;
6239 -       RELOC(g_max_loc_X) = width / 8;
6240 -       RELOC(g_max_loc_Y) = height / 16;
6241 -       bi->logicalDisplayBase = (unsigned char *)address;
6242 -       bi->dispDeviceBase = (unsigned char *)address;
6243 -       bi->dispDeviceRowBytes = pitch;
6244 -       bi->dispDeviceDepth = depth;
6245 -       bi->dispDeviceRect[0] = bi->dispDeviceRect[1] = 0;
6246 -       bi->dispDeviceRect[2] = width;
6247 -       bi->dispDeviceRect[3] = height;
6248 -}
6249 -#endif
6250 -
6251  __init
6252  static int
6253  prom_next_node(phandle *nodep)
6254 @@ -1106,18 +816,6 @@
6255  {
6256         unsigned long mem = (unsigned long) klimit;
6257  
6258 -       /* All newworld machines and CHRP now use the interrupt tree */
6259 -       struct device_node *np = allnodes;
6260 -       while(np && (_machine == _MACH_Pmac)) {
6261 -               if (get_property(np, "interrupt-parent", 0)) {
6262 -                       pmac_newworld = 1;
6263 -                       break;
6264 -               }
6265 -               np = np->allnext;
6266 -       }
6267 -       if ((_machine == _MACH_chrp) || (boot_infos == 0 && pmac_newworld))
6268 -               use_of_interrupt_tree = 1;
6269 -
6270         mem = finish_node(allnodes, mem, NULL);
6271         printk(KERN_INFO "device tree used %lu bytes\n",
6272                mem - (unsigned long) allnodes);
6273 @@ -1158,9 +856,6 @@
6274         if (ifunc != NULL) {
6275                 mem_start = ifunc(np, mem_start);
6276         }
6277 -       if (use_of_interrupt_tree) {
6278 -               mem_start = finish_node_interrupts(np, mem_start);
6279 -       }
6280  
6281         /* the f50 sets the name to 'display' and 'compatible' to what we
6282          * expect for the name -- Cort
6283 @@ -1207,151 +902,6 @@
6284         return mem_start;
6285  }
6286  
6287 -/* This routine walks the interrupt tree for a given device node and gather 
6288 - * all necessary informations according to the draft interrupt mapping
6289 - * for CHRP. The current version was only tested on Apple "Core99" machines
6290 - * and may not handle cascaded controllers correctly.
6291 - */
6292 -__init
6293 -static unsigned long
6294 -finish_node_interrupts(struct device_node *np, unsigned long mem_start)
6295 -{
6296 -       /* Finish this node */
6297 -       unsigned int *isizep, *asizep, *interrupts, *map, *map_mask, *reg;
6298 -       phandle *parent;
6299 -       struct device_node *node, *parent_node;
6300 -       int l, isize, ipsize, asize, map_size, regpsize;
6301 -
6302 -       /* Currently, we don't look at all nodes with no "interrupts" property */
6303 -       interrupts = (unsigned int *)get_property(np, "interrupts", &l);
6304 -       if (interrupts == NULL)
6305 -               return mem_start;
6306 -       ipsize = l>>2;
6307 -
6308 -       reg = (unsigned int *)get_property(np, "reg", &l);
6309 -       regpsize = l>>2;
6310 -
6311 -       /* We assume default interrupt cell size is 1 (bugus ?) */
6312 -       isize = 1;
6313 -       node = np;
6314 -       
6315 -       do {
6316 -           /* We adjust the cell size if the current parent contains an #interrupt-cells
6317 -            * property */
6318 -           isizep = (unsigned int *)get_property(node, "#interrupt-cells", &l);
6319 -           if (isizep)
6320 -               isize = *isizep;
6321 -
6322 -           /* We don't do interrupt cascade (ISA) for now, we stop on the first 
6323 -            * controller found
6324 -            */
6325 -           if (get_property(node, "interrupt-controller", &l)) {
6326 -               int i,j;
6327 -               np->intrs = (struct interrupt_info *) mem_start;
6328 -               np->n_intrs = ipsize / isize;
6329 -               mem_start += np->n_intrs * sizeof(struct interrupt_info);
6330 -               for (i = 0; i < np->n_intrs; ++i) {
6331 -                   np->intrs[i].line = *interrupts++;
6332 -                   np->intrs[i].sense = 0;
6333 -                   if (isize > 1)
6334 -                       np->intrs[i].sense = *interrupts++;
6335 -                   for (j=2; j<isize; j++)
6336 -                       interrupts++;
6337 -               }
6338 -               /*
6339 -                *  On the CHRP LongTrail, ISA interrupts are cascaded through
6340 -                *  the OpenPIC. For compatibility reasons, ISA interrupts are
6341 -                *  numbered 0-15 and OpenPIC interrupts start at 16.
6342 -                *  Hence we have to fixup the interrupt numbers for sources
6343 -                *  that are attached to the OpenPIC and thus have an
6344 -                *  interrupt-controller named `open-pic'.
6345 -                *
6346 -                *  FIXME: The name of the interrupt-controller node for the
6347 -                *         `ide' node has no name, although its parent is
6348 -                *         correctly specified in interrupt-map, so we check
6349 -                *         for a NULL name as well.
6350 -                */
6351 -               if (_machine == _MACH_chrp &&
6352 -                   ((node->name && !strcmp(node->name, "open-pic")) ||
6353 -                    !node->name)) {
6354 -                   for (i = 0; i < np->n_intrs; ++i)
6355 -                       np->intrs[i].line = np->intrs[i].line + NUM_8259_INTERRUPTS;
6356 -               }
6357 -               return mem_start;
6358 -           }
6359 -           /* We lookup for an interrupt-map. This code can only handle one interrupt
6360 -            * per device in the map. We also don't handle #address-cells in the parent
6361 -            * I skip the pci node itself here, may not be necessary but I don't like it's
6362 -            * reg property.
6363 -            */
6364 -           if (np != node)
6365 -               map = (unsigned int *)get_property(node, "interrupt-map", &l);
6366 -            else
6367 -               map = NULL;
6368 -           if (map && l) {
6369 -               int i, found, temp_isize;
6370 -               map_size = l>>2;
6371 -               map_mask = (unsigned int *)get_property(node, "interrupt-map-mask", &l);
6372 -               asizep = (unsigned int *)get_property(node, "#address-cells", &l);
6373 -               if (asizep && l == sizeof(unsigned int))
6374 -                   asize = *asizep;
6375 -               else
6376 -                   asize = 0;
6377 -               found = 0;
6378 -               while(map_size>0 && !found) {
6379 -                   found = 1;
6380 -                   for (i=0; i<asize; i++) {
6381 -                       unsigned int mask = map_mask ? map_mask[i] : 0xffffffff;
6382 -                       if (!reg || (i>=regpsize) || ((mask & *map) != (mask & reg[i])))
6383 -                           found = 0;
6384 -                       map++;
6385 -                       map_size--;
6386 -                   }
6387 -                   for (i=0; i<isize; i++) {
6388 -                       unsigned int mask = map_mask ? map_mask[i+asize] : 0xffffffff;
6389 -                       if ((mask & *map) != (mask & interrupts[i]))
6390 -                           found = 0;
6391 -                       map++;
6392 -                       map_size--;
6393 -                   }
6394 -                   parent = *((phandle *)(map));
6395 -                   map+=1; map_size-=1;
6396 -                   parent_node = find_phandle(parent);
6397 -                   temp_isize = isize;
6398 -                   if (parent_node) {
6399 -                       isizep = (unsigned int *)get_property(parent_node, "#interrupt-cells", &l);
6400 -                       if (isizep)
6401 -                           temp_isize = *isizep;
6402 -                   }
6403 -                   if (!found) {
6404 -                       map += temp_isize;
6405 -                       map_size-=temp_isize;
6406 -                   }
6407 -               }
6408 -               if (found) {
6409 -                   node = parent_node;
6410 -                   reg = NULL;
6411 -                   regpsize = 0;
6412 -                   interrupts = (unsigned int *)map;
6413 -                   ipsize = temp_isize*1;
6414 -                   continue;
6415 -               }
6416 -           }
6417 -           /* We look for an explicit interrupt-parent.
6418 -            */
6419 -           parent = (phandle *)get_property(node, "interrupt-parent", &l);
6420 -           if (parent && (l == sizeof(phandle)) &&
6421 -               (parent_node = find_phandle(*parent))) {
6422 -               node = parent_node;
6423 -               continue;
6424 -           }
6425 -           /* Default, get real parent */
6426 -           node = node->parent;
6427 -       } while(node);
6428 -
6429 -       return mem_start;
6430 -}
6431 -
6432  /*
6433   * When BootX makes a copy of the device tree from the MacOS
6434   * Name Registry, it is in the format we use but all of the pointers
6435 @@ -1410,9 +960,6 @@
6436                 mem_start += i * sizeof(struct address_range);
6437         }
6438  
6439 -       if (use_of_interrupt_tree)
6440 -               return mem_start;
6441 -
6442         /*
6443          * If the pci host bridge has an interrupt-map property,
6444          * look for our node in it.
6445 @@ -1422,28 +969,14 @@
6446                 get_property(np->parent, "interrupt-map", &ml)) != 0
6447             && (ip = (int *) get_property(np, "interrupts", &l)) != 0) {
6448                 unsigned int devfn = pci_addrs[0].addr.a_hi & 0xff00;
6449 -               unsigned int cell_size;
6450 -               struct device_node* np2;
6451 -               /* This is hackish, but is only used for BootX booting */
6452 -               cell_size = sizeof(struct pci_intr_map);
6453 -               np2 = np->parent;
6454 -               while(np2) {
6455 -                       if (device_is_compatible(np2, "uni-north")) {
6456 -                               cell_size += 4;
6457 -                               break;
6458 -                       }
6459 -                       np2 = np2->parent;
6460 -               }
6461                 np->n_intrs = 0;
6462                 np->intrs = (struct interrupt_info *) mem_start;
6463 -               for (i = 0; (ml -= cell_size) >= 0; ++i) {
6464 -                       if (imp->addr.a_hi == devfn) {
6465 -                               np->intrs[np->n_intrs].line = imp->intr;
6466 -                               np->intrs[np->n_intrs].sense = 0; /* FIXME */
6467 +               for (i = 0; (ml -= sizeof(struct pci_intr_map)) >= 0; ++i) {
6468 +                       if (imp[i].addr.a_hi == devfn) {
6469 +                               np->intrs[np->n_intrs].line = imp[i].intr;
6470 +                               np->intrs[np->n_intrs].sense = 0;
6471                                 ++np->n_intrs;
6472                         }
6473 -                       imp = (struct pci_intr_map *)(((unsigned int)imp)
6474 -                               + cell_size);
6475                 }
6476                 if (np->n_intrs == 0)
6477                         np->intrs = 0;
6478 @@ -1500,9 +1033,6 @@
6479                 mem_start += i * sizeof(struct address_range);
6480         }
6481  
6482 -       if (use_of_interrupt_tree)
6483 -               return mem_start;
6484 -
6485         ip = (int *) get_property(np, "AAPL,interrupts", &l);
6486         if (ip == 0)
6487                 ip = (int *) get_property(np, "interrupts", &l);
6488 @@ -1526,14 +1056,13 @@
6489         struct reg_property *rp;
6490         struct address_range *adr;
6491         unsigned long base_address;
6492 -       int i, l, keylargo, *ip;
6493 +       int i, l, *ip;
6494         struct device_node *db;
6495  
6496         base_address = 0;
6497         for (db = np->parent; db != NULL; db = db->parent) {
6498                 if (!strcmp(db->type, "mac-io") && db->n_addrs != 0) {
6499                         base_address = db->addrs[0].address;
6500 -                       keylargo = device_is_compatible(db, "Keylargo");
6501                         break;
6502                 }
6503         }
6504 @@ -1553,9 +1082,6 @@
6505                 mem_start += i * sizeof(struct address_range);
6506         }
6507  
6508 -       if (use_of_interrupt_tree)
6509 -               return mem_start;
6510 -
6511         ip = (int *) get_property(np, "interrupts", &l);
6512         if (ip == 0)
6513                 ip = (int *) get_property(np, "AAPL,interrupts", &l);
6514 @@ -1564,21 +1090,15 @@
6515                 if (_machine == _MACH_Pmac) {
6516                         /* for the iMac */
6517                         np->n_intrs = l / sizeof(int);
6518 -                       /* Hack for BootX on Core99 */
6519 -                       if (keylargo)
6520 -                               np->n_intrs = np->n_intrs/2;
6521                         for (i = 0; i < np->n_intrs; ++i) {
6522                                 np->intrs[i].line = *ip++;
6523 -                               if (keylargo)
6524 -                                       np->intrs[i].sense = *ip++;
6525 -                               else
6526 -                                       np->intrs[i].sense = 0;
6527 +                               np->intrs[i].sense = 0;
6528                         }
6529                 } else {
6530                         /* CHRP machines */
6531                         np->n_intrs = l / (2 * sizeof(int));
6532                         for (i = 0; i < np->n_intrs; ++i) {
6533 -                               np->intrs[i].line = (*ip++) + NUM_8259_INTERRUPTS;
6534 +                               np->intrs[i].line = openpic_to_irq(*ip++);
6535                                 np->intrs[i].sense = *ip++;
6536                         }
6537                 }
6538 @@ -1612,9 +1132,6 @@
6539                 mem_start += i * sizeof(struct address_range);
6540         }
6541  
6542 -       if (use_of_interrupt_tree)
6543 -               return mem_start;
6544
6545         ip = (int *) get_property(np, "interrupts", &l);
6546         if (ip != 0) {
6547                 np->intrs = (struct interrupt_info *) mem_start;
6548 @@ -1652,9 +1169,6 @@
6549                 mem_start += i * sizeof(struct address_range);
6550         }
6551  
6552 -       if (use_of_interrupt_tree)
6553 -               return mem_start;
6554 -
6555         ip = (int *) get_property(np, "AAPL,interrupts", &l);
6556         if (ip == 0)
6557                 ip = (int *) get_property(np, "interrupts", &l);
6558 @@ -1711,57 +1225,6 @@
6559         return head;
6560  }
6561  
6562 -/* Finds a device node given its PCI bus number, device number
6563 - * and function number
6564 - */
6565 -__openfirmware
6566 -struct device_node *
6567 -find_pci_device_OFnode(unsigned char bus, unsigned char dev_fn)
6568 -{
6569 -       struct device_node* np;
6570 -       unsigned int *reg;
6571 -       int l;
6572 -       
6573 -       for (np = allnodes; np != 0; np = np->allnext) {
6574 -               int in_macio = 0;
6575 -               struct device_node* parent = np->parent;
6576 -               while(parent) {
6577 -                       char *pname = (char *)get_property(parent, "name", &l);
6578 -                       if (pname && strcmp(pname, "mac-io") == 0) {
6579 -                               in_macio = 1;
6580 -                               break;
6581 -                       }
6582 -                       parent = parent->parent;
6583 -               }
6584 -               if (in_macio)
6585 -                       continue;
6586 -               reg = (unsigned int *) get_property(np, "reg", &l);
6587 -               if (reg == 0 || l < sizeof(struct reg_property))
6588 -                       continue;
6589 -               if (((reg[0] >> 8) & 0xff) == dev_fn && ((reg[0] >> 16) & 0xff) == bus)
6590 -                       break;
6591 -       }
6592 -       return np;
6593 -}
6594 -
6595 -/*
6596 - * Returns all nodes linked together
6597 - */
6598 -__openfirmware
6599 -struct device_node *
6600 -find_all_nodes(void)
6601 -{
6602 -       struct device_node *head, **prevp, *np;
6603 -
6604 -       prevp = &head;
6605 -       for (np = allnodes; np != 0; np = np->allnext) {
6606 -               *prevp = np;
6607 -               prevp = &np->next;
6608 -       }
6609 -       *prevp = 0;
6610 -       return head;
6611 -}
6612 -
6613  /* Checks if the given "compat" string matches one of the strings in
6614   * the device's "compatible" property
6615   */
6616 @@ -1851,7 +1314,7 @@
6617         struct property *pp;
6618  
6619         for (pp = np->properties; pp != 0; pp = pp->next)
6620 -               if (pp->name && strcmp(pp->name, name) == 0) {
6621 +               if (strcmp(pp->name, name) == 0) {
6622                         if (lenp != 0)
6623                                 *lenp = pp->length;
6624                         return pp->value;
6625 @@ -1963,63 +1426,18 @@
6626         prom_exit();
6627  }
6628  
6629 -/* Indicates whether the root node has a given value in its
6630 - * compatible property.
6631 - */
6632 -__openfirmware
6633 -int
6634 -machine_is_compatible(const char *compat)
6635 -{
6636 -       struct device_node *root;
6637 -       
6638 -       root = find_path_device("/");
6639 -       if (root == 0)
6640 -               return 0;
6641 -       return device_is_compatible(root, compat);
6642 -}
6643 -
6644 -
6645 -#ifdef CONFIG_BOOTX_TEXT
6646 -
6647 -/* Here's a small text engine to use during early boot or for debugging purposes
6648 - * 
6649 - * todo:
6650 - * 
6651 - *  - build some kind of vgacon with it to enable early printk
6652 - *  - move to a separate file
6653 - *  - add a few video driver hooks to keep in sync with display
6654 - *    changes.
6655 - */
6656 -
6657 +#ifdef CONFIG_XMON
6658  __init
6659  void
6660  map_bootx_text(void)
6661  {
6662 -       unsigned long base, offset, size;
6663 -       if (disp_bi == 0)
6664 +       if (boot_infos == 0)
6665                 return;
6666 -       base = ((unsigned long) disp_bi->dispDeviceBase) & 0xFFFFF000UL;
6667 -       offset = ((unsigned long) disp_bi->dispDeviceBase) - base;
6668 -       size = disp_bi->dispDeviceRowBytes * disp_bi->dispDeviceRect[3] + offset
6669 -               + disp_bi->dispDeviceRect[0];
6670 -       disp_bi->logicalDisplayBase = ioremap(base, size) + offset;
6671 -}
6672 -
6673 -__init
6674 -void
6675 -install_boot_console(void)
6676 -{
6677 -       register_console(&boot_cons);
6678 -       boot_cons_registered = 1;
6679 -}
6680 -
6681 -void
6682 -remove_boot_console(void)
6683 -{
6684 -       if (boot_cons_registered)
6685 -               unregister_console(&boot_cons);
6686 -       boot_cons_registered = 0;
6687 +       boot_infos->logicalDisplayBase =
6688 +               ioremap((unsigned long) boot_infos->dispDeviceBase,
6689 +                       boot_infos->dispDeviceRowBytes * boot_infos->dispDeviceRect[3]);
6690  }
6691 +#endif /* CONFIG_XMON */
6692  
6693  /* Calc the base address of a given point (x,y) */
6694  __pmac
6695 @@ -2041,7 +1459,7 @@
6696  clearscreen(void)
6697  {
6698         unsigned long offset    = reloc_offset();
6699 -       boot_infos_t* bi        = PTRRELOC(RELOC(disp_bi));
6700 +       boot_infos_t* bi        = PTRRELOC(RELOC(boot_infos));
6701         unsigned long *base     = (unsigned long *)calc_base(bi, 0, 0);
6702         unsigned long width     = ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
6703                                         (bi->dispDeviceDepth >> 3)) >> 2;
6704 @@ -2066,7 +1484,7 @@
6705  flushscreen(void)
6706  {
6707         unsigned long offset    = reloc_offset();
6708 -       boot_infos_t* bi        = PTRRELOC(RELOC(disp_bi));
6709 +       boot_infos_t* bi        = PTRRELOC(RELOC(boot_infos));
6710         unsigned long *base     = (unsigned long *)calc_base(bi, 0, 0);
6711         unsigned long width     = ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
6712                                         (bi->dispDeviceDepth >> 3)) >> 2;
6713 @@ -2083,22 +1501,68 @@
6714         }
6715  }
6716  
6717 +/* Indicates whether the root node has a given value in its
6718 + * compatible property.
6719 + */
6720 +__openfirmware
6721 +int
6722 +machine_is_compatible(const char *compat)
6723 +{
6724 +       struct device_node *root;
6725 +       
6726 +       root = find_path_device("/");
6727 +       if (root == 0)
6728 +               return 0;
6729 +       return device_is_compatible(root, compat);
6730 +}
6731 +
6732 +/* Finds a device node given its PCI bus number, device number
6733 + * and function number
6734 + */
6735 +__openfirmware
6736 +struct device_node *
6737 +find_pci_device_OFnode(unsigned char bus, unsigned char dev_fn)
6738 +{
6739 +       struct device_node* np;
6740 +       unsigned int *reg;
6741 +       int l;
6742 +       
6743 +       for (np = allnodes; np != 0; np = np->allnext) {
6744 +               int in_macio = 0;
6745 +               struct device_node* parent = np->parent;
6746 +               while(parent) {
6747 +                       char *pname = (char *)get_property(parent, "name", &l);
6748 +                       if (pname && strcmp(pname, "mac-io") == 0) {
6749 +                               in_macio = 1;
6750 +                               break;
6751 +                       }
6752 +                       parent = parent->parent;
6753 +               }
6754 +               if (in_macio)
6755 +                       continue;
6756 +               reg = (unsigned int *) get_property(np, "reg", &l);
6757 +               if (reg == 0 || l < sizeof(struct reg_property))
6758 +                       continue;
6759 +               if (((reg[0] >> 8) & 0xff) == dev_fn && ((reg[0] >> 16) & 0xff) == bus)
6760 +                       break;
6761 +       }
6762 +       return np;
6763 +}
6764 +
6765 +#ifdef CONFIG_BOOTX_TEXT
6766 +
6767  __pmac
6768  static void
6769  scrollscreen(void)
6770  {
6771         unsigned long offset            = reloc_offset();
6772 -       boot_infos_t* bi                = PTRRELOC(RELOC(disp_bi));
6773 +       boot_infos_t* bi                = PTRRELOC(RELOC(boot_infos));
6774         unsigned long *src              = (unsigned long *)calc_base(bi,0,16);
6775         unsigned long *dst              = (unsigned long *)calc_base(bi,0,0);
6776         unsigned long width             = ((bi->dispDeviceRect[2] - bi->dispDeviceRect[0]) *
6777                                                 (bi->dispDeviceDepth >> 3)) >> 2;
6778         int i,j;
6779 -
6780 -#ifdef CONFIG_POWERMAC
6781 -       pmu_suspend();
6782 -#endif
6783 -
6784 +       
6785         for (i=0; i<(bi->dispDeviceRect[3] - bi->dispDeviceRect[1] - 16); i++)
6786         {
6787                 unsigned long *src_ptr = src;
6788 @@ -2115,10 +1579,6 @@
6789                         *(dst_ptr++) = 0;
6790                 dst += (bi->dispDeviceRowBytes >> 2);
6791         }
6792 -
6793 -#ifdef CONFIG_POWERMAC
6794 -       pmu_resume();
6795 -#endif
6796  }
6797  
6798  __pmac
6799 @@ -2163,18 +1623,8 @@
6800                 drawchar(*c++);
6801  }
6802  
6803 -#ifdef CONFIG_BOOTX_TEXT
6804 -__pmac
6805 -static void boot_console_write(struct console *co, const char *s,
6806 -                                unsigned count)
6807 -{
6808 -       while(count--)
6809 -               drawchar(*s++);
6810 -}
6811 -#endif
6812 -
6813  __pmac
6814 -void
6815 +static void
6816  drawhex(unsigned long v)
6817  {
6818         static char hex_table[] = "0123456789abcdef";
6819 @@ -2196,20 +1646,19 @@
6820  draw_byte(unsigned char c, long locX, long locY)
6821  {
6822         unsigned long offset    = reloc_offset();
6823 -       boot_infos_t* bi        = PTRRELOC(RELOC(disp_bi));
6824 +       boot_infos_t* bi        = PTRRELOC(RELOC(boot_infos));
6825         unsigned char *base     = calc_base(bi, locX << 3, locY << 4);
6826         unsigned char *font     = &RELOC(vga_font)[((unsigned long)c) * 16];
6827 -       int rb                  = bi->dispDeviceRowBytes;
6828         
6829         switch(bi->dispDeviceDepth) {
6830                 case 32:
6831 -                       draw_byte_32(font, (unsigned long *)base, rb);
6832 +                       draw_byte_32(font, (unsigned long *)base);
6833                         break;
6834                 case 16:
6835 -                       draw_byte_16(font, (unsigned long *)base, rb);
6836 +                       draw_byte_16(font, (unsigned long *)base);
6837                         break;
6838                 case 8:
6839 -                       draw_byte_8(font, (unsigned long *)base, rb);
6840 +                       draw_byte_8(font, (unsigned long *)base);
6841                         break;
6842                 default:
6843                         break;
6844 @@ -2247,8 +1696,10 @@
6845  
6846  __pmac
6847  static void
6848 -draw_byte_32(unsigned char *font, unsigned long *base, int rb)
6849 +draw_byte_32(unsigned char *font, unsigned long *base)
6850  {
6851 +       unsigned long offset = reloc_offset();
6852 +       boot_infos_t* bi                = PTRRELOC(RELOC(boot_infos));
6853         int l, bits;    
6854         int fg = 0xFFFFFFFFUL;
6855         int bg = 0x00000000UL;
6856 @@ -2265,18 +1716,19 @@
6857                 base[5] = (-((bits >> 2) & 1) & fg) ^ bg;
6858                 base[6] = (-((bits >> 1) & 1) & fg) ^ bg;
6859                 base[7] = (-(bits & 1) & fg) ^ bg;
6860 -               base = (unsigned long *) ((char *)base + rb);
6861 +               base = (unsigned long *) ((char *)base + bi->dispDeviceRowBytes);
6862         }
6863  }
6864  
6865  __pmac
6866  static void
6867 -draw_byte_16(unsigned char *font, unsigned long *base, int rb)
6868 +draw_byte_16(unsigned char *font, unsigned long *base)
6869  {
6870 +       unsigned long offset = reloc_offset();
6871 +       boot_infos_t* bi                = PTRRELOC(RELOC(boot_infos));
6872         int l, bits;    
6873         int fg = 0xFFFFFFFFUL;
6874         int bg = 0x00000000UL;
6875 -       unsigned long offset = reloc_offset();
6876         unsigned long *eb = RELOC(expand_bits_16);
6877  
6878         for (l = 0; l < 16; ++l)
6879 @@ -2286,18 +1738,19 @@
6880                 base[1] = (eb[(bits >> 4) & 3] & fg) ^ bg;
6881                 base[2] = (eb[(bits >> 2) & 3] & fg) ^ bg;
6882                 base[3] = (eb[bits & 3] & fg) ^ bg;
6883 -               base = (unsigned long *) ((char *)base + rb);
6884 +               base = (unsigned long *) ((char *)base + bi->dispDeviceRowBytes);
6885         }
6886  }
6887  
6888  __pmac
6889  static void
6890 -draw_byte_8(unsigned char *font, unsigned long *base, int rb)
6891 +draw_byte_8(unsigned char *font, unsigned long *base)
6892  {
6893 +       unsigned long offset = reloc_offset();
6894 +       boot_infos_t* bi                = PTRRELOC(RELOC(boot_infos));
6895         int l, bits;    
6896         int fg = 0x0F0F0F0FUL;
6897         int bg = 0x00000000UL;
6898 -       unsigned long offset = reloc_offset();
6899         unsigned long *eb = RELOC(expand_bits_8);
6900  
6901         for (l = 0; l < 16; ++l)
6902 @@ -2305,7 +1758,7 @@
6903                 bits = *font++;
6904                 base[0] = (eb[bits >> 4] & fg) ^ bg;
6905                 base[1] = (eb[bits & 0xf] & fg) ^ bg;
6906 -               base = (unsigned long *) ((char *)base + rb);
6907 +               base = (unsigned long *) ((char *)base + bi->dispDeviceRowBytes);
6908         }
6909  }
6910  
6911 diff -urN linux.orig/arch/ppc/kernel/ptrace.c linux/arch/ppc/kernel/ptrace.c
6912 --- linux.orig/arch/ppc/kernel/ptrace.c Fri Nov  2 17:39:05 2001
6913 +++ linux/arch/ppc/kernel/ptrace.c      Thu Jul 11 15:43:29 2002
6914 @@ -29,6 +29,7 @@
6915  #include <asm/uaccess.h>
6916  #include <asm/page.h>
6917  #include <asm/pgtable.h>
6918 +#include <asm/pf-compat.h>
6919  #include <asm/system.h>
6920  
6921  /*
6922 @@ -341,10 +342,10 @@
6923         lock_kernel();
6924         if (request == PTRACE_TRACEME) {
6925                 /* are we already being traced? */
6926 -               if (current->ptrace & PT_PTRACED)
6927 +               if (current->flags & PF_PTRACED)
6928                         goto out;
6929                 /* set the ptrace bit in the process flags. */
6930 -               current->ptrace |= PT_PTRACED;
6931 +               current->flags |= PF_PTRACED;
6932                 ret = 0;
6933                 goto out;
6934         }
6935 @@ -370,9 +371,9 @@
6936                     (current->gid != child->gid)) && !capable(CAP_SYS_PTRACE))
6937                         goto out;
6938                 /* the same process cannot be attached many times */
6939 -               if (child->ptrace & PT_PTRACED)
6940 +               if (child->flags & PF_PTRACED)
6941                         goto out;
6942 -               child->ptrace |= PT_PTRACED;
6943 +               child->flags |= PF_PTRACED;
6944  
6945                 write_lock_irqsave(&tasklist_lock, flags);
6946                 if (child->p_pptr != current) {
6947 @@ -387,7 +388,7 @@
6948                 goto out;
6949         }
6950         ret = -ESRCH;
6951 -       if (!(child->ptrace & PT_PTRACED))
6952 +       if (!(child->flags & PF_PTRACED))
6953                 goto out;
6954         if (child->state != TASK_STOPPED) {
6955                 if (request != PTRACE_KILL)
6956 @@ -472,9 +473,9 @@
6957                         if ((unsigned long) data > _NSIG)
6958                                 goto out;
6959                         if (request == PTRACE_SYSCALL)
6960 -                               child->ptrace |= PT_TRACESYS;
6961 +                               child->flags |= PF_TRACESYS;
6962                         else
6963 -                               child->ptrace &= ~PT_TRACESYS;
6964 +                               child->flags &= ~PF_TRACESYS;
6965                         child->exit_code = data;
6966                         /* make sure the single step bit is not set. */
6967                         clear_single_step(child);
6968 @@ -503,7 +504,7 @@
6969                         ret = -EIO;
6970                         if ((unsigned long) data > _NSIG)
6971                                 goto out;
6972 -                       child->ptrace &= ~PT_TRACESYS;
6973 +                       child->flags &= ~PF_TRACESYS;
6974                         set_single_step(child);
6975                         child->exit_code = data;
6976                         /* give it a chance to run. */
6977 @@ -516,7 +517,7 @@
6978                         ret = -EIO;
6979                         if ((unsigned long) data > _NSIG)
6980                                 goto out;
6981 -                       child->ptrace &= ~(PT_PTRACED|PT_TRACESYS);
6982 +                       child->flags &= ~(PF_PTRACED|PF_TRACESYS);
6983                         child->exit_code = data;
6984                         write_lock_irqsave(&tasklist_lock, flags);
6985                         REMOVE_LINKS(child);
6986 @@ -541,8 +542,8 @@
6987  
6988  asmlinkage void syscall_trace(void)
6989  {
6990 -       if ((current->ptrace & (PT_PTRACED|PT_TRACESYS))
6991 -                       != (PT_PTRACED|PT_TRACESYS))
6992 +       if ((current->flags & (PF_PTRACED|PF_TRACESYS))
6993 +                       != (PF_PTRACED|PF_TRACESYS))
6994                 return;
6995         current->exit_code = SIGTRAP;
6996         current->state = TASK_STOPPED;
6997 diff -urN linux.orig/arch/ppc/kernel/setup.c linux/arch/ppc/kernel/setup.c
6998 --- linux.orig/arch/ppc/kernel/setup.c  Sun Mar 25 18:31:49 2001
6999 +++ linux/arch/ppc/kernel/setup.c       Thu Jul 11 15:47:12 2002
7000 @@ -31,7 +31,6 @@
7001  #endif
7002  #include <asm/bootx.h>
7003  #include <asm/machdep.h>
7004 -#include <asm/uaccess.h>
7005  
7006  extern void pmac_init(unsigned long r3,
7007                        unsigned long r4,
7008 @@ -69,10 +68,6 @@
7009                        unsigned long r6,
7010                        unsigned long r7);
7011  
7012 -#ifdef CONFIG_XMON
7013 -extern void xmon_map_scc(void);
7014 -#endif
7015 -
7016  extern boot_infos_t *boot_infos;
7017  extern char cmd_line[512];
7018  char saved_command_line[256];
7019 @@ -80,6 +75,10 @@
7020  
7021  struct ide_machdep_calls ppc_ide_md;
7022  
7023 +#ifdef CONFIG_MAGIC_SYSRQ
7024 +unsigned long SYSRQ_KEY;
7025 +#endif /* CONFIG_MAGIC_SYSRQ */
7026 +
7027  unsigned long ISA_DMA_THRESHOLD;
7028  unsigned long DMA_MODE_READ, DMA_MODE_WRITE;
7029  
7030 @@ -96,12 +95,6 @@
7031  
7032  struct machdep_calls ppc_md;
7033  
7034 -#ifdef CONFIG_MAGIC_SYSRQ
7035 -unsigned long SYSRQ_KEY;
7036 -#endif /* CONFIG_MAGIC_SYSRQ */
7037 -#ifdef CONFIG_VGA_CONSOLE
7038 -unsigned long vgacon_remap_base;
7039 -#endif
7040  
7041  /* copy of the residual data */
7042  #ifndef CONFIG_MBX
7043 @@ -267,9 +260,6 @@
7044                 case 10:
7045                         len += sprintf(len+buffer, "604ev5 (MachV)\n");
7046                         break;
7047 -               case 12:
7048 -                       len += sprintf(len+buffer, "7400 (G4)\n");
7049 -                       break;
7050                 case 50:
7051                         len += sprintf(len+buffer, "821\n");
7052                 case 80:
7053 @@ -322,6 +312,14 @@
7054                 bogosum += CD(loops_per_jiffy);
7055         }
7056  
7057 +#ifdef __SMP__
7058 +       if ( i )
7059 +               len += sprintf(buffer+len, "\n");
7060 +       len += sprintf(buffer+len,"total bogomips\t: %lu.%02lu\n",
7061 +                      (bogosum+2500)/500000,
7062 +                      (bogosum+2500)/5000 % 100);
7063 +#endif /* __SMP__ */
7064 +
7065         /*
7066          * Ooh's and aah's info about zero'd pages in idle task
7067          */ 
7068 @@ -486,21 +484,15 @@
7069  
7070         switch (_machine)
7071         {
7072 -#ifdef CONFIG_POWERMAC
7073         case _MACH_Pmac:
7074                  pmac_init(r3, r4, r5, r6, r7);
7075                 break;
7076 -#endif
7077 -#if defined(CONFIG_ALL_PPC) || defined(CONFIG_PREP)
7078         case _MACH_prep:
7079                  prep_init(r3, r4, r5, r6, r7);
7080                 break;
7081 -#endif
7082 -#if defined(CONFIG_ALL_PPC) || defined(CONFIG_CHRP)
7083         case _MACH_chrp:
7084                  chrp_init(r3, r4, r5, r6, r7);
7085                 break;
7086 -#endif
7087  #ifdef CONFIG_APUS
7088         case _MACH_apus:
7089                  apus_init(r3, r4, r5, r6, r7);
7090 @@ -554,13 +546,12 @@
7091  /* Checks "l2cr=xxxx" command-line option */
7092  void ppc_setup_l2cr(char *str, int *ints)
7093  {
7094 -       if ( ((_get_PVR() >> 16) == 8) || ((_get_PVR() >> 16) == 12) )
7095 +       if ( (_get_PVR() >> 16) == 8)
7096         {
7097                 unsigned long val = simple_strtoul(str, NULL, 0);
7098                 printk(KERN_INFO "l2cr set to %lx\n", val);
7099                 _set_L2CR(0);
7100 -               if (val)
7101 -                       _set_L2CR(val);
7102 +               _set_L2CR(val);
7103         }
7104  }
7105  
7106 @@ -581,16 +572,14 @@
7107         extern unsigned long find_available_memory(void);
7108         extern unsigned long *end_of_DRAM;
7109  
7110 -
7111  #ifdef CONFIG_XMON
7112 -       {
7113 -               char *p;
7114 +       extern void xmon_map_scc(void);
7115 +       char *p;
7116  
7117 -               xmon_map_scc();
7118 -               p = strstr(cmd_line, "xmon");
7119 -               if (p != NULL && (p == cmd_line || p[-1] == ' '))
7120 -                       xmon(0);
7121 -       }
7122 +       xmon_map_scc();
7123 +       p = strstr(cmd_line, "xmon");
7124 +       if (p != NULL && (p == cmd_line || p[-1] == ' '))
7125 +               xmon(0);
7126  #endif /* CONFIG_XMON */
7127   
7128         /* reboot on panic */   
7129 @@ -610,15 +599,7 @@
7130         *memory_end_p = (unsigned long) end_of_DRAM;
7131  
7132         ppc_md.setup_arch(memory_start_p, memory_end_p);
7133 -
7134 -       sort_exception_table();
7135 -}
7136 -
7137 -#ifndef CONFIG_POWERMAC
7138 -void note_bootable_part(kdev_t dev, int part, int goodness)
7139 -{
7140  }
7141 -#endif
7142  
7143  void ppc_generic_ide_fix_driveid(struct hd_driveid *id)
7144  {
7145 diff -urN linux.orig/arch/ppc/kernel/signal.c linux/arch/ppc/kernel/signal.c
7146 --- linux.orig/arch/ppc/kernel/signal.c Fri Nov  2 17:39:05 2001
7147 +++ linux/arch/ppc/kernel/signal.c      Thu Jul 11 15:43:29 2002
7148 @@ -14,16 +14,6 @@
7149   *  modify it under the terms of the GNU General Public License
7150   *  as published by the Free Software Foundation; either version
7151   *  2 of the License, or (at your option) any later version.
7152 - *
7153 - *
7154 - * 2000-04-7.
7155 - * Define a real-time signal frame with siginfo and ucontext
7156 - * structures (setup_rt_frame()).
7157 - * Stuck up a real-time signal frame when setting the signal
7158 - * frame with SA_SIGINFO flags.
7159 - * Add sys_rt_sigreturn() to undo the signal stack.
7160 - *
7161 - * Giovanna Ambrosini (ambrosini@lightning.ch)
7162   */
7163  
7164  #include <linux/sched.h>
7165 @@ -41,6 +31,7 @@
7166  #include <asm/ucontext.h>
7167  #include <asm/uaccess.h>
7168  #include <asm/pgtable.h>
7169 +#include <asm/pf-compat.h>
7170  
7171  #define DEBUG_SIG 0
7172  
7173 @@ -131,6 +122,13 @@
7174  }
7175  
7176  
7177 +asmlinkage int sys_rt_sigreturn(unsigned long __unused)
7178 +{
7179 +       printk("sys_rt_sigreturn(): %s/%d not yet implemented.\n",
7180 +              current->comm,current->pid);
7181 +       do_exit(SIGSEGV);
7182 +}
7183 +
7184  asmlinkage int
7185  sys_sigaltstack(const stack_t *uss, stack_t *uoss)
7186  {
7187 @@ -174,11 +172,13 @@
7188   * When we have signals to deliver, we set up on the
7189   * user stack, going down from the original stack pointer:
7190   *     a sigregs struct
7191 - * one or more sigcontext structs with
7192 + *     one or more sigcontext structs
7193   *     a gap of __SIGNAL_FRAMESIZE bytes
7194   *
7195   * Each of these things must be a multiple of 16 bytes in size.
7196   *
7197 + * XXX ultimately we will have to stack up a siginfo and ucontext
7198 + * for each rt signal.
7199   */
7200  struct sigregs {
7201         elf_gregset_t   gp_regs;
7202 @@ -189,15 +189,6 @@
7203         int             abigap[56];
7204  };
7205  
7206 -struct rt_sigframe
7207 -{
7208 - unsigned long _unused[2];
7209 - struct siginfo *pinfo;
7210 - void *puc;
7211 - struct siginfo info;
7212 - struct ucontext uc;
7213 -};
7214 -
7215  /*
7216   * Do a signal return; undo the signal stack.
7217   */
7218 @@ -230,10 +221,6 @@
7219                 sr = (struct sigregs *) sigctx.regs;
7220                 if (regs->msr & MSR_FP )
7221                         giveup_fpu(current);
7222 -#ifdef CONFIG_ALTIVEC
7223 -               if (regs->msr & MSR_VEC)
7224 -                       giveup_altivec(current);
7225 -#endif /* CONFIG_ALTIVEC */
7226                 if (copy_from_user(saved_regs, &sr->gp_regs,
7227                                    sizeof(sr->gp_regs)))
7228                         goto badframe;
7229 @@ -269,91 +256,6 @@
7230         do_exit(SIGSEGV);
7231  }      
7232  
7233 -
7234 -/*
7235 - *  When we have rt signals to deliver, we set up on the
7236 - *  user stack, going down from the original stack pointer:
7237 - *    a sigregs struct
7238 - *    one rt_sigframe struct (siginfo + ucontext)
7239 - *    a gap of __SIGNAL_FRAMESIZE bytes
7240 - *
7241 - *  Each of these things must be a multiple of 16 bytes in size.
7242 - *
7243 - */
7244 -asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
7245 -{
7246 - struct rt_sigframe *rt_sf;
7247 - struct sigcontext_struct sigctx;
7248 - struct sigregs *sr;
7249 - int ret;
7250 - elf_gregset_t saved_regs;  /* an array of ELF_NGREG unsigned longs */
7251 - sigset_t set;
7252 - stack_t st;
7253 - unsigned long prevsp;
7254 -
7255 - rt_sf = (struct rt_sigframe *)(regs->gpr[1] + __SIGNAL_FRAMESIZE);
7256 - if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx))
7257 -     || copy_from_user(&set, &rt_sf->uc.uc_sigmask, sizeof(set))
7258 -     || copy_from_user(&st, &rt_sf->uc.uc_stack, sizeof(st)))
7259 -  goto badframe;
7260 - sigdelsetmask(&set, ~_BLOCKABLE);
7261 - spin_lock_irq(&current->sigmask_lock);
7262 - current->blocked = set;
7263 - recalc_sigpending(current);
7264 - spin_unlock_irq(&current->sigmask_lock);
7265 -
7266 - rt_sf++;   /* Look at next rt_sigframe */
7267 - if (rt_sf == (struct rt_sigframe *)(sigctx.regs)) {
7268 -  /* Last stacked signal - restore registers -
7269 -   * sigctx is initialized to point to the
7270 -   * preamble frame (where registers are stored)
7271 -   * see handle_signal()
7272 -   */
7273 -  sr = (struct sigregs *) sigctx.regs;
7274 -  if (regs->msr & MSR_FP )
7275 -   giveup_fpu(current);
7276 -  if (copy_from_user(saved_regs, &sr->gp_regs,
7277 -       sizeof(sr->gp_regs)))
7278 -   goto badframe;
7279 -  saved_regs[PT_MSR] = (regs->msr & ~MSR_USERCHANGE)
7280 -   | (saved_regs[PT_MSR] & MSR_USERCHANGE);
7281 -  memcpy(regs, saved_regs, GP_REGS_SIZE);
7282 -  if (copy_from_user(current->tss.fpr, &sr->fp_regs,
7283 -       sizeof(sr->fp_regs)))
7284 -   goto badframe;
7285 -  /* This function sets back the stack flags into
7286 -     the current task structure.  */
7287 -  sys_sigaltstack(&st, NULL);
7288 -
7289 -  ret = regs->result;
7290 - } else {
7291 -  /* More signals to go */
7292 -  /* Set up registers for next signal handler */
7293 -  regs->gpr[1] = (unsigned long)rt_sf - __SIGNAL_FRAMESIZE;
7294 -  if (copy_from_user(&sigctx, &rt_sf->uc.uc_mcontext, sizeof(sigctx)))
7295 -   goto badframe;
7296 -  sr = (struct sigregs *) sigctx.regs;
7297 -  regs->gpr[3] = ret = sigctx.signal;
7298 -  /* Get the siginfo   */
7299 -  get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo);
7300 -  /* Get the ucontext */
7301 -  get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc);
7302 -  regs->gpr[6] = (unsigned long) rt_sf;
7303 -
7304 -  regs->link = (unsigned long) &sr->tramp;
7305 -  regs->nip = sigctx.handler;
7306 -  if (get_user(prevsp, &sr->gp_regs[PT_R1])
7307 -      || put_user(prevsp, (unsigned long *) regs->gpr[1]))
7308 -   goto badframe;
7309 - }
7310 - return ret;
7311 -
7312 -badframe:
7313 - lock_kernel();
7314 - do_exit(SIGSEGV);
7315 -}
7316 -
7317 -
7318  /*
7319   * Set up a signal frame.
7320   */
7321 @@ -367,10 +269,6 @@
7322                 goto badframe;
7323         if (regs->msr & MSR_FP)
7324                 giveup_fpu(current);
7325 -#ifdef CONFIG_ALTIVEC
7326 -       if (regs->msr & MSR_VEC)
7327 -               giveup_altivec(current);
7328 -#endif /* CONFIG_ALTIVEC */
7329         if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE)
7330             || __copy_to_user(&frame->fp_regs, current->tss.fpr,
7331                               ELF_NFPREG * sizeof(double))
7332 @@ -400,57 +298,6 @@
7333         do_exit(SIGSEGV);
7334  }
7335  
7336 -
7337 -static void
7338 -setup_rt_frame(struct pt_regs *regs, struct sigregs *frame,
7339 -        signed long newsp)
7340 -{
7341 - struct rt_sigframe *rt_sf = (struct rt_sigframe *) newsp;
7342 -
7343 - /* Set up preamble frame */
7344 - if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))
7345 -  goto badframe;
7346 - if (regs->msr & MSR_FP)
7347 -  giveup_fpu(current);
7348 - if (__copy_to_user(&frame->gp_regs, regs, GP_REGS_SIZE)
7349 -     || __copy_to_user(&frame->fp_regs, current->tss.fpr,
7350 -         ELF_NFPREG * sizeof(double))
7351 - /* Set up to return from user space.
7352 -    It calls the sc exception at offset 0x9999
7353 -    for sys_rt_sigreturn().
7354 - */
7355 -     || __put_user(0x38006666UL, &frame->tramp[0]) /* li r0,0x6666 */
7356 -     || __put_user(0x44000002UL, &frame->tramp[1])) /* sc */
7357 -  goto badframe;
7358 - flush_icache_range((unsigned long) &frame->tramp[0],
7359 -      (unsigned long) &frame->tramp[2]);
7360 -
7361 - /* Retrieve rt_sigframe from stack and
7362 -    set up registers for signal handler
7363 - */
7364 - newsp -= __SIGNAL_FRAMESIZE;
7365 - if (put_user(regs->gpr[1], (unsigned long *)newsp)
7366 -     || get_user(regs->nip, &rt_sf->uc.uc_mcontext.handler)
7367 -     || get_user(regs->gpr[3], &rt_sf->uc.uc_mcontext.signal)
7368 -     || get_user(regs->gpr[4], (unsigned long *)&rt_sf->pinfo)
7369 -     || get_user(regs->gpr[5], (unsigned long *)&rt_sf->puc))
7370 -  goto badframe;
7371 -
7372 - regs->gpr[1] = newsp;
7373 - regs->gpr[6] = (unsigned long) rt_sf;
7374 - regs->link = (unsigned long) frame->tramp;
7375 -
7376 - return;
7377 -
7378 -badframe:
7379 -#if DEBUG_SIG
7380 - printk("badframe in setup_rt_frame, regs=%p frame=%p newsp=%lx\n",
7381 -        regs, frame, newsp);
7382 -#endif
7383 - lock_kernel();
7384 - do_exit(SIGSEGV);
7385 -}
7386 -
7387  /*
7388   * OK, we're invoking a handler
7389   */
7390 @@ -460,7 +307,6 @@
7391               unsigned long *newspp, unsigned long frame)
7392  {
7393         struct sigcontext_struct *sc;
7394 - struct rt_sigframe *rt_sf;
7395  
7396         if (regs->trap == 0x0C00 /* System Call! */
7397             && ((int)regs->result == -ERESTARTNOHAND ||
7398 @@ -468,47 +314,20 @@
7399                  !(ka->sa.sa_flags & SA_RESTART))))
7400                 regs->result = -EINTR;
7401  
7402 - /* Set up Signal Frame */
7403 - if (ka->sa.sa_flags & SA_SIGINFO) {
7404 -  /* Put a Real Time Context onto stack */
7405 -  *newspp -= sizeof(*rt_sf);
7406 -  rt_sf = (struct rt_sigframe *) *newspp;
7407 -  if (verify_area(VERIFY_WRITE, rt_sf, sizeof(*rt_sf)))
7408 -   goto badframe;
7409 -
7410 -  if (__put_user((unsigned long) ka->sa.sa_handler, &rt_sf->uc.uc_mcontext.handler)
7411 -      || __put_user(&rt_sf->info, &rt_sf->pinfo)
7412 -      || __put_user(&rt_sf->uc, &rt_sf->puc)
7413 -      /* Put the siginfo */
7414 -      || __copy_to_user(&rt_sf->info, info, sizeof(*info))
7415 -      /* Create the ucontext */
7416 -      || __put_user(0, &rt_sf->uc.uc_flags)
7417 -      || __put_user(0, &rt_sf->uc.uc_link)
7418 -      || __put_user(current->sas_ss_sp, &rt_sf->uc.uc_stack.ss_sp)
7419 -      || __put_user(sas_ss_flags(regs->gpr[1]),
7420 -      &rt_sf->uc.uc_stack.ss_flags)
7421 -      || __put_user(current->sas_ss_size, &rt_sf->uc.uc_stack.ss_size)
7422 -      || __copy_to_user(&rt_sf->uc.uc_sigmask, oldset, sizeof(*oldset))
7423 -      /* mcontext.regs points to preamble register frame */
7424 -      || __put_user((struct pt_regs *)frame, &rt_sf->uc.uc_mcontext.regs)
7425 -      || __put_user(sig, &rt_sf->uc.uc_mcontext.signal))
7426 -   goto badframe;
7427 - } else {
7428 -  /* Put another sigcontext on the stack */
7429 -  *newspp -= sizeof(*sc);
7430 -  sc = (struct sigcontext_struct *) *newspp;
7431 -  if (verify_area(VERIFY_WRITE, sc, sizeof(*sc)))
7432 -   goto badframe;
7433 +       /* Put another sigcontext on the stack */
7434 +       *newspp -= sizeof(*sc);
7435 +       sc = (struct sigcontext_struct *) *newspp;
7436 +       if (verify_area(VERIFY_WRITE, sc, sizeof(*sc)))
7437 +               goto badframe;
7438  
7439 -  if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
7440 -      || __put_user(oldset->sig[0], &sc->oldmask)
7441 +       if (__put_user((unsigned long) ka->sa.sa_handler, &sc->handler)
7442 +           || __put_user(oldset->sig[0], &sc->oldmask)
7443  #if _NSIG_WORDS > 1
7444 -      || __put_user(oldset->sig[1], &sc->_unused[3])
7445 +           || __put_user(oldset->sig[1], &sc->_unused[3])
7446  #endif
7447 -      || __put_user((struct pt_regs *)frame, &sc->regs)
7448 -      || __put_user(sig, &sc->signal))
7449 -   goto badframe;
7450 - }
7451 +           || __put_user((struct pt_regs *)frame, &sc->regs)
7452 +           || __put_user(sig, &sc->signal))
7453 +               goto badframe;
7454  
7455         if (ka->sa.sa_flags & SA_ONESHOT)
7456                 ka->sa.sa_handler = SIG_DFL;
7457 @@ -558,7 +377,7 @@
7458                 if (!signr)
7459                         break;
7460  
7461 -               if ((current->ptrace & PT_PTRACED) && signr != SIGKILL) {
7462 +               if ((current->flags & PF_PTRACED) && signr != SIGKILL) {
7463                         /* Let the debugger run.  */
7464                         current->exit_code = signr;
7465                         current->state = TASK_STOPPED;
7466 @@ -664,10 +483,7 @@
7467         if (newsp == frame)
7468                 return 0;               /* no signals delivered */
7469  
7470 - if (ka->sa.sa_flags & SA_SIGINFO)
7471 -  setup_rt_frame(regs, (struct sigregs *) frame, newsp);
7472 - else
7473 -  setup_frame(regs, (struct sigregs *) frame, newsp);
7474 +       setup_frame(regs, (struct sigregs *) frame, newsp);
7475         return 1;
7476  
7477  }
7478 diff -urN linux.orig/arch/ppc/kernel/sleep.S linux/arch/ppc/kernel/sleep.S
7479 --- linux.orig/arch/ppc/kernel/sleep.S  Sun Mar 25 18:37:30 2001
7480 +++ linux/arch/ppc/kernel/sleep.S       Thu Jul 11 15:43:29 2002
7481 @@ -1,6 +1,6 @@
7482  /*
7483   * This file contains sleep low-level functions for PowerBook G3.
7484 - *    Copyright (C) 1999 Benjamin Herrenschmidt (benh@kernel.crashing.org)
7485 + *    Copyright (C) 1999 Benjamin Herrenschmidt (bh40@calva.net)
7486   *    and Paul Mackerras (paulus@cs.anu.edu.au).
7487   *
7488   * This program is free software; you can redistribute it and/or
7489 @@ -113,8 +113,8 @@
7490         stw     r4,SL_HID0(r1)
7491  
7492         /* Set up stuff at address 0 */
7493 -       lis     r5,grackle_wake_up@ha
7494 -       addi    r5,r5,grackle_wake_up@l
7495 +       lis     r5,wake_up@ha
7496 +       addi    r5,r5,wake_up@l
7497         tophys(r5,r5)
7498         stw     r5,SL_PC(r1)
7499         lis     r4,KERNELBASE@h
7500 @@ -124,28 +124,22 @@
7501         addi    r6,r6,MAGIC@l
7502         stw     r5,0(r4)
7503         stw     r6,4(r4)
7504 -       /* Setup stuffs at 0x80-0x84 for Core99 */
7505 -       lis     r3,core99_wake_up@ha
7506 -       addi    r3,r3,core99_wake_up@l
7507 -       tophys(r3,r3)
7508 -       stw     r3,0x80(r4)
7509 -       stw     r5,0x84(r4)
7510  
7511  /*
7512 - * Flush the L1 data cache by reading the first 128kB of RAM
7513 + * Flush the L1 data cache by reading the first 64kB of RAM
7514   * and then flushing the same area with the dcbf instruction.
7515   * The L2 cache has already been disabled.
7516   */
7517 -       li      r4,0x1000       /* 128kB / 32B */
7518 +       li      r4,0x0800       /* 64kB / 32B */
7519         mtctr   r4
7520         lis     r4,KERNELBASE@h
7521  1:
7522         lwz     r0,0(r4)
7523 -       addi    r4,r4,0x0020    /* Go to start of next cache line */
7524 +       addi    r4,r4,0x0020            /* Go to start of next cache line */
7525         bdnz    1b
7526         sync
7527         
7528 -       li      r4,0x1000       /* 128kB / 32B */
7529 +       li      r4,0x0800       /* 64k */
7530         mtctr   r4
7531         lis     r4,KERNELBASE@h
7532  1:
7533 @@ -154,14 +148,6 @@
7534         bdnz    1b
7535         sync
7536  
7537 -/* Turn off L1 (necessary ?) */
7538 -       mfspr   r3,HID0
7539 -       ori     r3,r3, HID0_ICE|HID0_DCE
7540 -       xori    r3,r3, HID0_ICE|HID0_DCE
7541 -       mtspr   HID0,r3
7542 -       sync
7543 -       isync
7544 -
7545  /*
7546   * Set the HID0 and MSR for sleep.
7547   */
7548 @@ -177,50 +163,20 @@
7549  1:     sync
7550         mtmsr   r2
7551         isync
7552 -       b       1b              
7553 +       b       1b
7554  
7555 -       
7556  /* 
7557   * Here is the resume code.
7558 - * Core99 machines resume here
7559 - * r4 has the physical address of SL_PC(sp).
7560 - */
7561 -
7562 -core99_wake_up:
7563 -       mr      r1,r4
7564 -       mfspr   r3,HID0
7565 -       /* use rlwinm ... */
7566 -       oris    r3,r3,HID0_SLEEP@h
7567 -       xoris   r3,r3,HID0_SLEEP@h
7568 -       mtspr   HID0,r3
7569 -       sync
7570 -       isync
7571 -       
7572 -       /* sanitize MSR */
7573 -       mfmsr   r3
7574 -       ori     r3,r3,MSR_EE|MSR_IP
7575 -       xori    r3,r3,MSR_EE|MSR_IP
7576 -       mtmsr   r3
7577 -       sync
7578 -       isync
7579 -               
7580 -/* 
7581 - * Here is the resume code for older machines.
7582   * r1 has the physical address of SL_PC(sp).
7583   */
7584         
7585 -grackle_wake_up:
7586 -       /* Enable and then Flash inval the instruction cache */
7587 +wake_up:
7588 +       /* Flash inval the instruction cache */
7589         mfspr   r3,HID0
7590 -       ori     r3,r3, HID0_ICE|HID0_ICFI|HID0_DCE|HID0_DCI
7591 -       sync
7592 -       isync
7593 -       mtspr   HID0,r3
7594 -       xori    r3,r3, HID0_ICFI|HID0_DCI
7595 +       ori     r3,r3, HID0_ICFI
7596         mtspr   HID0,r3
7597 -       sync
7598 -       
7599 -       /* Restore the remaining bits of the HID0 register. */
7600 +       isync
7601 +       /* Restore the HID0 register.  This turns on the L1 caches. */
7602         subi    r1,r1,SL_PC
7603         lwz     r3,SL_HID0(r1)
7604         sync
7605 @@ -283,13 +239,6 @@
7606         lwz     r4,SL_IBAT3+4(r1)
7607         mtibatl 3,r4
7608  
7609 -       /* Flush all TLBs */
7610 -       lis     r4, 0x1000
7611 -1:     addic.  r4, r4, -0x1000
7612 -       tlbie   r4
7613 -       blt     1b
7614 -       sync
7615 -
7616         /* restore the MSR and turn on the MMU */
7617         lwz     r3,SL_MSR(r1)
7618         bl      turn_on_mmu     
7619 @@ -298,8 +247,6 @@
7620         tovirt(r1,r1)
7621  
7622         /* Restore TB */
7623 -       lis r3,0
7624 -       mttbl   r3
7625         lwz     r3,SL_TB(r1)
7626         lwz     r4,SL_TB+4(r1)
7627         mttbu   r3
7628 @@ -320,4 +267,3 @@
7629         mtsrr1  r3
7630         sync
7631         rfi
7632 -       sync
7633 diff -urN linux.orig/arch/ppc/kernel/smp.c linux/arch/ppc/kernel/smp.c
7634 --- linux.orig/arch/ppc/kernel/smp.c    Sun Mar 25 18:31:49 2001
7635 +++ linux/arch/ppc/kernel/smp.c Thu Jul 11 16:28:25 2002
7636 @@ -7,9 +7,7 @@
7637   * deal of code from the sparc and intel versions.
7638   *
7639   * Support for PReP (Motorola MTX/MVME) SMP by Troy Benjegerdes
7640 - * (troy@blacklablinux.com, hozer@drgw.net)
7641 - * Support for PReP (Motorola MTX/MVME) and Macintosh G4 SMP 
7642 - * by Troy Benjegerdes (hozer@drgw.net)
7643 + * (troy@microux.com, hozer@drgw.net)
7644   */
7645  
7646  #include <linux/kernel.h>
7647 @@ -38,8 +36,8 @@
7648  #include <asm/prom.h>
7649  #include <asm/gemini.h>
7650  #include <asm/residual.h>
7651 -#include <asm/time.h>
7652 -#include <asm/feature.h>
7653 +
7654 +#include "time.h"
7655  #include "open_pic.h"
7656  
7657  int first_cpu_booted = 0;
7658 @@ -49,8 +47,7 @@
7659  struct cpuinfo_PPC cpu_data[NR_CPUS];
7660  struct klock_info_struct klock_info = { KLOCK_CLEAR, 0 };
7661  volatile unsigned char active_kernel_processor = NO_PROC_ID;   /* Processor holding kernel spinlock            */
7662 -atomic_t ipi_recv;
7663 -atomic_t ipi_sent;
7664 +volatile unsigned long ipi_count;
7665  spinlock_t kernel_flag = SPIN_LOCK_UNLOCKED;
7666  unsigned int prof_multiplier[NR_CPUS];
7667  unsigned int prof_counter[NR_CPUS];
7668 @@ -68,9 +65,6 @@
7669  extern unsigned long *MotSave_SmpIar;
7670  extern unsigned char *MotSave_CpusState[2];
7671  
7672 -/* l2 cache stuff for dual G4 macs */
7673 -extern void core99_init_l2(void);
7674
7675  /* register for interrupting the secondary processor on the powersurge */
7676  #define PSURGE_INTR    ((volatile unsigned *)0xf80000c0)
7677  
7678 @@ -121,7 +115,7 @@
7679  
7680  void smp_message_recv(int msg)
7681  {
7682 -       atomic_inc(&ipi_recv);
7683 +       ipi_count++;
7684         
7685         switch( msg )
7686         {
7687 @@ -143,7 +137,6 @@
7688         }
7689  }
7690  
7691 -#ifdef CONFIG_POWERMAC
7692  /*
7693   * As it is now, if we're sending two message at the same time
7694   * we have race conditions on Pmac.  The PowerSurge doesn't easily
7695 @@ -155,10 +148,10 @@
7696   * rather than this.
7697   *  -- Cort
7698   */
7699 -int psurge_smp_message[NR_CPUS];
7700 -void psurge_smp_message_recv(void)
7701 +int pmac_smp_message[NR_CPUS];
7702 +void pmac_smp_message_recv(void)
7703  {
7704 -       int msg = psurge_smp_message[smp_processor_id()];
7705 +       int msg = pmac_smp_message[smp_processor_id()];
7706  
7707         /* clear interrupt */
7708         out_be32(PSURGE_INTR, ~0);
7709 @@ -169,9 +162,9 @@
7710         smp_message_recv(msg);
7711  
7712         /* reset message */
7713 -       psurge_smp_message[smp_processor_id()] = -1;
7714 +       pmac_smp_message[smp_processor_id()] = -1;
7715  }
7716 -#endif /* powermac */
7717 +
7718  
7719  /*
7720   * 750's don't broadcast tlb invalidates so
7721 @@ -203,65 +196,49 @@
7722         smp_message_pass(MSG_ALL_BUT_SELF, MSG_STOP_CPU, 0, 0);
7723  }
7724  
7725 -#ifdef CONFIG_POWERMAC
7726 -static void psurge_message_pass(int target, int msg, unsigned long data, int wait)
7727 +void smp_message_pass(int target, int msg, unsigned long data, int wait)
7728  {
7729         int i;
7730         
7731 -       /*
7732 -        * IPI's on the Pmac are a hack but without reasonable
7733 -        * IPI hardware SMP on Pmac is a hack.
7734 -        *
7735 -        * We assume here that the msg is not -1.  If it is,
7736 -        * the recipient won't know the message was destined
7737 -        * for it. -- Cort
7738 -        */
7739 -       for ( i = 0; i <= smp_num_cpus ; i++ )
7740 -               psurge_smp_message[i] = -1;
7741 -       switch( target )
7742 -       {
7743 -       case MSG_ALL:
7744 -               psurge_smp_message[smp_processor_id()] = msg;
7745 -               /* fall through */
7746 -       case MSG_ALL_BUT_SELF:
7747 -               for ( i = 0 ; i < smp_num_cpus ; i++ )
7748 -                       if ( i != smp_processor_id () )
7749 -                               psurge_smp_message[i] = msg;
7750 -               break;
7751 -       default:
7752 -               psurge_smp_message[target] = msg;
7753 -               break;
7754 -       }
7755 -       /* interrupt secondary processor */
7756 -       out_be32(PSURGE_INTR, ~0);
7757 -       out_be32(PSURGE_INTR, 0);
7758 -       /*
7759 -        * Assume for now that the secondary doesn't send
7760 -        * IPI's -- Cort
7761 -        * Could be fixed with 2.4 code from Paulus -- BenH
7762 -        */
7763 -       /* interrupt primary */
7764 -       /**(volatile unsigned long *)(0xf3019000);*/
7765 -}
7766 -#endif /* powermac */
7767 -
7768 -void smp_message_pass(int target, int msg, unsigned long data, int wait)
7769 -{
7770 -       atomic_inc(&ipi_sent);
7771 -
7772         if ( !(_machine & (_MACH_Pmac|_MACH_chrp|_MACH_prep|_MACH_gemini)) )
7773                 return;
7774  
7775         switch (_machine) {
7776 -#ifdef CONFIG_POWERMAC
7777         case _MACH_Pmac:
7778 -               /* Hack, 2.4 does it cleanly */
7779 -               if (OpenPIC == NULL) {
7780 -                       psurge_message_pass(target, msg, data, wait);
7781 +               /*
7782 +                * IPI's on the Pmac are a hack but without reasonable
7783 +                * IPI hardware SMP on Pmac is a hack.
7784 +                *
7785 +                * We assume here that the msg is not -1.  If it is,
7786 +                * the recipient won't know the message was destined
7787 +                * for it. -- Cort
7788 +                */
7789 +               for ( i = 0; i <= smp_num_cpus ; i++ )
7790 +                       pmac_smp_message[i] = -1;
7791 +               switch( target )
7792 +               {
7793 +               case MSG_ALL:
7794 +                       pmac_smp_message[smp_processor_id()] = msg;
7795 +                       /* fall through */
7796 +               case MSG_ALL_BUT_SELF:
7797 +                       for ( i = 0 ; i < smp_num_cpus ; i++ )
7798 +                               if ( i != smp_processor_id () )
7799 +                                       pmac_smp_message[i] = msg;
7800                         break;
7801 -               } 
7802 -               /* else fall through and do something sane --Troy */
7803 -#endif
7804 +               default:
7805 +                       pmac_smp_message[target] = msg;
7806 +                       break;
7807 +               }
7808 +               /* interrupt secondary processor */
7809 +               out_be32(PSURGE_INTR, ~0);
7810 +               out_be32(PSURGE_INTR, 0);
7811 +               /*
7812 +                * Assume for now that the secondary doesn't send
7813 +                * IPI's -- Cort
7814 +                */
7815 +               /* interrupt primary */
7816 +               /**(volatile unsigned long *)(0xf3019000);*/
7817 +               break;
7818         case _MACH_chrp:
7819         case _MACH_prep:
7820         case _MACH_gemini:
7821 @@ -285,52 +262,6 @@
7822         }
7823  }
7824  
7825 -#ifdef CONFIG_POWERMAC
7826 -static void pmac_core99_kick_cpu(int nr)
7827 -{
7828 -       extern void __secondary_start_psurge(void);
7829 -
7830 -       unsigned long save_int;
7831 -       unsigned long flags;
7832 -       volatile unsigned long *vector
7833 -                = ((volatile unsigned long *)(KERNELBASE+0x500));
7834 -
7835 -       if (nr != 1)
7836 -               return;
7837 -
7838 -       __save_flags(flags);
7839 -       __cli();
7840 -       
7841 -       /* Save EE vector */
7842 -       save_int = *vector;
7843 -       
7844 -       /* Setup fake EE vector that does         
7845 -        *   b __secondary_start_psurge - KERNELBASE
7846 -        */   
7847 -       *vector = 0x48000002 +
7848 -               ((unsigned long)__secondary_start_psurge - KERNELBASE);
7849 -       
7850 -       /* flush data cache and inval instruction cache */
7851 -       flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
7852 -
7853 -       /* Put some life in our friend */
7854 -       feature_core99_kick_cpu1();
7855 -       
7856 -       /* FIXME: We wait a bit for the CPU to take the exception, I should
7857 -        * instead wait for the entry code to set something for me. Well,
7858 -        * ideally, all that crap will be done in prom.c and the CPU left
7859 -        * in a RAM-based wait loop like CHRP.
7860 -        */
7861 -       mdelay(1);
7862 -       
7863 -       /* Restore our exception vector */
7864 -       *vector = save_int;
7865 -       flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);
7866 -
7867 -       __restore_flags(flags);
7868 -}
7869 -#endif /* powermac */
7870 -
7871  void __init smp_boot_cpus(void)
7872  {
7873         extern struct task_struct *current_set[NR_CPUS];
7874 @@ -367,21 +298,15 @@
7875  
7876         switch ( _machine )
7877         {
7878 -#ifdef CONFIG_POWERMAC
7879         case _MACH_Pmac:
7880 -               /* assum e powersurge board - 2 processors -- Cort */
7881 -               /* or a dual G4 -- Troy */
7882 +               /* assume powersurge board - 2 processors -- Cort */
7883                 cpu_nr = 2;
7884                 break;
7885 -#endif
7886 -#if defined(CONFIG_ALL_PPC) || defined(CONFIG_CHRP)
7887         case _MACH_chrp:
7888                 cpu_nr = ((openpic_read(&OpenPIC->Global.Feature_Reporting0)
7889                                  & OPENPIC_FEATURE_LAST_PROCESSOR_MASK) >>
7890                                 OPENPIC_FEATURE_LAST_PROCESSOR_SHIFT)+1;
7891                 break;
7892 -#endif
7893 -#if defined(CONFIG_ALL_PPC) || defined(CONFIG_PREP)
7894         case _MACH_prep:
7895                 /* assume 2 for now == fix later -- Johnnie */
7896                 if ( mot_multi )
7897 @@ -389,13 +314,10 @@
7898                         cpu_nr = 2;
7899                         break;
7900                 }
7901 -#endif
7902 -#ifdef CONFIG_GEMINI
7903         case _MACH_gemini:
7904                  cpu_nr = (readb(GEMINI_CPUSTAT) & GEMINI_CPU_COUNT_MASK)>>2;
7905                  cpu_nr = (cpu_nr == 0) ? 4 : cpu_nr;
7906                 break;
7907 -#endif
7908         default:
7909                 printk("SMP not supported on this machine.\n");
7910                 return;
7911 @@ -426,41 +348,30 @@
7912                 /* wake up cpus */
7913                 switch ( _machine )
7914                 {
7915 -#ifdef CONFIG_POWERMAC
7916                 case _MACH_Pmac:
7917 -                       if (OpenPIC == NULL) {
7918 -                               /* setup entry point of secondary processor */
7919 -                               *(volatile unsigned long *)(0xf2800000) =
7920 -                                       (unsigned long)__secondary_start_psurge-KERNELBASE;
7921 -                               eieio();
7922 -                               /* interrupt secondary to begin executing code */
7923 -                               out_be32(PSURGE_INTR, ~0);
7924 -                               out_be32(PSURGE_INTR, 0);
7925 -                       } else
7926 -                               pmac_core99_kick_cpu(i);
7927 +                       /* setup entry point of secondary processor */
7928 +                       *(volatile unsigned long *)(0xf2800000) =
7929 +                               (unsigned long)__secondary_start_psurge-KERNELBASE;
7930 +                       eieio();
7931 +                       /* interrupt secondary to begin executing code */
7932 +                       out_be32(PSURGE_INTR, ~0);
7933 +                       out_be32(PSURGE_INTR, 0);
7934                         break;
7935 -#endif
7936 -#if defined(CONFIG_ALL_PPC) || defined(CONFIG_CHRP)
7937                 case _MACH_chrp:
7938                         *(unsigned long *)KERNELBASE = i;
7939                         asm volatile("dcbf 0,%0"::"r"(KERNELBASE):"memory");
7940                         break;
7941 -#endif
7942 -#if defined(CONFIG_ALL_PPC) || defined(CONFIG_PREP)
7943                 case _MACH_prep:
7944                         *MotSave_SmpIar = (unsigned long)__secondary_start_psurge - KERNELBASE;
7945                         *MotSave_CpusState[1] = CPU_GOOD;
7946                         printk("CPU1 reset, waiting\n");
7947                         break;
7948 -#endif
7949 -#ifdef CONFIG_GEMINI
7950                 case _MACH_gemini:
7951                         openpic_init_processor( 1<<i );
7952                         openpic_init_processor( 0 );
7953                         break;
7954 -#endif
7955                 }
7956 -
7957 +               
7958                 /*
7959                  * wait to see if the cpu made a callin (is actually up).
7960                  * use this value that I found through experimentation.
7961 @@ -481,9 +392,9 @@
7962                 }
7963         }
7964         
7965 -       if (OpenPIC)
7966 +       if ( _machine & (_MACH_gemini|_MACH_chrp|_MACH_prep) )
7967                 do_openpic_setup_cpu();
7968 -       else if ( _machine == _MACH_Pmac )
7969 +       if ( _machine == _MACH_Pmac )
7970         {
7971                 /* reset the entry point so if we get another intr we won't
7972                  * try to startup again */
7973 @@ -529,17 +440,10 @@
7974          * place to stick it for now.
7975          *  -- Cort
7976          */
7977 -       if (OpenPIC) {
7978 +       if ( _machine & (_MACH_gemini|_MACH_chrp|_MACH_prep) )
7979                 do_openpic_setup_cpu();
7980 -#ifdef CONFIG_POWERMAC
7981 -               if ( _machine == _MACH_Pmac )
7982 -                       core99_init_l2();
7983 -#endif
7984 -       }
7985 -#ifdef CONFIG_GEMINI
7986         if ( _machine == _MACH_gemini )
7987                 gemini_init_l2();
7988 -#endif
7989         while(!smp_commenced)
7990                 barrier();
7991         __sti();
7992 diff -urN linux.orig/arch/ppc/kernel/syscalls.c linux/arch/ppc/kernel/syscalls.c
7993 --- linux.orig/arch/ppc/kernel/syscalls.c       Sun Mar 25 18:31:49 2001
7994 +++ linux/arch/ppc/kernel/syscalls.c    Thu Jul 11 15:43:29 2002
7995 @@ -199,7 +199,6 @@
7996         struct file * file = NULL;
7997         int ret = -EBADF;
7998  
7999 -       down(&current->mm->mmap_sem);
8000         lock_kernel();
8001         if (!(flags & MAP_ANONYMOUS)) {
8002                 if (fd >= NR_OPEN || !(file = current->files->fd[fd]))
8003 @@ -210,7 +209,6 @@
8004         ret = do_mmap(file, addr, len, prot, flags, offset);
8005  out:
8006         unlock_kernel();
8007 -       up(&current->mm->mmap_sem);
8008         return ret;
8009  }
8010  
8011 @@ -248,14 +246,9 @@
8012  
8013  asmlinkage int sys_uname(struct old_utsname * name)
8014  {
8015 -       int err;
8016 -       
8017 -       if (!name)
8018 -               return -EFAULT;
8019 -       down(&uts_sem);
8020 -       err = copy_to_user(name, &system_utsname, sizeof (*name));
8021 -       up(&uts_sem);
8022 -       return err ? -EFAULT : 0;
8023 +       if (name && !copy_to_user(name, &system_utsname, sizeof (*name)))
8024 +               return 0;
8025 +       return -EFAULT;
8026  }
8027  
8028  asmlinkage int sys_olduname(struct oldold_utsname * name)
8029 @@ -267,7 +260,6 @@
8030         if (!access_ok(VERIFY_WRITE,name,sizeof(struct oldold_utsname)))
8031                 return -EFAULT;
8032    
8033 -       down(&uts_sem);
8034         error = __copy_to_user(&name->sysname,&system_utsname.sysname,__OLD_UTS_LEN);
8035         error -= __put_user(0,name->sysname+__OLD_UTS_LEN);
8036         error -= __copy_to_user(&name->nodename,&system_utsname.nodename,__OLD_UTS_LEN);
8037 @@ -279,18 +271,6 @@
8038         error -= __copy_to_user(&name->machine,&system_utsname.machine,__OLD_UTS_LEN);
8039         error = __put_user(0,name->machine+__OLD_UTS_LEN);
8040         error = error ? -EFAULT : 0;
8041 -       up(&uts_sem);
8042  
8043         return error;
8044  }
8045 -
8046 -#ifndef CONFIG_PCI
8047 -/*
8048 - * Those are normally defined in arch/ppc/kernel/pci.c. But when CONFIG_PCI is
8049 - * not defined, this file is not linked at all, so here are the "empty" versions
8050 - */
8051 -asmlinkage int sys_pciconfig_read() { return -ENOSYS; }
8052 -asmlinkage int sys_pciconfig_write() { return -ENOSYS; }
8053 -asmlinkage long sys_pciconfig_iobase() { return -ENOSYS; }
8054 -#endif
8055 -
8056 diff -urN linux.orig/arch/ppc/kernel/time.c linux/arch/ppc/kernel/time.c
8057 --- linux.orig/arch/ppc/kernel/time.c   Sun Mar 25 18:31:49 2001
8058 +++ linux/arch/ppc/kernel/time.c        Thu Jul 11 15:43:29 2002
8059 @@ -46,7 +46,7 @@
8060  #endif
8061  #include <asm/machdep.h>
8062  
8063 -#include <asm/time.h>
8064 +#include "time.h"
8065  
8066  void smp_local_timer_interrupt(struct pt_regs *);
8067  
8068 @@ -71,7 +71,7 @@
8069  {
8070         int dval, d;
8071         unsigned long cpu = smp_processor_id();
8072 -
8073 +       
8074         hardirq_enter(cpu);
8075  #ifdef __SMP__
8076         {
8077 @@ -106,13 +106,6 @@
8078                 if ( !smp_processor_id() )
8079                 {
8080                         do_timer(regs);
8081 -#if 0
8082 -       /* -- BenH -- I'm removing this for now since it can cause various
8083 -        *            troubles with local-time RTCs. Now that we have a
8084 -        *            /dev/rtc that uses ppc_md.set_rtc_time() on mac, it
8085 -        *            should be possible to program the RTC from userland
8086 -        *            in all cases.
8087 -        */
8088                         /*
8089                          * update the rtc when needed
8090                          */
8091 @@ -126,7 +119,6 @@
8092                                         /* do it again in 60 s */
8093                                         last_rtc_update = xtime.tv_sec;
8094                         }
8095 -#endif                 
8096                 }
8097         }
8098  #ifdef __SMP__
8099 @@ -192,10 +184,10 @@
8100  
8101  __initfunc(void time_init(void))
8102  {
8103 -       long time_offset = 0;
8104 -
8105          if (ppc_md.time_init != NULL)
8106 -                time_offset = ppc_md.time_init();
8107 +        {
8108 +                ppc_md.time_init();
8109 +        }
8110  
8111         if ((_get_PVR() >> 16) == 1) {
8112                 /* 601 processor: dec counts down by 128 every 128ns */
8113 @@ -208,12 +200,6 @@
8114  
8115          xtime.tv_sec = ppc_md.get_rtc_time();
8116          xtime.tv_usec = 0;
8117 -        if (time_offset) {
8118 -               struct timezone tz;
8119 -               tz.tz_minuteswest = time_offset/60;
8120 -               tz.tz_dsttime = 0; /* Not handled correctly by the kernel anyway */
8121 -               do_sys_settimeofday(NULL, &tz);
8122 -        }
8123  
8124         set_dec(decrementer_count);
8125         /* allow updates right away */
8126 diff -urN linux.orig/arch/ppc/kernel/time.h linux/arch/ppc/kernel/time.h
8127 --- linux.orig/arch/ppc/kernel/time.h   Thu Jan  1 01:00:00 1970
8128 +++ linux/arch/ppc/kernel/time.h        Thu Jul 11 15:43:29 2002
8129 @@ -0,0 +1,34 @@
8130 +/*
8131 + * $Id$
8132 + * Common time prototypes and such for all ppc machines.
8133 + *
8134 + * Written by Cort Dougan (cort@cs.nmt.edu) to merge
8135 + * Paul Mackerras' version and mine for PReP and Pmac.
8136 + */
8137 +
8138 +#include <linux/mc146818rtc.h>
8139 +
8140 +/* time.c */
8141 +extern unsigned decrementer_count;
8142 +extern unsigned count_period_num;
8143 +extern unsigned count_period_den;
8144 +extern unsigned long mktime(unsigned int, unsigned int, unsigned int,
8145 +                           unsigned int, unsigned int, unsigned int);
8146 +extern void to_tm(int tim, struct rtc_time * tm);
8147 +extern time_t last_rtc_update;
8148 +
8149 +int via_calibrate_decr(void);
8150 +
8151 +/* Accessor functions for the decrementer register. */
8152 +static __inline__ unsigned int get_dec(void)
8153 +{
8154 +       unsigned int ret;
8155 +
8156 +       asm volatile("mfspr %0,22" : "=r" (ret) :);
8157 +       return ret;
8158 +}
8159 +
8160 +static __inline__ void set_dec(unsigned int val)
8161 +{
8162 +       asm volatile("mtspr 22,%0" : : "r" (val));
8163 +}
8164 diff -urN linux.orig/arch/ppc/kernel/traps.c linux/arch/ppc/kernel/traps.c
8165 --- linux.orig/arch/ppc/kernel/traps.c  Sun Mar 25 18:31:48 2001
8166 +++ linux/arch/ppc/kernel/traps.c       Thu Jul 11 15:43:29 2002
8167 @@ -100,27 +100,26 @@
8168                         return;
8169                 }
8170  #endif
8171 -               printk("Machine check in kernel mode.  (regs at %p)\n", regs);
8172 -               printk("Caused by (from srr1): ");
8173 -               switch( regs->msr & 0x001F0000) {
8174 -               case 0x100000:
8175 -                       printk("L2 data cache parity error\n");
8176 +               printk("Machine check in kernel mode.\n");
8177 +               printk("Caused by (from msr): ");
8178 +               printk("regs %p ",regs);
8179 +               switch( regs->msr & 0x0000F000)
8180 +               {
8181 +               case (1<<12) :
8182 +                       printk("Machine check signal - probably due to mm fault\n"
8183 +                               "with mmu off\n");
8184                         break;
8185 -               case 0x80000:
8186 -                       printk("Machine check signal\n");
8187 -                       printk("(probably due to access of bad physical address\n");
8188 -                       break;
8189 -               case 0x40000:
8190 +               case (1<<13) :
8191                         printk("Transfer error ack signal\n");
8192                         break;
8193 -               case 0x20000:
8194 +               case (1<<14) :
8195                         printk("Data parity signal\n");
8196                         break;
8197 -               case 0x10000:
8198 +               case (1<<15) :
8199                         printk("Address parity signal\n");
8200                         break;
8201                 default:
8202 -                       printk("Unknown values in srr1\n");
8203 +                       printk("Unknown values in msr\n");
8204                 }
8205                 show_regs(regs);
8206  #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
8207 @@ -156,52 +155,9 @@
8208         _exception(SIGTRAP, regs);      
8209  }
8210  
8211 -/* Illegal instruction emulation support.  Originally written to
8212 - * provide the PVR to user applications using the mfspr rd, PVR.
8213 - * Return non-zero if we can't emulate, or EFAULT if the associated
8214 - * memory access caused an access fault.  Return zero on success.
8215 - *
8216 - * There are a couple of ways to do this, either "decode" the instruction
8217 - * or directly match lots of bits.  In this case, matching lots of
8218 - * bits is faster and easier.
8219 - *
8220 - */
8221 -#define INST_MFSPR_PVR         0x7c1f42a6
8222 -#define INST_MFSPR_PVR_MASK    0xfc1fffff
8223 -
8224 -static int
8225 -emulate_instruction(struct pt_regs *regs)
8226 -{
8227 -       uint    instword;
8228 -       uint    rd;
8229 -       int    retval;
8230 -
8231 -       retval = EINVAL;
8232 -       if (!user_mode(regs))
8233 -               return retval;
8234 -
8235 -       retval = EFAULT;
8236 -       if (get_user(instword, (uint *)(regs->nip)))
8237 -               return retval;
8238 -
8239 -       /* Emulate the mfspr rD, PVR.
8240 -        */
8241 -       retval = EINVAL;
8242 -       if ((instword & INST_MFSPR_PVR_MASK) == INST_MFSPR_PVR) {
8243 -               rd = (instword >> 21) & 0x1f;
8244 -               regs->gpr[rd] = _get_PVR();
8245 -               retval = 0;
8246 -       }
8247 -       if (retval == 0)
8248 -               regs->nip += 4;
8249 -       return(retval);
8250 -}
8251 -
8252  void
8253  ProgramCheckException(struct pt_regs *regs)
8254  {
8255 -       int errcode;
8256 -
8257         if (regs->msr & 0x100000) {
8258                 /* IEEE FP exception */
8259                 _exception(SIGFPE, regs);
8260 @@ -213,13 +169,7 @@
8261  #endif
8262                 _exception(SIGTRAP, regs);
8263         } else {
8264 -               /* Try to emulate it if we should. */
8265 -               if ((errcode = emulate_instruction(regs))) {
8266 -                       if (errcode == EFAULT)
8267 -                               _exception(SIGBUS, regs);
8268 -                       else
8269 -                               _exception(SIGILL, regs);
8270 -               }
8271 +               _exception(SIGILL, regs);
8272         }
8273  }
8274  
8275 diff -urN linux.orig/arch/ppc/lib/string.S linux/arch/ppc/lib/string.S
8276 --- linux.orig/arch/ppc/lib/string.S    Sun Mar 25 18:31:49 2001
8277 +++ linux/arch/ppc/lib/string.S Thu Jul 11 15:43:29 2002
8278 @@ -12,11 +12,6 @@
8279  #include <asm/processor.h>
8280  #include <asm/errno.h>
8281  
8282 -CACHELINE_BYTES = 32
8283 -LG_CACHELINE_BYTES = 5
8284 -CACHELINE_MASK = 0x1f
8285 -CACHELINE_WORDS = 8
8286 -
8287         .globl  strcpy
8288  strcpy:
8289         addi    r5,r3,-1
8290 @@ -87,35 +82,7 @@
8291         andi.   r0,r6,3
8292         add     r5,r0,r5
8293         subf    r6,r0,r6
8294 -#if 0  /* Clever, but breaks fb stuff -- paulus */
8295 -/*
8296 - * Use dcbz on the complete cache lines in the destination if
8297 - * we are setting to zero.  This requires that the destination
8298 - * area is cacheable.  -- paulus
8299 - */
8300 -       cmpwi   0,r4,0
8301 -       bne     2f
8302 -       clrlwi  r7,r6,32-LG_CACHELINE_BYTES
8303 -       add     r8,r7,r5
8304 -       srwi    r9,r8,LG_CACHELINE_BYTES
8305 -       addic.  r9,r9,-1        /* total number of complete cachelines */
8306 -       ble     2f
8307 -       xori    r0,r7,CACHELINE_MASK & ~3
8308 -       srwi.   r0,r0,2
8309 -       beq     3f
8310 -       mtctr   r0
8311 -4:     stwu    r4,4(r6)
8312 -       bdnz    4b
8313 -3:     mtctr   r9
8314 -       li      r7,4
8315 -10:    dcbz    r7,r6
8316 -       addi    r6,r6,CACHELINE_BYTES
8317 -       bdnz    10b
8318 -       clrlwi  r5,r8,32-LG_CACHELINE_BYTES
8319 -       addi    r5,r5,4
8320 -2:
8321 -#endif
8322 -       srwi    r0,r5,2
8323 +       rlwinm  r0,r5,32-2,2,31
8324         mtctr   r0
8325         bdz     6f
8326  1:     stwu    r4,4(r6)
8327 @@ -140,94 +107,11 @@
8328  memmove:
8329         cmplw   0,r3,r4
8330         bgt     backwards_memcpy
8331 -       b       forwards_memcpy
8332 +       /* fall through */
8333  
8334         .globl  memcpy
8335  memcpy:
8336 -#if 0  /* Clever, but will probably break fb stuff -- paulus */
8337 -/*
8338 - * This version uses dcbz on the complete cache lines in the
8339 - * destination area to reduce memory traffic.  This requires that
8340 - * the destination area is cacheable.
8341 - * We only use this version if the source and dest don't overlap.
8342 - * -- paulus.
8343 - */
8344 -       add     r7,r3,r5                /* test if the src & dst overlap */
8345 -       add     r8,r4,r5
8346 -       cmplw   0,r4,r7
8347 -       cmplw   1,r3,r8
8348 -       crand   0,0,4                   /* cr0.lt &= cr1.lt */
8349 -       blt     forwards_memcpy         /* if regions overlap */
8350 -
8351 -       addi    r4,r4,-4
8352 -       addi    r6,r3,-4
8353 -       neg     r0,r3
8354 -       andi.   r0,r0,CACHELINE_MASK    /* # bytes to start of cache line */
8355 -       beq     58f
8356 -
8357 -       cmplw   0,r5,r0                 /* is this more than total to do? */
8358 -       blt     63f                     /* if not much to do */
8359 -       andi.   r8,r0,3                 /* get it word-aligned first */
8360 -       subf    r5,r0,r5
8361 -       mtctr   r8
8362 -       beq+    61f
8363 -70:    lbz     r9,4(r4)                /* do some bytes */
8364 -       stb     r9,4(r6)
8365 -       addi    r4,r4,1
8366 -       addi    r6,r6,1
8367 -       bdnz    70b
8368 -61:    srwi.   r0,r0,2
8369 -       mtctr   r0
8370 -       beq     58f
8371 -72:    lwzu    r9,4(r4)                /* do some words */
8372 -       stwu    r9,4(r6)
8373 -       bdnz    72b
8374 -
8375 -58:    srwi.   r0,r5,LG_CACHELINE_BYTES /* # complete cachelines */
8376 -       clrlwi  r5,r5,32-LG_CACHELINE_BYTES
8377 -       li      r11,4
8378 -       mtctr   r0
8379 -       beq     63f
8380 -53:    dcbz    r11,r6
8381 -       lwz     r7,4(r4)
8382 -       lwz     r8,8(r4)
8383 -       lwz     r9,12(r4)
8384 -       lwzu    r10,16(r4)
8385 -       stw     r7,4(r6)
8386 -       stw     r8,8(r6)
8387 -       stw     r9,12(r6)
8388 -       stwu    r10,16(r6)
8389 -       lwz     r7,4(r4)
8390 -       lwz     r8,8(r4)
8391 -       lwz     r9,12(r4)
8392 -       lwzu    r10,16(r4)
8393 -       stw     r7,4(r6)
8394 -       stw     r8,8(r6)
8395 -       stw     r9,12(r6)
8396 -       stwu    r10,16(r6)
8397 -       bdnz    53b
8398 -
8399 -63:    srwi.   r0,r5,2
8400 -       mtctr   r0
8401 -       beq     64f
8402 -30:    lwzu    r0,4(r4)
8403 -       stwu    r0,4(r6)
8404 -       bdnz    30b
8405 -
8406 -64:    andi.   r0,r5,3
8407 -       mtctr   r0
8408 -       beq+    65f
8409 -40:    lbz     r0,4(r4)
8410 -       stb     r0,4(r6)
8411 -       addi    r4,r4,1
8412 -       addi    r6,r6,1
8413 -       bdnz    40b
8414 -65:    blr
8415 -#endif
8416 -
8417 -       .global forwards_memcpy
8418 -forwards_memcpy:
8419 -       srwi.   r7,r5,3
8420 +       rlwinm. r7,r5,32-3,3,31         /* r0 = r5 >> 3 */
8421         addi    r6,r3,-4
8422         addi    r4,r4,-4
8423         beq     2f                      /* if less than 8 bytes to do */
8424 @@ -334,167 +218,106 @@
8425  
8426         .globl  __copy_tofrom_user
8427  __copy_tofrom_user:
8428 -       addi    r4,r4,-4
8429 +       srwi.   r7,r5,3
8430         addi    r6,r3,-4
8431 -       neg     r0,r3
8432 -       andi.   r0,r0,CACHELINE_MASK    /* # bytes to start of cache line */
8433 -       beq     58f
8434 -
8435 -       cmplw   0,r5,r0                 /* is this more than total to do? */
8436 -       blt     63f                     /* if not much to do */
8437 -       andi.   r8,r0,3                 /* get it word-aligned first */
8438 -       mtctr   r8
8439 -       beq+    61f
8440 -70:    lbz     r9,4(r4)                /* do some bytes */
8441 -71:    stb     r9,4(r6)
8442 -       addi    r4,r4,1
8443 -       addi    r6,r6,1
8444 -       bdnz    70b
8445 -61:    subf    r5,r0,r5
8446 -       srwi.   r0,r0,2
8447 -       mtctr   r0
8448 -       beq     58f
8449 -72:    lwzu    r9,4(r4)                /* do some words */
8450 -73:    stwu    r9,4(r6)
8451 -       bdnz    72b
8452 -
8453 -58:    srwi.   r0,r5,LG_CACHELINE_BYTES /* # complete cachelines */
8454 -       clrlwi  r5,r5,32-LG_CACHELINE_BYTES
8455 -       li      r11,4
8456 -       mtctr   r0
8457 -       beq     63f
8458 -53:    dcbz    r11,r6
8459 -10:    lwz     r7,4(r4)
8460 -11:    lwz     r8,8(r4)
8461 -12:    lwz     r9,12(r4)
8462 -13:    lwzu    r10,16(r4)
8463 -14:    stw     r7,4(r6)
8464 -15:    stw     r8,8(r6)
8465 -16:    stw     r9,12(r6)
8466 -17:    stwu    r10,16(r6)
8467 -20:    lwz     r7,4(r4)
8468 -21:    lwz     r8,8(r4)
8469 -22:    lwz     r9,12(r4)
8470 -23:    lwzu    r10,16(r4)
8471 -24:    stw     r7,4(r6)
8472 -25:    stw     r8,8(r6)
8473 -26:    stw     r9,12(r6)
8474 -27:    stwu    r10,16(r6)
8475 -       bdnz    53b
8476 -
8477 -63:    srwi.   r0,r5,2
8478 -       mtctr   r0
8479 -       beq     64f
8480 -30:    lwzu    r0,4(r4)
8481 -31:    stwu    r0,4(r6)
8482 -       bdnz    30b
8483 -
8484 -64:    andi.   r0,r5,3
8485 -       mtctr   r0
8486 -       beq+    65f
8487 -40:    lbz     r0,4(r4)
8488 -41:    stb     r0,4(r6)
8489 +       addi    r4,r4,-4
8490 +       li      r3,0            /* success return value */
8491 +       beq     2f              /* if less than 8 bytes to do */
8492 +       andi.   r0,r6,3         /* get dest word aligned */
8493 +       mtctr   r7
8494 +       bne     5f
8495 +1:     lwz     r7,4(r4)
8496 +11:    lwzu    r8,8(r4)
8497 +12:    stw     r7,4(r6)
8498 +13:    stwu    r8,8(r6)
8499 +       bdnz    1b
8500 +       andi.   r5,r5,7
8501 +2:     cmplwi  0,r5,4
8502 +       blt     3f
8503 +14:    lwzu    r0,4(r4)
8504 +       addi    r5,r5,-4
8505 +15:    stwu    r0,4(r6)
8506 +3:     cmpwi   0,r5,0          /* do 1 byte at a time for the remainder */
8507 +       beqlr
8508 +       mtctr   r5
8509 +       addi    r4,r4,3
8510 +       addi    r6,r6,3
8511 +4:     lbzu    r0,1(r4)
8512 +16:    stbu    r0,1(r6)
8513 +       bdnz    4b
8514 +       blr
8515 +5:     subfic  r0,r0,4         /* copy bytes until we have the */
8516 +       mtctr   r0              /* destination 4-byte aligned */
8517 +       subf    r5,r0,r5
8518 +6:     lbz     r7,4(r4)
8519         addi    r4,r4,1
8520 +17:    stb     r7,4(r6)
8521         addi    r6,r6,1
8522 -       bdnz    40b
8523 -65:    li      r3,0
8524 -       blr
8525 -
8526 -/* read fault, initial single-byte copy */
8527 -100:   li      r4,0
8528 -       b       90f
8529 -/* write fault, initial single-byte copy */
8530 -101:   li      r4,1
8531 -90:    subf    r5,r8,r5
8532 -       li      r3,0
8533 -       b       99f
8534 -/* read fault, initial word copy */
8535 -102:   li      r4,0
8536 -       b       91f
8537 -/* write fault, initial word copy */
8538 -103:   li      r4,1
8539 -91:    li      r3,2
8540 -       b       99f
8541 -/* read fault in 2nd half of cacheline loop */
8542 -106:   addi    r5,r5,-16
8543 -/* read fault in 1st half of cacheline loop */
8544 -104:   li      r4,0
8545 -       b       92f
8546 -/* write fault in 2nd half of cacheline loop */
8547 -107:   addi    r5,r5,-16
8548 -/* fault on dcbz (effectively a write fault) */
8549 -/* or write fault in 1st half of cacheline loop */
8550 -105:   li      r4,1
8551 -92:    li      r3,LG_CACHELINE_BYTES
8552 -       b       99f
8553 -/* read fault in final word loop */
8554 -108:   li      r4,0
8555 -       b       93f
8556 -/* write fault in final word loop */
8557 -109:   li      r4,1
8558 -93:    andi.   r5,r5,3
8559 -       li      r3,2
8560 -       b       99f
8561 -/* read fault in final byte loop */
8562 -110:   li      r4,0
8563 -       b       94f
8564 -/* write fault in final byte loop */
8565 -111:   li      r4,1
8566 -94:    li      r5,0
8567 -       li      r3,0
8568 -/*
8569 - * At this stage the number of bytes not copied is
8570 - * r5 + (ctr << r3), and r4 is 0 for read or 1 for write.
8571 - */
8572 -99:    mfctr   r0
8573 -       slw     r3,r0,r3
8574 +       bdnz    6b
8575 +       srwi.   r7,r5,3
8576 +       beq     2b
8577 +       mtctr   r7
8578 +       b       1b
8579 +/* we come here on a fault in the 8-byte-at-a-time loop */
8580 +88:    subi    r4,r4,8         /* compensate for the lwzu */
8581 +98:    mfctr   r0
8582 +       rlwimi  r5,r0,3,0,28    /* use the byte-at-a-time loop to */
8583 +       b       3b              /* copy up to the byte at fault */
8584 +/* here on a write fault in the single-word copy */
8585 +96:    subi    r4,r4,4
8586 +       b       3b
8587 +/* here on a read fault in the initial single-byte copy */
8588 +90:    mfctr   r3
8589         add     r3,r3,r5
8590 -       cmpwi   0,r4,0
8591 -       bne     120f
8592 -/* for read fault, clear out the destination: r3 bytes starting at 4(r6) */
8593 -       srwi.   r0,r3,2
8594 -       li      r9,0
8595 -       mtctr   r0
8596 -       beq     113f
8597 -112:   stwu    r9,4(r6)
8598 -       bdnz    112b
8599 -113:   andi.   r0,r3,3
8600 -       mtctr   r0
8601 -       beq     120f
8602 -114:   stb     r9,4(r6)
8603 +       b       70f
8604 +/* here on a read fault in the final single-byte copy */
8605 +99:    mfctr   r3
8606 +       subi    r6,r6,3
8607 +/* clear out the rest of the destination: r3 bytes starting at 4(r6) */
8608 +70:    li      r0,0
8609 +       mr.     r5,r3
8610 +       beq     76f
8611 +71:    andi.   r4,r6,3
8612 +       beq     72f
8613 +77:    stb     r0,4(r6)
8614         addi    r6,r6,1
8615 -       bdnz    114b
8616 -120:   blr
8617 +       addic.  r5,r5,-1
8618 +       bne     71b
8619 +72:    srwi.   r7,r5,2
8620 +       beq     73f
8621 +       mtctr   r7
8622 +74:    stwu    r0,4(r6)
8623 +       bdnz    74b
8624 +73:    andi.   r5,r5,3
8625 +       beq     76f
8626 +       mtctr   r5
8627 +       addi    r6,r6,3
8628 +75:    stbu    r0,1(r6)
8629 +       bdnz    75b
8630 +76:    blr
8631 +/* here on a write fault in the initial single-byte copy */
8632 +80:    mfctr   r3
8633 +       add     r3,r3,r5
8634 +       blr
8635 +/* here on a write fault in the final single-byte copy */
8636 +81:    mfctr   r3
8637 +       blr
8638  
8639  .section __ex_table,"a"
8640         .align  2
8641 -       .long   70b,100b
8642 -       .long   71b,101b
8643 -       .long   72b,102b
8644 -       .long   73b,103b
8645 -       .long   53b,105b
8646 -       .long   10b,104b
8647 -       .long   11b,104b
8648 -       .long   12b,104b
8649 -       .long   13b,104b
8650 -       .long   14b,105b
8651 -       .long   15b,105b
8652 -       .long   16b,105b
8653 -       .long   17b,105b
8654 -       .long   20b,106b
8655 -       .long   21b,106b
8656 -       .long   22b,106b
8657 -       .long   23b,106b
8658 -       .long   24b,107b
8659 -       .long   25b,107b
8660 -       .long   26b,107b
8661 -       .long   27b,107b
8662 -       .long   30b,108b
8663 -       .long   31b,109b
8664 -       .long   40b,110b
8665 -       .long   41b,111b
8666 -       .long   112b,120b
8667 -       .long   114b,120b
8668 +       .long   1b,98b
8669 +       .long   11b,98b
8670 +       .long   12b,88b
8671 +       .long   13b,88b
8672 +       .long   14b,3b
8673 +       .long   15b,96b
8674 +       .long   4b,99b
8675 +       .long   16b,81b
8676 +       .long   6b,90b
8677 +       .long   17b,80b
8678 +       .long   77b,76b
8679 +       .long   74b,76b
8680 +       .long   75b,76b
8681  .text
8682  
8683         .globl  __clear_user
8684 @@ -511,6 +334,7 @@
8685         andi.   r0,r6,3
8686         add     r4,r0,r4
8687         subf    r6,r0,r6
8688 +       /*rlwinm        r0,r4,32-2,2,31*/
8689         srwi    r0,r4,2
8690         mtctr   r0
8691         bdz     6f
8692 diff -urN linux.orig/arch/ppc/mm/extable.c linux/arch/ppc/mm/extable.c
8693 --- linux.orig/arch/ppc/mm/extable.c    Sun Mar 25 18:31:48 2001
8694 +++ linux/arch/ppc/mm/extable.c Thu Jul 11 15:43:29 2002
8695 @@ -7,43 +7,8 @@
8696  #include <linux/module.h>
8697  #include <asm/uaccess.h>
8698  
8699 -extern struct exception_table_entry __start___ex_table[];
8700 -extern struct exception_table_entry __stop___ex_table[];
8701 -
8702 -/*
8703 - * The exception table needs to be sorted because we use the macros
8704 - * which put things into the exception table in a variety of segments
8705 - * such as the prep, pmac, chrp, etc. segments as well as the init
8706 - * segment and the main kernel text segment.
8707 - */
8708 -static inline void
8709 -sort_ex_table(struct exception_table_entry *start,
8710 -             struct exception_table_entry *finish)
8711 -{
8712 -       struct exception_table_entry el, *p, *q;
8713 -
8714 -       /* insertion sort */
8715 -       for (p = start + 1; p < finish; ++p) {
8716 -               /* start .. p-1 is sorted */
8717 -               if (p[0].insn < p[-1].insn) {
8718 -                       /* move element p down to its right place */
8719 -                       el = *p;
8720 -                       q = p;
8721 -                       do {
8722 -                               /* el comes before q[-1], move q[-1] up one */
8723 -                               q[0] = q[-1];
8724 -                               --q;
8725 -                       } while (q > start && el.insn < q[-1].insn);
8726 -                       *q = el;
8727 -               }
8728 -       }
8729 -}
8730 -
8731 -void
8732 -sort_exception_table(void)
8733 -{
8734 -       sort_ex_table(__start___ex_table, __stop___ex_table);
8735 -}
8736 +extern const struct exception_table_entry __start___ex_table[];
8737 +extern const struct exception_table_entry __stop___ex_table[];
8738  
8739  static inline unsigned long
8740  search_one_table(const struct exception_table_entry *first,
8741 @@ -71,7 +36,7 @@
8742  {
8743         unsigned long ret;
8744  
8745 -#ifndef CONFIG_MODULES
8746 +#if 1 /*ndef CONFIG_MODULES*/
8747         /* There is only the kernel to search.  */
8748         ret = search_one_table(__start___ex_table, __stop___ex_table-1, addr);
8749         if (ret) return ret;
8750 diff -urN linux.orig/arch/ppc/mm/fault.c linux/arch/ppc/mm/fault.c
8751 --- linux.orig/arch/ppc/mm/fault.c      Sun Mar 25 18:31:48 2001
8752 +++ linux/arch/ppc/mm/fault.c   Thu Jul 11 15:43:29 2002
8753 @@ -71,10 +71,7 @@
8754                (error_code&0x80000000)?"I/O ":"",
8755                (regs->trap == 0x400)?"instr":"data"
8756                );*/
8757 -
8758 -       if (regs->trap == 0x400)
8759 -               error_code &= 0x48200000;
8760 -
8761 +              
8762  #if defined(CONFIG_XMON) || defined(CONFIG_KGDB)
8763         if (debugger_fault_handler && regs->trap == 0x300) {
8764                 debugger_fault_handler(regs);
8765 diff -urN linux.orig/arch/ppc/mm/init.c linux/arch/ppc/mm/init.c
8766 --- linux.orig/arch/ppc/mm/init.c       Sun Mar 25 18:31:48 2001
8767 +++ linux/arch/ppc/mm/init.c    Thu Jul 11 15:43:30 2002
8768 @@ -416,12 +416,7 @@
8769  
8770  void iounmap(void *addr)
8771  {
8772 -       /* For support of dynamic hot swap on the cPCI bus this routine
8773 -          is now necessary.  This has been well tested on a Motorola
8774 -          MPC750 (Mesquite) processor board.  Johnnie Peters
8775 -       */
8776 -       if (addr > high_memory && (unsigned long) addr < ioremap_bot)
8777 -               return vfree((void *) (PAGE_MASK & (unsigned long) addr));
8778 +       /* XXX todo */
8779  }
8780  
8781  unsigned long iopa(unsigned long addr)
8782 @@ -933,21 +928,15 @@
8783                                 /* On the powerpc, no user access
8784                                    forces R/W kernel access */
8785                                 f |= _PAGE_USER;
8786 -                       map_page(v, p, f);
8787 -                       v += PAGE_SIZE;
8788 -                       p += PAGE_SIZE;
8789 -               }
8790 -       }
8791 -
8792  #else  /* CONFIG_8xx */
8793 -       for (i = 0; i < phys_mem.n_regions; ++i) {
8794 -               v = (ulong)__va(phys_mem.regions[i].address);
8795 -               p = phys_mem.regions[i].address;
8796 -               for (s = 0; s < phys_mem.regions[i].size; s += PAGE_SIZE) {
8797 +            for (i = 0; i < phys_mem.n_regions; ++i) {
8798 +                    v = (ulong)__va(phys_mem.regions[i].address);
8799 +                    p = phys_mem.regions[i].address;
8800 +                    for (s = 0; s < phys_mem.regions[i].size; s += PAGE_SIZE) {
8801                          /* On the MPC8xx, we want the page shared so we
8802                           * don't get ASID compares on kernel space.
8803                           */
8804 -                       f = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_SHARED;
8805 +                            f = _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_SHARED;
8806  
8807                          /* I don't really need the rest of this code, but
8808                           * I grabbed it because I think the line:
8809 @@ -957,14 +946,14 @@
8810                           * the MPC8xx, the PAGE_DIRTY takes care of that
8811                           * for us (along with the RW software state).
8812                           */
8813 -                       if ((char *) v < _stext || (char *) v >= etext)
8814 -                               f |= _PAGE_RW | _PAGE_DIRTY | _PAGE_HWWRITE;
8815 +                            if ((char *) v < _stext || (char *) v >= etext)
8816 +                                    f |= _PAGE_RW | _PAGE_DIRTY | _PAGE_HWWRITE;
8817 +#endif /* CONFIG_8xx */
8818                         map_page(v, p, f);
8819                         v += PAGE_SIZE;
8820                         p += PAGE_SIZE;
8821                 }
8822 -       }
8823 -#endif /* CONFIG_8xx */
8824 +       }           
8825  }
8826  
8827  /* This can get called from ioremap, so don't make it an initfunc, OK? */
8828 @@ -1044,9 +1033,6 @@
8829   * still be merged.
8830   * -- Cort
8831   */
8832 -#ifdef CONFIG_BOOTX_TEXT
8833 -extern boot_infos_t *disp_bi;
8834 -#endif
8835  __initfunc(void MMU_init(void))
8836  {
8837  #ifdef __SMP__
8838 @@ -1066,6 +1052,7 @@
8839  #endif /* CONFIG_GEMINI        */
8840         else /* prep */
8841                 end_of_DRAM = prep_find_end_of_memory();
8842 +*(unsigned long *)(KERNELBASE) = 0xdeadbeef;   
8843          hash_init();
8844          _SDR1 = __pa(Hash) | (Hash_mask >> 10);
8845         ioremap_base = 0xf8000000;
8846 @@ -1095,13 +1082,7 @@
8847                         struct device_node *macio = find_devices("mac-io");
8848                         if (macio && macio->n_addrs)
8849                                 base = macio->addrs[0].address;
8850 -                       /* Hrm... we have it at 0x80000000 on some machines
8851 -                        * and this is covered by the userland segment
8852 -                        * registers. Isn't that bad ? Well, the BAT takes
8853 -                        * precedence, but I don't like it. --BenH
8854 -                        */
8855 -                       if (base >= 0xf0000000)
8856 -                               setbat(0, base, base, 0x100000, IO_PAGE);
8857 +                       setbat(0, base, base, 0x100000, IO_PAGE);
8858                         ioremap_base = 0xf0000000;
8859                 }
8860                 break;
8861 @@ -1140,10 +1121,6 @@
8862          ioremap(0x80000000, 0x4000);
8863          ioremap(0x81000000, 0x4000);
8864  #endif /* CONFIG_8xx */
8865 -#ifdef CONFIG_BOOTX_TEXT
8866 -       if (_machine == _MACH_Pmac)
8867 -               map_bootx_text();
8868 -#endif
8869  }
8870  
8871  /*
8872 @@ -1275,8 +1252,8 @@
8873  #endif /* CONFIG_BLK_DEV_INITRD */
8874  #ifndef CONFIG_8xx               
8875                         if ( !rtas_data ||
8876 -                            addr < (rtas_data + KERNELBASE) ||
8877 -                            addr >= (rtas_data + KERNELBASE + rtas_size))
8878 +                            addr < (rtas_data & PAGE_MASK) ||
8879 +                            addr >= (rtas_data+rtas_size))
8880  #endif /* CONFIG_8xx */
8881                                 free_page(addr);
8882         }
8883 @@ -1337,7 +1314,6 @@
8884         return ret;
8885  }
8886  #endif /* CONFIG_MBX */
8887 -
8888  #ifndef CONFIG_8xx
8889  /*
8890   * On systems with Open Firmware, collect information about
8891 @@ -1404,7 +1380,6 @@
8892         if (boot_infos == 0) {
8893                 /* record which bits the prom is using */
8894                 get_mem_prop("available", &phys_avail);
8895 -               remove_mem_piece(&phys_avail, __max_memory, ~__max_memory, 0);
8896                 prom_mem = phys_mem;
8897                 for (i = 0; i < phys_avail.n_regions; ++i)
8898                         remove_mem_piece(&prom_mem,
8899 diff -urN linux.orig/arch/ppc/pmac_defconfig linux/arch/ppc/pmac_defconfig
8900 --- linux.orig/arch/ppc/pmac_defconfig  Sun Mar 25 18:31:50 2001
8901 +++ linux/arch/ppc/pmac_defconfig       Thu Jul 11 15:43:30 2002
8902 @@ -253,7 +253,6 @@
8903  CONFIG_NET_ETHERNET=y
8904  CONFIG_MACE=y
8905  CONFIG_BMAC=y
8906 -CONFIG_GMAC=y
8907  # CONFIG_NET_VENDOR_3COM is not set
8908  # CONFIG_LANCE is not set
8909  # CONFIG_NET_VENDOR_SMC is not set
8910 @@ -340,7 +339,6 @@
8911  CONFIG_FB_PLATINUM=y
8912  CONFIG_FB_VALKYRIE=y
8913  CONFIG_FB_ATY=y
8914 -CONFIG_FB_ATY128=y
8915  CONFIG_FB_IMSTT=y
8916  CONFIG_FB_CT65550=y
8917  # CONFIG_FB_S3TRIO is not set
8918 diff -urN linux.orig/arch/ppc/xmon/start.c linux/arch/ppc/xmon/start.c
8919 --- linux.orig/arch/ppc/xmon/start.c    Sun Mar 25 18:31:50 2001
8920 +++ linux/arch/ppc/xmon/start.c Thu Jul 11 15:43:30 2002
8921 @@ -11,30 +11,16 @@
8922  #include <asm/prom.h>
8923  #include <asm/bootx.h>
8924  #include <asm/pmu.h>
8925 -#include <asm/feature.h>
8926  
8927  static volatile unsigned char *sccc, *sccd;
8928  unsigned long TXRDY, RXRDY;
8929  extern void xmon_printf(const char *fmt, ...);
8930 +extern void map_bootx_text(void);
8931  extern void drawchar(char);
8932  extern void drawstring(const char *str);
8933 -static int xmon_expect(const char *str, unsigned int timeout);
8934  
8935  static int console = 0;
8936  static int use_screen = 0;
8937 -static int via_modem = 0;
8938 -static int xmon_use_sccb = 0;
8939 -static struct device_node *macio_node;
8940 -
8941 -#define TB_SPEED       25000000
8942 -
8943 -static inline unsigned int readtb(void)
8944 -{
8945 -       unsigned int ret;
8946 -
8947 -       asm volatile("mftb %0" : "=r" (ret) :);
8948 -       return ret;
8949 -}
8950  
8951  void buf_access(void)
8952  {
8953 @@ -50,18 +36,17 @@
8954         if ( _machine == _MACH_Pmac )
8955         {
8956                 struct device_node *np;
8957 +               extern boot_infos_t *boot_infos;
8958                 unsigned long addr;
8959 -#ifdef CONFIG_BOOTX_TEXT
8960 -               extern boot_infos_t *disp_bi;
8961  
8962 -               /* needs to be hacked if xmon_printk is to be used
8963 -                  from within find_via_pmu() */
8964 -               if (!via_modem && disp_bi && find_via_pmu()) {
8965 +#ifdef CONFIG_BOOTX_TEXT
8966 +               if (boot_infos != 0 && find_via_pmu()) {
8967                         printk(KERN_INFO "xmon uses screen and keyboard\n");
8968                         use_screen = 1;
8969 +                       map_bootx_text();
8970 +                       return;
8971                 }
8972  #endif
8973 -
8974  #ifdef CHRP_ESCC
8975                 addr = 0xc1013020;
8976  #else
8977 @@ -72,13 +57,18 @@
8978                 
8979                 np = find_devices("mac-io");
8980                 if (np && np->n_addrs) {
8981 -                       macio_node = np;
8982 -                       addr = np->addrs[0].address + 0x13020;
8983 +                       addr = np->addrs[0].address + 0x13000;
8984 +                       /* use the B channel on the iMac, A channel on others */
8985 +                       if (addr >= 0xf0000000)
8986 +                               addr += 0x20; /* use A channel */
8987                 }
8988 -               base = (volatile unsigned char *)
8989 -                       ioremap(addr & PAGE_MASK, PAGE_SIZE);
8990 +               base = (volatile unsigned char *) ioremap(addr & PAGE_MASK, PAGE_SIZE);
8991                 sccc = base + (addr & ~PAGE_MASK);
8992 -               sccd = sccc + 0x10;
8993 +#ifdef CHRP_ESCC
8994 +               sccd = sccc + (0xc1013030 - 0xc1013020);
8995 +#else
8996 +               sccd = sccc + (0xf3013030 - 0xf3013020);
8997 +#endif
8998         }
8999         else
9000         {
9001 @@ -99,7 +89,7 @@
9002  xmon_write(void *handle, void *ptr, int nb)
9003  {
9004      char *p = ptr;
9005 -    int i, c, ct;
9006 +    int i, ct;
9007  
9008  #ifdef CONFIG_BOOTX_TEXT
9009      if (use_screen) {
9010 @@ -111,23 +101,19 @@
9011  #endif
9012      if (!scc_initialized)
9013         xmon_init_scc();
9014 -    ct = 0;
9015      for (i = 0; i < nb; ++i) {
9016         while ((*sccc & TXRDY) == 0)
9017             if (adb_hardware == ADB_VIAPMU)
9018                 pmu_poll();
9019 -       c = p[i];
9020 -       if (c == '\n' && !ct) {
9021 -           c = '\r';
9022 -           ct = 1;
9023 -           --i;
9024 -       } else {
9025 -           if (console)
9026 -               printk("%c", c);
9027 -           ct = 0;
9028 -       }
9029         buf_access();
9030 -       *sccd = c;
9031 +       if ( console && (*p != '\r'))
9032 +               printk("%c", *p);
9033 +       ct = 0;
9034 +       if ( *p == '\n')
9035 +               ct = 1;
9036 +       *sccd = *p++;
9037 +       if ( ct )
9038 +               xmon_write(handle, "\r", 1);
9039      }
9040      return i;
9041  }
9042 @@ -213,30 +199,23 @@
9043             if (adb_hardware == ADB_VIAPMU)
9044                 pmu_poll();
9045         buf_access();
9046 -       *p++ = *sccd;
9047 +#if 0  
9048 +       if ( 0/*console*/ )
9049 +               *p++ = ppc_md.kbd_getkeycode();
9050 +       else
9051 +#endif         
9052 +               *p++ = *sccd;
9053      }
9054      return i;
9055  }
9056  
9057 -int
9058 -xmon_read_poll(void)
9059 -{
9060 -       if ((*sccc & RXRDY) == 0) {
9061 -               if (adb_hardware == ADB_VIAPMU)
9062 -                       pmu_poll();
9063 -               return -1;
9064 -       }
9065 -       buf_access();
9066 -       return *sccd;
9067 -}
9068 -
9069  static unsigned char scc_inittab[] = {
9070      13, 0,             /* set baud rate divisor */
9071      12, 1,
9072      14, 1,             /* baud rate gen enable, src=rtxc */
9073      11, 0x50,          /* clocks = br gen */
9074 -    5,  0xea,          /* tx 8 bits, assert DTR & RTS */
9075 -    4,  0x46,          /* x16 clock, 1 stop */
9076 +    5,  0x6a,          /* tx 8 bits, assert RTS */
9077 +    4,  0x44,          /* x16 clock, 1 stop */
9078      3,  0xc1,          /* rx enable, 8 bits */
9079  };
9080  
9081 @@ -256,21 +235,6 @@
9082         {
9083                 int i, x;
9084  
9085 -               if (macio_node != 0) {
9086 -                       unsigned int t0;
9087 -
9088 -                       feature_set(macio_node, FEATURE_Serial_enable);
9089 -                       if (via_modem) {
9090 -                               feature_set(macio_node, FEATURE_Modem_power);
9091 -                               t0 = readtb();
9092 -                               while (readtb() - t0 < 3*TB_SPEED)
9093 -                                       eieio();
9094 -                       }
9095 -               }
9096 -               if (xmon_use_sccb) {
9097 -                       sccc -= 0x20;
9098 -                       sccd -= 0x20;
9099 -               }
9100                 for (i = 20000; i != 0; --i) {
9101                         x = *sccc; eieio();
9102                 }
9103 @@ -282,18 +246,6 @@
9104                 }
9105         }
9106         scc_initialized = 1;
9107 -       if (via_modem) {
9108 -               for (;;) {
9109 -                       xmon_write(0, "ATE1V1\r", 7);
9110 -                       if (xmon_expect("OK", 5)) {
9111 -                               xmon_write(0, "ATA\r", 4);
9112 -                               if (xmon_expect("CONNECT", 40))
9113 -                                       break;
9114 -                       }
9115 -                       xmon_write(0, "+++", 3);
9116 -                       xmon_expect("OK", 3);
9117 -               }
9118 -       }
9119  }
9120  
9121  #if 0
9122 @@ -366,35 +318,6 @@
9123  static char *lineptr;
9124  static int lineleft;
9125  
9126 -int xmon_expect(const char *str, unsigned int timeout)
9127 -{
9128 -       int c;
9129 -       unsigned int t0;
9130 -
9131 -       timeout *= TB_SPEED;
9132 -       t0 = readtb();
9133 -       do {
9134 -               lineptr = line;
9135 -               for (;;) {
9136 -                       c = xmon_read_poll();
9137 -                       if (c == -1) {
9138 -                               if (readtb() - t0 > timeout) {
9139 -                                       printk("timeout\n");
9140 -                                       return 0;
9141 -                               }
9142 -                               continue;
9143 -                       }
9144 -                       if (c == '\n')
9145 -                               break;
9146 -                       printk("%c", c);
9147 -                       if (c != '\r' && lineptr < &line[sizeof(line) - 1])
9148 -                               *lineptr++ = c;
9149 -               }
9150 -               *lineptr = 0;
9151 -       } while (strstr(line, str) == NULL);
9152 -       return 1;
9153 -}
9154 -
9155  int
9156  xmon_getchar(void)
9157  {
9158 @@ -467,15 +390,3 @@
9159      *p = 0;
9160      return str;
9161  }
9162 -
9163 -void
9164 -xmon_enter(void)
9165 -{
9166 -       pmu_suspend();
9167 -}
9168 -
9169 -void
9170 -xmon_leave(void)
9171 -{
9172 -       pmu_resume();
9173 -}
9174 diff -urN linux.orig/arch/ppc/xmon/xmon.c linux/arch/ppc/xmon/xmon.c
9175 --- linux.orig/arch/ppc/xmon/xmon.c     Sun Mar 25 18:31:50 2001
9176 +++ linux/arch/ppc/xmon/xmon.c  Thu Jul 11 15:43:30 2002
9177 @@ -86,9 +86,6 @@
9178  extern int setjmp(u_int *);
9179  extern void longjmp(u_int *, int);
9180  
9181 -extern void xmon_enter(void);
9182 -extern void xmon_leave(void);
9183 -
9184  #define GETWORD(v)     (((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3])
9185  
9186  static char *help_string = "\
9187 @@ -142,7 +139,6 @@
9188         msr = get_msr();
9189         set_msr(msr & ~0x8000); /* disable interrupts */
9190         remove_bpts();
9191 -       xmon_enter();
9192         excprint(excp);
9193         cmd = cmds(excp);
9194         if (cmd == 's') {
9195 @@ -155,7 +151,6 @@
9196                 xmon_trace = 0;
9197                 insert_bpts();
9198         }
9199 -       xmon_leave();
9200         set_msr(msr);           /* restore interrupt enable */
9201  }
9202  
9203 diff -urN linux.orig/include/asm-ppc/irq-compat.h linux/include/asm-ppc/irq-compat.h
9204 --- linux.orig/include/asm-ppc/irq-compat.h     Thu Jan  1 01:00:00 1970
9205 +++ linux/include/asm-ppc/irq-compat.h  Thu Jul 11 15:43:30 2002
9206 @@ -0,0 +1,8 @@
9207 +#include <asm/irq.h>
9208 +
9209 +//#define NUM_8259_INTERRUPTS  16
9210 +//#define NUM_OPENPIC_INTERRUPTS       20
9211 +//#define is_8259_irq(n)               ((n) < NUM_8259_INTERRUPTS)
9212 +#define openpic_to_irq(n)      ((n)+NUM_8259_INTERRUPTS)
9213 +//#define irq_to_openpic(n)    ((n)-NUM_8259_INTERRUPTS)
9214 +//#define IRQ_8259_CASCADE     NUM_8259_INTERRUPTS
9215 diff -urN linux.orig/include/asm-ppc/ohare-compat.h linux/include/asm-ppc/ohare-compat.h
9216 --- linux.orig/include/asm-ppc/ohare-compat.h   Thu Jan  1 01:00:00 1970
9217 +++ linux/include/asm-ppc/ohare-compat.h        Thu Jul 11 15:43:30 2002
9218 @@ -0,0 +1,7 @@
9219 +#define OH_BAY_RESET           2       /* a guess */
9220 +#define OH_IDE_ENABLE          0x20
9221 +#define OH_IDE_POWER           0x40    /* a guess */
9222 +#define OH_BAY_ENABLE          0x80
9223 +#define OH_IDE_RESET           0x100   /* 0-based, a guess */
9224 +#define OH_VIA_ENABLE          0x10000
9225 +#define OH_IDECD_POWER         0x800000
9226 diff -urN linux.orig/include/asm-ppc/page.h linux/include/asm-ppc/page.h
9227 --- linux.orig/include/asm-ppc/page.h   Sun Mar 25 18:37:39 2001
9228 +++ linux/include/asm-ppc/page.h        Thu Jul 11 15:43:30 2002
9229 @@ -77,7 +77,7 @@
9230  #define PAGE_ALIGN(addr)       (((addr)+PAGE_SIZE-1)&PAGE_MASK)
9231  
9232  extern void clear_page(unsigned long page);
9233 -extern void copy_page(unsigned long to, unsigned long from);
9234 +#define copy_page(to,from)     memcpy((void *)(to), (void *)(from), PAGE_SIZE)
9235  
9236  /* map phys->virtual and virtual->phys for RAM pages */
9237  #ifdef CONFIG_APUS
9238 diff -urN linux.orig/include/asm-ppc/pf-compat.h linux/include/asm-ppc/pf-compat.h
9239 --- linux.orig/include/asm-ppc/pf-compat.h      Thu Jan  1 01:00:00 1970
9240 +++ linux/include/asm-ppc/pf-compat.h   Thu Jul 11 15:43:30 2002
9241 @@ -0,0 +1,2 @@
9242 +#define PF_TRACESYS    0x00000020      /* tracing system calls */
9243 +#define PF_PTRACED     0x00000010      /* set if ptrace (0) has been called */
This page took 0.724727 seconds and 3 git commands to generate.