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