diff options
68 files changed, 437 insertions, 3554 deletions
diff --git a/Documentation/Changes b/Documentation/Changes index afebdbcd553a..dfec7569d450 100644 --- a/Documentation/Changes +++ b/Documentation/Changes | |||
@@ -57,7 +57,7 @@ o e2fsprogs 1.29 # tune2fs | |||
57 | o jfsutils 1.1.3 # fsck.jfs -V | 57 | o jfsutils 1.1.3 # fsck.jfs -V |
58 | o reiserfsprogs 3.6.3 # reiserfsck -V 2>&1|grep reiserfsprogs | 58 | o reiserfsprogs 3.6.3 # reiserfsck -V 2>&1|grep reiserfsprogs |
59 | o xfsprogs 2.6.0 # xfs_db -V | 59 | o xfsprogs 2.6.0 # xfs_db -V |
60 | o pcmciautils 001 | 60 | o pcmciautils 004 |
61 | o pcmcia-cs 3.1.21 # cardmgr -V | 61 | o pcmcia-cs 3.1.21 # cardmgr -V |
62 | o quota-tools 3.09 # quota -V | 62 | o quota-tools 3.09 # quota -V |
63 | o PPP 2.4.0 # pppd --version | 63 | o PPP 2.4.0 # pppd --version |
diff --git a/Documentation/pcmcia/devicetable.txt b/Documentation/pcmcia/devicetable.txt index 045511acafc9..3351c0355143 100644 --- a/Documentation/pcmcia/devicetable.txt +++ b/Documentation/pcmcia/devicetable.txt | |||
@@ -19,9 +19,8 @@ PCMCIA_DEVICE_PROD_ID1("some_string", 0x(hash_of_some_string)), | |||
19 | If the hash is incorrect, the kernel will inform you about this in "dmesg" | 19 | If the hash is incorrect, the kernel will inform you about this in "dmesg" |
20 | upon module initialization, and tell you of the correct hash. | 20 | upon module initialization, and tell you of the correct hash. |
21 | 21 | ||
22 | You can determine the hash of the product ID strings by running | 22 | You can determine the hash of the product ID strings by catting the file |
23 | "pcmcia-modalias %n.%m" [%n being replaced with the socket number and %m being | 23 | "modalias" in the sysfs directory of the PCMCIA device. It generates a string |
24 | replaced with the device function] from pcmciautils. It generates a string | ||
25 | in the following form: | 24 | in the following form: |
26 | pcmcia:m0149cC1ABf06pfn00fn00pa725B842DpbF1EFEE84pc0877B627pd00000000 | 25 | pcmcia:m0149cC1ABf06pfn00fn00pa725B842DpbF1EFEE84pc0877B627pd00000000 |
27 | 26 | ||
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c index 93df90bbb87e..bd1dbf3bd223 100644 --- a/arch/i386/kernel/apic.c +++ b/arch/i386/kernel/apic.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <asm/desc.h> | 35 | #include <asm/desc.h> |
36 | #include <asm/arch_hooks.h> | 36 | #include <asm/arch_hooks.h> |
37 | #include <asm/hpet.h> | 37 | #include <asm/hpet.h> |
38 | #include <asm/i8253.h> | ||
38 | 39 | ||
39 | #include <mach_apic.h> | 40 | #include <mach_apic.h> |
40 | 41 | ||
@@ -879,7 +880,6 @@ fake_ioapic_page: | |||
879 | */ | 880 | */ |
880 | static unsigned int __devinit get_8254_timer_count(void) | 881 | static unsigned int __devinit get_8254_timer_count(void) |
881 | { | 882 | { |
882 | extern spinlock_t i8253_lock; | ||
883 | unsigned long flags; | 883 | unsigned long flags; |
884 | 884 | ||
885 | unsigned int count; | 885 | unsigned int count; |
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c index d48ce9290963..064211d5f41b 100644 --- a/arch/i386/kernel/apm.c +++ b/arch/i386/kernel/apm.c | |||
@@ -228,10 +228,10 @@ | |||
228 | #include <asm/system.h> | 228 | #include <asm/system.h> |
229 | #include <asm/uaccess.h> | 229 | #include <asm/uaccess.h> |
230 | #include <asm/desc.h> | 230 | #include <asm/desc.h> |
231 | #include <asm/i8253.h> | ||
231 | 232 | ||
232 | #include "io_ports.h" | 233 | #include "io_ports.h" |
233 | 234 | ||
234 | extern spinlock_t i8253_lock; | ||
235 | extern unsigned long get_cmos_time(void); | 235 | extern unsigned long get_cmos_time(void); |
236 | extern void machine_real_restart(unsigned char *, int); | 236 | extern void machine_real_restart(unsigned char *, int); |
237 | 237 | ||
@@ -1168,8 +1168,7 @@ static void get_time_diff(void) | |||
1168 | static void reinit_timer(void) | 1168 | static void reinit_timer(void) |
1169 | { | 1169 | { |
1170 | #ifdef INIT_TIMER_AFTER_SUSPEND | 1170 | #ifdef INIT_TIMER_AFTER_SUSPEND |
1171 | unsigned long flags; | 1171 | unsigned long flags; |
1172 | extern spinlock_t i8253_lock; | ||
1173 | 1172 | ||
1174 | spin_lock_irqsave(&i8253_lock, flags); | 1173 | spin_lock_irqsave(&i8253_lock, flags); |
1175 | /* set the clock to 100 Hz */ | 1174 | /* set the clock to 100 Hz */ |
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 35eb8e29c485..6578f40bd501 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <asm/smp.h> | 37 | #include <asm/smp.h> |
38 | #include <asm/desc.h> | 38 | #include <asm/desc.h> |
39 | #include <asm/timer.h> | 39 | #include <asm/timer.h> |
40 | #include <asm/i8259.h> | ||
40 | 41 | ||
41 | #include <mach_apic.h> | 42 | #include <mach_apic.h> |
42 | 43 | ||
@@ -1566,7 +1567,6 @@ void print_all_local_APICs (void) | |||
1566 | 1567 | ||
1567 | void /*__init*/ print_PIC(void) | 1568 | void /*__init*/ print_PIC(void) |
1568 | { | 1569 | { |
1569 | extern spinlock_t i8259A_lock; | ||
1570 | unsigned int v; | 1570 | unsigned int v; |
1571 | unsigned long flags; | 1571 | unsigned long flags; |
1572 | 1572 | ||
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c index e68d9fdb0759..2854c357377f 100644 --- a/arch/i386/kernel/time.c +++ b/arch/i386/kernel/time.c | |||
@@ -68,7 +68,8 @@ | |||
68 | 68 | ||
69 | #include "io_ports.h" | 69 | #include "io_ports.h" |
70 | 70 | ||
71 | extern spinlock_t i8259A_lock; | 71 | #include <asm/i8259.h> |
72 | |||
72 | int pit_latch_buggy; /* extern */ | 73 | int pit_latch_buggy; /* extern */ |
73 | 74 | ||
74 | #include "do_timer.h" | 75 | #include "do_timer.h" |
@@ -85,6 +86,8 @@ extern unsigned long wall_jiffies; | |||
85 | DEFINE_SPINLOCK(rtc_lock); | 86 | DEFINE_SPINLOCK(rtc_lock); |
86 | EXPORT_SYMBOL(rtc_lock); | 87 | EXPORT_SYMBOL(rtc_lock); |
87 | 88 | ||
89 | #include <asm/i8253.h> | ||
90 | |||
88 | DEFINE_SPINLOCK(i8253_lock); | 91 | DEFINE_SPINLOCK(i8253_lock); |
89 | EXPORT_SYMBOL(i8253_lock); | 92 | EXPORT_SYMBOL(i8253_lock); |
90 | 93 | ||
diff --git a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c index f6f1206a11bb..13892a65c941 100644 --- a/arch/i386/kernel/timers/timer_cyclone.c +++ b/arch/i386/kernel/timers/timer_cyclone.c | |||
@@ -17,9 +17,9 @@ | |||
17 | #include <asm/io.h> | 17 | #include <asm/io.h> |
18 | #include <asm/pgtable.h> | 18 | #include <asm/pgtable.h> |
19 | #include <asm/fixmap.h> | 19 | #include <asm/fixmap.h> |
20 | #include "io_ports.h" | 20 | #include <asm/i8253.h> |
21 | 21 | ||
22 | extern spinlock_t i8253_lock; | 22 | #include "io_ports.h" |
23 | 23 | ||
24 | /* Number of usecs that the last interrupt was delayed */ | 24 | /* Number of usecs that the last interrupt was delayed */ |
25 | static int delay_at_last_interrupt; | 25 | static int delay_at_last_interrupt; |
diff --git a/arch/i386/kernel/timers/timer_pit.c b/arch/i386/kernel/timers/timer_pit.c index 967d5453cd0e..06de036a820c 100644 --- a/arch/i386/kernel/timers/timer_pit.c +++ b/arch/i386/kernel/timers/timer_pit.c | |||
@@ -15,9 +15,8 @@ | |||
15 | #include <asm/smp.h> | 15 | #include <asm/smp.h> |
16 | #include <asm/io.h> | 16 | #include <asm/io.h> |
17 | #include <asm/arch_hooks.h> | 17 | #include <asm/arch_hooks.h> |
18 | #include <asm/i8253.h> | ||
18 | 19 | ||
19 | extern spinlock_t i8259A_lock; | ||
20 | extern spinlock_t i8253_lock; | ||
21 | #include "do_timer.h" | 20 | #include "do_timer.h" |
22 | #include "io_ports.h" | 21 | #include "io_ports.h" |
23 | 22 | ||
@@ -166,7 +165,6 @@ struct init_timer_opts __initdata timer_pit_init = { | |||
166 | 165 | ||
167 | void setup_pit_timer(void) | 166 | void setup_pit_timer(void) |
168 | { | 167 | { |
169 | extern spinlock_t i8253_lock; | ||
170 | unsigned long flags; | 168 | unsigned long flags; |
171 | 169 | ||
172 | spin_lock_irqsave(&i8253_lock, flags); | 170 | spin_lock_irqsave(&i8253_lock, flags); |
diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c index f46e625bab67..8f4e4d5bc560 100644 --- a/arch/i386/kernel/timers/timer_tsc.c +++ b/arch/i386/kernel/timers/timer_tsc.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "mach_timer.h" | 24 | #include "mach_timer.h" |
25 | 25 | ||
26 | #include <asm/hpet.h> | 26 | #include <asm/hpet.h> |
27 | #include <asm/i8253.h> | ||
27 | 28 | ||
28 | #ifdef CONFIG_HPET_TIMER | 29 | #ifdef CONFIG_HPET_TIMER |
29 | static unsigned long hpet_usec_quotient; | 30 | static unsigned long hpet_usec_quotient; |
@@ -35,8 +36,6 @@ static inline void cpufreq_delayed_get(void); | |||
35 | 36 | ||
36 | int tsc_disable __devinitdata = 0; | 37 | int tsc_disable __devinitdata = 0; |
37 | 38 | ||
38 | extern spinlock_t i8253_lock; | ||
39 | |||
40 | static int use_tsc; | 39 | static int use_tsc; |
41 | /* Number of usecs that the last interrupt was delayed */ | 40 | /* Number of usecs that the last interrupt was delayed */ |
42 | static int delay_at_last_interrupt; | 41 | static int delay_at_last_interrupt; |
diff --git a/arch/i386/mach-voyager/voyager_basic.c b/arch/i386/mach-voyager/voyager_basic.c index 602aea240e9b..3e439ce5e1b2 100644 --- a/arch/i386/mach-voyager/voyager_basic.c +++ b/arch/i386/mach-voyager/voyager_basic.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/irq.h> | 30 | #include <linux/irq.h> |
31 | #include <asm/tlbflush.h> | 31 | #include <asm/tlbflush.h> |
32 | #include <asm/arch_hooks.h> | 32 | #include <asm/arch_hooks.h> |
33 | #include <asm/i8253.h> | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Power off function, if any | 36 | * Power off function, if any |
@@ -182,7 +183,6 @@ voyager_timer_interrupt(struct pt_regs *regs) | |||
182 | * and swiftly introduce it to something sharp and | 183 | * and swiftly introduce it to something sharp and |
183 | * pointy. */ | 184 | * pointy. */ |
184 | __u16 val; | 185 | __u16 val; |
185 | extern spinlock_t i8253_lock; | ||
186 | 186 | ||
187 | spin_lock(&i8253_lock); | 187 | spin_lock(&i8253_lock); |
188 | 188 | ||
diff --git a/arch/ppc/kernel/relocate_kernel.S b/arch/ppc/kernel/relocate_kernel.S index 7ff69c4af920..9b2ad48e988c 100644 --- a/arch/ppc/kernel/relocate_kernel.S +++ b/arch/ppc/kernel/relocate_kernel.S | |||
@@ -34,9 +34,9 @@ relocate_new_kernel: | |||
34 | 34 | ||
35 | mr r8, r0 | 35 | mr r8, r0 |
36 | ori r8, r8, MSR_RI|MSR_ME | 36 | ori r8, r8, MSR_RI|MSR_ME |
37 | mtspr SRR1, r8 | 37 | mtspr SPRN_SRR1, r8 |
38 | addi r8, r4, 1f - relocate_new_kernel | 38 | addi r8, r4, 1f - relocate_new_kernel |
39 | mtspr SRR0, r8 | 39 | mtspr SPRN_SRR0, r8 |
40 | sync | 40 | sync |
41 | rfi | 41 | rfi |
42 | 42 | ||
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.c b/arch/ppc/platforms/85xx/mpc8540_ads.c index ddd2e9a5bb12..f761fdf160db 100644 --- a/arch/ppc/platforms/85xx/mpc8540_ads.c +++ b/arch/ppc/platforms/85xx/mpc8540_ads.c | |||
@@ -111,8 +111,8 @@ mpc8540ads_setup_arch(void) | |||
111 | memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6); | 111 | memcpy(pdata->mac_addr, binfo->bi_enet1addr, 6); |
112 | } | 112 | } |
113 | 113 | ||
114 | pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_FEC); | ||
114 | if (pdata) { | 115 | if (pdata) { |
115 | pdata = (struct gianfar_platform_data *) ppc_sys_get_pdata(MPC85xx_FEC); | ||
116 | pdata->board_flags = 0; | 116 | pdata->board_flags = 0; |
117 | pdata->interruptPHY = MPC85xx_IRQ_EXT5; | 117 | pdata->interruptPHY = MPC85xx_IRQ_EXT5; |
118 | pdata->phyid = 3; | 118 | pdata->phyid = 3; |
diff --git a/arch/ppc64/boot/Makefile b/arch/ppc64/boot/Makefile index d3e1d6af9203..683b2d43c15f 100644 --- a/arch/ppc64/boot/Makefile +++ b/arch/ppc64/boot/Makefile | |||
@@ -52,7 +52,7 @@ obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section))) | |||
52 | src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section))) | 52 | src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section))) |
53 | gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section))) | 53 | gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section))) |
54 | 54 | ||
55 | hostprogs-y := piggy addnote addRamDisk | 55 | hostprogs-y := addnote addRamDisk |
56 | targets += zImage zImage.initrd imagesize.c \ | 56 | targets += zImage zImage.initrd imagesize.c \ |
57 | $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \ | 57 | $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \ |
58 | $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \ | 58 | $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \ |
@@ -78,9 +78,6 @@ addsection = $(CROSS32OBJCOPY) $(1) \ | |||
78 | quiet_cmd_addnote = ADDNOTE $@ | 78 | quiet_cmd_addnote = ADDNOTE $@ |
79 | cmd_addnote = $(CROSS32LD) $(BOOTLFLAGS) -o $@ $(obj-boot) && $(obj)/addnote $@ | 79 | cmd_addnote = $(CROSS32LD) $(BOOTLFLAGS) -o $@ $(obj-boot) && $(obj)/addnote $@ |
80 | 80 | ||
81 | quiet_cmd_piggy = PIGGY $@ | ||
82 | cmd_piggy = $(obj)/piggyback $(@:.o=) < $< | $(CROSS32AS) -o $@ | ||
83 | |||
84 | $(call gz-sec, $(required)): $(obj)/kernel-%.gz: % FORCE | 81 | $(call gz-sec, $(required)): $(obj)/kernel-%.gz: % FORCE |
85 | $(call if_changed,gzip) | 82 | $(call if_changed,gzip) |
86 | 83 | ||
diff --git a/arch/ppc64/boot/main.c b/arch/ppc64/boot/main.c index da12ea2ca464..199d9804f61c 100644 --- a/arch/ppc64/boot/main.c +++ b/arch/ppc64/boot/main.c | |||
@@ -17,7 +17,6 @@ | |||
17 | 17 | ||
18 | extern void *finddevice(const char *); | 18 | extern void *finddevice(const char *); |
19 | extern int getprop(void *, const char *, void *, int); | 19 | extern int getprop(void *, const char *, void *, int); |
20 | extern void printk(char *fmt, ...); | ||
21 | extern void printf(const char *fmt, ...); | 20 | extern void printf(const char *fmt, ...); |
22 | extern int sprintf(char *buf, const char *fmt, ...); | 21 | extern int sprintf(char *buf, const char *fmt, ...); |
23 | void gunzip(void *, int, unsigned char *, int *); | 22 | void gunzip(void *, int, unsigned char *, int *); |
@@ -147,10 +146,10 @@ void start(unsigned long a1, unsigned long a2, void *promptr) | |||
147 | } | 146 | } |
148 | a1 = initrd.addr; | 147 | a1 = initrd.addr; |
149 | a2 = initrd.size; | 148 | a2 = initrd.size; |
150 | printf("initial ramdisk moving 0x%lx <- 0x%lx (%lx bytes)\n\r", | 149 | printf("initial ramdisk moving 0x%lx <- 0x%lx (0x%lx bytes)\n\r", |
151 | initrd.addr, (unsigned long)_initrd_start, initrd.size); | 150 | initrd.addr, (unsigned long)_initrd_start, initrd.size); |
152 | memmove((void *)initrd.addr, (void *)_initrd_start, initrd.size); | 151 | memmove((void *)initrd.addr, (void *)_initrd_start, initrd.size); |
153 | printf("initrd head: 0x%lx\n\r", *((u32 *)initrd.addr)); | 152 | printf("initrd head: 0x%lx\n\r", *((unsigned long *)initrd.addr)); |
154 | } | 153 | } |
155 | 154 | ||
156 | /* Eventually gunzip the kernel */ | 155 | /* Eventually gunzip the kernel */ |
@@ -201,9 +200,6 @@ void start(unsigned long a1, unsigned long a2, void *promptr) | |||
201 | 200 | ||
202 | flush_cache((void *)vmlinux.addr, vmlinux.size); | 201 | flush_cache((void *)vmlinux.addr, vmlinux.size); |
203 | 202 | ||
204 | if (a1) | ||
205 | printf("initrd head: 0x%lx\n\r", *((u32 *)initrd.addr)); | ||
206 | |||
207 | kernel_entry = (kernel_entry_t)vmlinux.addr; | 203 | kernel_entry = (kernel_entry_t)vmlinux.addr; |
208 | #ifdef DEBUG | 204 | #ifdef DEBUG |
209 | printf( "kernel:\n\r" | 205 | printf( "kernel:\n\r" |
diff --git a/arch/ppc64/boot/mknote.c b/arch/ppc64/boot/mknote.c deleted file mode 100644 index 120cc1d89739..000000000000 --- a/arch/ppc64/boot/mknote.c +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) Cort Dougan 1999. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * Generate a note section as per the CHRP specification. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <stdio.h> | ||
14 | |||
15 | #define PL(x) printf("%c%c%c%c", ((x)>>24)&0xff, ((x)>>16)&0xff, ((x)>>8)&0xff, (x)&0xff ); | ||
16 | |||
17 | int main(void) | ||
18 | { | ||
19 | /* header */ | ||
20 | /* namesz */ | ||
21 | PL(strlen("PowerPC")+1); | ||
22 | /* descrsz */ | ||
23 | PL(6*4); | ||
24 | /* type */ | ||
25 | PL(0x1275); | ||
26 | /* name */ | ||
27 | printf("PowerPC"); printf("%c", 0); | ||
28 | |||
29 | /* descriptor */ | ||
30 | /* real-mode */ | ||
31 | PL(0xffffffff); | ||
32 | /* real-base */ | ||
33 | PL(0x00c00000); | ||
34 | /* real-size */ | ||
35 | PL(0xffffffff); | ||
36 | /* virt-base */ | ||
37 | PL(0xffffffff); | ||
38 | /* virt-size */ | ||
39 | PL(0xffffffff); | ||
40 | /* load-base */ | ||
41 | PL(0x4000); | ||
42 | return 0; | ||
43 | } | ||
diff --git a/arch/ppc64/boot/piggyback.c b/arch/ppc64/boot/piggyback.c deleted file mode 100644 index 235c7a87269c..000000000000 --- a/arch/ppc64/boot/piggyback.c +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2001 IBM Corp | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | #include <stdio.h> | ||
10 | #include <unistd.h> | ||
11 | #include <string.h> | ||
12 | |||
13 | extern long ce_exec_config[]; | ||
14 | |||
15 | int main(int argc, char *argv[]) | ||
16 | { | ||
17 | int i, cnt, pos, len; | ||
18 | unsigned int cksum, val; | ||
19 | unsigned char *lp; | ||
20 | unsigned char buf[8192]; | ||
21 | char *varname; | ||
22 | if (argc != 2) | ||
23 | { | ||
24 | fprintf(stderr, "usage: %s name <in-file >out-file\n", | ||
25 | argv[0]); | ||
26 | exit(1); | ||
27 | } | ||
28 | |||
29 | varname = strrchr(argv[1], '/'); | ||
30 | if (varname) | ||
31 | varname++; | ||
32 | else | ||
33 | varname = argv[1]; | ||
34 | |||
35 | fprintf(stdout, "#\n"); | ||
36 | fprintf(stdout, "# Miscellaneous data structures:\n"); | ||
37 | fprintf(stdout, "# WARNING - this file is automatically generated!\n"); | ||
38 | fprintf(stdout, "#\n"); | ||
39 | fprintf(stdout, "\n"); | ||
40 | fprintf(stdout, "\t.data\n"); | ||
41 | fprintf(stdout, "\t.globl %s_data\n", varname); | ||
42 | fprintf(stdout, "%s_data:\n", varname); | ||
43 | pos = 0; | ||
44 | cksum = 0; | ||
45 | while ((len = read(0, buf, sizeof(buf))) > 0) | ||
46 | { | ||
47 | cnt = 0; | ||
48 | lp = (unsigned char *)buf; | ||
49 | len = (len + 3) & ~3; /* Round up to longwords */ | ||
50 | for (i = 0; i < len; i += 4) | ||
51 | { | ||
52 | if (cnt == 0) | ||
53 | { | ||
54 | fprintf(stdout, "\t.long\t"); | ||
55 | } | ||
56 | fprintf(stdout, "0x%02X%02X%02X%02X", lp[0], lp[1], lp[2], lp[3]); | ||
57 | val = *(unsigned long *)lp; | ||
58 | cksum ^= val; | ||
59 | lp += 4; | ||
60 | if (++cnt == 4) | ||
61 | { | ||
62 | cnt = 0; | ||
63 | fprintf(stdout, " # %x \n", pos+i-12); | ||
64 | fflush(stdout); | ||
65 | } else | ||
66 | { | ||
67 | fprintf(stdout, ","); | ||
68 | } | ||
69 | } | ||
70 | if (cnt) | ||
71 | { | ||
72 | fprintf(stdout, "0\n"); | ||
73 | } | ||
74 | pos += len; | ||
75 | } | ||
76 | fprintf(stdout, "\t.globl %s_len\n", varname); | ||
77 | fprintf(stdout, "%s_len:\t.long\t0x%x\n", varname, pos); | ||
78 | fflush(stdout); | ||
79 | fclose(stdout); | ||
80 | fprintf(stderr, "cksum = %x\n", cksum); | ||
81 | exit(0); | ||
82 | } | ||
83 | |||
diff --git a/arch/ppc64/boot/prom.c b/arch/ppc64/boot/prom.c index d5218b15824e..5e48b80ff5a0 100644 --- a/arch/ppc64/boot/prom.c +++ b/arch/ppc64/boot/prom.c | |||
@@ -40,7 +40,7 @@ void *finddevice(const char *name); | |||
40 | int getprop(void *phandle, const char *name, void *buf, int buflen); | 40 | int getprop(void *phandle, const char *name, void *buf, int buflen); |
41 | void chrpboot(int a1, int a2, void *prom); /* in main.c */ | 41 | void chrpboot(int a1, int a2, void *prom); /* in main.c */ |
42 | 42 | ||
43 | void printk(char *fmt, ...); | 43 | int printf(char *fmt, ...); |
44 | 44 | ||
45 | /* there is no convenient header to get this from... -- paulus */ | 45 | /* there is no convenient header to get this from... -- paulus */ |
46 | extern unsigned long strlen(const char *); | 46 | extern unsigned long strlen(const char *); |
@@ -220,7 +220,7 @@ readchar(void) | |||
220 | case 1: | 220 | case 1: |
221 | return ch; | 221 | return ch; |
222 | case -1: | 222 | case -1: |
223 | printk("read(stdin) returned -1\r\n"); | 223 | printf("read(stdin) returned -1\r\n"); |
224 | return -1; | 224 | return -1; |
225 | } | 225 | } |
226 | } | 226 | } |
@@ -627,18 +627,6 @@ int sprintf(char * buf, const char *fmt, ...) | |||
627 | 627 | ||
628 | static char sprint_buf[1024]; | 628 | static char sprint_buf[1024]; |
629 | 629 | ||
630 | void | ||
631 | printk(char *fmt, ...) | ||
632 | { | ||
633 | va_list args; | ||
634 | int n; | ||
635 | |||
636 | va_start(args, fmt); | ||
637 | n = vsprintf(sprint_buf, fmt, args); | ||
638 | va_end(args); | ||
639 | write(stdout, sprint_buf, n); | ||
640 | } | ||
641 | |||
642 | int | 630 | int |
643 | printf(char *fmt, ...) | 631 | printf(char *fmt, ...) |
644 | { | 632 | { |
diff --git a/arch/ppc64/kernel/ItLpQueue.c b/arch/ppc64/kernel/ItLpQueue.c index cdea00d7707f..4231861288a3 100644 --- a/arch/ppc64/kernel/ItLpQueue.c +++ b/arch/ppc64/kernel/ItLpQueue.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * ItLpQueue.c | 2 | * ItLpQueue.c |
3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation | 3 | * Copyright (C) 2001 Mike Corrigan IBM Corporation |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or |
@@ -11,156 +11,252 @@ | |||
11 | #include <linux/stddef.h> | 11 | #include <linux/stddef.h> |
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/bootmem.h> | ||
15 | #include <linux/seq_file.h> | ||
16 | #include <linux/proc_fs.h> | ||
14 | #include <asm/system.h> | 17 | #include <asm/system.h> |
15 | #include <asm/paca.h> | 18 | #include <asm/paca.h> |
16 | #include <asm/iSeries/ItLpQueue.h> | 19 | #include <asm/iSeries/ItLpQueue.h> |
17 | #include <asm/iSeries/HvLpEvent.h> | 20 | #include <asm/iSeries/HvLpEvent.h> |
18 | #include <asm/iSeries/HvCallEvent.h> | 21 | #include <asm/iSeries/HvCallEvent.h> |
19 | 22 | ||
20 | static __inline__ int set_inUse( struct ItLpQueue * lpQueue ) | 23 | /* |
21 | { | 24 | * The LpQueue is used to pass event data from the hypervisor to |
22 | int t; | 25 | * the partition. This is where I/O interrupt events are communicated. |
23 | u32 * inUseP = &(lpQueue->xInUseWord); | 26 | * |
24 | 27 | * It is written to by the hypervisor so cannot end up in the BSS. | |
25 | __asm__ __volatile__("\n\ | 28 | */ |
26 | 1: lwarx %0,0,%2 \n\ | 29 | struct hvlpevent_queue hvlpevent_queue __attribute__((__section__(".data"))); |
27 | cmpwi 0,%0,0 \n\ | ||
28 | li %0,0 \n\ | ||
29 | bne- 2f \n\ | ||
30 | addi %0,%0,1 \n\ | ||
31 | stwcx. %0,0,%2 \n\ | ||
32 | bne- 1b \n\ | ||
33 | 2: eieio" | ||
34 | : "=&r" (t), "=m" (lpQueue->xInUseWord) | ||
35 | : "r" (inUseP), "m" (lpQueue->xInUseWord) | ||
36 | : "cc"); | ||
37 | |||
38 | return t; | ||
39 | } | ||
40 | 30 | ||
41 | static __inline__ void clear_inUse( struct ItLpQueue * lpQueue ) | 31 | DEFINE_PER_CPU(unsigned long[HvLpEvent_Type_NumTypes], hvlpevent_counts); |
42 | { | 32 | |
43 | lpQueue->xInUseWord = 0; | 33 | static char *event_types[HvLpEvent_Type_NumTypes] = { |
44 | } | 34 | "Hypervisor", |
35 | "Machine Facilities", | ||
36 | "Session Manager", | ||
37 | "SPD I/O", | ||
38 | "Virtual Bus", | ||
39 | "PCI I/O", | ||
40 | "RIO I/O", | ||
41 | "Virtual Lan", | ||
42 | "Virtual I/O" | ||
43 | }; | ||
45 | 44 | ||
46 | /* Array of LpEvent handler functions */ | 45 | /* Array of LpEvent handler functions */ |
47 | extern LpEventHandler lpEventHandler[HvLpEvent_Type_NumTypes]; | 46 | extern LpEventHandler lpEventHandler[HvLpEvent_Type_NumTypes]; |
48 | unsigned long ItLpQueueInProcess = 0; | ||
49 | 47 | ||
50 | struct HvLpEvent * ItLpQueue_getNextLpEvent( struct ItLpQueue * lpQueue ) | 48 | static struct HvLpEvent * get_next_hvlpevent(void) |
51 | { | 49 | { |
52 | struct HvLpEvent * nextLpEvent = | 50 | struct HvLpEvent * event; |
53 | (struct HvLpEvent *)lpQueue->xSlicCurEventPtr; | 51 | event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr; |
54 | if ( nextLpEvent->xFlags.xValid ) { | 52 | |
53 | if (event->xFlags.xValid) { | ||
55 | /* rmb() needed only for weakly consistent machines (regatta) */ | 54 | /* rmb() needed only for weakly consistent machines (regatta) */ |
56 | rmb(); | 55 | rmb(); |
57 | /* Set pointer to next potential event */ | 56 | /* Set pointer to next potential event */ |
58 | lpQueue->xSlicCurEventPtr += ((nextLpEvent->xSizeMinus1 + | 57 | hvlpevent_queue.xSlicCurEventPtr += ((event->xSizeMinus1 + |
59 | LpEventAlign ) / | 58 | LpEventAlign) / LpEventAlign) * LpEventAlign; |
60 | LpEventAlign ) * | 59 | |
61 | LpEventAlign; | ||
62 | /* Wrap to beginning if no room at end */ | 60 | /* Wrap to beginning if no room at end */ |
63 | if (lpQueue->xSlicCurEventPtr > lpQueue->xSlicLastValidEventPtr) | 61 | if (hvlpevent_queue.xSlicCurEventPtr > |
64 | lpQueue->xSlicCurEventPtr = lpQueue->xSlicEventStackPtr; | 62 | hvlpevent_queue.xSlicLastValidEventPtr) { |
63 | hvlpevent_queue.xSlicCurEventPtr = | ||
64 | hvlpevent_queue.xSlicEventStackPtr; | ||
65 | } | ||
66 | } else { | ||
67 | event = NULL; | ||
65 | } | 68 | } |
66 | else | ||
67 | nextLpEvent = NULL; | ||
68 | 69 | ||
69 | return nextLpEvent; | 70 | return event; |
70 | } | 71 | } |
71 | 72 | ||
72 | int ItLpQueue_isLpIntPending( struct ItLpQueue * lpQueue ) | 73 | static unsigned long spread_lpevents = NR_CPUS; |
74 | |||
75 | int hvlpevent_is_pending(void) | ||
73 | { | 76 | { |
74 | int retval = 0; | 77 | struct HvLpEvent *next_event; |
75 | struct HvLpEvent * nextLpEvent; | 78 | |
76 | if ( lpQueue ) { | 79 | if (smp_processor_id() >= spread_lpevents) |
77 | nextLpEvent = (struct HvLpEvent *)lpQueue->xSlicCurEventPtr; | 80 | return 0; |
78 | retval = nextLpEvent->xFlags.xValid | lpQueue->xPlicOverflowIntPending; | 81 | |
79 | } | 82 | next_event = (struct HvLpEvent *)hvlpevent_queue.xSlicCurEventPtr; |
80 | return retval; | 83 | |
84 | return next_event->xFlags.xValid | | ||
85 | hvlpevent_queue.xPlicOverflowIntPending; | ||
81 | } | 86 | } |
82 | 87 | ||
83 | void ItLpQueue_clearValid( struct HvLpEvent * event ) | 88 | static void hvlpevent_clear_valid(struct HvLpEvent * event) |
84 | { | 89 | { |
85 | /* Clear the valid bit of the event | 90 | /* Tell the Hypervisor that we're done with this event. |
86 | * Also clear bits within this event that might | 91 | * Also clear bits within this event that might look like valid bits. |
87 | * look like valid bits (on 64-byte boundaries) | 92 | * ie. on 64-byte boundaries. |
88 | */ | 93 | */ |
89 | unsigned extra = (( event->xSizeMinus1 + LpEventAlign ) / | 94 | struct HvLpEvent *tmp; |
90 | LpEventAlign ) - 1; | 95 | unsigned extra = ((event->xSizeMinus1 + LpEventAlign) / |
91 | switch ( extra ) { | 96 | LpEventAlign) - 1; |
92 | case 3: | 97 | |
93 | ((struct HvLpEvent*)((char*)event+3*LpEventAlign))->xFlags.xValid=0; | 98 | switch (extra) { |
94 | case 2: | 99 | case 3: |
95 | ((struct HvLpEvent*)((char*)event+2*LpEventAlign))->xFlags.xValid=0; | 100 | tmp = (struct HvLpEvent*)((char*)event + 3 * LpEventAlign); |
96 | case 1: | 101 | tmp->xFlags.xValid = 0; |
97 | ((struct HvLpEvent*)((char*)event+1*LpEventAlign))->xFlags.xValid=0; | 102 | case 2: |
98 | case 0: | 103 | tmp = (struct HvLpEvent*)((char*)event + 2 * LpEventAlign); |
99 | ; | 104 | tmp->xFlags.xValid = 0; |
105 | case 1: | ||
106 | tmp = (struct HvLpEvent*)((char*)event + 1 * LpEventAlign); | ||
107 | tmp->xFlags.xValid = 0; | ||
100 | } | 108 | } |
109 | |||
101 | mb(); | 110 | mb(); |
111 | |||
102 | event->xFlags.xValid = 0; | 112 | event->xFlags.xValid = 0; |
103 | } | 113 | } |
104 | 114 | ||
105 | unsigned ItLpQueue_process( struct ItLpQueue * lpQueue, struct pt_regs *regs ) | 115 | void process_hvlpevents(struct pt_regs *regs) |
106 | { | 116 | { |
107 | unsigned numIntsProcessed = 0; | 117 | struct HvLpEvent * event; |
108 | struct HvLpEvent * nextLpEvent; | ||
109 | 118 | ||
110 | /* If we have recursed, just return */ | 119 | /* If we have recursed, just return */ |
111 | if ( !set_inUse( lpQueue ) ) | 120 | if (!spin_trylock(&hvlpevent_queue.lock)) |
112 | return 0; | 121 | return; |
113 | |||
114 | if (ItLpQueueInProcess == 0) | ||
115 | ItLpQueueInProcess = 1; | ||
116 | else | ||
117 | BUG(); | ||
118 | 122 | ||
119 | for (;;) { | 123 | for (;;) { |
120 | nextLpEvent = ItLpQueue_getNextLpEvent( lpQueue ); | 124 | event = get_next_hvlpevent(); |
121 | if ( nextLpEvent ) { | 125 | if (event) { |
122 | /* Count events to return to caller | 126 | /* Call appropriate handler here, passing |
123 | * and count processed events in lpQueue | ||
124 | */ | ||
125 | ++numIntsProcessed; | ||
126 | lpQueue->xLpIntCount++; | ||
127 | /* Call appropriate handler here, passing | ||
128 | * a pointer to the LpEvent. The handler | 127 | * a pointer to the LpEvent. The handler |
129 | * must make a copy of the LpEvent if it | 128 | * must make a copy of the LpEvent if it |
130 | * needs it in a bottom half. (perhaps for | 129 | * needs it in a bottom half. (perhaps for |
131 | * an ACK) | 130 | * an ACK) |
132 | * | 131 | * |
133 | * Handlers are responsible for ACK processing | 132 | * Handlers are responsible for ACK processing |
134 | * | 133 | * |
135 | * The Hypervisor guarantees that LpEvents will | 134 | * The Hypervisor guarantees that LpEvents will |
136 | * only be delivered with types that we have | 135 | * only be delivered with types that we have |
137 | * registered for, so no type check is necessary | 136 | * registered for, so no type check is necessary |
138 | * here! | 137 | * here! |
139 | */ | 138 | */ |
140 | if ( nextLpEvent->xType < HvLpEvent_Type_NumTypes ) | 139 | if (event->xType < HvLpEvent_Type_NumTypes) |
141 | lpQueue->xLpIntCountByType[nextLpEvent->xType]++; | 140 | __get_cpu_var(hvlpevent_counts)[event->xType]++; |
142 | if ( nextLpEvent->xType < HvLpEvent_Type_NumTypes && | 141 | if (event->xType < HvLpEvent_Type_NumTypes && |
143 | lpEventHandler[nextLpEvent->xType] ) | 142 | lpEventHandler[event->xType]) |
144 | lpEventHandler[nextLpEvent->xType](nextLpEvent, regs); | 143 | lpEventHandler[event->xType](event, regs); |
145 | else | 144 | else |
146 | printk(KERN_INFO "Unexpected Lp Event type=%d\n", nextLpEvent->xType ); | 145 | printk(KERN_INFO "Unexpected Lp Event type=%d\n", event->xType ); |
147 | 146 | ||
148 | ItLpQueue_clearValid( nextLpEvent ); | 147 | hvlpevent_clear_valid(event); |
149 | } else if ( lpQueue->xPlicOverflowIntPending ) | 148 | } else if (hvlpevent_queue.xPlicOverflowIntPending) |
150 | /* | 149 | /* |
151 | * No more valid events. If overflow events are | 150 | * No more valid events. If overflow events are |
152 | * pending process them | 151 | * pending process them |
153 | */ | 152 | */ |
154 | HvCallEvent_getOverflowLpEvents( lpQueue->xIndex); | 153 | HvCallEvent_getOverflowLpEvents(hvlpevent_queue.xIndex); |
155 | else | 154 | else |
156 | break; | 155 | break; |
157 | } | 156 | } |
158 | 157 | ||
159 | ItLpQueueInProcess = 0; | 158 | spin_unlock(&hvlpevent_queue.lock); |
160 | mb(); | 159 | } |
161 | clear_inUse( lpQueue ); | 160 | |
161 | static int set_spread_lpevents(char *str) | ||
162 | { | ||
163 | unsigned long val = simple_strtoul(str, NULL, 0); | ||
164 | |||
165 | /* | ||
166 | * The parameter is the number of processors to share in processing | ||
167 | * lp events. | ||
168 | */ | ||
169 | if (( val > 0) && (val <= NR_CPUS)) { | ||
170 | spread_lpevents = val; | ||
171 | printk("lpevent processing spread over %ld processors\n", val); | ||
172 | } else { | ||
173 | printk("invalid spread_lpevents %ld\n", val); | ||
174 | } | ||
162 | 175 | ||
163 | get_paca()->lpevent_count += numIntsProcessed; | 176 | return 1; |
177 | } | ||
178 | __setup("spread_lpevents=", set_spread_lpevents); | ||
179 | |||
180 | void setup_hvlpevent_queue(void) | ||
181 | { | ||
182 | void *eventStack; | ||
183 | |||
184 | /* | ||
185 | * Allocate a page for the Event Stack. The Hypervisor needs the | ||
186 | * absolute real address, so we subtract out the KERNELBASE and add | ||
187 | * in the absolute real address of the kernel load area. | ||
188 | */ | ||
189 | eventStack = alloc_bootmem_pages(LpEventStackSize); | ||
190 | memset(eventStack, 0, LpEventStackSize); | ||
191 | |||
192 | /* Invoke the hypervisor to initialize the event stack */ | ||
193 | HvCallEvent_setLpEventStack(0, eventStack, LpEventStackSize); | ||
194 | |||
195 | hvlpevent_queue.xSlicEventStackPtr = (char *)eventStack; | ||
196 | hvlpevent_queue.xSlicCurEventPtr = (char *)eventStack; | ||
197 | hvlpevent_queue.xSlicLastValidEventPtr = (char *)eventStack + | ||
198 | (LpEventStackSize - LpEventMaxSize); | ||
199 | hvlpevent_queue.xIndex = 0; | ||
200 | } | ||
201 | |||
202 | static int proc_lpevents_show(struct seq_file *m, void *v) | ||
203 | { | ||
204 | int cpu, i; | ||
205 | unsigned long sum; | ||
206 | static unsigned long cpu_totals[NR_CPUS]; | ||
207 | |||
208 | /* FIXME: do we care that there's no locking here? */ | ||
209 | sum = 0; | ||
210 | for_each_online_cpu(cpu) { | ||
211 | cpu_totals[cpu] = 0; | ||
212 | for (i = 0; i < HvLpEvent_Type_NumTypes; i++) { | ||
213 | cpu_totals[cpu] += per_cpu(hvlpevent_counts, cpu)[i]; | ||
214 | } | ||
215 | sum += cpu_totals[cpu]; | ||
216 | } | ||
217 | |||
218 | seq_printf(m, "LpEventQueue 0\n"); | ||
219 | seq_printf(m, " events processed:\t%lu\n", sum); | ||
220 | |||
221 | for (i = 0; i < HvLpEvent_Type_NumTypes; ++i) { | ||
222 | sum = 0; | ||
223 | for_each_online_cpu(cpu) { | ||
224 | sum += per_cpu(hvlpevent_counts, cpu)[i]; | ||
225 | } | ||
226 | |||
227 | seq_printf(m, " %-20s %10lu\n", event_types[i], sum); | ||
228 | } | ||
229 | |||
230 | seq_printf(m, "\n events processed by processor:\n"); | ||
231 | |||
232 | for_each_online_cpu(cpu) { | ||
233 | seq_printf(m, " CPU%02d %10lu\n", cpu, cpu_totals[cpu]); | ||
234 | } | ||
235 | |||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | static int proc_lpevents_open(struct inode *inode, struct file *file) | ||
240 | { | ||
241 | return single_open(file, proc_lpevents_show, NULL); | ||
242 | } | ||
164 | 243 | ||
165 | return numIntsProcessed; | 244 | static struct file_operations proc_lpevents_operations = { |
245 | .open = proc_lpevents_open, | ||
246 | .read = seq_read, | ||
247 | .llseek = seq_lseek, | ||
248 | .release = single_release, | ||
249 | }; | ||
250 | |||
251 | static int __init proc_lpevents_init(void) | ||
252 | { | ||
253 | struct proc_dir_entry *e; | ||
254 | |||
255 | e = create_proc_entry("iSeries/lpevents", S_IFREG|S_IRUGO, NULL); | ||
256 | if (e) | ||
257 | e->proc_fops = &proc_lpevents_operations; | ||
258 | |||
259 | return 0; | ||
166 | } | 260 | } |
261 | __initcall(proc_lpevents_init); | ||
262 | |||
diff --git a/arch/ppc64/kernel/LparData.c b/arch/ppc64/kernel/LparData.c index badc5a443614..6ffcf67dd507 100644 --- a/arch/ppc64/kernel/LparData.c +++ b/arch/ppc64/kernel/LparData.c | |||
@@ -28,13 +28,6 @@ | |||
28 | #include <asm/iSeries/IoHriProcessorVpd.h> | 28 | #include <asm/iSeries/IoHriProcessorVpd.h> |
29 | #include <asm/iSeries/ItSpCommArea.h> | 29 | #include <asm/iSeries/ItSpCommArea.h> |
30 | 30 | ||
31 | /* The LpQueue is used to pass event data from the hypervisor to | ||
32 | * the partition. This is where I/O interrupt events are communicated. | ||
33 | */ | ||
34 | |||
35 | /* May be filled in by the hypervisor so cannot end up in the BSS */ | ||
36 | struct ItLpQueue xItLpQueue __attribute__((__section__(".data"))); | ||
37 | |||
38 | 31 | ||
39 | /* The HvReleaseData is the root of the information shared between | 32 | /* The HvReleaseData is the root of the information shared between |
40 | * the hypervisor and Linux. | 33 | * the hypervisor and Linux. |
@@ -200,7 +193,7 @@ struct ItVpdAreas itVpdAreas = { | |||
200 | 0,0,0, /* 13 - 15 */ | 193 | 0,0,0, /* 13 - 15 */ |
201 | sizeof(struct IoHriProcessorVpd),/* 16 length of Proc Vpd */ | 194 | sizeof(struct IoHriProcessorVpd),/* 16 length of Proc Vpd */ |
202 | 0,0,0,0,0,0, /* 17 - 22 */ | 195 | 0,0,0,0,0,0, /* 17 - 22 */ |
203 | sizeof(struct ItLpQueue),/* 23 length of Lp Queue */ | 196 | sizeof(struct hvlpevent_queue), /* 23 length of Lp Queue */ |
204 | 0,0 /* 24 - 25 */ | 197 | 0,0 /* 24 - 25 */ |
205 | }, | 198 | }, |
206 | .xSlicVpdAdrs = { /* VPD addresses */ | 199 | .xSlicVpdAdrs = { /* VPD addresses */ |
@@ -218,7 +211,7 @@ struct ItVpdAreas itVpdAreas = { | |||
218 | 0,0,0, /* 13 - 15 */ | 211 | 0,0,0, /* 13 - 15 */ |
219 | &xIoHriProcessorVpd, /* 16 Proc Vpd */ | 212 | &xIoHriProcessorVpd, /* 16 Proc Vpd */ |
220 | 0,0,0,0,0,0, /* 17 - 22 */ | 213 | 0,0,0,0,0,0, /* 17 - 22 */ |
221 | &xItLpQueue, /* 23 Lp Queue */ | 214 | &hvlpevent_queue, /* 23 Lp Queue */ |
222 | 0,0 | 215 | 0,0 |
223 | } | 216 | } |
224 | }; | 217 | }; |
diff --git a/arch/ppc64/kernel/iSeries_proc.c b/arch/ppc64/kernel/iSeries_proc.c index 356bd9931fcc..0fe3116eba29 100644 --- a/arch/ppc64/kernel/iSeries_proc.c +++ b/arch/ppc64/kernel/iSeries_proc.c | |||
@@ -40,50 +40,6 @@ static int __init iseries_proc_create(void) | |||
40 | } | 40 | } |
41 | core_initcall(iseries_proc_create); | 41 | core_initcall(iseries_proc_create); |
42 | 42 | ||
43 | static char *event_types[9] = { | ||
44 | "Hypervisor\t\t", | ||
45 | "Machine Facilities\t", | ||
46 | "Session Manager\t", | ||
47 | "SPD I/O\t\t", | ||
48 | "Virtual Bus\t\t", | ||
49 | "PCI I/O\t\t", | ||
50 | "RIO I/O\t\t", | ||
51 | "Virtual Lan\t\t", | ||
52 | "Virtual I/O\t\t" | ||
53 | }; | ||
54 | |||
55 | static int proc_lpevents_show(struct seq_file *m, void *v) | ||
56 | { | ||
57 | unsigned int i; | ||
58 | |||
59 | seq_printf(m, "LpEventQueue 0\n"); | ||
60 | seq_printf(m, " events processed:\t%lu\n", | ||
61 | (unsigned long)xItLpQueue.xLpIntCount); | ||
62 | |||
63 | for (i = 0; i < 9; ++i) | ||
64 | seq_printf(m, " %s %10lu\n", event_types[i], | ||
65 | (unsigned long)xItLpQueue.xLpIntCountByType[i]); | ||
66 | |||
67 | seq_printf(m, "\n events processed by processor:\n"); | ||
68 | |||
69 | for_each_online_cpu(i) | ||
70 | seq_printf(m, " CPU%02d %10u\n", i, paca[i].lpevent_count); | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int proc_lpevents_open(struct inode *inode, struct file *file) | ||
76 | { | ||
77 | return single_open(file, proc_lpevents_show, NULL); | ||
78 | } | ||
79 | |||
80 | static struct file_operations proc_lpevents_operations = { | ||
81 | .open = proc_lpevents_open, | ||
82 | .read = seq_read, | ||
83 | .llseek = seq_lseek, | ||
84 | .release = single_release, | ||
85 | }; | ||
86 | |||
87 | static unsigned long startTitan = 0; | 43 | static unsigned long startTitan = 0; |
88 | static unsigned long startTb = 0; | 44 | static unsigned long startTb = 0; |
89 | 45 | ||
@@ -148,10 +104,6 @@ static int __init iseries_proc_init(void) | |||
148 | { | 104 | { |
149 | struct proc_dir_entry *e; | 105 | struct proc_dir_entry *e; |
150 | 106 | ||
151 | e = create_proc_entry("iSeries/lpevents", S_IFREG|S_IRUGO, NULL); | ||
152 | if (e) | ||
153 | e->proc_fops = &proc_lpevents_operations; | ||
154 | |||
155 | e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL); | 107 | e = create_proc_entry("iSeries/titanTod", S_IFREG|S_IRUGO, NULL); |
156 | if (e) | 108 | if (e) |
157 | e->proc_fops = &proc_titantod_operations; | 109 | e->proc_fops = &proc_titantod_operations; |
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c index 86966ce76b58..b3f770f6d402 100644 --- a/arch/ppc64/kernel/iSeries_setup.c +++ b/arch/ppc64/kernel/iSeries_setup.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/smp.h> | 24 | #include <linux/smp.h> |
25 | #include <linux/param.h> | 25 | #include <linux/param.h> |
26 | #include <linux/string.h> | 26 | #include <linux/string.h> |
27 | #include <linux/bootmem.h> | ||
28 | #include <linux/initrd.h> | 27 | #include <linux/initrd.h> |
29 | #include <linux/seq_file.h> | 28 | #include <linux/seq_file.h> |
30 | #include <linux/kdev_t.h> | 29 | #include <linux/kdev_t.h> |
@@ -676,7 +675,6 @@ static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr) | |||
676 | */ | 675 | */ |
677 | static void __init iSeries_setup_arch(void) | 676 | static void __init iSeries_setup_arch(void) |
678 | { | 677 | { |
679 | void *eventStack; | ||
680 | unsigned procIx = get_paca()->lppaca.dyn_hv_phys_proc_index; | 678 | unsigned procIx = get_paca()->lppaca.dyn_hv_phys_proc_index; |
681 | 679 | ||
682 | /* Add an eye catcher and the systemcfg layout version number */ | 680 | /* Add an eye catcher and the systemcfg layout version number */ |
@@ -685,24 +683,7 @@ static void __init iSeries_setup_arch(void) | |||
685 | systemcfg->version.minor = SYSTEMCFG_MINOR; | 683 | systemcfg->version.minor = SYSTEMCFG_MINOR; |
686 | 684 | ||
687 | /* Setup the Lp Event Queue */ | 685 | /* Setup the Lp Event Queue */ |
688 | 686 | setup_hvlpevent_queue(); | |
689 | /* Allocate a page for the Event Stack | ||
690 | * The hypervisor wants the absolute real address, so | ||
691 | * we subtract out the KERNELBASE and add in the | ||
692 | * absolute real address of the kernel load area | ||
693 | */ | ||
694 | eventStack = alloc_bootmem_pages(LpEventStackSize); | ||
695 | memset(eventStack, 0, LpEventStackSize); | ||
696 | |||
697 | /* Invoke the hypervisor to initialize the event stack */ | ||
698 | HvCallEvent_setLpEventStack(0, eventStack, LpEventStackSize); | ||
699 | |||
700 | /* Initialize fields in our Lp Event Queue */ | ||
701 | xItLpQueue.xSlicEventStackPtr = (char *)eventStack; | ||
702 | xItLpQueue.xSlicCurEventPtr = (char *)eventStack; | ||
703 | xItLpQueue.xSlicLastValidEventPtr = (char *)eventStack + | ||
704 | (LpEventStackSize - LpEventMaxSize); | ||
705 | xItLpQueue.xIndex = 0; | ||
706 | 687 | ||
707 | /* Compute processor frequency */ | 688 | /* Compute processor frequency */ |
708 | procFreqHz = ((1UL << 34) * 1000000) / | 689 | procFreqHz = ((1UL << 34) * 1000000) / |
@@ -853,28 +834,6 @@ static int __init iSeries_src_init(void) | |||
853 | 834 | ||
854 | late_initcall(iSeries_src_init); | 835 | late_initcall(iSeries_src_init); |
855 | 836 | ||
856 | static int set_spread_lpevents(char *str) | ||
857 | { | ||
858 | unsigned long i; | ||
859 | unsigned long val = simple_strtoul(str, NULL, 0); | ||
860 | |||
861 | /* | ||
862 | * The parameter is the number of processors to share in processing | ||
863 | * lp events. | ||
864 | */ | ||
865 | if (( val > 0) && (val <= NR_CPUS)) { | ||
866 | for (i = 1; i < val; ++i) | ||
867 | paca[i].lpqueue_ptr = paca[0].lpqueue_ptr; | ||
868 | |||
869 | printk("lpevent processing spread over %ld processors\n", val); | ||
870 | } else { | ||
871 | printk("invalid spread_lpevents %ld\n", val); | ||
872 | } | ||
873 | |||
874 | return 1; | ||
875 | } | ||
876 | __setup("spread_lpevents=", set_spread_lpevents); | ||
877 | |||
878 | #ifndef CONFIG_PCI | 837 | #ifndef CONFIG_PCI |
879 | void __init iSeries_init_IRQ(void) { } | 838 | void __init iSeries_init_IRQ(void) { } |
880 | #endif | 839 | #endif |
diff --git a/arch/ppc64/kernel/idle.c b/arch/ppc64/kernel/idle.c index bdf13b4dc1c8..08952c7e6216 100644 --- a/arch/ppc64/kernel/idle.c +++ b/arch/ppc64/kernel/idle.c | |||
@@ -88,7 +88,7 @@ static int iSeries_idle(void) | |||
88 | 88 | ||
89 | while (1) { | 89 | while (1) { |
90 | if (lpaca->lppaca.shared_proc) { | 90 | if (lpaca->lppaca.shared_proc) { |
91 | if (ItLpQueue_isLpIntPending(lpaca->lpqueue_ptr)) | 91 | if (hvlpevent_is_pending()) |
92 | process_iSeries_events(); | 92 | process_iSeries_events(); |
93 | if (!need_resched()) | 93 | if (!need_resched()) |
94 | yield_shared_processor(); | 94 | yield_shared_processor(); |
@@ -100,7 +100,7 @@ static int iSeries_idle(void) | |||
100 | 100 | ||
101 | while (!need_resched()) { | 101 | while (!need_resched()) { |
102 | HMT_medium(); | 102 | HMT_medium(); |
103 | if (ItLpQueue_isLpIntPending(lpaca->lpqueue_ptr)) | 103 | if (hvlpevent_is_pending()) |
104 | process_iSeries_events(); | 104 | process_iSeries_events(); |
105 | HMT_low(); | 105 | HMT_low(); |
106 | } | 106 | } |
diff --git a/arch/ppc64/kernel/irq.c b/arch/ppc64/kernel/irq.c index ffe300611f00..f41afe545045 100644 --- a/arch/ppc64/kernel/irq.c +++ b/arch/ppc64/kernel/irq.c | |||
@@ -66,7 +66,6 @@ EXPORT_SYMBOL(irq_desc); | |||
66 | int distribute_irqs = 1; | 66 | int distribute_irqs = 1; |
67 | int __irq_offset_value; | 67 | int __irq_offset_value; |
68 | int ppc_spurious_interrupts; | 68 | int ppc_spurious_interrupts; |
69 | unsigned long lpevent_count; | ||
70 | u64 ppc64_interrupt_controller; | 69 | u64 ppc64_interrupt_controller; |
71 | 70 | ||
72 | int show_interrupts(struct seq_file *p, void *v) | 71 | int show_interrupts(struct seq_file *p, void *v) |
@@ -269,7 +268,6 @@ out: | |||
269 | void do_IRQ(struct pt_regs *regs) | 268 | void do_IRQ(struct pt_regs *regs) |
270 | { | 269 | { |
271 | struct paca_struct *lpaca; | 270 | struct paca_struct *lpaca; |
272 | struct ItLpQueue *lpq; | ||
273 | 271 | ||
274 | irq_enter(); | 272 | irq_enter(); |
275 | 273 | ||
@@ -295,9 +293,8 @@ void do_IRQ(struct pt_regs *regs) | |||
295 | iSeries_smp_message_recv(regs); | 293 | iSeries_smp_message_recv(regs); |
296 | } | 294 | } |
297 | #endif /* CONFIG_SMP */ | 295 | #endif /* CONFIG_SMP */ |
298 | lpq = lpaca->lpqueue_ptr; | 296 | if (hvlpevent_is_pending()) |
299 | if (lpq && ItLpQueue_isLpIntPending(lpq)) | 297 | process_hvlpevents(regs); |
300 | lpevent_count += ItLpQueue_process(lpq, regs); | ||
301 | 298 | ||
302 | irq_exit(); | 299 | irq_exit(); |
303 | 300 | ||
diff --git a/arch/ppc64/kernel/mf.c b/arch/ppc64/kernel/mf.c index d98bebf7042f..ef4a338ebd01 100644 --- a/arch/ppc64/kernel/mf.c +++ b/arch/ppc64/kernel/mf.c | |||
@@ -801,10 +801,8 @@ int mf_get_boot_rtc(struct rtc_time *tm) | |||
801 | return rc; | 801 | return rc; |
802 | /* We need to poll here as we are not yet taking interrupts */ | 802 | /* We need to poll here as we are not yet taking interrupts */ |
803 | while (rtc_data.busy) { | 803 | while (rtc_data.busy) { |
804 | extern unsigned long lpevent_count; | 804 | if (hvlpevent_is_pending()) |
805 | struct ItLpQueue *lpq = get_paca()->lpqueue_ptr; | 805 | process_hvlpevents(NULL); |
806 | if (lpq && ItLpQueue_isLpIntPending(lpq)) | ||
807 | lpevent_count += ItLpQueue_process(lpq, NULL); | ||
808 | } | 806 | } |
809 | return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm); | 807 | return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm); |
810 | } | 808 | } |
diff --git a/arch/ppc64/kernel/nvram.c b/arch/ppc64/kernel/nvram.c index 4e71781a4414..4fb1a9f5060d 100644 --- a/arch/ppc64/kernel/nvram.c +++ b/arch/ppc64/kernel/nvram.c | |||
@@ -338,9 +338,8 @@ static int nvram_remove_os_partition(void) | |||
338 | */ | 338 | */ |
339 | static int nvram_create_os_partition(void) | 339 | static int nvram_create_os_partition(void) |
340 | { | 340 | { |
341 | struct list_head * p; | 341 | struct nvram_partition *part; |
342 | struct nvram_partition *part = NULL; | 342 | struct nvram_partition *new_part; |
343 | struct nvram_partition *new_part = NULL; | ||
344 | struct nvram_partition *free_part = NULL; | 343 | struct nvram_partition *free_part = NULL; |
345 | int seq_init[2] = { 0, 0 }; | 344 | int seq_init[2] = { 0, 0 }; |
346 | loff_t tmp_index; | 345 | loff_t tmp_index; |
@@ -349,8 +348,7 @@ static int nvram_create_os_partition(void) | |||
349 | 348 | ||
350 | /* Find a free partition that will give us the maximum needed size | 349 | /* Find a free partition that will give us the maximum needed size |
351 | If can't find one that will give us the minimum size needed */ | 350 | If can't find one that will give us the minimum size needed */ |
352 | list_for_each(p, &nvram_part->partition) { | 351 | list_for_each_entry(part, &nvram_part->partition, partition) { |
353 | part = list_entry(p, struct nvram_partition, partition); | ||
354 | if (part->header.signature != NVRAM_SIG_FREE) | 352 | if (part->header.signature != NVRAM_SIG_FREE) |
355 | continue; | 353 | continue; |
356 | 354 | ||
diff --git a/arch/ppc64/kernel/pacaData.c b/arch/ppc64/kernel/pacaData.c index a3e0975c26c1..6316188737b6 100644 --- a/arch/ppc64/kernel/pacaData.c +++ b/arch/ppc64/kernel/pacaData.c | |||
@@ -42,21 +42,7 @@ extern unsigned long __toc_start; | |||
42 | * processors. The processor VPD array needs one entry per physical | 42 | * processors. The processor VPD array needs one entry per physical |
43 | * processor (not thread). | 43 | * processor (not thread). |
44 | */ | 44 | */ |
45 | #ifdef CONFIG_PPC_ISERIES | 45 | #define PACA_INIT_COMMON(number, start, asrr, asrv) \ |
46 | #define EXTRA_INITS(number, lpq) \ | ||
47 | .lppaca_ptr = &paca[number].lppaca, \ | ||
48 | .lpqueue_ptr = (lpq), /* &xItLpQueue, */ \ | ||
49 | .reg_save_ptr = &paca[number].reg_save, \ | ||
50 | .reg_save = { \ | ||
51 | .xDesc = 0xd397d9e2, /* "LpRS" */ \ | ||
52 | .xSize = sizeof(struct ItLpRegSave) \ | ||
53 | }, | ||
54 | #else | ||
55 | #define EXTRA_INITS(number, lpq) | ||
56 | #endif | ||
57 | |||
58 | #define PACAINITDATA(number,start,lpq,asrr,asrv) \ | ||
59 | { \ | ||
60 | .lock_token = 0x8000, \ | 46 | .lock_token = 0x8000, \ |
61 | .paca_index = (number), /* Paca Index */ \ | 47 | .paca_index = (number), /* Paca Index */ \ |
62 | .default_decr = 0x00ff0000, /* Initial Decr */ \ | 48 | .default_decr = 0x00ff0000, /* Initial Decr */ \ |
@@ -74,147 +60,79 @@ extern unsigned long __toc_start; | |||
74 | .end_of_quantum = 0xfffffffffffffffful, \ | 60 | .end_of_quantum = 0xfffffffffffffffful, \ |
75 | .slb_count = 64, \ | 61 | .slb_count = 64, \ |
76 | }, \ | 62 | }, \ |
77 | EXTRA_INITS((number), (lpq)) \ | ||
78 | } | ||
79 | 63 | ||
80 | struct paca_struct paca[] = { | ||
81 | #ifdef CONFIG_PPC_ISERIES | 64 | #ifdef CONFIG_PPC_ISERIES |
82 | PACAINITDATA( 0, 1, &xItLpQueue, 0, STAB0_VIRT_ADDR), | 65 | #define PACA_INIT_ISERIES(number) \ |
66 | .lppaca_ptr = &paca[number].lppaca, \ | ||
67 | .reg_save_ptr = &paca[number].reg_save, \ | ||
68 | .reg_save = { \ | ||
69 | .xDesc = 0xd397d9e2, /* "LpRS" */ \ | ||
70 | .xSize = sizeof(struct ItLpRegSave) \ | ||
71 | } | ||
72 | |||
73 | #define PACA_INIT(number) \ | ||
74 | { \ | ||
75 | PACA_INIT_COMMON(number, 0, 0, 0) \ | ||
76 | PACA_INIT_ISERIES(number) \ | ||
77 | } | ||
78 | |||
79 | #define BOOTCPU_PACA_INIT(number) \ | ||
80 | { \ | ||
81 | PACA_INIT_COMMON(number, 1, 0, STAB0_VIRT_ADDR) \ | ||
82 | PACA_INIT_ISERIES(number) \ | ||
83 | } | ||
84 | |||
83 | #else | 85 | #else |
84 | PACAINITDATA( 0, 1, NULL, STAB0_PHYS_ADDR, STAB0_VIRT_ADDR), | 86 | #define PACA_INIT(number) \ |
87 | { \ | ||
88 | PACA_INIT_COMMON(number, 0, 0, 0) \ | ||
89 | } | ||
90 | |||
91 | #define BOOTCPU_PACA_INIT(number) \ | ||
92 | { \ | ||
93 | PACA_INIT_COMMON(number, 1, STAB0_PHYS_ADDR, STAB0_VIRT_ADDR) \ | ||
94 | } | ||
85 | #endif | 95 | #endif |
96 | |||
97 | struct paca_struct paca[] = { | ||
98 | BOOTCPU_PACA_INIT(0), | ||
86 | #if NR_CPUS > 1 | 99 | #if NR_CPUS > 1 |
87 | PACAINITDATA( 1, 0, NULL, 0, 0), | 100 | PACA_INIT( 1), PACA_INIT( 2), PACA_INIT( 3), |
88 | PACAINITDATA( 2, 0, NULL, 0, 0), | ||
89 | PACAINITDATA( 3, 0, NULL, 0, 0), | ||
90 | #if NR_CPUS > 4 | 101 | #if NR_CPUS > 4 |
91 | PACAINITDATA( 4, 0, NULL, 0, 0), | 102 | PACA_INIT( 4), PACA_INIT( 5), PACA_INIT( 6), PACA_INIT( 7), |
92 | PACAINITDATA( 5, 0, NULL, 0, 0), | ||
93 | PACAINITDATA( 6, 0, NULL, 0, 0), | ||
94 | PACAINITDATA( 7, 0, NULL, 0, 0), | ||
95 | #if NR_CPUS > 8 | 103 | #if NR_CPUS > 8 |
96 | PACAINITDATA( 8, 0, NULL, 0, 0), | 104 | PACA_INIT( 8), PACA_INIT( 9), PACA_INIT( 10), PACA_INIT( 11), |
97 | PACAINITDATA( 9, 0, NULL, 0, 0), | 105 | PACA_INIT( 12), PACA_INIT( 13), PACA_INIT( 14), PACA_INIT( 15), |
98 | PACAINITDATA(10, 0, NULL, 0, 0), | 106 | PACA_INIT( 16), PACA_INIT( 17), PACA_INIT( 18), PACA_INIT( 19), |
99 | PACAINITDATA(11, 0, NULL, 0, 0), | 107 | PACA_INIT( 20), PACA_INIT( 21), PACA_INIT( 22), PACA_INIT( 23), |
100 | PACAINITDATA(12, 0, NULL, 0, 0), | 108 | PACA_INIT( 24), PACA_INIT( 25), PACA_INIT( 26), PACA_INIT( 27), |
101 | PACAINITDATA(13, 0, NULL, 0, 0), | 109 | PACA_INIT( 28), PACA_INIT( 29), PACA_INIT( 30), PACA_INIT( 31), |
102 | PACAINITDATA(14, 0, NULL, 0, 0), | ||
103 | PACAINITDATA(15, 0, NULL, 0, 0), | ||
104 | PACAINITDATA(16, 0, NULL, 0, 0), | ||
105 | PACAINITDATA(17, 0, NULL, 0, 0), | ||
106 | PACAINITDATA(18, 0, NULL, 0, 0), | ||
107 | PACAINITDATA(19, 0, NULL, 0, 0), | ||
108 | PACAINITDATA(20, 0, NULL, 0, 0), | ||
109 | PACAINITDATA(21, 0, NULL, 0, 0), | ||
110 | PACAINITDATA(22, 0, NULL, 0, 0), | ||
111 | PACAINITDATA(23, 0, NULL, 0, 0), | ||
112 | PACAINITDATA(24, 0, NULL, 0, 0), | ||
113 | PACAINITDATA(25, 0, NULL, 0, 0), | ||
114 | PACAINITDATA(26, 0, NULL, 0, 0), | ||
115 | PACAINITDATA(27, 0, NULL, 0, 0), | ||
116 | PACAINITDATA(28, 0, NULL, 0, 0), | ||
117 | PACAINITDATA(29, 0, NULL, 0, 0), | ||
118 | PACAINITDATA(30, 0, NULL, 0, 0), | ||
119 | PACAINITDATA(31, 0, NULL, 0, 0), | ||
120 | #if NR_CPUS > 32 | 110 | #if NR_CPUS > 32 |
121 | PACAINITDATA(32, 0, NULL, 0, 0), | 111 | PACA_INIT( 32), PACA_INIT( 33), PACA_INIT( 34), PACA_INIT( 35), |
122 | PACAINITDATA(33, 0, NULL, 0, 0), | 112 | PACA_INIT( 36), PACA_INIT( 37), PACA_INIT( 38), PACA_INIT( 39), |
123 | PACAINITDATA(34, 0, NULL, 0, 0), | 113 | PACA_INIT( 40), PACA_INIT( 41), PACA_INIT( 42), PACA_INIT( 43), |
124 | PACAINITDATA(35, 0, NULL, 0, 0), | 114 | PACA_INIT( 44), PACA_INIT( 45), PACA_INIT( 46), PACA_INIT( 47), |
125 | PACAINITDATA(36, 0, NULL, 0, 0), | 115 | PACA_INIT( 48), PACA_INIT( 49), PACA_INIT( 50), PACA_INIT( 51), |
126 | PACAINITDATA(37, 0, NULL, 0, 0), | 116 | PACA_INIT( 52), PACA_INIT( 53), PACA_INIT( 54), PACA_INIT( 55), |
127 | PACAINITDATA(38, 0, NULL, 0, 0), | 117 | PACA_INIT( 56), PACA_INIT( 57), PACA_INIT( 58), PACA_INIT( 59), |
128 | PACAINITDATA(39, 0, NULL, 0, 0), | 118 | PACA_INIT( 60), PACA_INIT( 61), PACA_INIT( 62), PACA_INIT( 63), |
129 | PACAINITDATA(40, 0, NULL, 0, 0), | ||
130 | PACAINITDATA(41, 0, NULL, 0, 0), | ||
131 | PACAINITDATA(42, 0, NULL, 0, 0), | ||
132 | PACAINITDATA(43, 0, NULL, 0, 0), | ||
133 | PACAINITDATA(44, 0, NULL, 0, 0), | ||
134 | PACAINITDATA(45, 0, NULL, 0, 0), | ||
135 | PACAINITDATA(46, 0, NULL, 0, 0), | ||
136 | PACAINITDATA(47, 0, NULL, 0, 0), | ||
137 | PACAINITDATA(48, 0, NULL, 0, 0), | ||
138 | PACAINITDATA(49, 0, NULL, 0, 0), | ||
139 | PACAINITDATA(50, 0, NULL, 0, 0), | ||
140 | PACAINITDATA(51, 0, NULL, 0, 0), | ||
141 | PACAINITDATA(52, 0, NULL, 0, 0), | ||
142 | PACAINITDATA(53, 0, NULL, 0, 0), | ||
143 | PACAINITDATA(54, 0, NULL, 0, 0), | ||
144 | PACAINITDATA(55, 0, NULL, 0, 0), | ||
145 | PACAINITDATA(56, 0, NULL, 0, 0), | ||
146 | PACAINITDATA(57, 0, NULL, 0, 0), | ||
147 | PACAINITDATA(58, 0, NULL, 0, 0), | ||
148 | PACAINITDATA(59, 0, NULL, 0, 0), | ||
149 | PACAINITDATA(60, 0, NULL, 0, 0), | ||
150 | PACAINITDATA(61, 0, NULL, 0, 0), | ||
151 | PACAINITDATA(62, 0, NULL, 0, 0), | ||
152 | PACAINITDATA(63, 0, NULL, 0, 0), | ||
153 | #if NR_CPUS > 64 | 119 | #if NR_CPUS > 64 |
154 | PACAINITDATA(64, 0, NULL, 0, 0), | 120 | PACA_INIT( 64), PACA_INIT( 65), PACA_INIT( 66), PACA_INIT( 67), |
155 | PACAINITDATA(65, 0, NULL, 0, 0), | 121 | PACA_INIT( 68), PACA_INIT( 69), PACA_INIT( 70), PACA_INIT( 71), |
156 | PACAINITDATA(66, 0, NULL, 0, 0), | 122 | PACA_INIT( 72), PACA_INIT( 73), PACA_INIT( 74), PACA_INIT( 75), |
157 | PACAINITDATA(67, 0, NULL, 0, 0), | 123 | PACA_INIT( 76), PACA_INIT( 77), PACA_INIT( 78), PACA_INIT( 79), |
158 | PACAINITDATA(68, 0, NULL, 0, 0), | 124 | PACA_INIT( 80), PACA_INIT( 81), PACA_INIT( 82), PACA_INIT( 83), |
159 | PACAINITDATA(69, 0, NULL, 0, 0), | 125 | PACA_INIT( 84), PACA_INIT( 85), PACA_INIT( 86), PACA_INIT( 87), |
160 | PACAINITDATA(70, 0, NULL, 0, 0), | 126 | PACA_INIT( 88), PACA_INIT( 89), PACA_INIT( 90), PACA_INIT( 91), |
161 | PACAINITDATA(71, 0, NULL, 0, 0), | 127 | PACA_INIT( 92), PACA_INIT( 93), PACA_INIT( 94), PACA_INIT( 95), |
162 | PACAINITDATA(72, 0, NULL, 0, 0), | 128 | PACA_INIT( 96), PACA_INIT( 97), PACA_INIT( 98), PACA_INIT( 99), |
163 | PACAINITDATA(73, 0, NULL, 0, 0), | 129 | PACA_INIT(100), PACA_INIT(101), PACA_INIT(102), PACA_INIT(103), |
164 | PACAINITDATA(74, 0, NULL, 0, 0), | 130 | PACA_INIT(104), PACA_INIT(105), PACA_INIT(106), PACA_INIT(107), |
165 | PACAINITDATA(75, 0, NULL, 0, 0), | 131 | PACA_INIT(108), PACA_INIT(109), PACA_INIT(110), PACA_INIT(111), |
166 | PACAINITDATA(76, 0, NULL, 0, 0), | 132 | PACA_INIT(112), PACA_INIT(113), PACA_INIT(114), PACA_INIT(115), |
167 | PACAINITDATA(77, 0, NULL, 0, 0), | 133 | PACA_INIT(116), PACA_INIT(117), PACA_INIT(118), PACA_INIT(119), |
168 | PACAINITDATA(78, 0, NULL, 0, 0), | 134 | PACA_INIT(120), PACA_INIT(121), PACA_INIT(122), PACA_INIT(123), |
169 | PACAINITDATA(79, 0, NULL, 0, 0), | 135 | PACA_INIT(124), PACA_INIT(125), PACA_INIT(126), PACA_INIT(127), |
170 | PACAINITDATA(80, 0, NULL, 0, 0), | ||
171 | PACAINITDATA(81, 0, NULL, 0, 0), | ||
172 | PACAINITDATA(82, 0, NULL, 0, 0), | ||
173 | PACAINITDATA(83, 0, NULL, 0, 0), | ||
174 | PACAINITDATA(84, 0, NULL, 0, 0), | ||
175 | PACAINITDATA(85, 0, NULL, 0, 0), | ||
176 | PACAINITDATA(86, 0, NULL, 0, 0), | ||
177 | PACAINITDATA(87, 0, NULL, 0, 0), | ||
178 | PACAINITDATA(88, 0, NULL, 0, 0), | ||
179 | PACAINITDATA(89, 0, NULL, 0, 0), | ||
180 | PACAINITDATA(90, 0, NULL, 0, 0), | ||
181 | PACAINITDATA(91, 0, NULL, 0, 0), | ||
182 | PACAINITDATA(92, 0, NULL, 0, 0), | ||
183 | PACAINITDATA(93, 0, NULL, 0, 0), | ||
184 | PACAINITDATA(94, 0, NULL, 0, 0), | ||
185 | PACAINITDATA(95, 0, NULL, 0, 0), | ||
186 | PACAINITDATA(96, 0, NULL, 0, 0), | ||
187 | PACAINITDATA(97, 0, NULL, 0, 0), | ||
188 | PACAINITDATA(98, 0, NULL, 0, 0), | ||
189 | PACAINITDATA(99, 0, NULL, 0, 0), | ||
190 | PACAINITDATA(100, 0, NULL, 0, 0), | ||
191 | PACAINITDATA(101, 0, NULL, 0, 0), | ||
192 | PACAINITDATA(102, 0, NULL, 0, 0), | ||
193 | PACAINITDATA(103, 0, NULL, 0, 0), | ||
194 | PACAINITDATA(104, 0, NULL, 0, 0), | ||
195 | PACAINITDATA(105, 0, NULL, 0, 0), | ||
196 | PACAINITDATA(106, 0, NULL, 0, 0), | ||
197 | PACAINITDATA(107, 0, NULL, 0, 0), | ||
198 | PACAINITDATA(108, 0, NULL, 0, 0), | ||
199 | PACAINITDATA(109, 0, NULL, 0, 0), | ||
200 | PACAINITDATA(110, 0, NULL, 0, 0), | ||
201 | PACAINITDATA(111, 0, NULL, 0, 0), | ||
202 | PACAINITDATA(112, 0, NULL, 0, 0), | ||
203 | PACAINITDATA(113, 0, NULL, 0, 0), | ||
204 | PACAINITDATA(114, 0, NULL, 0, 0), | ||
205 | PACAINITDATA(115, 0, NULL, 0, 0), | ||
206 | PACAINITDATA(116, 0, NULL, 0, 0), | ||
207 | PACAINITDATA(117, 0, NULL, 0, 0), | ||
208 | PACAINITDATA(118, 0, NULL, 0, 0), | ||
209 | PACAINITDATA(119, 0, NULL, 0, 0), | ||
210 | PACAINITDATA(120, 0, NULL, 0, 0), | ||
211 | PACAINITDATA(121, 0, NULL, 0, 0), | ||
212 | PACAINITDATA(122, 0, NULL, 0, 0), | ||
213 | PACAINITDATA(123, 0, NULL, 0, 0), | ||
214 | PACAINITDATA(124, 0, NULL, 0, 0), | ||
215 | PACAINITDATA(125, 0, NULL, 0, 0), | ||
216 | PACAINITDATA(126, 0, NULL, 0, 0), | ||
217 | PACAINITDATA(127, 0, NULL, 0, 0), | ||
218 | #endif | 136 | #endif |
219 | #endif | 137 | #endif |
220 | #endif | 138 | #endif |
diff --git a/arch/ppc64/kernel/sysfs.c b/arch/ppc64/kernel/sysfs.c index c8fa6569b2fd..2f704a2cafb1 100644 --- a/arch/ppc64/kernel/sysfs.c +++ b/arch/ppc64/kernel/sysfs.c | |||
@@ -400,7 +400,12 @@ static int __init topology_init(void) | |||
400 | struct cpu *c = &per_cpu(cpu_devices, cpu); | 400 | struct cpu *c = &per_cpu(cpu_devices, cpu); |
401 | 401 | ||
402 | #ifdef CONFIG_NUMA | 402 | #ifdef CONFIG_NUMA |
403 | parent = &node_devices[cpu_to_node(cpu)]; | 403 | /* The node to which a cpu belongs can't be known |
404 | * until the cpu is made present. | ||
405 | */ | ||
406 | parent = NULL; | ||
407 | if (cpu_present(cpu)) | ||
408 | parent = &node_devices[cpu_to_node(cpu)]; | ||
404 | #endif | 409 | #endif |
405 | /* | 410 | /* |
406 | * For now, we just see if the system supports making | 411 | * For now, we just see if the system supports making |
diff --git a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c index 2a532db9138a..909462e1adea 100644 --- a/arch/ppc64/kernel/time.c +++ b/arch/ppc64/kernel/time.c | |||
@@ -99,7 +99,6 @@ unsigned long tb_to_ns_shift; | |||
99 | struct gettimeofday_struct do_gtod; | 99 | struct gettimeofday_struct do_gtod; |
100 | 100 | ||
101 | extern unsigned long wall_jiffies; | 101 | extern unsigned long wall_jiffies; |
102 | extern unsigned long lpevent_count; | ||
103 | extern int smp_tb_synchronized; | 102 | extern int smp_tb_synchronized; |
104 | 103 | ||
105 | extern struct timezone sys_tz; | 104 | extern struct timezone sys_tz; |
@@ -367,11 +366,8 @@ int timer_interrupt(struct pt_regs * regs) | |||
367 | set_dec(next_dec); | 366 | set_dec(next_dec); |
368 | 367 | ||
369 | #ifdef CONFIG_PPC_ISERIES | 368 | #ifdef CONFIG_PPC_ISERIES |
370 | { | 369 | if (hvlpevent_is_pending()) |
371 | struct ItLpQueue *lpq = lpaca->lpqueue_ptr; | 370 | process_hvlpevents(regs); |
372 | if (lpq && ItLpQueue_isLpIntPending(lpq)) | ||
373 | lpevent_count += ItLpQueue_process(lpq, regs); | ||
374 | } | ||
375 | #endif | 371 | #endif |
376 | 372 | ||
377 | /* collect purr register values often, for accurate calculations */ | 373 | /* collect purr register values often, for accurate calculations */ |
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c index 157190d986bb..d206d7e49cf5 100644 --- a/arch/x86_64/kernel/io_apic.c +++ b/arch/x86_64/kernel/io_apic.c | |||
@@ -1064,7 +1064,6 @@ void print_all_local_APICs (void) | |||
1064 | 1064 | ||
1065 | void __apicdebuginit print_PIC(void) | 1065 | void __apicdebuginit print_PIC(void) |
1066 | { | 1066 | { |
1067 | extern spinlock_t i8259A_lock; | ||
1068 | unsigned int v; | 1067 | unsigned int v; |
1069 | unsigned long flags; | 1068 | unsigned long flags; |
1070 | 1069 | ||
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 3e89767cea72..c9b5d298e3c4 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig | |||
@@ -132,7 +132,7 @@ config XTENSA_CPU_CLOCK | |||
132 | config GENERIC_CALIBRATE_DELAY | 132 | config GENERIC_CALIBRATE_DELAY |
133 | bool "Auto calibration of the BogoMIPS value" | 133 | bool "Auto calibration of the BogoMIPS value" |
134 | ---help--- | 134 | ---help--- |
135 | The BogoMIPS value can easily derived from the CPU frequency. | 135 | The BogoMIPS value can easily be derived from the CPU frequency. |
136 | 136 | ||
137 | config CMDLINE_BOOL | 137 | config CMDLINE_BOOL |
138 | bool "Default bootloader kernel arguments" | 138 | bool "Default bootloader kernel arguments" |
@@ -158,6 +158,8 @@ config XTENSA_ISS_NETWORK | |||
158 | depends on XTENSA_PLATFORM_ISS | 158 | depends on XTENSA_PLATFORM_ISS |
159 | default y | 159 | default y |
160 | 160 | ||
161 | source "mm/Kconfig" | ||
162 | |||
161 | endmenu | 163 | endmenu |
162 | 164 | ||
163 | menu "Bus options" | 165 | menu "Bus options" |
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile index 4fa27453b1f9..27847e4ffcbf 100644 --- a/arch/xtensa/Makefile +++ b/arch/xtensa/Makefile | |||
@@ -21,23 +21,17 @@ export CPU | |||
21 | 21 | ||
22 | # Platform configuration | 22 | # Platform configuration |
23 | 23 | ||
24 | platform-y := common | ||
25 | platform-$(CONFIG_XTENSA_PLATFORM_XT2000) := xt2000 | 24 | platform-$(CONFIG_XTENSA_PLATFORM_XT2000) := xt2000 |
26 | platform-$(CONFIG_XTENSA_PLATFORM_ISS) := iss | 25 | platform-$(CONFIG_XTENSA_PLATFORM_ISS) := iss |
27 | 26 | ||
28 | PLATFORM = $(platform-y) | 27 | PLATFORM = $(platform-y) |
29 | export PLATFORM | 28 | export PLATFORM |
30 | 29 | ||
31 | #LDFLAGS_vmlinux := -T$(word 1,$(LINKSCRIPT)) | 30 | CPPFLAGS += $(if $(KBUILD_SRC),-I$(srctree)/include/asm-xtensa/) |
32 | AFLAGS_vmlinux.lds.o := -Uxtensa | 31 | CPPFLAGS += -Iinclude/asm |
33 | CPPFLAGS += -Iarch/xtensa -Iinclude/asm -mlongcalls -g | 32 | CFLAGS += -pipe -mlongcalls |
34 | AFLAGS += -Iarch/xtensa -Iinclude/asm | ||
35 | CPP = $(CC) -E $(CFLAGS) | ||
36 | 33 | ||
37 | cflags-y += -Iarch/xtensa -pipe -mlongcalls | 34 | KBUILD_DEFCONFIG := iss_defconfig |
38 | |||
39 | |||
40 | KBUILD_DEFCONFIG := common_defconfig | ||
41 | 35 | ||
42 | # ramdisk/initrd support | 36 | # ramdisk/initrd support |
43 | # You need a compressed ramdisk image, named ramdisk.gz in | 37 | # You need a compressed ramdisk image, named ramdisk.gz in |
@@ -62,30 +56,36 @@ endif | |||
62 | LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) | 56 | LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) |
63 | 57 | ||
64 | head-y := arch/xtensa/kernel/head.o | 58 | head-y := arch/xtensa/kernel/head.o |
65 | core-y += arch/xtensa/kernel/ \ | 59 | core-y += arch/xtensa/kernel/ arch/xtensa/mm/ |
66 | arch/xtensa/mm/ arch/xtensa/platform-$(PLATFORM)/ | 60 | ifneq ($(PLATFORM),) |
61 | core-y += arch/xtensa/platform-$(PLATFORM)/ | ||
62 | endif | ||
67 | libs-y += arch/xtensa/lib/ $(LIBGCC) | 63 | libs-y += arch/xtensa/lib/ $(LIBGCC) |
68 | 64 | ||
69 | boot := arch/xtensa/boot | 65 | boot := arch/xtensa/boot |
66 | |||
67 | archinc := include/asm-xtensa | ||
70 | 68 | ||
71 | arch/xtensa/kernel/asm-offsets.s: \ | 69 | arch/xtensa/kernel/asm-offsets.s: \ |
72 | arch/xtensa/kernel/asm-offsets.c \ | 70 | arch/xtensa/kernel/asm-offsets.c $(archinc)/.platform |
73 | include/asm-xtensa/.platform | ||
74 | 71 | ||
75 | include/asm-xtensa/offsets.h: arch/xtensa/kernel/asm-offsets.s | 72 | include/asm-xtensa/offsets.h: arch/xtensa/kernel/asm-offsets.s |
76 | $(call filechk,gen-asm-offsets) | 73 | $(call filechk,gen-asm-offsets) |
77 | 74 | ||
78 | prepare: include/asm-xtensa/.platform include/asm-xtensa/offsets.h | 75 | prepare: $(archinc)/.platform $(archinc)/offsets.h |
79 | 76 | ||
80 | # Update machine cpu and platform symlinks if something which affects | 77 | # Update machine cpu and platform symlinks if something which affects |
81 | # them changed. | 78 | # them changed. |
82 | 79 | ||
83 | include/asm-xtensa/.platform: $(wildcard include/config/arch/*.h) | 80 | $(archinc)/.platform: $(wildcard include/config/arch/*.h) include/config/MARKER |
84 | @echo ' Setting up cpu ($(CPU)) and platform ($(PLATFORM)) symlinks' | 81 | @echo ' SYMLINK $(archinc)/xtensa/config -> $(archinc)/xtensa/config-$(CPU)' |
85 | $(Q)rm -f include/asm-xtensa/platform | 82 | $(Q)mkdir -p $(archinc) |
86 | $(Q)rm -f include/asm-xtensa/xtensa/config | 83 | $(Q)mkdir -p $(archinc)/xtensa |
87 | $(Q)(cd include/asm-xtensa/; ln -sf platform-$(PLATFORM) platform) | 84 | $(Q)ln -fsn $(srctree)/$(archinc)/xtensa/config-$(CPU) $(archinc)/xtensa/config |
88 | $(Q)(cd include/asm-xtensa/xtensa; ln -sf config-$(CPU) config) | 85 | @echo ' SYMLINK $(archinc)/platform -> $(archinc)/platform-$(PLATFORM)' |
86 | $(Q)ln -fsn $(srctree)/$(archinc)/platform-$(PLATFORM) $(archinc)/platform | ||
87 | @touch $@ | ||
88 | |||
89 | 89 | ||
90 | all: zImage | 90 | all: zImage |
91 | 91 | ||
@@ -94,7 +94,9 @@ bzImage : zImage | |||
94 | zImage zImage.initrd: vmlinux | 94 | zImage zImage.initrd: vmlinux |
95 | $(Q)$(MAKE) $(build)=$(boot) $@ | 95 | $(Q)$(MAKE) $(build)=$(boot) $@ |
96 | 96 | ||
97 | CLEAN_FILES += arch/xtensa/vmlinux.lds include/asm-xtensa/offset.h | 97 | CLEAN_FILES += arch/xtensa/vmlinux.lds $(archinc)/offset.h \ |
98 | $(archinc)/platform $(archinc)/xtensa/config \ | ||
99 | $(archinc)/.platform | ||
98 | 100 | ||
99 | define archhelp | 101 | define archhelp |
100 | @echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)' | 102 | @echo '* zImage - Compressed kernel image (arch/xtensa/boot/images/zImage.*)' |
diff --git a/arch/xtensa/boot/Makefile b/arch/xtensa/boot/Makefile index 260f456ccf0b..820b31d10ae4 100644 --- a/arch/xtensa/boot/Makefile +++ b/arch/xtensa/boot/Makefile | |||
@@ -11,21 +11,19 @@ | |||
11 | CFLAGS += -fno-builtin -Iarch/$(ARCH)/boot/include | 11 | CFLAGS += -fno-builtin -Iarch/$(ARCH)/boot/include |
12 | HOSTFLAGS += -Iarch/$(ARCH)/boot/include | 12 | HOSTFLAGS += -Iarch/$(ARCH)/boot/include |
13 | 13 | ||
14 | BIG_ENDIAN := $(shell echo -e "\#ifdef __XTENSA_EL__\nint little;\n\#else\nint big;\n\#endif" | $(CC) -E -|grep -c big) | 14 | BIG_ENDIAN := $(shell echo -e __XTENSA_EB__ | $(CC) -E - | grep -v "\#") |
15 | |||
16 | 15 | ||
17 | export CFLAGS | 16 | export CFLAGS |
18 | export AFLAGS | 17 | export AFLAGS |
19 | export BIG_ENDIAN | 18 | export BIG_ENDIAN |
20 | 19 | ||
20 | subdir-y := lib | ||
21 | |||
21 | # Subdirs for the boot loader(s) | 22 | # Subdirs for the boot loader(s) |
22 | 23 | ||
23 | bootdir-$(CONFIG_XTENSA_PLATFORM_ISS) += boot-elf | 24 | bootdir-$(CONFIG_XTENSA_PLATFORM_ISS) += boot-elf |
24 | bootdir-$(CONFIG_XTENSA_PLATFORM_XT2000) += boot-redboot boot-elf | 25 | bootdir-$(CONFIG_XTENSA_PLATFORM_XT2000) += boot-redboot boot-elf |
25 | 26 | ||
26 | subdir-y := lib/ | ||
27 | |||
28 | subdir-y += boot-elf/ boot-redboot/ | ||
29 | 27 | ||
30 | zImage zImage.initrd Image Image.initrd: $(bootdir-y) | 28 | zImage zImage.initrd Image Image.initrd: $(bootdir-y) |
31 | 29 | ||
@@ -33,5 +31,3 @@ $(bootdir-y): $(addprefix $(obj)/,$(subdir-y)) \ | |||
33 | $(addprefix $(obj)/,$(host-progs)) | 31 | $(addprefix $(obj)/,$(host-progs)) |
34 | $(Q)$(MAKE) $(build)=$(obj)/$@ $(MAKECMDGOALS) | 32 | $(Q)$(MAKE) $(build)=$(obj)/$@ $(MAKECMDGOALS) |
35 | 33 | ||
36 | |||
37 | |||
diff --git a/arch/xtensa/boot/boot-elf/Makefile b/arch/xtensa/boot/boot-elf/Makefile index f6ef6a369667..734db7f76583 100644 --- a/arch/xtensa/boot/boot-elf/Makefile +++ b/arch/xtensa/boot/boot-elf/Makefile | |||
@@ -27,7 +27,7 @@ Image: vmlinux $(OBJS) | |||
27 | --set-section-flags image=contents,alloc,load,load,data \ | 27 | --set-section-flags image=contents,alloc,load,load,data \ |
28 | $(OBJS) $@.tmp | 28 | $(OBJS) $@.tmp |
29 | $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) \ | 29 | $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) \ |
30 | -T arch/$(ARCH)/boot/boot-elf/boot.ld \ | 30 | -T $(srctree)/arch/$(ARCH)/boot/boot-elf/boot.ld \ |
31 | -o arch/$(ARCH)/boot/$@.elf $@.tmp | 31 | -o arch/$(ARCH)/boot/$@.elf $@.tmp |
32 | rm -f $@.tmp vmlinux.tmp | 32 | rm -f $@.tmp vmlinux.tmp |
33 | 33 | ||
@@ -41,7 +41,7 @@ Image.initrd: vmlinux $(OBJS) | |||
41 | --set-section-flags image=contents,alloc,load,load,data \ | 41 | --set-section-flags image=contents,alloc,load,load,data \ |
42 | $(OBJS) $@.tmp | 42 | $(OBJS) $@.tmp |
43 | $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) \ | 43 | $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) \ |
44 | -T arch/$(ARCH)/boot/boot-elf/boot.ld \ | 44 | -T $(srctree)/arch/$(ARCH)/boot/boot-elf/boot.ld \ |
45 | -o arch/$(ARCH)/boot/$@.elf $@.tmp | 45 | -o arch/$(ARCH)/boot/$@.elf $@.tmp |
46 | rm -f $@.tmp vmlinux.tmp | 46 | rm -f $@.tmp vmlinux.tmp |
47 | 47 | ||
diff --git a/arch/xtensa/boot/boot-redboot/Makefile b/arch/xtensa/boot/boot-redboot/Makefile index ca8a68bc8472..f53262c2e1f3 100644 --- a/arch/xtensa/boot/boot-redboot/Makefile +++ b/arch/xtensa/boot/boot-redboot/Makefile | |||
@@ -12,24 +12,24 @@ else | |||
12 | OBJCOPY_ARGS := -O elf32-xtensa-le | 12 | OBJCOPY_ARGS := -O elf32-xtensa-le |
13 | endif | 13 | endif |
14 | 14 | ||
15 | LD_ARGS = -T $(obj)/boot.ld | 15 | LD_ARGS = -T $(srctree)/$(obj)/boot.ld |
16 | 16 | ||
17 | boot-y := bootstrap.o | 17 | boot-y := bootstrap.o |
18 | 18 | ||
19 | OBJS := $(addprefix $(obj)/,$(boot-y)) | 19 | OBJS := $(addprefix $(obj)/,$(boot-y)) |
20 | LIBS := arch/$(ARCH)/boot/lib/lib.a arch/$(ARCH)/lib/lib.a | 20 | LIBS := arch/xtensa/boot/lib/lib.a arch/xtensa/lib/lib.a |
21 | 21 | ||
22 | LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) | 22 | LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) |
23 | 23 | ||
24 | zImage: vmlinux $(OBJS) $(LIBS) | 24 | zImage: vmlinux $(OBJS) $(LIBS) |
25 | $(OBJCOPY) --strip-all -R .comment -R .xt.insn -O binary \ | 25 | $(OBJCOPY) --strip-all -R .comment -R .xt.insn -O binary \ |
26 | $(TOPDIR)/vmlinux vmlinux.tmp | 26 | vmlinux vmlinux.tmp |
27 | gzip -vf9 vmlinux.tmp | 27 | gzip -vf9 vmlinux.tmp |
28 | $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ | 28 | $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ |
29 | --add-section image=vmlinux.tmp.gz \ | 29 | --add-section image=vmlinux.tmp.gz \ |
30 | --set-section-flags image=contents,alloc,load,load,data \ | 30 | --set-section-flags image=contents,alloc,load,load,data \ |
31 | $(OBJS) $@.tmp | 31 | $(OBJS) $@.tmp |
32 | $(LD) $(LD_ARGS) -o $@.elf $@.tmp $(LIBS) -L/xtensa-elf/lib $(LIBGCC) | 32 | $(LD) $(LD_ARGS) -o $@.elf $@.tmp $(LIBS) -L/xtensa-elf/lib $(LIBGCC) |
33 | $(OBJCOPY) -S -O binary $@.elf arch/$(ARCH)/boot/images/$@.redboot | 33 | $(OBJCOPY) -S -O binary $@.elf arch/$(ARCH)/boot/$@.redboot |
34 | # rm -f $@.tmp $@.elf vmlinux.tmp.gz | 34 | rm -f $@.tmp $@.elf vmlinux.tmp.gz |
35 | 35 | ||
diff --git a/arch/xtensa/boot/include/zlib.h b/arch/xtensa/boot/include/zlib.h deleted file mode 100644 index ea29b6237852..000000000000 --- a/arch/xtensa/boot/include/zlib.h +++ /dev/null | |||
@@ -1,433 +0,0 @@ | |||
1 | /* | ||
2 | * BK Id: SCCS/s.zlib.h 1.8 05/18/01 15:17:23 cort | ||
3 | */ | ||
4 | /* | ||
5 | * This file is derived from zlib.h and zconf.h from the zlib-0.95 | ||
6 | * distribution by Jean-loup Gailly and Mark Adler, with some additions | ||
7 | * by Paul Mackerras to aid in implementing Deflate compression and | ||
8 | * decompression for PPP packets. | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * ==FILEVERSION 960122== | ||
13 | * | ||
14 | * This marker is used by the Linux installation script to determine | ||
15 | * whether an up-to-date version of this file is already installed. | ||
16 | */ | ||
17 | |||
18 | /* zlib.h -- interface of the 'zlib' general purpose compression library | ||
19 | version 0.95, Aug 16th, 1995. | ||
20 | |||
21 | Copyright (C) 1995 Jean-loup Gailly and Mark Adler | ||
22 | |||
23 | This software is provided 'as-is', without any express or implied | ||
24 | warranty. In no event will the authors be held liable for any damages | ||
25 | arising from the use of this software. | ||
26 | |||
27 | Permission is granted to anyone to use this software for any purpose, | ||
28 | including commercial applications, and to alter it and redistribute it | ||
29 | freely, subject to the following restrictions: | ||
30 | |||
31 | 1. The origin of this software must not be misrepresented; you must not | ||
32 | claim that you wrote the original software. If you use this software | ||
33 | in a product, an acknowledgment in the product documentation would be | ||
34 | appreciated but is not required. | ||
35 | 2. Altered source versions must be plainly marked as such, and must not be | ||
36 | misrepresented as being the original software. | ||
37 | 3. This notice may not be removed or altered from any source distribution. | ||
38 | |||
39 | Jean-loup Gailly Mark Adler | ||
40 | gzip@prep.ai.mit.edu madler@alumni.caltech.edu | ||
41 | */ | ||
42 | |||
43 | #ifndef _ZLIB_H | ||
44 | #define _ZLIB_H | ||
45 | |||
46 | /* #include "zconf.h" */ /* included directly here */ | ||
47 | |||
48 | /* zconf.h -- configuration of the zlib compression library | ||
49 | * Copyright (C) 1995 Jean-loup Gailly. | ||
50 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
51 | */ | ||
52 | |||
53 | /* From: zconf.h,v 1.12 1995/05/03 17:27:12 jloup Exp */ | ||
54 | |||
55 | /* | ||
56 | The library does not install any signal handler. It is recommended to | ||
57 | add at least a handler for SIGSEGV when decompressing; the library checks | ||
58 | the consistency of the input data whenever possible but may go nuts | ||
59 | for some forms of corrupted input. | ||
60 | */ | ||
61 | |||
62 | /* | ||
63 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more | ||
64 | * than 64k bytes at a time (needed on systems with 16-bit int). | ||
65 | * Compile with -DUNALIGNED_OK if it is OK to access shorts or ints | ||
66 | * at addresses which are not a multiple of their size. | ||
67 | * Under DOS, -DFAR=far or -DFAR=__far may be needed. | ||
68 | */ | ||
69 | |||
70 | #ifndef STDC | ||
71 | # if defined(MSDOS) || defined(__STDC__) || defined(__cplusplus) | ||
72 | # define STDC | ||
73 | # endif | ||
74 | #endif | ||
75 | |||
76 | #ifdef __MWERKS__ /* Metrowerks CodeWarrior declares fileno() in unix.h */ | ||
77 | # include <unix.h> | ||
78 | #endif | ||
79 | |||
80 | /* Maximum value for memLevel in deflateInit2 */ | ||
81 | #ifndef MAX_MEM_LEVEL | ||
82 | # ifdef MAXSEG_64K | ||
83 | # define MAX_MEM_LEVEL 8 | ||
84 | # else | ||
85 | # define MAX_MEM_LEVEL 9 | ||
86 | # endif | ||
87 | #endif | ||
88 | |||
89 | #ifndef FAR | ||
90 | # define FAR | ||
91 | #endif | ||
92 | |||
93 | /* Maximum value for windowBits in deflateInit2 and inflateInit2 */ | ||
94 | #ifndef MAX_WBITS | ||
95 | # define MAX_WBITS 15 /* 32K LZ77 window */ | ||
96 | #endif | ||
97 | |||
98 | /* The memory requirements for deflate are (in bytes): | ||
99 | 1 << (windowBits+2) + 1 << (memLevel+9) | ||
100 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) | ||
101 | plus a few kilobytes for small objects. For example, if you want to reduce | ||
102 | the default memory requirements from 256K to 128K, compile with | ||
103 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" | ||
104 | Of course this will generally degrade compression (there's no free lunch). | ||
105 | |||
106 | The memory requirements for inflate are (in bytes) 1 << windowBits | ||
107 | that is, 32K for windowBits=15 (default value) plus a few kilobytes | ||
108 | for small objects. | ||
109 | */ | ||
110 | |||
111 | /* Type declarations */ | ||
112 | |||
113 | #ifndef OF /* function prototypes */ | ||
114 | # ifdef STDC | ||
115 | # define OF(args) args | ||
116 | # else | ||
117 | # define OF(args) () | ||
118 | # endif | ||
119 | #endif | ||
120 | |||
121 | typedef unsigned char Byte; /* 8 bits */ | ||
122 | typedef unsigned int uInt; /* 16 bits or more */ | ||
123 | typedef unsigned long uLong; /* 32 bits or more */ | ||
124 | |||
125 | typedef Byte FAR Bytef; | ||
126 | typedef char FAR charf; | ||
127 | typedef int FAR intf; | ||
128 | typedef uInt FAR uIntf; | ||
129 | typedef uLong FAR uLongf; | ||
130 | |||
131 | #ifdef STDC | ||
132 | typedef void FAR *voidpf; | ||
133 | typedef void *voidp; | ||
134 | #else | ||
135 | typedef Byte FAR *voidpf; | ||
136 | typedef Byte *voidp; | ||
137 | #endif | ||
138 | |||
139 | /* end of original zconf.h */ | ||
140 | |||
141 | #define ZLIB_VERSION "0.95P" | ||
142 | |||
143 | /* | ||
144 | The 'zlib' compression library provides in-memory compression and | ||
145 | decompression functions, including integrity checks of the uncompressed | ||
146 | data. This version of the library supports only one compression method | ||
147 | (deflation) but other algorithms may be added later and will have the same | ||
148 | stream interface. | ||
149 | |||
150 | For compression the application must provide the output buffer and | ||
151 | may optionally provide the input buffer for optimization. For decompression, | ||
152 | the application must provide the input buffer and may optionally provide | ||
153 | the output buffer for optimization. | ||
154 | |||
155 | Compression can be done in a single step if the buffers are large | ||
156 | enough (for example if an input file is mmap'ed), or can be done by | ||
157 | repeated calls of the compression function. In the latter case, the | ||
158 | application must provide more input and/or consume the output | ||
159 | (providing more output space) before each call. | ||
160 | */ | ||
161 | |||
162 | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); | ||
163 | typedef void (*free_func) OF((voidpf opaque, voidpf address, uInt nbytes)); | ||
164 | |||
165 | struct internal_state; | ||
166 | |||
167 | typedef struct z_stream_s { | ||
168 | Bytef *next_in; /* next input byte */ | ||
169 | uInt avail_in; /* number of bytes available at next_in */ | ||
170 | uLong total_in; /* total nb of input bytes read so far */ | ||
171 | |||
172 | Bytef *next_out; /* next output byte should be put there */ | ||
173 | uInt avail_out; /* remaining free space at next_out */ | ||
174 | uLong total_out; /* total nb of bytes output so far */ | ||
175 | |||
176 | char *msg; /* last error message, NULL if no error */ | ||
177 | struct internal_state FAR *state; /* not visible by applications */ | ||
178 | |||
179 | alloc_func zalloc; /* used to allocate the internal state */ | ||
180 | free_func zfree; /* used to free the internal state */ | ||
181 | voidp opaque; /* private data object passed to zalloc and zfree */ | ||
182 | |||
183 | Byte data_type; /* best guess about the data type: ascii or binary */ | ||
184 | |||
185 | } z_stream; | ||
186 | |||
187 | /* | ||
188 | The application must update next_in and avail_in when avail_in has | ||
189 | dropped to zero. It must update next_out and avail_out when avail_out | ||
190 | has dropped to zero. The application must initialize zalloc, zfree and | ||
191 | opaque before calling the init function. All other fields are set by the | ||
192 | compression library and must not be updated by the application. | ||
193 | |||
194 | The opaque value provided by the application will be passed as the first | ||
195 | parameter for calls of zalloc and zfree. This can be useful for custom | ||
196 | memory management. The compression library attaches no meaning to the | ||
197 | opaque value. | ||
198 | |||
199 | zalloc must return Z_NULL if there is not enough memory for the object. | ||
200 | On 16-bit systems, the functions zalloc and zfree must be able to allocate | ||
201 | exactly 65536 bytes, but will not be required to allocate more than this | ||
202 | if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, | ||
203 | pointers returned by zalloc for objects of exactly 65536 bytes *must* | ||
204 | have their offset normalized to zero. The default allocation function | ||
205 | provided by this library ensures this (see zutil.c). To reduce memory | ||
206 | requirements and avoid any allocation of 64K objects, at the expense of | ||
207 | compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). | ||
208 | |||
209 | The fields total_in and total_out can be used for statistics or | ||
210 | progress reports. After compression, total_in holds the total size of | ||
211 | the uncompressed data and may be saved for use in the decompressor | ||
212 | (particularly if the decompressor wants to decompress everything in | ||
213 | a single step). | ||
214 | */ | ||
215 | |||
216 | /* constants */ | ||
217 | |||
218 | #define Z_NO_FLUSH 0 | ||
219 | #define Z_PARTIAL_FLUSH 1 | ||
220 | #define Z_FULL_FLUSH 2 | ||
221 | #define Z_SYNC_FLUSH 3 /* experimental: partial_flush + byte align */ | ||
222 | #define Z_FINISH 4 | ||
223 | #define Z_PACKET_FLUSH 5 | ||
224 | /* See deflate() below for the usage of these constants */ | ||
225 | |||
226 | #define Z_OK 0 | ||
227 | #define Z_STREAM_END 1 | ||
228 | #define Z_ERRNO (-1) | ||
229 | #define Z_STREAM_ERROR (-2) | ||
230 | #define Z_DATA_ERROR (-3) | ||
231 | #define Z_MEM_ERROR (-4) | ||
232 | #define Z_BUF_ERROR (-5) | ||
233 | /* error codes for the compression/decompression functions */ | ||
234 | |||
235 | #define Z_BEST_SPEED 1 | ||
236 | #define Z_BEST_COMPRESSION 9 | ||
237 | #define Z_DEFAULT_COMPRESSION (-1) | ||
238 | /* compression levels */ | ||
239 | |||
240 | #define Z_FILTERED 1 | ||
241 | #define Z_HUFFMAN_ONLY 2 | ||
242 | #define Z_DEFAULT_STRATEGY 0 | ||
243 | |||
244 | #define Z_BINARY 0 | ||
245 | #define Z_ASCII 1 | ||
246 | #define Z_UNKNOWN 2 | ||
247 | /* Used to set the data_type field */ | ||
248 | |||
249 | #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ | ||
250 | |||
251 | extern char *zlib_version; | ||
252 | /* The application can compare zlib_version and ZLIB_VERSION for consistency. | ||
253 | If the first character differs, the library code actually used is | ||
254 | not compatible with the zlib.h header file used by the application. | ||
255 | */ | ||
256 | |||
257 | /* basic functions */ | ||
258 | |||
259 | extern int inflateInit OF((z_stream *strm)); | ||
260 | /* | ||
261 | Initializes the internal stream state for decompression. The fields | ||
262 | zalloc and zfree must be initialized before by the caller. If zalloc and | ||
263 | zfree are set to Z_NULL, inflateInit updates them to use default allocation | ||
264 | functions. | ||
265 | |||
266 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not | ||
267 | enough memory. msg is set to null if there is no error message. | ||
268 | inflateInit does not perform any decompression: this will be done by | ||
269 | inflate(). | ||
270 | */ | ||
271 | |||
272 | |||
273 | extern int inflate OF((z_stream *strm, int flush)); | ||
274 | /* | ||
275 | Performs one or both of the following actions: | ||
276 | |||
277 | - Decompress more input starting at next_in and update next_in and avail_in | ||
278 | accordingly. If not all input can be processed (because there is not | ||
279 | enough room in the output buffer), next_in is updated and processing | ||
280 | will resume at this point for the next call of inflate(). | ||
281 | |||
282 | - Provide more output starting at next_out and update next_out and avail_out | ||
283 | accordingly. inflate() always provides as much output as possible | ||
284 | (until there is no more input data or no more space in the output buffer). | ||
285 | |||
286 | Before the call of inflate(), the application should ensure that at least | ||
287 | one of the actions is possible, by providing more input and/or consuming | ||
288 | more output, and updating the next_* and avail_* values accordingly. | ||
289 | The application can consume the uncompressed output when it wants, for | ||
290 | example when the output buffer is full (avail_out == 0), or after each | ||
291 | call of inflate(). | ||
292 | |||
293 | If the parameter flush is set to Z_PARTIAL_FLUSH or Z_PACKET_FLUSH, | ||
294 | inflate flushes as much output as possible to the output buffer. The | ||
295 | flushing behavior of inflate is not specified for values of the flush | ||
296 | parameter other than Z_PARTIAL_FLUSH, Z_PACKET_FLUSH or Z_FINISH, but the | ||
297 | current implementation actually flushes as much output as possible | ||
298 | anyway. For Z_PACKET_FLUSH, inflate checks that once all the input data | ||
299 | has been consumed, it is expecting to see the length field of a stored | ||
300 | block; if not, it returns Z_DATA_ERROR. | ||
301 | |||
302 | inflate() should normally be called until it returns Z_STREAM_END or an | ||
303 | error. However if all decompression is to be performed in a single step | ||
304 | (a single call of inflate), the parameter flush should be set to | ||
305 | Z_FINISH. In this case all pending input is processed and all pending | ||
306 | output is flushed; avail_out must be large enough to hold all the | ||
307 | uncompressed data. (The size of the uncompressed data may have been saved | ||
308 | by the compressor for this purpose.) The next operation on this stream must | ||
309 | be inflateEnd to deallocate the decompression state. The use of Z_FINISH | ||
310 | is never required, but can be used to inform inflate that a faster routine | ||
311 | may be used for the single inflate() call. | ||
312 | |||
313 | inflate() returns Z_OK if some progress has been made (more input | ||
314 | processed or more output produced), Z_STREAM_END if the end of the | ||
315 | compressed data has been reached and all uncompressed output has been | ||
316 | produced, Z_DATA_ERROR if the input data was corrupted, Z_STREAM_ERROR if | ||
317 | the stream structure was inconsistent (for example if next_in or next_out | ||
318 | was NULL), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no | ||
319 | progress is possible or if there was not enough room in the output buffer | ||
320 | when Z_FINISH is used. In the Z_DATA_ERROR case, the application may then | ||
321 | call inflateSync to look for a good compression block. */ | ||
322 | |||
323 | |||
324 | extern int inflateEnd OF((z_stream *strm)); | ||
325 | /* | ||
326 | All dynamically allocated data structures for this stream are freed. | ||
327 | This function discards any unprocessed input and does not flush any | ||
328 | pending output. | ||
329 | |||
330 | inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state | ||
331 | was inconsistent. In the error case, msg may be set but then points to a | ||
332 | static string (which must not be deallocated). | ||
333 | */ | ||
334 | |||
335 | /* advanced functions */ | ||
336 | |||
337 | extern int inflateInit2 OF((z_stream *strm, | ||
338 | int windowBits)); | ||
339 | /* | ||
340 | This is another version of inflateInit with more compression options. The | ||
341 | fields next_out, zalloc and zfree must be initialized before by the caller. | ||
342 | |||
343 | The windowBits parameter is the base two logarithm of the maximum window | ||
344 | size (the size of the history buffer). It should be in the range 8..15 for | ||
345 | this version of the library (the value 16 will be allowed soon). The | ||
346 | default value is 15 if inflateInit is used instead. If a compressed stream | ||
347 | with a larger window size is given as input, inflate() will return with | ||
348 | the error code Z_DATA_ERROR instead of trying to allocate a larger window. | ||
349 | |||
350 | If next_out is not null, the library will use this buffer for the history | ||
351 | buffer; the buffer must either be large enough to hold the entire output | ||
352 | data, or have at least 1<<windowBits bytes. If next_out is null, the | ||
353 | library will allocate its own buffer (and leave next_out null). next_in | ||
354 | need not be provided here but must be provided by the application for the | ||
355 | next call of inflate(). | ||
356 | |||
357 | If the history buffer is provided by the application, next_out must | ||
358 | never be changed by the application since the decompressor maintains | ||
359 | history information inside this buffer from call to call; the application | ||
360 | can only reset next_out to the beginning of the history buffer when | ||
361 | avail_out is zero and all output has been consumed. | ||
362 | |||
363 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was | ||
364 | not enough memory, Z_STREAM_ERROR if a parameter is invalid (such as | ||
365 | windowBits < 8). msg is set to null if there is no error message. | ||
366 | inflateInit2 does not perform any decompression: this will be done by | ||
367 | inflate(). | ||
368 | */ | ||
369 | |||
370 | extern int inflateSync OF((z_stream *strm)); | ||
371 | /* | ||
372 | Skips invalid compressed data until the special marker (see deflate() | ||
373 | above) can be found, or until all available input is skipped. No output | ||
374 | is provided. | ||
375 | |||
376 | inflateSync returns Z_OK if the special marker has been found, Z_BUF_ERROR | ||
377 | if no more input was provided, Z_DATA_ERROR if no marker has been found, | ||
378 | or Z_STREAM_ERROR if the stream structure was inconsistent. In the success | ||
379 | case, the application may save the current current value of total_in which | ||
380 | indicates where valid compressed data was found. In the error case, the | ||
381 | application may repeatedly call inflateSync, providing more input each time, | ||
382 | until success or end of the input data. | ||
383 | */ | ||
384 | |||
385 | extern int inflateReset OF((z_stream *strm)); | ||
386 | /* | ||
387 | This function is equivalent to inflateEnd followed by inflateInit, | ||
388 | but does not free and reallocate all the internal decompression state. | ||
389 | The stream will keep attributes that may have been set by inflateInit2. | ||
390 | |||
391 | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source | ||
392 | stream state was inconsistent (such as zalloc or state being NULL). | ||
393 | */ | ||
394 | |||
395 | extern int inflateIncomp OF((z_stream *strm)); | ||
396 | /* | ||
397 | This function adds the data at next_in (avail_in bytes) to the output | ||
398 | history without performing any output. There must be no pending output, | ||
399 | and the decompressor must be expecting to see the start of a block. | ||
400 | Calling this function is equivalent to decompressing a stored block | ||
401 | containing the data at next_in (except that the data is not output). | ||
402 | */ | ||
403 | |||
404 | /* checksum functions */ | ||
405 | |||
406 | /* | ||
407 | This function is not related to compression but is exported | ||
408 | anyway because it might be useful in applications using the | ||
409 | compression library. | ||
410 | */ | ||
411 | |||
412 | extern uLong adler32 OF((uLong adler, Bytef *buf, uInt len)); | ||
413 | |||
414 | /* | ||
415 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and | ||
416 | return the updated checksum. If buf is NULL, this function returns | ||
417 | the required initial value for the checksum. | ||
418 | An Adler-32 checksum is almost as reliable as a CRC32 but can be computed | ||
419 | much faster. Usage example: | ||
420 | |||
421 | uLong adler = adler32(0L, Z_NULL, 0); | ||
422 | |||
423 | while (read_buffer(buffer, length) != EOF) { | ||
424 | adler = adler32(adler, buffer, length); | ||
425 | } | ||
426 | if (adler != original_adler) error(); | ||
427 | */ | ||
428 | |||
429 | #ifndef _Z_UTIL_H | ||
430 | struct internal_state {int dummy;}; /* hack for buggy compilers */ | ||
431 | #endif | ||
432 | |||
433 | #endif /* _ZLIB_H */ | ||
diff --git a/arch/xtensa/boot/lib/Makefile b/arch/xtensa/boot/lib/Makefile index c0a74dc3a0df..9e73bb8aeb7a 100644 --- a/arch/xtensa/boot/lib/Makefile +++ b/arch/xtensa/boot/lib/Makefile | |||
@@ -2,5 +2,16 @@ | |||
2 | # Makefile for some libs needed by zImage. | 2 | # Makefile for some libs needed by zImage. |
3 | # | 3 | # |
4 | 4 | ||
5 | zlib := infblock.c infcodes.c inffast.c inflate.c inftrees.c infutil.c | ||
5 | 6 | ||
6 | lib-y := zlib.o zmem.o | 7 | lib-y += $(zlib:.c=.o) zmem.o |
8 | |||
9 | EXTRA_CFLAGS += -Ilib/zlib_inflate | ||
10 | |||
11 | quiet_cmd_copy_zlib = COPY $@ | ||
12 | cmd_copy_zlib = cat $< > $@ | ||
13 | |||
14 | $(addprefix $(obj)/,$(zlib)): $(obj)/%: $(srctree)/lib/zlib_inflate/% | ||
15 | $(call cmd,copy_zlib) | ||
16 | |||
17 | clean-files := $(zlib) | ||
diff --git a/arch/xtensa/boot/lib/memcpy.S b/arch/xtensa/boot/lib/memcpy.S deleted file mode 100644 index a029f5df2d5c..000000000000 --- a/arch/xtensa/boot/lib/memcpy.S +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | /* | ||
2 | * arch/xtensa/lib/memcpy.S | ||
3 | * | ||
4 | * ANSI C standard library function memcpy | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of the GNU General | ||
7 | * Public License. See the file "COPYING" in the main directory of | ||
8 | * this archive for more details. | ||
9 | * | ||
10 | * Copyright (C) 2002 Tensilica Inc. | ||
11 | */ | ||
12 | |||
13 | #define _ASMLANGUAGE | ||
14 | #include <xtensa/config/core.h> | ||
15 | |||
16 | .text | ||
17 | .align 4 | ||
18 | .global bcopy | ||
19 | .type bcopy,@function | ||
20 | bcopy: | ||
21 | movi a14, xthal_bcopy // a14 safe to use regardless of whether caller | ||
22 | // used call4 or call8 (can't have used call12) | ||
23 | jx a14 // let the Core HAL do the work | ||
24 | |||
25 | .text | ||
26 | .align 4 | ||
27 | .global memcpy | ||
28 | .type memcpy,@function | ||
29 | memcpy: | ||
30 | .global memmove | ||
31 | .type memmove,@function | ||
32 | memmove: | ||
33 | movi a14, xthal_memcpy // a14 safe to use regardless of whether caller | ||
34 | // used call4 or call8 (can't have used call12) | ||
35 | jx a14 // let the Core HAL do the work | ||
36 | |||
diff --git a/arch/xtensa/boot/lib/zlib.c b/arch/xtensa/boot/lib/zlib.c deleted file mode 100644 index e3859f631077..000000000000 --- a/arch/xtensa/boot/lib/zlib.c +++ /dev/null | |||
@@ -1,2150 +0,0 @@ | |||
1 | /* | ||
2 | * BK Id: SCCS/s.zlib.c 1.8 05/18/01 15:17:24 cort | ||
3 | */ | ||
4 | /* | ||
5 | * This file is derived from various .h and .c files from the zlib-0.95 | ||
6 | * distribution by Jean-loup Gailly and Mark Adler, with some additions | ||
7 | * by Paul Mackerras to aid in implementing Deflate compression and | ||
8 | * decompression for PPP packets. See zlib.h for conditions of | ||
9 | * distribution and use. | ||
10 | * | ||
11 | * Changes that have been made include: | ||
12 | * - changed functions not used outside this file to "local" | ||
13 | * - added minCompression parameter to deflateInit2 | ||
14 | * - added Z_PACKET_FLUSH (see zlib.h for details) | ||
15 | * - added inflateIncomp | ||
16 | * | ||
17 | */ | ||
18 | |||
19 | /*+++++*/ | ||
20 | /* zutil.h -- internal interface and configuration of the compression library | ||
21 | * Copyright (C) 1995 Jean-loup Gailly. | ||
22 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
23 | */ | ||
24 | |||
25 | /* WARNING: this file should *not* be used by applications. It is | ||
26 | part of the implementation of the compression library and is | ||
27 | subject to change. Applications should only use zlib.h. | ||
28 | */ | ||
29 | |||
30 | /* From: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp */ | ||
31 | |||
32 | #define _Z_UTIL_H | ||
33 | |||
34 | #include "zlib.h" | ||
35 | |||
36 | #ifndef local | ||
37 | # define local static | ||
38 | #endif | ||
39 | /* compile with -Dlocal if your debugger can't find static symbols */ | ||
40 | |||
41 | #define FAR | ||
42 | |||
43 | typedef unsigned char uch; | ||
44 | typedef uch FAR uchf; | ||
45 | typedef unsigned short ush; | ||
46 | typedef ush FAR ushf; | ||
47 | typedef unsigned long ulg; | ||
48 | |||
49 | extern char *z_errmsg[]; /* indexed by 1-zlib_error */ | ||
50 | |||
51 | #define ERR_RETURN(strm,err) return (strm->msg=z_errmsg[1-err], err) | ||
52 | /* To be used only when the state is known to be valid */ | ||
53 | |||
54 | #ifndef NULL | ||
55 | #define NULL ((void *) 0) | ||
56 | #endif | ||
57 | |||
58 | /* common constants */ | ||
59 | |||
60 | #define DEFLATED 8 | ||
61 | |||
62 | #ifndef DEF_WBITS | ||
63 | # define DEF_WBITS MAX_WBITS | ||
64 | #endif | ||
65 | /* default windowBits for decompression. MAX_WBITS is for compression only */ | ||
66 | |||
67 | #if MAX_MEM_LEVEL >= 8 | ||
68 | # define DEF_MEM_LEVEL 8 | ||
69 | #else | ||
70 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL | ||
71 | #endif | ||
72 | /* default memLevel */ | ||
73 | |||
74 | #define STORED_BLOCK 0 | ||
75 | #define STATIC_TREES 1 | ||
76 | #define DYN_TREES 2 | ||
77 | /* The three kinds of block type */ | ||
78 | |||
79 | #define MIN_MATCH 3 | ||
80 | #define MAX_MATCH 258 | ||
81 | /* The minimum and maximum match lengths */ | ||
82 | |||
83 | /* functions */ | ||
84 | |||
85 | #include <linux/string.h> | ||
86 | #define zmemcpy memcpy | ||
87 | #define zmemzero(dest, len) memset(dest, 0, len) | ||
88 | |||
89 | /* Diagnostic functions */ | ||
90 | #ifdef DEBUG_ZLIB | ||
91 | # include <stdio.h> | ||
92 | # ifndef verbose | ||
93 | # define verbose 0 | ||
94 | # endif | ||
95 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} | ||
96 | # define Trace(x) fprintf x | ||
97 | # define Tracev(x) {if (verbose) fprintf x ;} | ||
98 | # define Tracevv(x) {if (verbose>1) fprintf x ;} | ||
99 | # define Tracec(c,x) {if (verbose && (c)) fprintf x ;} | ||
100 | # define Tracecv(c,x) {if (verbose>1 && (c)) fprintf x ;} | ||
101 | #else | ||
102 | # define Assert(cond,msg) | ||
103 | # define Trace(x) | ||
104 | # define Tracev(x) | ||
105 | # define Tracevv(x) | ||
106 | # define Tracec(c,x) | ||
107 | # define Tracecv(c,x) | ||
108 | #endif | ||
109 | |||
110 | |||
111 | typedef uLong (*check_func) OF((uLong check, Bytef *buf, uInt len)); | ||
112 | |||
113 | /* voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); */ | ||
114 | /* void zcfree OF((voidpf opaque, voidpf ptr)); */ | ||
115 | |||
116 | #define ZALLOC(strm, items, size) \ | ||
117 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) | ||
118 | #define ZFREE(strm, addr, size) \ | ||
119 | (*((strm)->zfree))((strm)->opaque, (voidpf)(addr), (size)) | ||
120 | #define TRY_FREE(s, p, n) {if (p) ZFREE(s, p, n);} | ||
121 | |||
122 | /* deflate.h -- internal compression state | ||
123 | * Copyright (C) 1995 Jean-loup Gailly | ||
124 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
125 | */ | ||
126 | |||
127 | /* WARNING: this file should *not* be used by applications. It is | ||
128 | part of the implementation of the compression library and is | ||
129 | subject to change. Applications should only use zlib.h. | ||
130 | */ | ||
131 | |||
132 | /*+++++*/ | ||
133 | /* infblock.h -- header to use infblock.c | ||
134 | * Copyright (C) 1995 Mark Adler | ||
135 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
136 | */ | ||
137 | |||
138 | /* WARNING: this file should *not* be used by applications. It is | ||
139 | part of the implementation of the compression library and is | ||
140 | subject to change. Applications should only use zlib.h. | ||
141 | */ | ||
142 | |||
143 | struct inflate_blocks_state; | ||
144 | typedef struct inflate_blocks_state FAR inflate_blocks_statef; | ||
145 | |||
146 | local inflate_blocks_statef * inflate_blocks_new OF(( | ||
147 | z_stream *z, | ||
148 | check_func c, /* check function */ | ||
149 | uInt w)); /* window size */ | ||
150 | |||
151 | local int inflate_blocks OF(( | ||
152 | inflate_blocks_statef *, | ||
153 | z_stream *, | ||
154 | int)); /* initial return code */ | ||
155 | |||
156 | local void inflate_blocks_reset OF(( | ||
157 | inflate_blocks_statef *, | ||
158 | z_stream *, | ||
159 | uLongf *)); /* check value on output */ | ||
160 | |||
161 | local int inflate_blocks_free OF(( | ||
162 | inflate_blocks_statef *, | ||
163 | z_stream *, | ||
164 | uLongf *)); /* check value on output */ | ||
165 | |||
166 | local int inflate_addhistory OF(( | ||
167 | inflate_blocks_statef *, | ||
168 | z_stream *)); | ||
169 | |||
170 | local int inflate_packet_flush OF(( | ||
171 | inflate_blocks_statef *)); | ||
172 | |||
173 | /*+++++*/ | ||
174 | /* inftrees.h -- header to use inftrees.c | ||
175 | * Copyright (C) 1995 Mark Adler | ||
176 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
177 | */ | ||
178 | |||
179 | /* WARNING: this file should *not* be used by applications. It is | ||
180 | part of the implementation of the compression library and is | ||
181 | subject to change. Applications should only use zlib.h. | ||
182 | */ | ||
183 | |||
184 | /* Huffman code lookup table entry--this entry is four bytes for machines | ||
185 | that have 16-bit pointers (e.g. PC's in the small or medium model). */ | ||
186 | |||
187 | typedef struct inflate_huft_s FAR inflate_huft; | ||
188 | |||
189 | struct inflate_huft_s { | ||
190 | union { | ||
191 | struct { | ||
192 | Byte Exop; /* number of extra bits or operation */ | ||
193 | Byte Bits; /* number of bits in this code or subcode */ | ||
194 | } what; | ||
195 | uInt Nalloc; /* number of these allocated here */ | ||
196 | Bytef *pad; /* pad structure to a power of 2 (4 bytes for */ | ||
197 | } word; /* 16-bit, 8 bytes for 32-bit machines) */ | ||
198 | union { | ||
199 | uInt Base; /* literal, length base, or distance base */ | ||
200 | inflate_huft *Next; /* pointer to next level of table */ | ||
201 | } more; | ||
202 | }; | ||
203 | |||
204 | #ifdef DEBUG_ZLIB | ||
205 | local uInt inflate_hufts; | ||
206 | #endif | ||
207 | |||
208 | local int inflate_trees_bits OF(( | ||
209 | uIntf *, /* 19 code lengths */ | ||
210 | uIntf *, /* bits tree desired/actual depth */ | ||
211 | inflate_huft * FAR *, /* bits tree result */ | ||
212 | z_stream *)); /* for zalloc, zfree functions */ | ||
213 | |||
214 | local int inflate_trees_dynamic OF(( | ||
215 | uInt, /* number of literal/length codes */ | ||
216 | uInt, /* number of distance codes */ | ||
217 | uIntf *, /* that many (total) code lengths */ | ||
218 | uIntf *, /* literal desired/actual bit depth */ | ||
219 | uIntf *, /* distance desired/actual bit depth */ | ||
220 | inflate_huft * FAR *, /* literal/length tree result */ | ||
221 | inflate_huft * FAR *, /* distance tree result */ | ||
222 | z_stream *)); /* for zalloc, zfree functions */ | ||
223 | |||
224 | local int inflate_trees_fixed OF(( | ||
225 | uIntf *, /* literal desired/actual bit depth */ | ||
226 | uIntf *, /* distance desired/actual bit depth */ | ||
227 | inflate_huft * FAR *, /* literal/length tree result */ | ||
228 | inflate_huft * FAR *)); /* distance tree result */ | ||
229 | |||
230 | local int inflate_trees_free OF(( | ||
231 | inflate_huft *, /* tables to free */ | ||
232 | z_stream *)); /* for zfree function */ | ||
233 | |||
234 | |||
235 | /*+++++*/ | ||
236 | /* infcodes.h -- header to use infcodes.c | ||
237 | * Copyright (C) 1995 Mark Adler | ||
238 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
239 | */ | ||
240 | |||
241 | /* WARNING: this file should *not* be used by applications. It is | ||
242 | part of the implementation of the compression library and is | ||
243 | subject to change. Applications should only use zlib.h. | ||
244 | */ | ||
245 | |||
246 | struct inflate_codes_state; | ||
247 | typedef struct inflate_codes_state FAR inflate_codes_statef; | ||
248 | |||
249 | local inflate_codes_statef *inflate_codes_new OF(( | ||
250 | uInt, uInt, | ||
251 | inflate_huft *, inflate_huft *, | ||
252 | z_stream *)); | ||
253 | |||
254 | local int inflate_codes OF(( | ||
255 | inflate_blocks_statef *, | ||
256 | z_stream *, | ||
257 | int)); | ||
258 | |||
259 | local void inflate_codes_free OF(( | ||
260 | inflate_codes_statef *, | ||
261 | z_stream *)); | ||
262 | |||
263 | |||
264 | /*+++++*/ | ||
265 | /* inflate.c -- zlib interface to inflate modules | ||
266 | * Copyright (C) 1995 Mark Adler | ||
267 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
268 | */ | ||
269 | |||
270 | /* inflate private state */ | ||
271 | struct internal_state { | ||
272 | |||
273 | /* mode */ | ||
274 | enum { | ||
275 | METHOD, /* waiting for method byte */ | ||
276 | FLAG, /* waiting for flag byte */ | ||
277 | BLOCKS, /* decompressing blocks */ | ||
278 | CHECK4, /* four check bytes to go */ | ||
279 | CHECK3, /* three check bytes to go */ | ||
280 | CHECK2, /* two check bytes to go */ | ||
281 | CHECK1, /* one check byte to go */ | ||
282 | DONE, /* finished check, done */ | ||
283 | BAD} /* got an error--stay here */ | ||
284 | mode; /* current inflate mode */ | ||
285 | |||
286 | /* mode dependent information */ | ||
287 | union { | ||
288 | uInt method; /* if FLAGS, method byte */ | ||
289 | struct { | ||
290 | uLong was; /* computed check value */ | ||
291 | uLong need; /* stream check value */ | ||
292 | } check; /* if CHECK, check values to compare */ | ||
293 | uInt marker; /* if BAD, inflateSync's marker bytes count */ | ||
294 | } sub; /* submode */ | ||
295 | |||
296 | /* mode independent information */ | ||
297 | int nowrap; /* flag for no wrapper */ | ||
298 | uInt wbits; /* log2(window size) (8..15, defaults to 15) */ | ||
299 | inflate_blocks_statef | ||
300 | *blocks; /* current inflate_blocks state */ | ||
301 | |||
302 | }; | ||
303 | |||
304 | |||
305 | int inflateReset(z) | ||
306 | z_stream *z; | ||
307 | { | ||
308 | uLong c; | ||
309 | |||
310 | if (z == Z_NULL || z->state == Z_NULL) | ||
311 | return Z_STREAM_ERROR; | ||
312 | z->total_in = z->total_out = 0; | ||
313 | z->msg = Z_NULL; | ||
314 | z->state->mode = z->state->nowrap ? BLOCKS : METHOD; | ||
315 | inflate_blocks_reset(z->state->blocks, z, &c); | ||
316 | Trace((stderr, "inflate: reset\n")); | ||
317 | return Z_OK; | ||
318 | } | ||
319 | |||
320 | |||
321 | int inflateEnd(z) | ||
322 | z_stream *z; | ||
323 | { | ||
324 | uLong c; | ||
325 | |||
326 | if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) | ||
327 | return Z_STREAM_ERROR; | ||
328 | if (z->state->blocks != Z_NULL) | ||
329 | inflate_blocks_free(z->state->blocks, z, &c); | ||
330 | ZFREE(z, z->state, sizeof(struct internal_state)); | ||
331 | z->state = Z_NULL; | ||
332 | Trace((stderr, "inflate: end\n")); | ||
333 | return Z_OK; | ||
334 | } | ||
335 | |||
336 | |||
337 | int inflateInit2(z, w) | ||
338 | z_stream *z; | ||
339 | int w; | ||
340 | { | ||
341 | /* initialize state */ | ||
342 | if (z == Z_NULL) | ||
343 | return Z_STREAM_ERROR; | ||
344 | /* if (z->zalloc == Z_NULL) z->zalloc = zcalloc; */ | ||
345 | /* if (z->zfree == Z_NULL) z->zfree = zcfree; */ | ||
346 | if ((z->state = (struct internal_state FAR *) | ||
347 | ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) | ||
348 | return Z_MEM_ERROR; | ||
349 | z->state->blocks = Z_NULL; | ||
350 | |||
351 | /* handle undocumented nowrap option (no zlib header or check) */ | ||
352 | z->state->nowrap = 0; | ||
353 | if (w < 0) | ||
354 | { | ||
355 | w = - w; | ||
356 | z->state->nowrap = 1; | ||
357 | } | ||
358 | |||
359 | /* set window size */ | ||
360 | if (w < 8 || w > 15) | ||
361 | { | ||
362 | inflateEnd(z); | ||
363 | return Z_STREAM_ERROR; | ||
364 | } | ||
365 | z->state->wbits = (uInt)w; | ||
366 | |||
367 | /* create inflate_blocks state */ | ||
368 | if ((z->state->blocks = | ||
369 | inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, 1 << w)) | ||
370 | == Z_NULL) | ||
371 | { | ||
372 | inflateEnd(z); | ||
373 | return Z_MEM_ERROR; | ||
374 | } | ||
375 | Trace((stderr, "inflate: allocated\n")); | ||
376 | |||
377 | /* reset state */ | ||
378 | inflateReset(z); | ||
379 | return Z_OK; | ||
380 | } | ||
381 | |||
382 | |||
383 | int inflateInit(z) | ||
384 | z_stream *z; | ||
385 | { | ||
386 | return inflateInit2(z, DEF_WBITS); | ||
387 | } | ||
388 | |||
389 | |||
390 | #define NEEDBYTE {if(z->avail_in==0)goto empty;r=Z_OK;} | ||
391 | #define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) | ||
392 | |||
393 | int inflate(z, f) | ||
394 | z_stream *z; | ||
395 | int f; | ||
396 | { | ||
397 | int r; | ||
398 | uInt b; | ||
399 | |||
400 | if (z == Z_NULL || z->next_in == Z_NULL) | ||
401 | return Z_STREAM_ERROR; | ||
402 | r = Z_BUF_ERROR; | ||
403 | while (1) switch (z->state->mode) | ||
404 | { | ||
405 | case METHOD: | ||
406 | NEEDBYTE | ||
407 | if (((z->state->sub.method = NEXTBYTE) & 0xf) != DEFLATED) | ||
408 | { | ||
409 | z->state->mode = BAD; | ||
410 | z->msg = "unknown compression method"; | ||
411 | z->state->sub.marker = 5; /* can't try inflateSync */ | ||
412 | break; | ||
413 | } | ||
414 | if ((z->state->sub.method >> 4) + 8 > z->state->wbits) | ||
415 | { | ||
416 | z->state->mode = BAD; | ||
417 | z->msg = "invalid window size"; | ||
418 | z->state->sub.marker = 5; /* can't try inflateSync */ | ||
419 | break; | ||
420 | } | ||
421 | z->state->mode = FLAG; | ||
422 | case FLAG: | ||
423 | NEEDBYTE | ||
424 | if ((b = NEXTBYTE) & 0x20) | ||
425 | { | ||
426 | z->state->mode = BAD; | ||
427 | z->msg = "invalid reserved bit"; | ||
428 | z->state->sub.marker = 5; /* can't try inflateSync */ | ||
429 | break; | ||
430 | } | ||
431 | if (((z->state->sub.method << 8) + b) % 31) | ||
432 | { | ||
433 | z->state->mode = BAD; | ||
434 | z->msg = "incorrect header check"; | ||
435 | z->state->sub.marker = 5; /* can't try inflateSync */ | ||
436 | break; | ||
437 | } | ||
438 | Trace((stderr, "inflate: zlib header ok\n")); | ||
439 | z->state->mode = BLOCKS; | ||
440 | case BLOCKS: | ||
441 | r = inflate_blocks(z->state->blocks, z, r); | ||
442 | if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0) | ||
443 | r = inflate_packet_flush(z->state->blocks); | ||
444 | if (r == Z_DATA_ERROR) | ||
445 | { | ||
446 | z->state->mode = BAD; | ||
447 | z->state->sub.marker = 0; /* can try inflateSync */ | ||
448 | break; | ||
449 | } | ||
450 | if (r != Z_STREAM_END) | ||
451 | return r; | ||
452 | r = Z_OK; | ||
453 | inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); | ||
454 | if (z->state->nowrap) | ||
455 | { | ||
456 | z->state->mode = DONE; | ||
457 | break; | ||
458 | } | ||
459 | z->state->mode = CHECK4; | ||
460 | case CHECK4: | ||
461 | NEEDBYTE | ||
462 | z->state->sub.check.need = (uLong)NEXTBYTE << 24; | ||
463 | z->state->mode = CHECK3; | ||
464 | case CHECK3: | ||
465 | NEEDBYTE | ||
466 | z->state->sub.check.need += (uLong)NEXTBYTE << 16; | ||
467 | z->state->mode = CHECK2; | ||
468 | case CHECK2: | ||
469 | NEEDBYTE | ||
470 | z->state->sub.check.need += (uLong)NEXTBYTE << 8; | ||
471 | z->state->mode = CHECK1; | ||
472 | case CHECK1: | ||
473 | NEEDBYTE | ||
474 | z->state->sub.check.need += (uLong)NEXTBYTE; | ||
475 | |||
476 | if (z->state->sub.check.was != z->state->sub.check.need) | ||
477 | { | ||
478 | z->state->mode = BAD; | ||
479 | z->msg = "incorrect data check"; | ||
480 | z->state->sub.marker = 5; /* can't try inflateSync */ | ||
481 | break; | ||
482 | } | ||
483 | Trace((stderr, "inflate: zlib check ok\n")); | ||
484 | z->state->mode = DONE; | ||
485 | case DONE: | ||
486 | return Z_STREAM_END; | ||
487 | case BAD: | ||
488 | return Z_DATA_ERROR; | ||
489 | default: | ||
490 | return Z_STREAM_ERROR; | ||
491 | } | ||
492 | |||
493 | empty: | ||
494 | if (f != Z_PACKET_FLUSH) | ||
495 | return r; | ||
496 | z->state->mode = BAD; | ||
497 | z->state->sub.marker = 0; /* can try inflateSync */ | ||
498 | return Z_DATA_ERROR; | ||
499 | } | ||
500 | |||
501 | /* | ||
502 | * This subroutine adds the data at next_in/avail_in to the output history | ||
503 | * without performing any output. The output buffer must be "caught up"; | ||
504 | * i.e. no pending output (hence s->read equals s->write), and the state must | ||
505 | * be BLOCKS (i.e. we should be willing to see the start of a series of | ||
506 | * BLOCKS). On exit, the output will also be caught up, and the checksum | ||
507 | * will have been updated if need be. | ||
508 | */ | ||
509 | |||
510 | int inflateIncomp(z) | ||
511 | z_stream *z; | ||
512 | { | ||
513 | if (z->state->mode != BLOCKS) | ||
514 | return Z_DATA_ERROR; | ||
515 | return inflate_addhistory(z->state->blocks, z); | ||
516 | } | ||
517 | |||
518 | |||
519 | int inflateSync(z) | ||
520 | z_stream *z; | ||
521 | { | ||
522 | uInt n; /* number of bytes to look at */ | ||
523 | Bytef *p; /* pointer to bytes */ | ||
524 | uInt m; /* number of marker bytes found in a row */ | ||
525 | uLong r, w; /* temporaries to save total_in and total_out */ | ||
526 | |||
527 | /* set up */ | ||
528 | if (z == Z_NULL || z->state == Z_NULL) | ||
529 | return Z_STREAM_ERROR; | ||
530 | if (z->state->mode != BAD) | ||
531 | { | ||
532 | z->state->mode = BAD; | ||
533 | z->state->sub.marker = 0; | ||
534 | } | ||
535 | if ((n = z->avail_in) == 0) | ||
536 | return Z_BUF_ERROR; | ||
537 | p = z->next_in; | ||
538 | m = z->state->sub.marker; | ||
539 | |||
540 | /* search */ | ||
541 | while (n && m < 4) | ||
542 | { | ||
543 | if (*p == (Byte)(m < 2 ? 0 : 0xff)) | ||
544 | m++; | ||
545 | else if (*p) | ||
546 | m = 0; | ||
547 | else | ||
548 | m = 4 - m; | ||
549 | p++, n--; | ||
550 | } | ||
551 | |||
552 | /* restore */ | ||
553 | z->total_in += p - z->next_in; | ||
554 | z->next_in = p; | ||
555 | z->avail_in = n; | ||
556 | z->state->sub.marker = m; | ||
557 | |||
558 | /* return no joy or set up to restart on a new block */ | ||
559 | if (m != 4) | ||
560 | return Z_DATA_ERROR; | ||
561 | r = z->total_in; w = z->total_out; | ||
562 | inflateReset(z); | ||
563 | z->total_in = r; z->total_out = w; | ||
564 | z->state->mode = BLOCKS; | ||
565 | return Z_OK; | ||
566 | } | ||
567 | |||
568 | #undef NEEDBYTE | ||
569 | #undef NEXTBYTE | ||
570 | |||
571 | /*+++++*/ | ||
572 | /* infutil.h -- types and macros common to blocks and codes | ||
573 | * Copyright (C) 1995 Mark Adler | ||
574 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
575 | */ | ||
576 | |||
577 | /* WARNING: this file should *not* be used by applications. It is | ||
578 | part of the implementation of the compression library and is | ||
579 | subject to change. Applications should only use zlib.h. | ||
580 | */ | ||
581 | |||
582 | /* inflate blocks semi-private state */ | ||
583 | struct inflate_blocks_state { | ||
584 | |||
585 | /* mode */ | ||
586 | enum { | ||
587 | TYPE, /* get type bits (3, including end bit) */ | ||
588 | LENS, /* get lengths for stored */ | ||
589 | STORED, /* processing stored block */ | ||
590 | TABLE, /* get table lengths */ | ||
591 | BTREE, /* get bit lengths tree for a dynamic block */ | ||
592 | DTREE, /* get length, distance trees for a dynamic block */ | ||
593 | CODES, /* processing fixed or dynamic block */ | ||
594 | DRY, /* output remaining window bytes */ | ||
595 | DONEB, /* finished last block, done */ | ||
596 | BADB} /* got a data error--stuck here */ | ||
597 | mode; /* current inflate_block mode */ | ||
598 | |||
599 | /* mode dependent information */ | ||
600 | union { | ||
601 | uInt left; /* if STORED, bytes left to copy */ | ||
602 | struct { | ||
603 | uInt table; /* table lengths (14 bits) */ | ||
604 | uInt index; /* index into blens (or border) */ | ||
605 | uIntf *blens; /* bit lengths of codes */ | ||
606 | uInt bb; /* bit length tree depth */ | ||
607 | inflate_huft *tb; /* bit length decoding tree */ | ||
608 | int nblens; /* # elements allocated at blens */ | ||
609 | } trees; /* if DTREE, decoding info for trees */ | ||
610 | struct { | ||
611 | inflate_huft *tl, *td; /* trees to free */ | ||
612 | inflate_codes_statef | ||
613 | *codes; | ||
614 | } decode; /* if CODES, current state */ | ||
615 | } sub; /* submode */ | ||
616 | uInt last; /* true if this block is the last block */ | ||
617 | |||
618 | /* mode independent information */ | ||
619 | uInt bitk; /* bits in bit buffer */ | ||
620 | uLong bitb; /* bit buffer */ | ||
621 | Bytef *window; /* sliding window */ | ||
622 | Bytef *end; /* one byte after sliding window */ | ||
623 | Bytef *read; /* window read pointer */ | ||
624 | Bytef *write; /* window write pointer */ | ||
625 | check_func checkfn; /* check function */ | ||
626 | uLong check; /* check on output */ | ||
627 | |||
628 | }; | ||
629 | |||
630 | |||
631 | /* defines for inflate input/output */ | ||
632 | /* update pointers and return */ | ||
633 | #define UPDBITS {s->bitb=b;s->bitk=k;} | ||
634 | #define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} | ||
635 | #define UPDOUT {s->write=q;} | ||
636 | #define UPDATE {UPDBITS UPDIN UPDOUT} | ||
637 | #define LEAVE {UPDATE return inflate_flush(s,z,r);} | ||
638 | /* get bytes and bits */ | ||
639 | #define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} | ||
640 | #define NEEDBYTE {if(n)r=Z_OK;else LEAVE} | ||
641 | #define NEXTBYTE (n--,*p++) | ||
642 | #define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} | ||
643 | #define DUMPBITS(j) {b>>=(j);k-=(j);} | ||
644 | /* output bytes */ | ||
645 | #define WAVAIL (q<s->read?s->read-q-1:s->end-q) | ||
646 | #define LOADOUT {q=s->write;m=WAVAIL;} | ||
647 | #define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=WAVAIL;}} | ||
648 | #define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} | ||
649 | #define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} | ||
650 | #define OUTBYTE(a) {*q++=(Byte)(a);m--;} | ||
651 | /* load local pointers */ | ||
652 | #define LOAD {LOADIN LOADOUT} | ||
653 | |||
654 | /* | ||
655 | * The IBM 150 firmware munges the data right after _etext[]. This | ||
656 | * protects it. -- Cort | ||
657 | */ | ||
658 | local uInt protect_mask[] = {0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0}; | ||
659 | /* And'ing with mask[n] masks the lower n bits */ | ||
660 | local uInt inflate_mask[] = { | ||
661 | 0x0000, | ||
662 | 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, | ||
663 | 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff | ||
664 | }; | ||
665 | |||
666 | /* copy as much as possible from the sliding window to the output area */ | ||
667 | local int inflate_flush OF(( | ||
668 | inflate_blocks_statef *, | ||
669 | z_stream *, | ||
670 | int)); | ||
671 | |||
672 | /*+++++*/ | ||
673 | /* inffast.h -- header to use inffast.c | ||
674 | * Copyright (C) 1995 Mark Adler | ||
675 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
676 | */ | ||
677 | |||
678 | /* WARNING: this file should *not* be used by applications. It is | ||
679 | part of the implementation of the compression library and is | ||
680 | subject to change. Applications should only use zlib.h. | ||
681 | */ | ||
682 | |||
683 | local int inflate_fast OF(( | ||
684 | uInt, | ||
685 | uInt, | ||
686 | inflate_huft *, | ||
687 | inflate_huft *, | ||
688 | inflate_blocks_statef *, | ||
689 | z_stream *)); | ||
690 | |||
691 | |||
692 | /*+++++*/ | ||
693 | /* infblock.c -- interpret and process block types to last block | ||
694 | * Copyright (C) 1995 Mark Adler | ||
695 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
696 | */ | ||
697 | |||
698 | /* Table for deflate from PKZIP's appnote.txt. */ | ||
699 | local uInt border[] = { /* Order of the bit length code lengths */ | ||
700 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; | ||
701 | |||
702 | /* | ||
703 | Notes beyond the 1.93a appnote.txt: | ||
704 | |||
705 | 1. Distance pointers never point before the beginning of the output | ||
706 | stream. | ||
707 | 2. Distance pointers can point back across blocks, up to 32k away. | ||
708 | 3. There is an implied maximum of 7 bits for the bit length table and | ||
709 | 15 bits for the actual data. | ||
710 | 4. If only one code exists, then it is encoded using one bit. (Zero | ||
711 | would be more efficient, but perhaps a little confusing.) If two | ||
712 | codes exist, they are coded using one bit each (0 and 1). | ||
713 | 5. There is no way of sending zero distance codes--a dummy must be | ||
714 | sent if there are none. (History: a pre 2.0 version of PKZIP would | ||
715 | store blocks with no distance codes, but this was discovered to be | ||
716 | too harsh a criterion.) Valid only for 1.93a. 2.04c does allow | ||
717 | zero distance codes, which is sent as one code of zero bits in | ||
718 | length. | ||
719 | 6. There are up to 286 literal/length codes. Code 256 represents the | ||
720 | end-of-block. Note however that the static length tree defines | ||
721 | 288 codes just to fill out the Huffman codes. Codes 286 and 287 | ||
722 | cannot be used though, since there is no length base or extra bits | ||
723 | defined for them. Similarily, there are up to 30 distance codes. | ||
724 | However, static trees define 32 codes (all 5 bits) to fill out the | ||
725 | Huffman codes, but the last two had better not show up in the data. | ||
726 | 7. Unzip can check dynamic Huffman blocks for complete code sets. | ||
727 | The exception is that a single code would not be complete (see #4). | ||
728 | 8. The five bits following the block type is really the number of | ||
729 | literal codes sent minus 257. | ||
730 | 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits | ||
731 | (1+6+6). Therefore, to output three times the length, you output | ||
732 | three codes (1+1+1), whereas to output four times the same length, | ||
733 | you only need two codes (1+3). Hmm. | ||
734 | 10. In the tree reconstruction algorithm, Code = Code + Increment | ||
735 | only if BitLength(i) is not zero. (Pretty obvious.) | ||
736 | 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) | ||
737 | 12. Note: length code 284 can represent 227-258, but length code 285 | ||
738 | really is 258. The last length deserves its own, short code | ||
739 | since it gets used a lot in very redundant files. The length | ||
740 | 258 is special since 258 - 3 (the min match length) is 255. | ||
741 | 13. The literal/length and distance code bit lengths are read as a | ||
742 | single stream of lengths. It is possible (and advantageous) for | ||
743 | a repeat code (16, 17, or 18) to go across the boundary between | ||
744 | the two sets of lengths. | ||
745 | */ | ||
746 | |||
747 | |||
748 | local void inflate_blocks_reset(s, z, c) | ||
749 | inflate_blocks_statef *s; | ||
750 | z_stream *z; | ||
751 | uLongf *c; | ||
752 | { | ||
753 | if (s->checkfn != Z_NULL) | ||
754 | *c = s->check; | ||
755 | if (s->mode == BTREE || s->mode == DTREE) | ||
756 | ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt)); | ||
757 | if (s->mode == CODES) | ||
758 | { | ||
759 | inflate_codes_free(s->sub.decode.codes, z); | ||
760 | inflate_trees_free(s->sub.decode.td, z); | ||
761 | inflate_trees_free(s->sub.decode.tl, z); | ||
762 | } | ||
763 | s->mode = TYPE; | ||
764 | s->bitk = 0; | ||
765 | s->bitb = 0; | ||
766 | s->read = s->write = s->window; | ||
767 | if (s->checkfn != Z_NULL) | ||
768 | s->check = (*s->checkfn)(0L, Z_NULL, 0); | ||
769 | Trace((stderr, "inflate: blocks reset\n")); | ||
770 | } | ||
771 | |||
772 | |||
773 | local inflate_blocks_statef *inflate_blocks_new(z, c, w) | ||
774 | z_stream *z; | ||
775 | check_func c; | ||
776 | uInt w; | ||
777 | { | ||
778 | inflate_blocks_statef *s; | ||
779 | |||
780 | if ((s = (inflate_blocks_statef *)ZALLOC | ||
781 | (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) | ||
782 | return s; | ||
783 | if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) | ||
784 | { | ||
785 | ZFREE(z, s, sizeof(struct inflate_blocks_state)); | ||
786 | return Z_NULL; | ||
787 | } | ||
788 | s->end = s->window + w; | ||
789 | s->checkfn = c; | ||
790 | s->mode = TYPE; | ||
791 | Trace((stderr, "inflate: blocks allocated\n")); | ||
792 | inflate_blocks_reset(s, z, &s->check); | ||
793 | return s; | ||
794 | } | ||
795 | |||
796 | |||
797 | local int inflate_blocks(s, z, r) | ||
798 | inflate_blocks_statef *s; | ||
799 | z_stream *z; | ||
800 | int r; | ||
801 | { | ||
802 | uInt t; /* temporary storage */ | ||
803 | uLong b; /* bit buffer */ | ||
804 | uInt k; /* bits in bit buffer */ | ||
805 | Bytef *p; /* input data pointer */ | ||
806 | uInt n; /* bytes available there */ | ||
807 | Bytef *q; /* output window write pointer */ | ||
808 | uInt m; /* bytes to end of window or read pointer */ | ||
809 | |||
810 | /* copy input/output information to locals (UPDATE macro restores) */ | ||
811 | LOAD | ||
812 | |||
813 | /* process input based on current state */ | ||
814 | while (1) switch (s->mode) | ||
815 | { | ||
816 | case TYPE: | ||
817 | NEEDBITS(3) | ||
818 | t = (uInt)b & 7; | ||
819 | s->last = t & 1; | ||
820 | switch (t >> 1) | ||
821 | { | ||
822 | case 0: /* stored */ | ||
823 | Trace((stderr, "inflate: stored block%s\n", | ||
824 | s->last ? " (last)" : "")); | ||
825 | DUMPBITS(3) | ||
826 | t = k & 7; /* go to byte boundary */ | ||
827 | DUMPBITS(t) | ||
828 | s->mode = LENS; /* get length of stored block */ | ||
829 | break; | ||
830 | case 1: /* fixed */ | ||
831 | Trace((stderr, "inflate: fixed codes block%s\n", | ||
832 | s->last ? " (last)" : "")); | ||
833 | { | ||
834 | uInt bl, bd; | ||
835 | inflate_huft *tl, *td; | ||
836 | |||
837 | inflate_trees_fixed(&bl, &bd, &tl, &td); | ||
838 | s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); | ||
839 | if (s->sub.decode.codes == Z_NULL) | ||
840 | { | ||
841 | r = Z_MEM_ERROR; | ||
842 | LEAVE | ||
843 | } | ||
844 | s->sub.decode.tl = Z_NULL; /* don't try to free these */ | ||
845 | s->sub.decode.td = Z_NULL; | ||
846 | } | ||
847 | DUMPBITS(3) | ||
848 | s->mode = CODES; | ||
849 | break; | ||
850 | case 2: /* dynamic */ | ||
851 | Trace((stderr, "inflate: dynamic codes block%s\n", | ||
852 | s->last ? " (last)" : "")); | ||
853 | DUMPBITS(3) | ||
854 | s->mode = TABLE; | ||
855 | break; | ||
856 | case 3: /* illegal */ | ||
857 | DUMPBITS(3) | ||
858 | s->mode = BADB; | ||
859 | z->msg = "invalid block type"; | ||
860 | r = Z_DATA_ERROR; | ||
861 | LEAVE | ||
862 | } | ||
863 | break; | ||
864 | case LENS: | ||
865 | NEEDBITS(32) | ||
866 | if (((~b) >> 16) != (b & 0xffff)) | ||
867 | { | ||
868 | s->mode = BADB; | ||
869 | z->msg = "invalid stored block lengths"; | ||
870 | r = Z_DATA_ERROR; | ||
871 | LEAVE | ||
872 | } | ||
873 | s->sub.left = (uInt)b & 0xffff; | ||
874 | b = k = 0; /* dump bits */ | ||
875 | Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); | ||
876 | s->mode = s->sub.left ? STORED : TYPE; | ||
877 | break; | ||
878 | case STORED: | ||
879 | if (n == 0) | ||
880 | LEAVE | ||
881 | NEEDOUT | ||
882 | t = s->sub.left; | ||
883 | if (t > n) t = n; | ||
884 | if (t > m) t = m; | ||
885 | zmemcpy(q, p, t); | ||
886 | p += t; n -= t; | ||
887 | q += t; m -= t; | ||
888 | if ((s->sub.left -= t) != 0) | ||
889 | break; | ||
890 | Tracev((stderr, "inflate: stored end, %lu total out\n", | ||
891 | z->total_out + (q >= s->read ? q - s->read : | ||
892 | (s->end - s->read) + (q - s->window)))); | ||
893 | s->mode = s->last ? DRY : TYPE; | ||
894 | break; | ||
895 | case TABLE: | ||
896 | NEEDBITS(14) | ||
897 | s->sub.trees.table = t = (uInt)b & 0x3fff; | ||
898 | #ifndef PKZIP_BUG_WORKAROUND | ||
899 | if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) | ||
900 | { | ||
901 | s->mode = BADB; | ||
902 | z->msg = "too many length or distance symbols"; | ||
903 | r = Z_DATA_ERROR; | ||
904 | LEAVE | ||
905 | } | ||
906 | #endif | ||
907 | t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); | ||
908 | if (t < 19) | ||
909 | t = 19; | ||
910 | if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) | ||
911 | { | ||
912 | r = Z_MEM_ERROR; | ||
913 | LEAVE | ||
914 | } | ||
915 | s->sub.trees.nblens = t; | ||
916 | DUMPBITS(14) | ||
917 | s->sub.trees.index = 0; | ||
918 | Tracev((stderr, "inflate: table sizes ok\n")); | ||
919 | s->mode = BTREE; | ||
920 | case BTREE: | ||
921 | while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) | ||
922 | { | ||
923 | NEEDBITS(3) | ||
924 | s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; | ||
925 | DUMPBITS(3) | ||
926 | } | ||
927 | while (s->sub.trees.index < 19) | ||
928 | s->sub.trees.blens[border[s->sub.trees.index++]] = 0; | ||
929 | s->sub.trees.bb = 7; | ||
930 | t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, | ||
931 | &s->sub.trees.tb, z); | ||
932 | if (t != Z_OK) | ||
933 | { | ||
934 | r = t; | ||
935 | if (r == Z_DATA_ERROR) | ||
936 | s->mode = BADB; | ||
937 | LEAVE | ||
938 | } | ||
939 | s->sub.trees.index = 0; | ||
940 | Tracev((stderr, "inflate: bits tree ok\n")); | ||
941 | s->mode = DTREE; | ||
942 | case DTREE: | ||
943 | while (t = s->sub.trees.table, | ||
944 | s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) | ||
945 | { | ||
946 | inflate_huft *h; | ||
947 | uInt i, j, c; | ||
948 | |||
949 | t = s->sub.trees.bb; | ||
950 | NEEDBITS(t) | ||
951 | h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); | ||
952 | t = h->word.what.Bits; | ||
953 | c = h->more.Base; | ||
954 | if (c < 16) | ||
955 | { | ||
956 | DUMPBITS(t) | ||
957 | s->sub.trees.blens[s->sub.trees.index++] = c; | ||
958 | } | ||
959 | else /* c == 16..18 */ | ||
960 | { | ||
961 | i = c == 18 ? 7 : c - 14; | ||
962 | j = c == 18 ? 11 : 3; | ||
963 | NEEDBITS(t + i) | ||
964 | DUMPBITS(t) | ||
965 | j += (uInt)b & inflate_mask[i]; | ||
966 | DUMPBITS(i) | ||
967 | i = s->sub.trees.index; | ||
968 | t = s->sub.trees.table; | ||
969 | if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || | ||
970 | (c == 16 && i < 1)) | ||
971 | { | ||
972 | s->mode = BADB; | ||
973 | z->msg = "invalid bit length repeat"; | ||
974 | r = Z_DATA_ERROR; | ||
975 | LEAVE | ||
976 | } | ||
977 | c = c == 16 ? s->sub.trees.blens[i - 1] : 0; | ||
978 | do { | ||
979 | s->sub.trees.blens[i++] = c; | ||
980 | } while (--j); | ||
981 | s->sub.trees.index = i; | ||
982 | } | ||
983 | } | ||
984 | inflate_trees_free(s->sub.trees.tb, z); | ||
985 | s->sub.trees.tb = Z_NULL; | ||
986 | { | ||
987 | uInt bl, bd; | ||
988 | inflate_huft *tl, *td; | ||
989 | inflate_codes_statef *c; | ||
990 | |||
991 | bl = 9; /* must be <= 9 for lookahead assumptions */ | ||
992 | bd = 6; /* must be <= 9 for lookahead assumptions */ | ||
993 | t = s->sub.trees.table; | ||
994 | t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), | ||
995 | s->sub.trees.blens, &bl, &bd, &tl, &td, z); | ||
996 | if (t != Z_OK) | ||
997 | { | ||
998 | if (t == (uInt)Z_DATA_ERROR) | ||
999 | s->mode = BADB; | ||
1000 | r = t; | ||
1001 | LEAVE | ||
1002 | } | ||
1003 | Tracev((stderr, "inflate: trees ok\n")); | ||
1004 | if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) | ||
1005 | { | ||
1006 | inflate_trees_free(td, z); | ||
1007 | inflate_trees_free(tl, z); | ||
1008 | r = Z_MEM_ERROR; | ||
1009 | LEAVE | ||
1010 | } | ||
1011 | ZFREE(z, s->sub.trees.blens, s->sub.trees.nblens * sizeof(uInt)); | ||
1012 | s->sub.decode.codes = c; | ||
1013 | s->sub.decode.tl = tl; | ||
1014 | s->sub.decode.td = td; | ||
1015 | } | ||
1016 | s->mode = CODES; | ||
1017 | case CODES: | ||
1018 | UPDATE | ||
1019 | if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) | ||
1020 | return inflate_flush(s, z, r); | ||
1021 | r = Z_OK; | ||
1022 | inflate_codes_free(s->sub.decode.codes, z); | ||
1023 | inflate_trees_free(s->sub.decode.td, z); | ||
1024 | inflate_trees_free(s->sub.decode.tl, z); | ||
1025 | LOAD | ||
1026 | Tracev((stderr, "inflate: codes end, %lu total out\n", | ||
1027 | z->total_out + (q >= s->read ? q - s->read : | ||
1028 | (s->end - s->read) + (q - s->window)))); | ||
1029 | if (!s->last) | ||
1030 | { | ||
1031 | s->mode = TYPE; | ||
1032 | break; | ||
1033 | } | ||
1034 | if (k > 7) /* return unused byte, if any */ | ||
1035 | { | ||
1036 | Assert(k < 16, "inflate_codes grabbed too many bytes") | ||
1037 | k -= 8; | ||
1038 | n++; | ||
1039 | p--; /* can always return one */ | ||
1040 | } | ||
1041 | s->mode = DRY; | ||
1042 | case DRY: | ||
1043 | FLUSH | ||
1044 | if (s->read != s->write) | ||
1045 | LEAVE | ||
1046 | s->mode = DONEB; | ||
1047 | case DONEB: | ||
1048 | r = Z_STREAM_END; | ||
1049 | LEAVE | ||
1050 | case BADB: | ||
1051 | r = Z_DATA_ERROR; | ||
1052 | LEAVE | ||
1053 | default: | ||
1054 | r = Z_STREAM_ERROR; | ||
1055 | LEAVE | ||
1056 | } | ||
1057 | } | ||
1058 | |||
1059 | |||
1060 | local int inflate_blocks_free(s, z, c) | ||
1061 | inflate_blocks_statef *s; | ||
1062 | z_stream *z; | ||
1063 | uLongf *c; | ||
1064 | { | ||
1065 | inflate_blocks_reset(s, z, c); | ||
1066 | ZFREE(z, s->window, s->end - s->window); | ||
1067 | ZFREE(z, s, sizeof(struct inflate_blocks_state)); | ||
1068 | Trace((stderr, "inflate: blocks freed\n")); | ||
1069 | return Z_OK; | ||
1070 | } | ||
1071 | |||
1072 | /* | ||
1073 | * This subroutine adds the data at next_in/avail_in to the output history | ||
1074 | * without performing any output. The output buffer must be "caught up"; | ||
1075 | * i.e. no pending output (hence s->read equals s->write), and the state must | ||
1076 | * be BLOCKS (i.e. we should be willing to see the start of a series of | ||
1077 | * BLOCKS). On exit, the output will also be caught up, and the checksum | ||
1078 | * will have been updated if need be. | ||
1079 | */ | ||
1080 | local int inflate_addhistory(s, z) | ||
1081 | inflate_blocks_statef *s; | ||
1082 | z_stream *z; | ||
1083 | { | ||
1084 | uLong b; /* bit buffer */ /* NOT USED HERE */ | ||
1085 | uInt k; /* bits in bit buffer */ /* NOT USED HERE */ | ||
1086 | uInt t; /* temporary storage */ | ||
1087 | Bytef *p; /* input data pointer */ | ||
1088 | uInt n; /* bytes available there */ | ||
1089 | Bytef *q; /* output window write pointer */ | ||
1090 | uInt m; /* bytes to end of window or read pointer */ | ||
1091 | |||
1092 | if (s->read != s->write) | ||
1093 | return Z_STREAM_ERROR; | ||
1094 | if (s->mode != TYPE) | ||
1095 | return Z_DATA_ERROR; | ||
1096 | |||
1097 | /* we're ready to rock */ | ||
1098 | LOAD | ||
1099 | /* while there is input ready, copy to output buffer, moving | ||
1100 | * pointers as needed. | ||
1101 | */ | ||
1102 | while (n) { | ||
1103 | t = n; /* how many to do */ | ||
1104 | /* is there room until end of buffer? */ | ||
1105 | if (t > m) t = m; | ||
1106 | /* update check information */ | ||
1107 | if (s->checkfn != Z_NULL) | ||
1108 | s->check = (*s->checkfn)(s->check, q, t); | ||
1109 | zmemcpy(q, p, t); | ||
1110 | q += t; | ||
1111 | p += t; | ||
1112 | n -= t; | ||
1113 | z->total_out += t; | ||
1114 | s->read = q; /* drag read pointer forward */ | ||
1115 | /* WRAP */ /* expand WRAP macro by hand to handle s->read */ | ||
1116 | if (q == s->end) { | ||
1117 | s->read = q = s->window; | ||
1118 | m = WAVAIL; | ||
1119 | } | ||
1120 | } | ||
1121 | UPDATE | ||
1122 | return Z_OK; | ||
1123 | } | ||
1124 | |||
1125 | |||
1126 | /* | ||
1127 | * At the end of a Deflate-compressed PPP packet, we expect to have seen | ||
1128 | * a `stored' block type value but not the (zero) length bytes. | ||
1129 | */ | ||
1130 | local int inflate_packet_flush(s) | ||
1131 | inflate_blocks_statef *s; | ||
1132 | { | ||
1133 | if (s->mode != LENS) | ||
1134 | return Z_DATA_ERROR; | ||
1135 | s->mode = TYPE; | ||
1136 | return Z_OK; | ||
1137 | } | ||
1138 | |||
1139 | |||
1140 | /*+++++*/ | ||
1141 | /* inftrees.c -- generate Huffman trees for efficient decoding | ||
1142 | * Copyright (C) 1995 Mark Adler | ||
1143 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
1144 | */ | ||
1145 | |||
1146 | /* simplify the use of the inflate_huft type with some defines */ | ||
1147 | #define base more.Base | ||
1148 | #define next more.Next | ||
1149 | #define exop word.what.Exop | ||
1150 | #define bits word.what.Bits | ||
1151 | |||
1152 | |||
1153 | local int huft_build OF(( | ||
1154 | uIntf *, /* code lengths in bits */ | ||
1155 | uInt, /* number of codes */ | ||
1156 | uInt, /* number of "simple" codes */ | ||
1157 | uIntf *, /* list of base values for non-simple codes */ | ||
1158 | uIntf *, /* list of extra bits for non-simple codes */ | ||
1159 | inflate_huft * FAR*,/* result: starting table */ | ||
1160 | uIntf *, /* maximum lookup bits (returns actual) */ | ||
1161 | z_stream *)); /* for zalloc function */ | ||
1162 | |||
1163 | local voidpf falloc OF(( | ||
1164 | voidpf, /* opaque pointer (not used) */ | ||
1165 | uInt, /* number of items */ | ||
1166 | uInt)); /* size of item */ | ||
1167 | |||
1168 | local void ffree OF(( | ||
1169 | voidpf q, /* opaque pointer (not used) */ | ||
1170 | voidpf p, /* what to free (not used) */ | ||
1171 | uInt n)); /* number of bytes (not used) */ | ||
1172 | |||
1173 | /* Tables for deflate from PKZIP's appnote.txt. */ | ||
1174 | local uInt cplens[] = { /* Copy lengths for literal codes 257..285 */ | ||
1175 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
1176 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; | ||
1177 | /* actually lengths - 2; also see note #13 above about 258 */ | ||
1178 | local uInt cplext[] = { /* Extra bits for literal codes 257..285 */ | ||
1179 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||
1180 | 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 192, 192}; /* 192==invalid */ | ||
1181 | local uInt cpdist[] = { /* Copy offsets for distance codes 0..29 */ | ||
1182 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
1183 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
1184 | 8193, 12289, 16385, 24577}; | ||
1185 | local uInt cpdext[] = { /* Extra bits for distance codes */ | ||
1186 | 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||
1187 | 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||
1188 | 12, 12, 13, 13}; | ||
1189 | |||
1190 | /* | ||
1191 | Huffman code decoding is performed using a multi-level table lookup. | ||
1192 | The fastest way to decode is to simply build a lookup table whose | ||
1193 | size is determined by the longest code. However, the time it takes | ||
1194 | to build this table can also be a factor if the data being decoded | ||
1195 | is not very long. The most common codes are necessarily the | ||
1196 | shortest codes, so those codes dominate the decoding time, and hence | ||
1197 | the speed. The idea is you can have a shorter table that decodes the | ||
1198 | shorter, more probable codes, and then point to subsidiary tables for | ||
1199 | the longer codes. The time it costs to decode the longer codes is | ||
1200 | then traded against the time it takes to make longer tables. | ||
1201 | |||
1202 | This results of this trade are in the variables lbits and dbits | ||
1203 | below. lbits is the number of bits the first level table for literal/ | ||
1204 | length codes can decode in one step, and dbits is the same thing for | ||
1205 | the distance codes. Subsequent tables are also less than or equal to | ||
1206 | those sizes. These values may be adjusted either when all of the | ||
1207 | codes are shorter than that, in which case the longest code length in | ||
1208 | bits is used, or when the shortest code is *longer* than the requested | ||
1209 | table size, in which case the length of the shortest code in bits is | ||
1210 | used. | ||
1211 | |||
1212 | There are two different values for the two tables, since they code a | ||
1213 | different number of possibilities each. The literal/length table | ||
1214 | codes 286 possible values, or in a flat code, a little over eight | ||
1215 | bits. The distance table codes 30 possible values, or a little less | ||
1216 | than five bits, flat. The optimum values for speed end up being | ||
1217 | about one bit more than those, so lbits is 8+1 and dbits is 5+1. | ||
1218 | The optimum values may differ though from machine to machine, and | ||
1219 | possibly even between compilers. Your mileage may vary. | ||
1220 | */ | ||
1221 | |||
1222 | |||
1223 | /* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ | ||
1224 | #define BMAX 15 /* maximum bit length of any code */ | ||
1225 | #define N_MAX 288 /* maximum number of codes in any set */ | ||
1226 | |||
1227 | #ifdef DEBUG_ZLIB | ||
1228 | uInt inflate_hufts; | ||
1229 | #endif | ||
1230 | |||
1231 | local int huft_build(b, n, s, d, e, t, m, zs) | ||
1232 | uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ | ||
1233 | uInt n; /* number of codes (assumed <= N_MAX) */ | ||
1234 | uInt s; /* number of simple-valued codes (0..s-1) */ | ||
1235 | uIntf *d; /* list of base values for non-simple codes */ | ||
1236 | uIntf *e; /* list of extra bits for non-simple codes */ | ||
1237 | inflate_huft * FAR *t; /* result: starting table */ | ||
1238 | uIntf *m; /* maximum lookup bits, returns actual */ | ||
1239 | z_stream *zs; /* for zalloc function */ | ||
1240 | /* Given a list of code lengths and a maximum table size, make a set of | ||
1241 | tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR | ||
1242 | if the given code set is incomplete (the tables are still built in this | ||
1243 | case), Z_DATA_ERROR if the input is invalid (all zero length codes or an | ||
1244 | over-subscribed set of lengths), or Z_MEM_ERROR if not enough memory. */ | ||
1245 | { | ||
1246 | |||
1247 | uInt a; /* counter for codes of length k */ | ||
1248 | uInt c[BMAX+1]; /* bit length count table */ | ||
1249 | uInt f; /* i repeats in table every f entries */ | ||
1250 | int g; /* maximum code length */ | ||
1251 | int h; /* table level */ | ||
1252 | register uInt i; /* counter, current code */ | ||
1253 | register uInt j; /* counter */ | ||
1254 | register int k; /* number of bits in current code */ | ||
1255 | int l; /* bits per table (returned in m) */ | ||
1256 | register uIntf *p; /* pointer into c[], b[], or v[] */ | ||
1257 | inflate_huft *q; /* points to current table */ | ||
1258 | struct inflate_huft_s r; /* table entry for structure assignment */ | ||
1259 | inflate_huft *u[BMAX]; /* table stack */ | ||
1260 | uInt v[N_MAX]; /* values in order of bit length */ | ||
1261 | register int w; /* bits before this table == (l * h) */ | ||
1262 | uInt x[BMAX+1]; /* bit offsets, then code stack */ | ||
1263 | uIntf *xp; /* pointer into x */ | ||
1264 | int y; /* number of dummy codes added */ | ||
1265 | uInt z; /* number of entries in current table */ | ||
1266 | |||
1267 | |||
1268 | /* Generate counts for each bit length */ | ||
1269 | p = c; | ||
1270 | #define C0 *p++ = 0; | ||
1271 | #define C2 C0 C0 C0 C0 | ||
1272 | #define C4 C2 C2 C2 C2 | ||
1273 | C4 /* clear c[]--assume BMAX+1 is 16 */ | ||
1274 | p = b; i = n; | ||
1275 | do { | ||
1276 | c[*p++]++; /* assume all entries <= BMAX */ | ||
1277 | } while (--i); | ||
1278 | if (c[0] == n) /* null input--all zero length codes */ | ||
1279 | { | ||
1280 | *t = (inflate_huft *)Z_NULL; | ||
1281 | *m = 0; | ||
1282 | return Z_OK; | ||
1283 | } | ||
1284 | |||
1285 | |||
1286 | /* Find minimum and maximum length, bound *m by those */ | ||
1287 | l = *m; | ||
1288 | for (j = 1; j <= BMAX; j++) | ||
1289 | if (c[j]) | ||
1290 | break; | ||
1291 | k = j; /* minimum code length */ | ||
1292 | if ((uInt)l < j) | ||
1293 | l = j; | ||
1294 | for (i = BMAX; i; i--) | ||
1295 | if (c[i]) | ||
1296 | break; | ||
1297 | g = i; /* maximum code length */ | ||
1298 | if ((uInt)l > i) | ||
1299 | l = i; | ||
1300 | *m = l; | ||
1301 | |||
1302 | |||
1303 | /* Adjust last length count to fill out codes, if needed */ | ||
1304 | for (y = 1 << j; j < i; j++, y <<= 1) | ||
1305 | if ((y -= c[j]) < 0) | ||
1306 | return Z_DATA_ERROR; | ||
1307 | if ((y -= c[i]) < 0) | ||
1308 | return Z_DATA_ERROR; | ||
1309 | c[i] += y; | ||
1310 | |||
1311 | |||
1312 | /* Generate starting offsets into the value table for each length */ | ||
1313 | x[1] = j = 0; | ||
1314 | p = c + 1; xp = x + 2; | ||
1315 | while (--i) { /* note that i == g from above */ | ||
1316 | *xp++ = (j += *p++); | ||
1317 | } | ||
1318 | |||
1319 | |||
1320 | /* Make a table of values in order of bit lengths */ | ||
1321 | p = b; i = 0; | ||
1322 | do { | ||
1323 | if ((j = *p++) != 0) | ||
1324 | v[x[j]++] = i; | ||
1325 | } while (++i < n); | ||
1326 | |||
1327 | |||
1328 | /* Generate the Huffman codes and for each, make the table entries */ | ||
1329 | x[0] = i = 0; /* first Huffman code is zero */ | ||
1330 | p = v; /* grab values in bit order */ | ||
1331 | h = -1; /* no tables yet--level -1 */ | ||
1332 | w = -l; /* bits decoded == (l * h) */ | ||
1333 | u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ | ||
1334 | q = (inflate_huft *)Z_NULL; /* ditto */ | ||
1335 | z = 0; /* ditto */ | ||
1336 | |||
1337 | /* go through the bit lengths (k already is bits in shortest code) */ | ||
1338 | for (; k <= g; k++) | ||
1339 | { | ||
1340 | a = c[k]; | ||
1341 | while (a--) | ||
1342 | { | ||
1343 | /* here i is the Huffman code of length k bits for value *p */ | ||
1344 | /* make tables up to required level */ | ||
1345 | while (k > w + l) | ||
1346 | { | ||
1347 | h++; | ||
1348 | w += l; /* previous table always l bits */ | ||
1349 | |||
1350 | /* compute minimum size table less than or equal to l bits */ | ||
1351 | z = (z = g - w) > (uInt)l ? l : z; /* table size upper limit */ | ||
1352 | if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ | ||
1353 | { /* too few codes for k-w bit table */ | ||
1354 | f -= a + 1; /* deduct codes from patterns left */ | ||
1355 | xp = c + k; | ||
1356 | if (j < z) | ||
1357 | while (++j < z) /* try smaller tables up to z bits */ | ||
1358 | { | ||
1359 | if ((f <<= 1) <= *++xp) | ||
1360 | break; /* enough codes to use up j bits */ | ||
1361 | f -= *xp; /* else deduct codes from patterns */ | ||
1362 | } | ||
1363 | } | ||
1364 | z = 1 << j; /* table entries for j-bit table */ | ||
1365 | |||
1366 | /* allocate and link in new table */ | ||
1367 | if ((q = (inflate_huft *)ZALLOC | ||
1368 | (zs,z + 1,sizeof(inflate_huft))) == Z_NULL) | ||
1369 | { | ||
1370 | if (h) | ||
1371 | inflate_trees_free(u[0], zs); | ||
1372 | return Z_MEM_ERROR; /* not enough memory */ | ||
1373 | } | ||
1374 | q->word.Nalloc = z + 1; | ||
1375 | #ifdef DEBUG_ZLIB | ||
1376 | inflate_hufts += z + 1; | ||
1377 | #endif | ||
1378 | *t = q + 1; /* link to list for huft_free() */ | ||
1379 | *(t = &(q->next)) = Z_NULL; | ||
1380 | u[h] = ++q; /* table starts after link */ | ||
1381 | |||
1382 | /* connect to last table, if there is one */ | ||
1383 | if (h) | ||
1384 | { | ||
1385 | x[h] = i; /* save pattern for backing up */ | ||
1386 | r.bits = (Byte)l; /* bits to dump before this table */ | ||
1387 | r.exop = (Byte)j; /* bits in this table */ | ||
1388 | r.next = q; /* pointer to this table */ | ||
1389 | j = i >> (w - l); /* (get around Turbo C bug) */ | ||
1390 | u[h-1][j] = r; /* connect to last table */ | ||
1391 | } | ||
1392 | } | ||
1393 | |||
1394 | /* set up table entry in r */ | ||
1395 | r.bits = (Byte)(k - w); | ||
1396 | if (p >= v + n) | ||
1397 | r.exop = 128 + 64; /* out of values--invalid code */ | ||
1398 | else if (*p < s) | ||
1399 | { | ||
1400 | r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ | ||
1401 | r.base = *p++; /* simple code is just the value */ | ||
1402 | } | ||
1403 | else | ||
1404 | { | ||
1405 | r.exop = (Byte)e[*p - s] + 16 + 64; /* non-simple--look up in lists */ | ||
1406 | r.base = d[*p++ - s]; | ||
1407 | } | ||
1408 | |||
1409 | /* fill code-like entries with r */ | ||
1410 | f = 1 << (k - w); | ||
1411 | for (j = i >> w; j < z; j += f) | ||
1412 | q[j] = r; | ||
1413 | |||
1414 | /* backwards increment the k-bit code i */ | ||
1415 | for (j = 1 << (k - 1); i & j; j >>= 1) | ||
1416 | i ^= j; | ||
1417 | i ^= j; | ||
1418 | |||
1419 | /* backup over finished tables */ | ||
1420 | while ((i & ((1 << w) - 1)) != x[h]) | ||
1421 | { | ||
1422 | h--; /* don't need to update q */ | ||
1423 | w -= l; | ||
1424 | } | ||
1425 | } | ||
1426 | } | ||
1427 | |||
1428 | |||
1429 | /* Return Z_BUF_ERROR if we were given an incomplete table */ | ||
1430 | return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; | ||
1431 | } | ||
1432 | |||
1433 | |||
1434 | local int inflate_trees_bits(c, bb, tb, z) | ||
1435 | uIntf *c; /* 19 code lengths */ | ||
1436 | uIntf *bb; /* bits tree desired/actual depth */ | ||
1437 | inflate_huft * FAR *tb; /* bits tree result */ | ||
1438 | z_stream *z; /* for zfree function */ | ||
1439 | { | ||
1440 | int r; | ||
1441 | |||
1442 | r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z); | ||
1443 | if (r == Z_DATA_ERROR) | ||
1444 | z->msg = "oversubscribed dynamic bit lengths tree"; | ||
1445 | else if (r == Z_BUF_ERROR) | ||
1446 | { | ||
1447 | inflate_trees_free(*tb, z); | ||
1448 | z->msg = "incomplete dynamic bit lengths tree"; | ||
1449 | r = Z_DATA_ERROR; | ||
1450 | } | ||
1451 | return r; | ||
1452 | } | ||
1453 | |||
1454 | |||
1455 | local int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, z) | ||
1456 | uInt nl; /* number of literal/length codes */ | ||
1457 | uInt nd; /* number of distance codes */ | ||
1458 | uIntf *c; /* that many (total) code lengths */ | ||
1459 | uIntf *bl; /* literal desired/actual bit depth */ | ||
1460 | uIntf *bd; /* distance desired/actual bit depth */ | ||
1461 | inflate_huft * FAR *tl; /* literal/length tree result */ | ||
1462 | inflate_huft * FAR *td; /* distance tree result */ | ||
1463 | z_stream *z; /* for zfree function */ | ||
1464 | { | ||
1465 | int r; | ||
1466 | |||
1467 | /* build literal/length tree */ | ||
1468 | if ((r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z)) != Z_OK) | ||
1469 | { | ||
1470 | if (r == Z_DATA_ERROR) | ||
1471 | z->msg = "oversubscribed literal/length tree"; | ||
1472 | else if (r == Z_BUF_ERROR) | ||
1473 | { | ||
1474 | inflate_trees_free(*tl, z); | ||
1475 | z->msg = "incomplete literal/length tree"; | ||
1476 | r = Z_DATA_ERROR; | ||
1477 | } | ||
1478 | return r; | ||
1479 | } | ||
1480 | |||
1481 | /* build distance tree */ | ||
1482 | if ((r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z)) != Z_OK) | ||
1483 | { | ||
1484 | if (r == Z_DATA_ERROR) | ||
1485 | z->msg = "oversubscribed literal/length tree"; | ||
1486 | else if (r == Z_BUF_ERROR) { | ||
1487 | #ifdef PKZIP_BUG_WORKAROUND | ||
1488 | r = Z_OK; | ||
1489 | } | ||
1490 | #else | ||
1491 | inflate_trees_free(*td, z); | ||
1492 | z->msg = "incomplete literal/length tree"; | ||
1493 | r = Z_DATA_ERROR; | ||
1494 | } | ||
1495 | inflate_trees_free(*tl, z); | ||
1496 | return r; | ||
1497 | #endif | ||
1498 | } | ||
1499 | |||
1500 | /* done */ | ||
1501 | return Z_OK; | ||
1502 | } | ||
1503 | |||
1504 | |||
1505 | /* build fixed tables only once--keep them here */ | ||
1506 | local int fixed_lock = 0; | ||
1507 | local int fixed_built = 0; | ||
1508 | #define FIXEDH 530 /* number of hufts used by fixed tables */ | ||
1509 | local uInt fixed_left = FIXEDH; | ||
1510 | local inflate_huft fixed_mem[FIXEDH]; | ||
1511 | local uInt fixed_bl; | ||
1512 | local uInt fixed_bd; | ||
1513 | local inflate_huft *fixed_tl; | ||
1514 | local inflate_huft *fixed_td; | ||
1515 | |||
1516 | |||
1517 | local voidpf falloc(q, n, s) | ||
1518 | voidpf q; /* opaque pointer (not used) */ | ||
1519 | uInt n; /* number of items */ | ||
1520 | uInt s; /* size of item */ | ||
1521 | { | ||
1522 | Assert(s == sizeof(inflate_huft) && n <= fixed_left, | ||
1523 | "inflate_trees falloc overflow"); | ||
1524 | if (q) s++; /* to make some compilers happy */ | ||
1525 | fixed_left -= n; | ||
1526 | return (voidpf)(fixed_mem + fixed_left); | ||
1527 | } | ||
1528 | |||
1529 | |||
1530 | local void ffree(q, p, n) | ||
1531 | voidpf q; | ||
1532 | voidpf p; | ||
1533 | uInt n; | ||
1534 | { | ||
1535 | Assert(0, "inflate_trees ffree called!"); | ||
1536 | if (q) q = p; /* to make some compilers happy */ | ||
1537 | } | ||
1538 | |||
1539 | |||
1540 | local int inflate_trees_fixed(bl, bd, tl, td) | ||
1541 | uIntf *bl; /* literal desired/actual bit depth */ | ||
1542 | uIntf *bd; /* distance desired/actual bit depth */ | ||
1543 | inflate_huft * FAR *tl; /* literal/length tree result */ | ||
1544 | inflate_huft * FAR *td; /* distance tree result */ | ||
1545 | { | ||
1546 | /* build fixed tables if not built already--lock out other instances */ | ||
1547 | while (++fixed_lock > 1) | ||
1548 | fixed_lock--; | ||
1549 | if (!fixed_built) | ||
1550 | { | ||
1551 | int k; /* temporary variable */ | ||
1552 | unsigned c[288]; /* length list for huft_build */ | ||
1553 | z_stream z; /* for falloc function */ | ||
1554 | |||
1555 | /* set up fake z_stream for memory routines */ | ||
1556 | z.zalloc = falloc; | ||
1557 | z.zfree = ffree; | ||
1558 | z.opaque = Z_NULL; | ||
1559 | |||
1560 | /* literal table */ | ||
1561 | for (k = 0; k < 144; k++) | ||
1562 | c[k] = 8; | ||
1563 | for (; k < 256; k++) | ||
1564 | c[k] = 9; | ||
1565 | for (; k < 280; k++) | ||
1566 | c[k] = 7; | ||
1567 | for (; k < 288; k++) | ||
1568 | c[k] = 8; | ||
1569 | fixed_bl = 7; | ||
1570 | huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, &z); | ||
1571 | |||
1572 | /* distance table */ | ||
1573 | for (k = 0; k < 30; k++) | ||
1574 | c[k] = 5; | ||
1575 | fixed_bd = 5; | ||
1576 | huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, &z); | ||
1577 | |||
1578 | /* done */ | ||
1579 | fixed_built = 1; | ||
1580 | } | ||
1581 | fixed_lock--; | ||
1582 | *bl = fixed_bl; | ||
1583 | *bd = fixed_bd; | ||
1584 | *tl = fixed_tl; | ||
1585 | *td = fixed_td; | ||
1586 | return Z_OK; | ||
1587 | } | ||
1588 | |||
1589 | |||
1590 | local int inflate_trees_free(t, z) | ||
1591 | inflate_huft *t; /* table to free */ | ||
1592 | z_stream *z; /* for zfree function */ | ||
1593 | /* Free the malloc'ed tables built by huft_build(), which makes a linked | ||
1594 | list of the tables it made, with the links in a dummy first entry of | ||
1595 | each table. */ | ||
1596 | { | ||
1597 | register inflate_huft *p, *q; | ||
1598 | |||
1599 | /* Go through linked list, freeing from the malloced (t[-1]) address. */ | ||
1600 | p = t; | ||
1601 | while (p != Z_NULL) | ||
1602 | { | ||
1603 | q = (--p)->next; | ||
1604 | ZFREE(z, p, p->word.Nalloc * sizeof(inflate_huft)); | ||
1605 | p = q; | ||
1606 | } | ||
1607 | return Z_OK; | ||
1608 | } | ||
1609 | |||
1610 | /*+++++*/ | ||
1611 | /* infcodes.c -- process literals and length/distance pairs | ||
1612 | * Copyright (C) 1995 Mark Adler | ||
1613 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
1614 | */ | ||
1615 | |||
1616 | /* simplify the use of the inflate_huft type with some defines */ | ||
1617 | #define base more.Base | ||
1618 | #define next more.Next | ||
1619 | #define exop word.what.Exop | ||
1620 | #define bits word.what.Bits | ||
1621 | |||
1622 | /* inflate codes private state */ | ||
1623 | struct inflate_codes_state { | ||
1624 | |||
1625 | /* mode */ | ||
1626 | enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ | ||
1627 | START, /* x: set up for LEN */ | ||
1628 | LEN, /* i: get length/literal/eob next */ | ||
1629 | LENEXT, /* i: getting length extra (have base) */ | ||
1630 | DIST, /* i: get distance next */ | ||
1631 | DISTEXT, /* i: getting distance extra */ | ||
1632 | COPY, /* o: copying bytes in window, waiting for space */ | ||
1633 | LIT, /* o: got literal, waiting for output space */ | ||
1634 | WASH, /* o: got eob, possibly still output waiting */ | ||
1635 | END, /* x: got eob and all data flushed */ | ||
1636 | BADCODE} /* x: got error */ | ||
1637 | mode; /* current inflate_codes mode */ | ||
1638 | |||
1639 | /* mode dependent information */ | ||
1640 | uInt len; | ||
1641 | union { | ||
1642 | struct { | ||
1643 | inflate_huft *tree; /* pointer into tree */ | ||
1644 | uInt need; /* bits needed */ | ||
1645 | } code; /* if LEN or DIST, where in tree */ | ||
1646 | uInt lit; /* if LIT, literal */ | ||
1647 | struct { | ||
1648 | uInt get; /* bits to get for extra */ | ||
1649 | uInt dist; /* distance back to copy from */ | ||
1650 | } copy; /* if EXT or COPY, where and how much */ | ||
1651 | } sub; /* submode */ | ||
1652 | |||
1653 | /* mode independent information */ | ||
1654 | Byte lbits; /* ltree bits decoded per branch */ | ||
1655 | Byte dbits; /* dtree bits decoder per branch */ | ||
1656 | inflate_huft *ltree; /* literal/length/eob tree */ | ||
1657 | inflate_huft *dtree; /* distance tree */ | ||
1658 | |||
1659 | }; | ||
1660 | |||
1661 | |||
1662 | local inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) | ||
1663 | uInt bl, bd; | ||
1664 | inflate_huft *tl, *td; | ||
1665 | z_stream *z; | ||
1666 | { | ||
1667 | inflate_codes_statef *c; | ||
1668 | |||
1669 | if ((c = (inflate_codes_statef *) | ||
1670 | ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) | ||
1671 | { | ||
1672 | c->mode = START; | ||
1673 | c->lbits = (Byte)bl; | ||
1674 | c->dbits = (Byte)bd; | ||
1675 | c->ltree = tl; | ||
1676 | c->dtree = td; | ||
1677 | Tracev((stderr, "inflate: codes new\n")); | ||
1678 | } | ||
1679 | return c; | ||
1680 | } | ||
1681 | |||
1682 | |||
1683 | local int inflate_codes(s, z, r) | ||
1684 | inflate_blocks_statef *s; | ||
1685 | z_stream *z; | ||
1686 | int r; | ||
1687 | { | ||
1688 | uInt j; /* temporary storage */ | ||
1689 | inflate_huft *t; /* temporary pointer */ | ||
1690 | uInt e; /* extra bits or operation */ | ||
1691 | uLong b; /* bit buffer */ | ||
1692 | uInt k; /* bits in bit buffer */ | ||
1693 | Bytef *p; /* input data pointer */ | ||
1694 | uInt n; /* bytes available there */ | ||
1695 | Bytef *q; /* output window write pointer */ | ||
1696 | uInt m; /* bytes to end of window or read pointer */ | ||
1697 | Bytef *f; /* pointer to copy strings from */ | ||
1698 | inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ | ||
1699 | |||
1700 | /* copy input/output information to locals (UPDATE macro restores) */ | ||
1701 | LOAD | ||
1702 | |||
1703 | /* process input and output based on current state */ | ||
1704 | while (1) switch (c->mode) | ||
1705 | { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ | ||
1706 | case START: /* x: set up for LEN */ | ||
1707 | #ifndef SLOW | ||
1708 | if (m >= 258 && n >= 10) | ||
1709 | { | ||
1710 | UPDATE | ||
1711 | r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); | ||
1712 | LOAD | ||
1713 | if (r != Z_OK) | ||
1714 | { | ||
1715 | c->mode = r == Z_STREAM_END ? WASH : BADCODE; | ||
1716 | break; | ||
1717 | } | ||
1718 | } | ||
1719 | #endif /* !SLOW */ | ||
1720 | c->sub.code.need = c->lbits; | ||
1721 | c->sub.code.tree = c->ltree; | ||
1722 | c->mode = LEN; | ||
1723 | case LEN: /* i: get length/literal/eob next */ | ||
1724 | j = c->sub.code.need; | ||
1725 | NEEDBITS(j) | ||
1726 | t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); | ||
1727 | DUMPBITS(t->bits) | ||
1728 | e = (uInt)(t->exop); | ||
1729 | if (e == 0) /* literal */ | ||
1730 | { | ||
1731 | c->sub.lit = t->base; | ||
1732 | Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? | ||
1733 | "inflate: literal '%c'\n" : | ||
1734 | "inflate: literal 0x%02x\n", t->base)); | ||
1735 | c->mode = LIT; | ||
1736 | break; | ||
1737 | } | ||
1738 | if (e & 16) /* length */ | ||
1739 | { | ||
1740 | c->sub.copy.get = e & 15; | ||
1741 | c->len = t->base; | ||
1742 | c->mode = LENEXT; | ||
1743 | break; | ||
1744 | } | ||
1745 | if ((e & 64) == 0) /* next table */ | ||
1746 | { | ||
1747 | c->sub.code.need = e; | ||
1748 | c->sub.code.tree = t->next; | ||
1749 | break; | ||
1750 | } | ||
1751 | if (e & 32) /* end of block */ | ||
1752 | { | ||
1753 | Tracevv((stderr, "inflate: end of block\n")); | ||
1754 | c->mode = WASH; | ||
1755 | break; | ||
1756 | } | ||
1757 | c->mode = BADCODE; /* invalid code */ | ||
1758 | z->msg = "invalid literal/length code"; | ||
1759 | r = Z_DATA_ERROR; | ||
1760 | LEAVE | ||
1761 | case LENEXT: /* i: getting length extra (have base) */ | ||
1762 | j = c->sub.copy.get; | ||
1763 | NEEDBITS(j) | ||
1764 | c->len += (uInt)b & inflate_mask[j]; | ||
1765 | DUMPBITS(j) | ||
1766 | c->sub.code.need = c->dbits; | ||
1767 | c->sub.code.tree = c->dtree; | ||
1768 | Tracevv((stderr, "inflate: length %u\n", c->len)); | ||
1769 | c->mode = DIST; | ||
1770 | case DIST: /* i: get distance next */ | ||
1771 | j = c->sub.code.need; | ||
1772 | NEEDBITS(j) | ||
1773 | t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); | ||
1774 | DUMPBITS(t->bits) | ||
1775 | e = (uInt)(t->exop); | ||
1776 | if (e & 16) /* distance */ | ||
1777 | { | ||
1778 | c->sub.copy.get = e & 15; | ||
1779 | c->sub.copy.dist = t->base; | ||
1780 | c->mode = DISTEXT; | ||
1781 | break; | ||
1782 | } | ||
1783 | if ((e & 64) == 0) /* next table */ | ||
1784 | { | ||
1785 | c->sub.code.need = e; | ||
1786 | c->sub.code.tree = t->next; | ||
1787 | break; | ||
1788 | } | ||
1789 | c->mode = BADCODE; /* invalid code */ | ||
1790 | z->msg = "invalid distance code"; | ||
1791 | r = Z_DATA_ERROR; | ||
1792 | LEAVE | ||
1793 | case DISTEXT: /* i: getting distance extra */ | ||
1794 | j = c->sub.copy.get; | ||
1795 | NEEDBITS(j) | ||
1796 | c->sub.copy.dist += (uInt)b & inflate_mask[j]; | ||
1797 | DUMPBITS(j) | ||
1798 | Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); | ||
1799 | c->mode = COPY; | ||
1800 | case COPY: /* o: copying bytes in window, waiting for space */ | ||
1801 | #ifndef __TURBOC__ /* Turbo C bug for following expression */ | ||
1802 | f = (uInt)(q - s->window) < c->sub.copy.dist ? | ||
1803 | s->end - (c->sub.copy.dist - (q - s->window)) : | ||
1804 | q - c->sub.copy.dist; | ||
1805 | #else | ||
1806 | f = q - c->sub.copy.dist; | ||
1807 | if ((uInt)(q - s->window) < c->sub.copy.dist) | ||
1808 | f = s->end - (c->sub.copy.dist - (q - s->window)); | ||
1809 | #endif | ||
1810 | while (c->len) | ||
1811 | { | ||
1812 | NEEDOUT | ||
1813 | OUTBYTE(*f++) | ||
1814 | if (f == s->end) | ||
1815 | f = s->window; | ||
1816 | c->len--; | ||
1817 | } | ||
1818 | c->mode = START; | ||
1819 | break; | ||
1820 | case LIT: /* o: got literal, waiting for output space */ | ||
1821 | NEEDOUT | ||
1822 | OUTBYTE(c->sub.lit) | ||
1823 | c->mode = START; | ||
1824 | break; | ||
1825 | case WASH: /* o: got eob, possibly more output */ | ||
1826 | FLUSH | ||
1827 | if (s->read != s->write) | ||
1828 | LEAVE | ||
1829 | c->mode = END; | ||
1830 | case END: | ||
1831 | r = Z_STREAM_END; | ||
1832 | LEAVE | ||
1833 | case BADCODE: /* x: got error */ | ||
1834 | r = Z_DATA_ERROR; | ||
1835 | LEAVE | ||
1836 | default: | ||
1837 | r = Z_STREAM_ERROR; | ||
1838 | LEAVE | ||
1839 | } | ||
1840 | } | ||
1841 | |||
1842 | |||
1843 | local void inflate_codes_free(c, z) | ||
1844 | inflate_codes_statef *c; | ||
1845 | z_stream *z; | ||
1846 | { | ||
1847 | ZFREE(z, c, sizeof(struct inflate_codes_state)); | ||
1848 | Tracev((stderr, "inflate: codes free\n")); | ||
1849 | } | ||
1850 | |||
1851 | /*+++++*/ | ||
1852 | /* inflate_util.c -- data and routines common to blocks and codes | ||
1853 | * Copyright (C) 1995 Mark Adler | ||
1854 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
1855 | */ | ||
1856 | |||
1857 | /* copy as much as possible from the sliding window to the output area */ | ||
1858 | local int inflate_flush(s, z, r) | ||
1859 | inflate_blocks_statef *s; | ||
1860 | z_stream *z; | ||
1861 | int r; | ||
1862 | { | ||
1863 | uInt n; | ||
1864 | Bytef *p, *q; | ||
1865 | |||
1866 | /* local copies of source and destination pointers */ | ||
1867 | p = z->next_out; | ||
1868 | q = s->read; | ||
1869 | |||
1870 | /* compute number of bytes to copy as far as end of window */ | ||
1871 | n = (uInt)((q <= s->write ? s->write : s->end) - q); | ||
1872 | if (n > z->avail_out) n = z->avail_out; | ||
1873 | if (n && r == Z_BUF_ERROR) r = Z_OK; | ||
1874 | |||
1875 | /* update counters */ | ||
1876 | z->avail_out -= n; | ||
1877 | z->total_out += n; | ||
1878 | |||
1879 | /* update check information */ | ||
1880 | if (s->checkfn != Z_NULL) | ||
1881 | s->check = (*s->checkfn)(s->check, q, n); | ||
1882 | |||
1883 | /* copy as far as end of window */ | ||
1884 | zmemcpy(p, q, n); | ||
1885 | p += n; | ||
1886 | q += n; | ||
1887 | |||
1888 | /* see if more to copy at beginning of window */ | ||
1889 | if (q == s->end) | ||
1890 | { | ||
1891 | /* wrap pointers */ | ||
1892 | q = s->window; | ||
1893 | if (s->write == s->end) | ||
1894 | s->write = s->window; | ||
1895 | |||
1896 | /* compute bytes to copy */ | ||
1897 | n = (uInt)(s->write - q); | ||
1898 | if (n > z->avail_out) n = z->avail_out; | ||
1899 | if (n && r == Z_BUF_ERROR) r = Z_OK; | ||
1900 | |||
1901 | /* update counters */ | ||
1902 | z->avail_out -= n; | ||
1903 | z->total_out += n; | ||
1904 | |||
1905 | /* update check information */ | ||
1906 | if (s->checkfn != Z_NULL) | ||
1907 | s->check = (*s->checkfn)(s->check, q, n); | ||
1908 | |||
1909 | /* copy */ | ||
1910 | zmemcpy(p, q, n); | ||
1911 | p += n; | ||
1912 | q += n; | ||
1913 | } | ||
1914 | |||
1915 | /* update pointers */ | ||
1916 | z->next_out = p; | ||
1917 | s->read = q; | ||
1918 | |||
1919 | /* done */ | ||
1920 | return r; | ||
1921 | } | ||
1922 | |||
1923 | |||
1924 | /*+++++*/ | ||
1925 | /* inffast.c -- process literals and length/distance pairs fast | ||
1926 | * Copyright (C) 1995 Mark Adler | ||
1927 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
1928 | */ | ||
1929 | |||
1930 | /* simplify the use of the inflate_huft type with some defines */ | ||
1931 | #define base more.Base | ||
1932 | #define next more.Next | ||
1933 | #define exop word.what.Exop | ||
1934 | #define bits word.what.Bits | ||
1935 | |||
1936 | /* macros for bit input with no checking and for returning unused bytes */ | ||
1937 | #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} | ||
1938 | #define UNGRAB {n+=(c=k>>3);p-=c;k&=7;} | ||
1939 | |||
1940 | /* Called with number of bytes left to write in window at least 258 | ||
1941 | (the maximum string length) and number of input bytes available | ||
1942 | at least ten. The ten bytes are six bytes for the longest length/ | ||
1943 | distance pair plus four bytes for overloading the bit buffer. */ | ||
1944 | |||
1945 | local int inflate_fast(bl, bd, tl, td, s, z) | ||
1946 | uInt bl, bd; | ||
1947 | inflate_huft *tl, *td; | ||
1948 | inflate_blocks_statef *s; | ||
1949 | z_stream *z; | ||
1950 | { | ||
1951 | inflate_huft *t; /* temporary pointer */ | ||
1952 | uInt e; /* extra bits or operation */ | ||
1953 | uLong b; /* bit buffer */ | ||
1954 | uInt k; /* bits in bit buffer */ | ||
1955 | Bytef *p; /* input data pointer */ | ||
1956 | uInt n; /* bytes available there */ | ||
1957 | Bytef *q; /* output window write pointer */ | ||
1958 | uInt m; /* bytes to end of window or read pointer */ | ||
1959 | uInt ml; /* mask for literal/length tree */ | ||
1960 | uInt md; /* mask for distance tree */ | ||
1961 | uInt c; /* bytes to copy */ | ||
1962 | uInt d; /* distance back to copy from */ | ||
1963 | Bytef *r; /* copy source pointer */ | ||
1964 | |||
1965 | /* load input, output, bit values */ | ||
1966 | LOAD | ||
1967 | |||
1968 | /* initialize masks */ | ||
1969 | ml = inflate_mask[bl]; | ||
1970 | md = inflate_mask[bd]; | ||
1971 | |||
1972 | /* do until not enough input or output space for fast loop */ | ||
1973 | do { /* assume called with m >= 258 && n >= 10 */ | ||
1974 | /* get literal/length code */ | ||
1975 | GRABBITS(20) /* max bits for literal/length code */ | ||
1976 | if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) | ||
1977 | { | ||
1978 | DUMPBITS(t->bits) | ||
1979 | Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? | ||
1980 | "inflate: * literal '%c'\n" : | ||
1981 | "inflate: * literal 0x%02x\n", t->base)); | ||
1982 | *q++ = (Byte)t->base; | ||
1983 | m--; | ||
1984 | continue; | ||
1985 | } | ||
1986 | do { | ||
1987 | DUMPBITS(t->bits) | ||
1988 | if (e & 16) | ||
1989 | { | ||
1990 | /* get extra bits for length */ | ||
1991 | e &= 15; | ||
1992 | c = t->base + ((uInt)b & inflate_mask[e]); | ||
1993 | DUMPBITS(e) | ||
1994 | Tracevv((stderr, "inflate: * length %u\n", c)); | ||
1995 | |||
1996 | /* decode distance base of block to copy */ | ||
1997 | GRABBITS(15); /* max bits for distance code */ | ||
1998 | e = (t = td + ((uInt)b & md))->exop; | ||
1999 | do { | ||
2000 | DUMPBITS(t->bits) | ||
2001 | if (e & 16) | ||
2002 | { | ||
2003 | /* get extra bits to add to distance base */ | ||
2004 | e &= 15; | ||
2005 | GRABBITS(e) /* get extra bits (up to 13) */ | ||
2006 | d = t->base + ((uInt)b & inflate_mask[e]); | ||
2007 | DUMPBITS(e) | ||
2008 | Tracevv((stderr, "inflate: * distance %u\n", d)); | ||
2009 | |||
2010 | /* do the copy */ | ||
2011 | m -= c; | ||
2012 | if ((uInt)(q - s->window) >= d) /* offset before dest */ | ||
2013 | { /* just copy */ | ||
2014 | r = q - d; | ||
2015 | *q++ = *r++; c--; /* minimum count is three, */ | ||
2016 | *q++ = *r++; c--; /* so unroll loop a little */ | ||
2017 | } | ||
2018 | else /* else offset after destination */ | ||
2019 | { | ||
2020 | e = d - (q - s->window); /* bytes from offset to end */ | ||
2021 | r = s->end - e; /* pointer to offset */ | ||
2022 | if (c > e) /* if source crosses, */ | ||
2023 | { | ||
2024 | c -= e; /* copy to end of window */ | ||
2025 | do { | ||
2026 | *q++ = *r++; | ||
2027 | } while (--e); | ||
2028 | r = s->window; /* copy rest from start of window */ | ||
2029 | } | ||
2030 | } | ||
2031 | do { /* copy all or what's left */ | ||
2032 | *q++ = *r++; | ||
2033 | } while (--c); | ||
2034 | break; | ||
2035 | } | ||
2036 | else if ((e & 64) == 0) | ||
2037 | e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop; | ||
2038 | else | ||
2039 | { | ||
2040 | z->msg = "invalid distance code"; | ||
2041 | UNGRAB | ||
2042 | UPDATE | ||
2043 | return Z_DATA_ERROR; | ||
2044 | } | ||
2045 | } while (1); | ||
2046 | break; | ||
2047 | } | ||
2048 | if ((e & 64) == 0) | ||
2049 | { | ||
2050 | if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0) | ||
2051 | { | ||
2052 | DUMPBITS(t->bits) | ||
2053 | Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? | ||
2054 | "inflate: * literal '%c'\n" : | ||
2055 | "inflate: * literal 0x%02x\n", t->base)); | ||
2056 | *q++ = (Byte)t->base; | ||
2057 | m--; | ||
2058 | break; | ||
2059 | } | ||
2060 | } | ||
2061 | else if (e & 32) | ||
2062 | { | ||
2063 | Tracevv((stderr, "inflate: * end of block\n")); | ||
2064 | UNGRAB | ||
2065 | UPDATE | ||
2066 | return Z_STREAM_END; | ||
2067 | } | ||
2068 | else | ||
2069 | { | ||
2070 | z->msg = "invalid literal/length code"; | ||
2071 | UNGRAB | ||
2072 | UPDATE | ||
2073 | return Z_DATA_ERROR; | ||
2074 | } | ||
2075 | } while (1); | ||
2076 | } while (m >= 258 && n >= 10); | ||
2077 | |||
2078 | /* not enough input or output--restore pointers and return */ | ||
2079 | UNGRAB | ||
2080 | UPDATE | ||
2081 | return Z_OK; | ||
2082 | } | ||
2083 | |||
2084 | |||
2085 | /*+++++*/ | ||
2086 | /* zutil.c -- target dependent utility functions for the compression library | ||
2087 | * Copyright (C) 1995 Jean-loup Gailly. | ||
2088 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
2089 | */ | ||
2090 | |||
2091 | /* From: zutil.c,v 1.8 1995/05/03 17:27:12 jloup Exp */ | ||
2092 | |||
2093 | char *zlib_version = ZLIB_VERSION; | ||
2094 | |||
2095 | char *z_errmsg[] = { | ||
2096 | "stream end", /* Z_STREAM_END 1 */ | ||
2097 | "", /* Z_OK 0 */ | ||
2098 | "file error", /* Z_ERRNO (-1) */ | ||
2099 | "stream error", /* Z_STREAM_ERROR (-2) */ | ||
2100 | "data error", /* Z_DATA_ERROR (-3) */ | ||
2101 | "insufficient memory", /* Z_MEM_ERROR (-4) */ | ||
2102 | "buffer error", /* Z_BUF_ERROR (-5) */ | ||
2103 | ""}; | ||
2104 | |||
2105 | |||
2106 | /*+++++*/ | ||
2107 | /* adler32.c -- compute the Adler-32 checksum of a data stream | ||
2108 | * Copyright (C) 1995 Mark Adler | ||
2109 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
2110 | */ | ||
2111 | |||
2112 | /* From: adler32.c,v 1.6 1995/05/03 17:27:08 jloup Exp */ | ||
2113 | |||
2114 | #define BASE 65521L /* largest prime smaller than 65536 */ | ||
2115 | #define NMAX 5552 | ||
2116 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ | ||
2117 | |||
2118 | #define DO1(buf) {s1 += *buf++; s2 += s1;} | ||
2119 | #define DO2(buf) DO1(buf); DO1(buf); | ||
2120 | #define DO4(buf) DO2(buf); DO2(buf); | ||
2121 | #define DO8(buf) DO4(buf); DO4(buf); | ||
2122 | #define DO16(buf) DO8(buf); DO8(buf); | ||
2123 | |||
2124 | /* ========================================================================= */ | ||
2125 | uLong adler32(adler, buf, len) | ||
2126 | uLong adler; | ||
2127 | Bytef *buf; | ||
2128 | uInt len; | ||
2129 | { | ||
2130 | unsigned long s1 = adler & 0xffff; | ||
2131 | unsigned long s2 = (adler >> 16) & 0xffff; | ||
2132 | int k; | ||
2133 | |||
2134 | if (buf == Z_NULL) return 1L; | ||
2135 | |||
2136 | while (len > 0) { | ||
2137 | k = len < NMAX ? len : NMAX; | ||
2138 | len -= k; | ||
2139 | while (k >= 16) { | ||
2140 | DO16(buf); | ||
2141 | k -= 16; | ||
2142 | } | ||
2143 | if (k != 0) do { | ||
2144 | DO1(buf); | ||
2145 | } while (--k); | ||
2146 | s1 %= BASE; | ||
2147 | s2 %= BASE; | ||
2148 | } | ||
2149 | return (s2 << 16) | s1; | ||
2150 | } | ||
diff --git a/arch/xtensa/boot/lib/zmem.c b/arch/xtensa/boot/lib/zmem.c index 7848f126d67d..d9862aa8ca25 100644 --- a/arch/xtensa/boot/lib/zmem.c +++ b/arch/xtensa/boot/lib/zmem.c | |||
@@ -1,4 +1,4 @@ | |||
1 | #include "zlib.h" | 1 | #include <linux/zlib.h> |
2 | 2 | ||
3 | /* bits taken from ppc */ | 3 | /* bits taken from ppc */ |
4 | 4 | ||
@@ -9,11 +9,10 @@ void exit (void) | |||
9 | for (;;); | 9 | for (;;); |
10 | } | 10 | } |
11 | 11 | ||
12 | void *zalloc(void *x, unsigned items, unsigned size) | 12 | void *zalloc(unsigned size) |
13 | { | 13 | { |
14 | void *p = avail_ram; | 14 | void *p = avail_ram; |
15 | 15 | ||
16 | size *= items; | ||
17 | size = (size + 7) & -8; | 16 | size = (size + 7) & -8; |
18 | avail_ram += size; | 17 | avail_ram += size; |
19 | if (avail_ram > end_avail) { | 18 | if (avail_ram > end_avail) { |
@@ -24,11 +23,6 @@ void *zalloc(void *x, unsigned items, unsigned size) | |||
24 | return p; | 23 | return p; |
25 | } | 24 | } |
26 | 25 | ||
27 | void zfree(void *x, void *addr, unsigned nb) | ||
28 | { | ||
29 | } | ||
30 | |||
31 | |||
32 | #define HEAD_CRC 2 | 26 | #define HEAD_CRC 2 |
33 | #define EXTRA_FIELD 4 | 27 | #define EXTRA_FIELD 4 |
34 | #define ORIG_NAME 8 | 28 | #define ORIG_NAME 8 |
@@ -43,7 +37,6 @@ void gunzip (void *dst, int dstlen, unsigned char *src, int *lenp) | |||
43 | int r, i, flags; | 37 | int r, i, flags; |
44 | 38 | ||
45 | /* skip header */ | 39 | /* skip header */ |
46 | |||
47 | i = 10; | 40 | i = 10; |
48 | flags = src[3]; | 41 | flags = src[3]; |
49 | if (src[2] != DEFLATED || (flags & RESERVED) != 0) { | 42 | if (src[2] != DEFLATED || (flags & RESERVED) != 0) { |
@@ -65,9 +58,8 @@ void gunzip (void *dst, int dstlen, unsigned char *src, int *lenp) | |||
65 | exit(); | 58 | exit(); |
66 | } | 59 | } |
67 | 60 | ||
68 | s.zalloc = zalloc; | 61 | s.workspace = zalloc(zlib_inflate_workspacesize()); |
69 | s.zfree = zfree; | 62 | r = zlib_inflateInit2(&s, -MAX_WBITS); |
70 | r = inflateInit2(&s, -MAX_WBITS); | ||
71 | if (r != Z_OK) { | 63 | if (r != Z_OK) { |
72 | //puts("inflateInit2 returned "); puthex(r); puts("\n"); | 64 | //puts("inflateInit2 returned "); puthex(r); puts("\n"); |
73 | exit(); | 65 | exit(); |
@@ -76,12 +68,12 @@ void gunzip (void *dst, int dstlen, unsigned char *src, int *lenp) | |||
76 | s.avail_in = *lenp - i; | 68 | s.avail_in = *lenp - i; |
77 | s.next_out = dst; | 69 | s.next_out = dst; |
78 | s.avail_out = dstlen; | 70 | s.avail_out = dstlen; |
79 | r = inflate(&s, Z_FINISH); | 71 | r = zlib_inflate(&s, Z_FINISH); |
80 | if (r != Z_OK && r != Z_STREAM_END) { | 72 | if (r != Z_OK && r != Z_STREAM_END) { |
81 | //puts("inflate returned "); puthex(r); puts("\n"); | 73 | //puts("inflate returned "); puthex(r); puts("\n"); |
82 | exit(); | 74 | exit(); |
83 | } | 75 | } |
84 | *lenp = s.next_out - (unsigned char *) dst; | 76 | *lenp = s.next_out - (unsigned char *) dst; |
85 | inflateEnd(&s); | 77 | zlib_inflateEnd(&s); |
86 | } | 78 | } |
87 | 79 | ||
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index d29a81648637..09887c96e9a1 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c | |||
@@ -57,50 +57,6 @@ struct pci_controller** pci_ctrl_tail = &pci_ctrl_head; | |||
57 | 57 | ||
58 | static int pci_bus_count; | 58 | static int pci_bus_count; |
59 | 59 | ||
60 | static void pcibios_fixup_resources(struct pci_dev* dev); | ||
61 | |||
62 | #if 0 // FIXME | ||
63 | struct pci_fixup pcibios_fixups[] = { | ||
64 | { DECLARE_PCI_FIXUP_HEADER, PCI_ANY_ID, PCI_ANY_ID, pcibios_fixup_resources }, | ||
65 | { 0 } | ||
66 | }; | ||
67 | #endif | ||
68 | |||
69 | void | ||
70 | pcibios_update_resource(struct pci_dev *dev, struct resource *root, | ||
71 | struct resource *res, int resource) | ||
72 | { | ||
73 | u32 new, check, mask; | ||
74 | int reg; | ||
75 | struct pci_controller* pci_ctrl = dev->sysdata; | ||
76 | |||
77 | new = res->start; | ||
78 | if (pci_ctrl && res->flags & IORESOURCE_IO) { | ||
79 | new -= pci_ctrl->io_space.base; | ||
80 | } | ||
81 | new |= (res->flags & PCI_REGION_FLAG_MASK); | ||
82 | if (resource < 6) { | ||
83 | reg = PCI_BASE_ADDRESS_0 + 4*resource; | ||
84 | } else if (resource == PCI_ROM_RESOURCE) { | ||
85 | res->flags |= PCI_ROM_ADDRESS_ENABLE; | ||
86 | reg = dev->rom_base_reg; | ||
87 | } else { | ||
88 | /* Somebody might have asked allocation of a non-standard resource */ | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | pci_write_config_dword(dev, reg, new); | ||
93 | pci_read_config_dword(dev, reg, &check); | ||
94 | mask = (new & PCI_BASE_ADDRESS_SPACE_IO) ? | ||
95 | PCI_BASE_ADDRESS_IO_MASK : PCI_BASE_ADDRESS_MEM_MASK; | ||
96 | |||
97 | if ((new ^ check) & mask) { | ||
98 | printk(KERN_ERR "PCI: Error while updating region " | ||
99 | "%s/%d (%08x != %08x)\n", dev->slot_name, resource, | ||
100 | new, check); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | /* | 60 | /* |
105 | * We need to avoid collisions with `mirrored' VGA ports | 61 | * We need to avoid collisions with `mirrored' VGA ports |
106 | * and other strange ISA hardware, so we always want the | 62 | * and other strange ISA hardware, so we always want the |
@@ -125,7 +81,7 @@ pcibios_align_resource(void *data, struct resource *res, unsigned long size, | |||
125 | 81 | ||
126 | if (size > 0x100) { | 82 | if (size > 0x100) { |
127 | printk(KERN_ERR "PCI: I/O Region %s/%d too large" | 83 | printk(KERN_ERR "PCI: I/O Region %s/%d too large" |
128 | " (%ld bytes)\n", dev->slot_name, | 84 | " (%ld bytes)\n", pci_name(dev), |
129 | dev->resource - res, size); | 85 | dev->resource - res, size); |
130 | } | 86 | } |
131 | 87 | ||
@@ -149,7 +105,7 @@ pcibios_enable_resources(struct pci_dev *dev, int mask) | |||
149 | r = &dev->resource[idx]; | 105 | r = &dev->resource[idx]; |
150 | if (!r->start && r->end) { | 106 | if (!r->start && r->end) { |
151 | printk (KERN_ERR "PCI: Device %s not available because " | 107 | printk (KERN_ERR "PCI: Device %s not available because " |
152 | "of resource collisions\n", dev->slot_name); | 108 | "of resource collisions\n", pci_name(dev)); |
153 | return -EINVAL; | 109 | return -EINVAL; |
154 | } | 110 | } |
155 | if (r->flags & IORESOURCE_IO) | 111 | if (r->flags & IORESOURCE_IO) |
@@ -161,7 +117,7 @@ pcibios_enable_resources(struct pci_dev *dev, int mask) | |||
161 | cmd |= PCI_COMMAND_MEMORY; | 117 | cmd |= PCI_COMMAND_MEMORY; |
162 | if (cmd != old_cmd) { | 118 | if (cmd != old_cmd) { |
163 | printk("PCI: Enabling device %s (%04x -> %04x)\n", | 119 | printk("PCI: Enabling device %s (%04x -> %04x)\n", |
164 | dev->slot_name, old_cmd, cmd); | 120 | pci_name(dev), old_cmd, cmd); |
165 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 121 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
166 | } | 122 | } |
167 | return 0; | 123 | return 0; |
@@ -293,7 +249,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) | |||
293 | r = &dev->resource[idx]; | 249 | r = &dev->resource[idx]; |
294 | if (!r->start && r->end) { | 250 | if (!r->start && r->end) { |
295 | printk(KERN_ERR "PCI: Device %s not available because " | 251 | printk(KERN_ERR "PCI: Device %s not available because " |
296 | "of resource collisions\n", dev->slot_name); | 252 | "of resource collisions\n", pci_name(dev)); |
297 | return -EINVAL; | 253 | return -EINVAL; |
298 | } | 254 | } |
299 | if (r->flags & IORESOURCE_IO) | 255 | if (r->flags & IORESOURCE_IO) |
@@ -303,7 +259,7 @@ int pcibios_enable_device(struct pci_dev *dev, int mask) | |||
303 | } | 259 | } |
304 | if (cmd != old_cmd) { | 260 | if (cmd != old_cmd) { |
305 | printk("PCI: Enabling device %s (%04x -> %04x)\n", | 261 | printk("PCI: Enabling device %s (%04x -> %04x)\n", |
306 | dev->slot_name, old_cmd, cmd); | 262 | pci_name(dev), old_cmd, cmd); |
307 | pci_write_config_word(dev, PCI_COMMAND, cmd); | 263 | pci_write_config_word(dev, PCI_COMMAND, cmd); |
308 | } | 264 | } |
309 | 265 | ||
@@ -325,47 +281,6 @@ pci_controller_num(struct pci_dev *dev) | |||
325 | 281 | ||
326 | #endif /* CONFIG_PROC_FS */ | 282 | #endif /* CONFIG_PROC_FS */ |
327 | 283 | ||
328 | |||
329 | static void | ||
330 | pcibios_fixup_resources(struct pci_dev *dev) | ||
331 | { | ||
332 | struct pci_controller* pci_ctrl = (struct pci_controller *)dev->sysdata; | ||
333 | int i; | ||
334 | unsigned long offset; | ||
335 | |||
336 | if (!pci_ctrl) { | ||
337 | printk(KERN_ERR "No pci_ctrl for PCI dev %s!\n",dev->slot_name); | ||
338 | return; | ||
339 | } | ||
340 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | ||
341 | struct resource *res = dev->resource + i; | ||
342 | if (!res->start || !res->flags) | ||
343 | continue; | ||
344 | if (res->end == 0xffffffff) { | ||
345 | DBG("PCI:%s Resource %d [%08lx-%08lx] is unassigned\n", | ||
346 | dev->slot_name, i, res->start, res->end); | ||
347 | res->end -= res->start; | ||
348 | res->start = 0; | ||
349 | continue; | ||
350 | } | ||
351 | offset = 0; | ||
352 | if (res->flags & IORESOURCE_IO) | ||
353 | offset = (unsigned long) pci_ctrl->io_space.base; | ||
354 | else if (res->flags & IORESOURCE_MEM) | ||
355 | offset = (unsigned long) pci_ctrl->mem_space.base; | ||
356 | |||
357 | if (offset != 0) { | ||
358 | res->start += offset; | ||
359 | res->end += offset; | ||
360 | #ifdef DEBUG | ||
361 | printk("Fixup res %d (%lx) of dev %s: %lx -> %lx\n", | ||
362 | i, res->flags, dev->slot_name, | ||
363 | res->start - offset, res->start); | ||
364 | #endif | ||
365 | } | ||
366 | } | ||
367 | } | ||
368 | |||
369 | /* | 284 | /* |
370 | * Platform support for /proc/bus/pci/X/Y mmap()s, | 285 | * Platform support for /proc/bus/pci/X/Y mmap()s, |
371 | * modelled on the sparc64 implementation by Dave Miller. | 286 | * modelled on the sparc64 implementation by Dave Miller. |
diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c index 9ef07a4dd2a2..2659efdd4e99 100644 --- a/arch/xtensa/kernel/ptrace.c +++ b/arch/xtensa/kernel/ptrace.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/smp.h> | 22 | #include <linux/smp.h> |
23 | #include <linux/smp_lock.h> | 23 | #include <linux/smp_lock.h> |
24 | #include <linux/security.h> | 24 | #include <linux/security.h> |
25 | #include <linux/signal.h> | ||
25 | 26 | ||
26 | #include <asm/pgtable.h> | 27 | #include <asm/pgtable.h> |
27 | #include <asm/page.h> | 28 | #include <asm/page.h> |
@@ -239,7 +240,7 @@ int sys_ptrace(long request, long pid, long addr, long data) | |||
239 | case PTRACE_CONT: /* restart after signal. */ | 240 | case PTRACE_CONT: /* restart after signal. */ |
240 | { | 241 | { |
241 | ret = -EIO; | 242 | ret = -EIO; |
242 | if ((unsigned long) data > _NSIG) | 243 | if (!valid_signal(data)) |
243 | break; | 244 | break; |
244 | if (request == PTRACE_SYSCALL) | 245 | if (request == PTRACE_SYSCALL) |
245 | set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | 246 | set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); |
@@ -269,7 +270,7 @@ int sys_ptrace(long request, long pid, long addr, long data) | |||
269 | 270 | ||
270 | case PTRACE_SINGLESTEP: | 271 | case PTRACE_SINGLESTEP: |
271 | ret = -EIO; | 272 | ret = -EIO; |
272 | if ((unsigned long) data > _NSIG) | 273 | if (!valid_signal(data)) |
273 | break; | 274 | break; |
274 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); | 275 | clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); |
275 | child->ptrace |= PT_SINGLESTEP; | 276 | child->ptrace |= PT_SINGLESTEP; |
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 854475c54f0e..049d128ae7f0 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -464,7 +464,7 @@ void __devexit tpm_remove(struct pci_dev *pci_dev) | |||
464 | 464 | ||
465 | pci_set_drvdata(pci_dev, NULL); | 465 | pci_set_drvdata(pci_dev, NULL); |
466 | misc_deregister(&chip->vendor->miscdev); | 466 | misc_deregister(&chip->vendor->miscdev); |
467 | kfree(&chip->vendor->miscdev.name); | 467 | kfree(chip->vendor->miscdev.name); |
468 | 468 | ||
469 | sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group); | 469 | sysfs_remove_group(&pci_dev->dev.kobj, chip->vendor->attr_group); |
470 | 470 | ||
diff --git a/drivers/ide/legacy/hd.c b/drivers/ide/legacy/hd.c index e884cd4b22fd..242029c9c0ca 100644 --- a/drivers/ide/legacy/hd.c +++ b/drivers/ide/legacy/hd.c | |||
@@ -156,11 +156,13 @@ else \ | |||
156 | 156 | ||
157 | 157 | ||
158 | #if (HD_DELAY > 0) | 158 | #if (HD_DELAY > 0) |
159 | |||
160 | #include <asm/i8253.h> | ||
161 | |||
159 | unsigned long last_req; | 162 | unsigned long last_req; |
160 | 163 | ||
161 | unsigned long read_timer(void) | 164 | unsigned long read_timer(void) |
162 | { | 165 | { |
163 | extern spinlock_t i8253_lock; | ||
164 | unsigned long t, flags; | 166 | unsigned long t, flags; |
165 | int i; | 167 | int i; |
166 | 168 | ||
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index 3e72c9b1461e..ab09cf4093e3 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c | |||
@@ -60,12 +60,13 @@ static void gameport_disconnect_port(struct gameport *gameport); | |||
60 | 60 | ||
61 | #if defined(__i386__) | 61 | #if defined(__i386__) |
62 | 62 | ||
63 | #include <asm/i8253.h> | ||
64 | |||
63 | #define DELTA(x,y) ((y)-(x)+((y)<(x)?1193182/HZ:0)) | 65 | #define DELTA(x,y) ((y)-(x)+((y)<(x)?1193182/HZ:0)) |
64 | #define GET_TIME(x) do { x = get_time_pit(); } while (0) | 66 | #define GET_TIME(x) do { x = get_time_pit(); } while (0) |
65 | 67 | ||
66 | static unsigned int get_time_pit(void) | 68 | static unsigned int get_time_pit(void) |
67 | { | 69 | { |
68 | extern spinlock_t i8253_lock; | ||
69 | unsigned long flags; | 70 | unsigned long flags; |
70 | unsigned int count; | 71 | unsigned int count; |
71 | 72 | ||
diff --git a/drivers/input/joystick/analog.c b/drivers/input/joystick/analog.c index 504b7d550567..c3a5739030c3 100644 --- a/drivers/input/joystick/analog.c +++ b/drivers/input/joystick/analog.c | |||
@@ -140,12 +140,14 @@ struct analog_port { | |||
140 | */ | 140 | */ |
141 | 141 | ||
142 | #ifdef __i386__ | 142 | #ifdef __i386__ |
143 | |||
144 | #include <asm/i8253.h> | ||
145 | |||
143 | #define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0) | 146 | #define GET_TIME(x) do { if (cpu_has_tsc) rdtscl(x); else x = get_time_pit(); } while (0) |
144 | #define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0))) | 147 | #define DELTA(x,y) (cpu_has_tsc ? ((y) - (x)) : ((x) - (y) + ((x) < (y) ? CLOCK_TICK_RATE / HZ : 0))) |
145 | #define TIME_NAME (cpu_has_tsc?"TSC":"PIT") | 148 | #define TIME_NAME (cpu_has_tsc?"TSC":"PIT") |
146 | static unsigned int get_time_pit(void) | 149 | static unsigned int get_time_pit(void) |
147 | { | 150 | { |
148 | extern spinlock_t i8253_lock; | ||
149 | unsigned long flags; | 151 | unsigned long flags; |
150 | unsigned int count; | 152 | unsigned int count; |
151 | 153 | ||
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index cabddd49f6ff..d5afd557fe37 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -847,7 +847,7 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]); | |||
847 | pcmcia_device_stringattr(prod_id3, prod_id[2]); | 847 | pcmcia_device_stringattr(prod_id3, prod_id[2]); |
848 | pcmcia_device_stringattr(prod_id4, prod_id[3]); | 848 | pcmcia_device_stringattr(prod_id4, prod_id[3]); |
849 | 849 | ||
850 | static ssize_t modalias_show(struct device *dev, char *buf) | 850 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) |
851 | { | 851 | { |
852 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); | 852 | struct pcmcia_device *p_dev = to_pcmcia_dev(dev); |
853 | int i; | 853 | int i; |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 8ccee8415488..3e31c4a736f1 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -1331,12 +1331,21 @@ void __exit fat_cache_destroy(void); | |||
1331 | 1331 | ||
1332 | static int __init init_fat_fs(void) | 1332 | static int __init init_fat_fs(void) |
1333 | { | 1333 | { |
1334 | int ret; | 1334 | int err; |
1335 | 1335 | ||
1336 | ret = fat_cache_init(); | 1336 | err = fat_cache_init(); |
1337 | if (ret < 0) | 1337 | if (err) |
1338 | return ret; | 1338 | return err; |
1339 | return fat_init_inodecache(); | 1339 | |
1340 | err = fat_init_inodecache(); | ||
1341 | if (err) | ||
1342 | goto failed; | ||
1343 | |||
1344 | return 0; | ||
1345 | |||
1346 | failed: | ||
1347 | fat_cache_destroy(); | ||
1348 | return err; | ||
1340 | } | 1349 | } |
1341 | 1350 | ||
1342 | static void __exit exit_fat_fs(void) | 1351 | static void __exit exit_fat_fs(void) |
diff --git a/fs/freevxfs/vxfs.h b/fs/freevxfs/vxfs.h index 8da0252642a4..583bd78086d8 100644 --- a/fs/freevxfs/vxfs.h +++ b/fs/freevxfs/vxfs.h | |||
@@ -37,7 +37,6 @@ | |||
37 | * superblocks of the Veritas Filesystem. | 37 | * superblocks of the Veritas Filesystem. |
38 | */ | 38 | */ |
39 | #include <linux/types.h> | 39 | #include <linux/types.h> |
40 | #include "vxfs_kcompat.h" | ||
41 | 40 | ||
42 | 41 | ||
43 | /* | 42 | /* |
diff --git a/fs/freevxfs/vxfs_bmap.c b/fs/freevxfs/vxfs_bmap.c index bc4b57da306a..d3f6b2835bc8 100644 --- a/fs/freevxfs/vxfs_bmap.c +++ b/fs/freevxfs/vxfs_bmap.c | |||
@@ -101,7 +101,7 @@ vxfs_bmap_ext4(struct inode *ip, long bn) | |||
101 | return 0; | 101 | return 0; |
102 | 102 | ||
103 | fail_size: | 103 | fail_size: |
104 | printk("vxfs: indirect extent to big!\n"); | 104 | printk("vxfs: indirect extent too big!\n"); |
105 | fail_buf: | 105 | fail_buf: |
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
diff --git a/fs/freevxfs/vxfs_fshead.c b/fs/freevxfs/vxfs_fshead.c index 05b19f70bf97..6dee109aeea4 100644 --- a/fs/freevxfs/vxfs_fshead.c +++ b/fs/freevxfs/vxfs_fshead.c | |||
@@ -78,17 +78,18 @@ vxfs_getfsh(struct inode *ip, int which) | |||
78 | struct buffer_head *bp; | 78 | struct buffer_head *bp; |
79 | 79 | ||
80 | bp = vxfs_bread(ip, which); | 80 | bp = vxfs_bread(ip, which); |
81 | if (buffer_mapped(bp)) { | 81 | if (bp) { |
82 | struct vxfs_fsh *fhp; | 82 | struct vxfs_fsh *fhp; |
83 | 83 | ||
84 | if (!(fhp = kmalloc(sizeof(*fhp), SLAB_KERNEL))) | 84 | if (!(fhp = kmalloc(sizeof(*fhp), GFP_KERNEL))) |
85 | return NULL; | 85 | goto out; |
86 | memcpy(fhp, bp->b_data, sizeof(*fhp)); | 86 | memcpy(fhp, bp->b_data, sizeof(*fhp)); |
87 | 87 | ||
88 | brelse(bp); | 88 | put_bh(bp); |
89 | return (fhp); | 89 | return (fhp); |
90 | } | 90 | } |
91 | 91 | out: | |
92 | brelse(bp); | ||
92 | return NULL; | 93 | return NULL; |
93 | } | 94 | } |
94 | 95 | ||
diff --git a/fs/freevxfs/vxfs_kcompat.h b/fs/freevxfs/vxfs_kcompat.h deleted file mode 100644 index 342a4cc860f4..000000000000 --- a/fs/freevxfs/vxfs_kcompat.h +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | #ifndef _VXFS_KCOMPAT_H | ||
2 | #define _VXFS_KCOMPAT_H | ||
3 | |||
4 | #include <linux/version.h> | ||
5 | |||
6 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) | ||
7 | |||
8 | #include <linux/blkdev.h> | ||
9 | |||
10 | typedef long sector_t; | ||
11 | |||
12 | /* From include/linux/fs.h (Linux 2.5.2-pre3) */ | ||
13 | static inline struct buffer_head * sb_bread(struct super_block *sb, int block) | ||
14 | { | ||
15 | return bread(sb->s_dev, block, sb->s_blocksize); | ||
16 | } | ||
17 | |||
18 | /* Dito. */ | ||
19 | static inline void map_bh(struct buffer_head *bh, struct super_block *sb, int block) | ||
20 | { | ||
21 | bh->b_state |= 1 << BH_Mapped; | ||
22 | bh->b_dev = sb->s_dev; | ||
23 | bh->b_blocknr = block; | ||
24 | } | ||
25 | |||
26 | /* From fs/block_dev.c (Linux 2.5.2-pre2) */ | ||
27 | static inline int sb_set_blocksize(struct super_block *sb, int size) | ||
28 | { | ||
29 | int bits; | ||
30 | if (set_blocksize(sb->s_dev, size) < 0) | ||
31 | return 0; | ||
32 | sb->s_blocksize = size; | ||
33 | for (bits = 9, size >>= 9; size >>= 1; bits++) | ||
34 | ; | ||
35 | sb->s_blocksize_bits = bits; | ||
36 | return sb->s_blocksize; | ||
37 | } | ||
38 | |||
39 | /* Dito. */ | ||
40 | static inline int sb_min_blocksize(struct super_block *sb, int size) | ||
41 | { | ||
42 | int minsize = get_hardsect_size(sb->s_dev); | ||
43 | if (size < minsize) | ||
44 | size = minsize; | ||
45 | return sb_set_blocksize(sb, size); | ||
46 | } | ||
47 | |||
48 | #endif /* Kernel 2.4 */ | ||
49 | #endif /* _VXFS_KCOMPAT_H */ | ||
diff --git a/fs/freevxfs/vxfs_lookup.c b/fs/freevxfs/vxfs_lookup.c index 506ae251d2c0..554eb455722c 100644 --- a/fs/freevxfs/vxfs_lookup.c +++ b/fs/freevxfs/vxfs_lookup.c | |||
@@ -61,13 +61,13 @@ struct file_operations vxfs_dir_operations = { | |||
61 | }; | 61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | static __inline__ u_long | 64 | static inline u_long |
65 | dir_pages(struct inode *inode) | 65 | dir_pages(struct inode *inode) |
66 | { | 66 | { |
67 | return (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | 67 | return (inode->i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; |
68 | } | 68 | } |
69 | 69 | ||
70 | static __inline__ u_long | 70 | static inline u_long |
71 | dir_blocks(struct inode *ip) | 71 | dir_blocks(struct inode *ip) |
72 | { | 72 | { |
73 | u_long bsize = ip->i_sb->s_blocksize; | 73 | u_long bsize = ip->i_sb->s_blocksize; |
@@ -79,7 +79,7 @@ dir_blocks(struct inode *ip) | |||
79 | * | 79 | * |
80 | * len <= VXFS_NAMELEN and de != NULL are guaranteed by caller. | 80 | * len <= VXFS_NAMELEN and de != NULL are guaranteed by caller. |
81 | */ | 81 | */ |
82 | static __inline__ int | 82 | static inline int |
83 | vxfs_match(int len, const char * const name, struct vxfs_direct *de) | 83 | vxfs_match(int len, const char * const name, struct vxfs_direct *de) |
84 | { | 84 | { |
85 | if (len != de->d_namelen) | 85 | if (len != de->d_namelen) |
@@ -89,7 +89,7 @@ vxfs_match(int len, const char * const name, struct vxfs_direct *de) | |||
89 | return !memcmp(name, de->d_name, len); | 89 | return !memcmp(name, de->d_name, len); |
90 | } | 90 | } |
91 | 91 | ||
92 | static __inline__ struct vxfs_direct * | 92 | static inline struct vxfs_direct * |
93 | vxfs_next_entry(struct vxfs_direct *de) | 93 | vxfs_next_entry(struct vxfs_direct *de) |
94 | { | 94 | { |
95 | return ((struct vxfs_direct *)((char*)de + de->d_reclen)); | 95 | return ((struct vxfs_direct *)((char*)de + de->d_reclen)); |
diff --git a/fs/freevxfs/vxfs_olt.c b/fs/freevxfs/vxfs_olt.c index 7a204e31aad9..133476201d84 100644 --- a/fs/freevxfs/vxfs_olt.c +++ b/fs/freevxfs/vxfs_olt.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include "vxfs_olt.h" | 38 | #include "vxfs_olt.h" |
39 | 39 | ||
40 | 40 | ||
41 | static __inline__ void | 41 | static inline void |
42 | vxfs_get_fshead(struct vxfs_oltfshead *fshp, struct vxfs_sb_info *infp) | 42 | vxfs_get_fshead(struct vxfs_oltfshead *fshp, struct vxfs_sb_info *infp) |
43 | { | 43 | { |
44 | if (infp->vsi_fshino) | 44 | if (infp->vsi_fshino) |
@@ -46,7 +46,7 @@ vxfs_get_fshead(struct vxfs_oltfshead *fshp, struct vxfs_sb_info *infp) | |||
46 | infp->vsi_fshino = fshp->olt_fsino[0]; | 46 | infp->vsi_fshino = fshp->olt_fsino[0]; |
47 | } | 47 | } |
48 | 48 | ||
49 | static __inline__ void | 49 | static inline void |
50 | vxfs_get_ilist(struct vxfs_oltilist *ilistp, struct vxfs_sb_info *infp) | 50 | vxfs_get_ilist(struct vxfs_oltilist *ilistp, struct vxfs_sb_info *infp) |
51 | { | 51 | { |
52 | if (infp->vsi_iext) | 52 | if (infp->vsi_iext) |
@@ -54,7 +54,7 @@ vxfs_get_ilist(struct vxfs_oltilist *ilistp, struct vxfs_sb_info *infp) | |||
54 | infp->vsi_iext = ilistp->olt_iext[0]; | 54 | infp->vsi_iext = ilistp->olt_iext[0]; |
55 | } | 55 | } |
56 | 56 | ||
57 | static __inline__ u_long | 57 | static inline u_long |
58 | vxfs_oblock(struct super_block *sbp, daddr_t block, u_long bsize) | 58 | vxfs_oblock(struct super_block *sbp, daddr_t block, u_long bsize) |
59 | { | 59 | { |
60 | if (sbp->s_blocksize % bsize) | 60 | if (sbp->s_blocksize % bsize) |
@@ -104,8 +104,8 @@ vxfs_read_olt(struct super_block *sbp, u_long bsize) | |||
104 | goto fail; | 104 | goto fail; |
105 | } | 105 | } |
106 | 106 | ||
107 | oaddr = (char *)bp->b_data + op->olt_size; | 107 | oaddr = bp->b_data + op->olt_size; |
108 | eaddr = (char *)bp->b_data + (infp->vsi_oltsize * sbp->s_blocksize); | 108 | eaddr = bp->b_data + (infp->vsi_oltsize * sbp->s_blocksize); |
109 | 109 | ||
110 | while (oaddr < eaddr) { | 110 | while (oaddr < eaddr) { |
111 | struct vxfs_oltcommon *ocp = | 111 | struct vxfs_oltcommon *ocp = |
diff --git a/fs/freevxfs/vxfs_subr.c b/fs/freevxfs/vxfs_subr.c index 5e305612054a..50aae77651b2 100644 --- a/fs/freevxfs/vxfs_subr.c +++ b/fs/freevxfs/vxfs_subr.c | |||
@@ -36,7 +36,6 @@ | |||
36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
37 | #include <linux/pagemap.h> | 37 | #include <linux/pagemap.h> |
38 | 38 | ||
39 | #include "vxfs_kcompat.h" | ||
40 | #include "vxfs_extern.h" | 39 | #include "vxfs_extern.h" |
41 | 40 | ||
42 | 41 | ||
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c index 0ae2c7b8182a..27f66d3e8a04 100644 --- a/fs/freevxfs/vxfs_super.c +++ b/fs/freevxfs/vxfs_super.c | |||
@@ -155,12 +155,11 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) | |||
155 | 155 | ||
156 | sbp->s_flags |= MS_RDONLY; | 156 | sbp->s_flags |= MS_RDONLY; |
157 | 157 | ||
158 | infp = kmalloc(sizeof(*infp), GFP_KERNEL); | 158 | infp = kcalloc(1, sizeof(*infp), GFP_KERNEL); |
159 | if (!infp) { | 159 | if (!infp) { |
160 | printk(KERN_WARNING "vxfs: unable to allocate incore superblock\n"); | 160 | printk(KERN_WARNING "vxfs: unable to allocate incore superblock\n"); |
161 | return -ENOMEM; | 161 | return -ENOMEM; |
162 | } | 162 | } |
163 | memset(infp, 0, sizeof(*infp)); | ||
164 | 163 | ||
165 | bsize = sb_min_blocksize(sbp, BLOCK_SIZE); | 164 | bsize = sb_min_blocksize(sbp, BLOCK_SIZE); |
166 | if (!bsize) { | 165 | if (!bsize) { |
@@ -196,7 +195,7 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) | |||
196 | #endif | 195 | #endif |
197 | 196 | ||
198 | sbp->s_magic = rsbp->vs_magic; | 197 | sbp->s_magic = rsbp->vs_magic; |
199 | sbp->s_fs_info = (void *)infp; | 198 | sbp->s_fs_info = infp; |
200 | 199 | ||
201 | infp->vsi_raw = rsbp; | 200 | infp->vsi_raw = rsbp; |
202 | infp->vsi_bp = bp; | 201 | infp->vsi_bp = bp; |
@@ -263,7 +262,7 @@ vxfs_init(void) | |||
263 | sizeof(struct vxfs_inode_info), 0, | 262 | sizeof(struct vxfs_inode_info), 0, |
264 | SLAB_RECLAIM_ACCOUNT, NULL, NULL); | 263 | SLAB_RECLAIM_ACCOUNT, NULL, NULL); |
265 | if (vxfs_inode_cachep) | 264 | if (vxfs_inode_cachep) |
266 | return (register_filesystem(&vxfs_fs_type)); | 265 | return register_filesystem(&vxfs_fs_type); |
267 | return -ENOMEM; | 266 | return -ENOMEM; |
268 | } | 267 | } |
269 | 268 | ||
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index d50a5cd860ce..4b80ab95d338 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c | |||
@@ -1053,10 +1053,9 @@ static void handle_barrier_mode(struct super_block *s, unsigned long bits) { | |||
1053 | 1053 | ||
1054 | static void handle_attrs( struct super_block *s ) | 1054 | static void handle_attrs( struct super_block *s ) |
1055 | { | 1055 | { |
1056 | struct reiserfs_super_block * rs; | 1056 | struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (s); |
1057 | 1057 | ||
1058 | if( reiserfs_attrs( s ) ) { | 1058 | if( reiserfs_attrs( s ) ) { |
1059 | rs = SB_DISK_SUPER_BLOCK (s); | ||
1060 | if( old_format_only(s) ) { | 1059 | if( old_format_only(s) ) { |
1061 | reiserfs_warning(s, "reiserfs: cannot support attributes on 3.5.x disk format" ); | 1060 | reiserfs_warning(s, "reiserfs: cannot support attributes on 3.5.x disk format" ); |
1062 | REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS ); | 1061 | REISERFS_SB(s) -> s_mount_opt &= ~ ( 1 << REISERFS_ATTRS ); |
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 4673157b262f..ac191ed7df0a 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -164,11 +164,7 @@ udf_find_entry(struct inode *dir, struct dentry *dentry, | |||
164 | uint32_t extoffset, elen, offset; | 164 | uint32_t extoffset, elen, offset; |
165 | struct buffer_head *bh = NULL; | 165 | struct buffer_head *bh = NULL; |
166 | 166 | ||
167 | if (!dir) | ||
168 | return NULL; | ||
169 | |||
170 | size = (udf_ext0_offset(dir) + dir->i_size) >> 2; | 167 | size = (udf_ext0_offset(dir) + dir->i_size) >> 2; |
171 | |||
172 | f_pos = (udf_ext0_offset(dir) >> 2); | 168 | f_pos = (udf_ext0_offset(dir) >> 2); |
173 | 169 | ||
174 | fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; | 170 | fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; |
diff --git a/include/asm-i386/i8253.h b/include/asm-i386/i8253.h new file mode 100644 index 000000000000..015d8df07690 --- /dev/null +++ b/include/asm-i386/i8253.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_I8253_H__ | ||
2 | #define __ASM_I8253_H__ | ||
3 | |||
4 | extern spinlock_t i8253_lock; | ||
5 | |||
6 | #endif /* __ASM_I8253_H__ */ | ||
diff --git a/include/asm-i386/mach-default/do_timer.h b/include/asm-i386/mach-default/do_timer.h index 03dd13a48a8c..56211414fc95 100644 --- a/include/asm-i386/mach-default/do_timer.h +++ b/include/asm-i386/mach-default/do_timer.h | |||
@@ -1,6 +1,7 @@ | |||
1 | /* defines for inline arch setup functions */ | 1 | /* defines for inline arch setup functions */ |
2 | 2 | ||
3 | #include <asm/apic.h> | 3 | #include <asm/apic.h> |
4 | #include <asm/i8259.h> | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * do_timer_interrupt_hook - hook into timer tick | 7 | * do_timer_interrupt_hook - hook into timer tick |
diff --git a/include/asm-ppc64/iSeries/ItLpQueue.h b/include/asm-ppc64/iSeries/ItLpQueue.h index 393299e04d7f..69b26ad74135 100644 --- a/include/asm-ppc64/iSeries/ItLpQueue.h +++ b/include/asm-ppc64/iSeries/ItLpQueue.h | |||
@@ -41,7 +41,7 @@ struct HvLpEvent; | |||
41 | #define LpEventMaxSize 256 | 41 | #define LpEventMaxSize 256 |
42 | #define LpEventAlign 64 | 42 | #define LpEventAlign 64 |
43 | 43 | ||
44 | struct ItLpQueue { | 44 | struct hvlpevent_queue { |
45 | /* | 45 | /* |
46 | * The xSlicCurEventPtr is the pointer to the next event stack entry | 46 | * The xSlicCurEventPtr is the pointer to the next event stack entry |
47 | * that will become valid. The OS must peek at this entry to determine | 47 | * that will become valid. The OS must peek at this entry to determine |
@@ -69,16 +69,13 @@ struct ItLpQueue { | |||
69 | char *xSlicEventStackPtr; // 0x20 | 69 | char *xSlicEventStackPtr; // 0x20 |
70 | u8 xIndex; // 0x28 unique sequential index. | 70 | u8 xIndex; // 0x28 unique sequential index. |
71 | u8 xSlicRsvd[3]; // 0x29-2b | 71 | u8 xSlicRsvd[3]; // 0x29-2b |
72 | u32 xInUseWord; // 0x2C | 72 | spinlock_t lock; |
73 | u64 xLpIntCount; // 0x30 Total Lp Int msgs processed | ||
74 | u64 xLpIntCountByType[9]; // 0x38-0x7F Event counts by type | ||
75 | }; | 73 | }; |
76 | 74 | ||
77 | extern struct ItLpQueue xItLpQueue; | 75 | extern struct hvlpevent_queue hvlpevent_queue; |
78 | 76 | ||
79 | extern struct HvLpEvent *ItLpQueue_getNextLpEvent(struct ItLpQueue *); | 77 | extern int hvlpevent_is_pending(void); |
80 | extern int ItLpQueue_isLpIntPending(struct ItLpQueue *); | 78 | extern void process_hvlpevents(struct pt_regs *); |
81 | extern unsigned ItLpQueue_process(struct ItLpQueue *, struct pt_regs *); | 79 | extern void setup_hvlpevent_queue(void); |
82 | extern void ItLpQueue_clearValid(struct HvLpEvent *); | ||
83 | 80 | ||
84 | #endif /* _ITLPQUEUE_H */ | 81 | #endif /* _ITLPQUEUE_H */ |
diff --git a/include/asm-ppc64/paca.h b/include/asm-ppc64/paca.h index ae76cae1483f..2f0f36f73d38 100644 --- a/include/asm-ppc64/paca.h +++ b/include/asm-ppc64/paca.h | |||
@@ -20,7 +20,6 @@ | |||
20 | #include <asm/types.h> | 20 | #include <asm/types.h> |
21 | #include <asm/lppaca.h> | 21 | #include <asm/lppaca.h> |
22 | #include <asm/iSeries/ItLpRegSave.h> | 22 | #include <asm/iSeries/ItLpRegSave.h> |
23 | #include <asm/iSeries/ItLpQueue.h> | ||
24 | #include <asm/mmu.h> | 23 | #include <asm/mmu.h> |
25 | 24 | ||
26 | register struct paca_struct *local_paca asm("r13"); | 25 | register struct paca_struct *local_paca asm("r13"); |
@@ -62,7 +61,6 @@ struct paca_struct { | |||
62 | u16 paca_index; /* Logical processor number */ | 61 | u16 paca_index; /* Logical processor number */ |
63 | 62 | ||
64 | u32 default_decr; /* Default decrementer value */ | 63 | u32 default_decr; /* Default decrementer value */ |
65 | struct ItLpQueue *lpqueue_ptr; /* LpQueue handled by this CPU */ | ||
66 | u64 kernel_toc; /* Kernel TOC address */ | 64 | u64 kernel_toc; /* Kernel TOC address */ |
67 | u64 stab_real; /* Absolute address of segment table */ | 65 | u64 stab_real; /* Absolute address of segment table */ |
68 | u64 stab_addr; /* Virtual address of segment table */ | 66 | u64 stab_addr; /* Virtual address of segment table */ |
@@ -91,7 +89,6 @@ struct paca_struct { | |||
91 | u64 next_jiffy_update_tb; /* TB value for next jiffy update */ | 89 | u64 next_jiffy_update_tb; /* TB value for next jiffy update */ |
92 | u64 saved_r1; /* r1 save for RTAS calls */ | 90 | u64 saved_r1; /* r1 save for RTAS calls */ |
93 | u64 saved_msr; /* MSR saved here by enter_rtas */ | 91 | u64 saved_msr; /* MSR saved here by enter_rtas */ |
94 | u32 lpevent_count; /* lpevents processed */ | ||
95 | u8 proc_enabled; /* irq soft-enable flag */ | 92 | u8 proc_enabled; /* irq soft-enable flag */ |
96 | 93 | ||
97 | /* not yet used */ | 94 | /* not yet used */ |
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h index b4a9f05a93d6..864cae7e1fd6 100644 --- a/include/asm-s390/system.h +++ b/include/asm-s390/system.h | |||
@@ -107,11 +107,9 @@ static inline void restore_access_regs(unsigned int *acrs) | |||
107 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING | 107 | #ifdef CONFIG_VIRT_CPU_ACCOUNTING |
108 | extern void account_user_vtime(struct task_struct *); | 108 | extern void account_user_vtime(struct task_struct *); |
109 | extern void account_system_vtime(struct task_struct *); | 109 | extern void account_system_vtime(struct task_struct *); |
110 | #else | ||
111 | #define account_system_vtime(prev) do { } while (0) | ||
112 | #endif | 110 | #endif |
113 | 111 | ||
114 | #define finish_arch_switch(rq, prev) do { \ | 112 | #define finish_arch_switch(prev) do { \ |
115 | set_fs(current->thread.mm_segment); \ | 113 | set_fs(current->thread.mm_segment); \ |
116 | account_system_vtime(prev); \ | 114 | account_system_vtime(prev); \ |
117 | } while (0) | 115 | } while (0) |
diff --git a/include/asm-x86_64/io_apic.h b/include/asm-x86_64/io_apic.h index 32573749004c..a8babd2bbe84 100644 --- a/include/asm-x86_64/io_apic.h +++ b/include/asm-x86_64/io_apic.h | |||
@@ -217,4 +217,6 @@ extern int assign_irq_vector(int irq); | |||
217 | 217 | ||
218 | void enable_NMI_through_LVT0 (void * dummy); | 218 | void enable_NMI_through_LVT0 (void * dummy); |
219 | 219 | ||
220 | extern spinlock_t i8259A_lock; | ||
221 | |||
220 | #endif | 222 | #endif |
diff --git a/include/asm-xtensa/delay.h b/include/asm-xtensa/delay.h index 6359c55e77a8..0a123d53a636 100644 --- a/include/asm-xtensa/delay.h +++ b/include/asm-xtensa/delay.h | |||
@@ -21,7 +21,7 @@ extern unsigned long loops_per_jiffy; | |||
21 | extern __inline__ void __delay(unsigned long loops) | 21 | extern __inline__ void __delay(unsigned long loops) |
22 | { | 22 | { |
23 | /* 2 cycles per loop. */ | 23 | /* 2 cycles per loop. */ |
24 | __asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 1, 1b" | 24 | __asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 2, 1b" |
25 | : "=r" (loops) : "0" (loops)); | 25 | : "=r" (loops) : "0" (loops)); |
26 | } | 26 | } |
27 | 27 | ||
diff --git a/include/asm-xtensa/errno.h b/include/asm-xtensa/errno.h index ced5194d2750..a0f3b96b79b4 100644 --- a/include/asm-xtensa/errno.h +++ b/include/asm-xtensa/errno.h | |||
@@ -11,132 +11,6 @@ | |||
11 | #ifndef _XTENSA_ERRNO_H | 11 | #ifndef _XTENSA_ERRNO_H |
12 | #define _XTENSA_ERRNO_H | 12 | #define _XTENSA_ERRNO_H |
13 | 13 | ||
14 | #define EPERM 1 /* Operation not permitted */ | 14 | #include <asm-generic/errno.h> |
15 | #define ENOENT 2 /* No such file or directory */ | ||
16 | #define ESRCH 3 /* No such process */ | ||
17 | #define EINTR 4 /* Interrupted system call */ | ||
18 | #define EIO 5 /* I/O error */ | ||
19 | #define ENXIO 6 /* No such device or address */ | ||
20 | #define E2BIG 7 /* Arg list too long */ | ||
21 | #define ENOEXEC 8 /* Exec format error */ | ||
22 | #define EBADF 9 /* Bad file number */ | ||
23 | #define ECHILD 10 /* No child processes */ | ||
24 | #define EAGAIN 11 /* Try again */ | ||
25 | #define ENOMEM 12 /* Out of memory */ | ||
26 | #define EACCES 13 /* Permission denied */ | ||
27 | #define EFAULT 14 /* Bad address */ | ||
28 | #define ENOTBLK 15 /* Block device required */ | ||
29 | #define EBUSY 16 /* Device or resource busy */ | ||
30 | #define EEXIST 17 /* File exists */ | ||
31 | #define EXDEV 18 /* Cross-device link */ | ||
32 | #define ENODEV 19 /* No such device */ | ||
33 | #define ENOTDIR 20 /* Not a directory */ | ||
34 | #define EISDIR 21 /* Is a directory */ | ||
35 | #define EINVAL 22 /* Invalid argument */ | ||
36 | #define ENFILE 23 /* File table overflow */ | ||
37 | #define EMFILE 24 /* Too many open files */ | ||
38 | #define ENOTTY 25 /* Not a typewriter */ | ||
39 | #define ETXTBSY 26 /* Text file busy */ | ||
40 | #define EFBIG 27 /* File too large */ | ||
41 | #define ENOSPC 28 /* No space left on device */ | ||
42 | #define ESPIPE 29 /* Illegal seek */ | ||
43 | #define EROFS 30 /* Read-only file system */ | ||
44 | #define EMLINK 31 /* Too many links */ | ||
45 | #define EPIPE 32 /* Broken pipe */ | ||
46 | #define EDOM 33 /* Math argument out of domain of func */ | ||
47 | #define ERANGE 34 /* Math result not representable */ | ||
48 | #define EDEADLK 35 /* Resource deadlock would occur */ | ||
49 | #define ENAMETOOLONG 36 /* File name too long */ | ||
50 | #define ENOLCK 37 /* No record locks available */ | ||
51 | #define ENOSYS 38 /* Function not implemented */ | ||
52 | #define ENOTEMPTY 39 /* Directory not empty */ | ||
53 | #define ELOOP 40 /* Too many symbolic links encountered */ | ||
54 | #define EWOULDBLOCK EAGAIN /* Operation would block */ | ||
55 | #define ENOMSG 42 /* No message of desired type */ | ||
56 | #define EIDRM 43 /* Identifier removed */ | ||
57 | #define ECHRNG 44 /* Channel number out of range */ | ||
58 | #define EL2NSYNC 45 /* Level 2 not synchronized */ | ||
59 | #define EL3HLT 46 /* Level 3 halted */ | ||
60 | #define EL3RST 47 /* Level 3 reset */ | ||
61 | #define ELNRNG 48 /* Link number out of range */ | ||
62 | #define EUNATCH 49 /* Protocol driver not attached */ | ||
63 | #define ENOCSI 50 /* No CSI structure available */ | ||
64 | #define EL2HLT 51 /* Level 2 halted */ | ||
65 | #define EBADE 52 /* Invalid exchange */ | ||
66 | #define EBADR 53 /* Invalid request descriptor */ | ||
67 | #define EXFULL 54 /* Exchange full */ | ||
68 | #define ENOANO 55 /* No anode */ | ||
69 | #define EBADRQC 56 /* Invalid request code */ | ||
70 | #define EBADSLT 57 /* Invalid slot */ | ||
71 | |||
72 | #define EDEADLOCK EDEADLK | ||
73 | |||
74 | #define EBFONT 59 /* Bad font file format */ | ||
75 | #define ENOSTR 60 /* Device not a stream */ | ||
76 | #define ENODATA 61 /* No data available */ | ||
77 | #define ETIME 62 /* Timer expired */ | ||
78 | #define ENOSR 63 /* Out of streams resources */ | ||
79 | #define ENONET 64 /* Machine is not on the network */ | ||
80 | #define ENOPKG 65 /* Package not installed */ | ||
81 | #define EREMOTE 66 /* Object is remote */ | ||
82 | #define ENOLINK 67 /* Link has been severed */ | ||
83 | #define EADV 68 /* Advertise error */ | ||
84 | #define ESRMNT 69 /* Srmount error */ | ||
85 | #define ECOMM 70 /* Communication error on send */ | ||
86 | #define EPROTO 71 /* Protocol error */ | ||
87 | #define EMULTIHOP 72 /* Multihop attempted */ | ||
88 | #define EDOTDOT 73 /* RFS specific error */ | ||
89 | #define EBADMSG 74 /* Not a data message */ | ||
90 | #define EOVERFLOW 75 /* Value too large for defined data type */ | ||
91 | #define ENOTUNIQ 76 /* Name not unique on network */ | ||
92 | #define EBADFD 77 /* File descriptor in bad state */ | ||
93 | #define EREMCHG 78 /* Remote address changed */ | ||
94 | #define ELIBACC 79 /* Can not access a needed shared library */ | ||
95 | #define ELIBBAD 80 /* Accessing a corrupted shared library */ | ||
96 | #define ELIBSCN 81 /* .lib section in a.out corrupted */ | ||
97 | #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ | ||
98 | #define ELIBEXEC 83 /* Cannot exec a shared library directly */ | ||
99 | #define EILSEQ 84 /* Illegal byte sequence */ | ||
100 | #define ERESTART 85 /* Interrupted system call should be restarted */ | ||
101 | #define ESTRPIPE 86 /* Streams pipe error */ | ||
102 | #define EUSERS 87 /* Too many users */ | ||
103 | #define ENOTSOCK 88 /* Socket operation on non-socket */ | ||
104 | #define EDESTADDRREQ 89 /* Destination address required */ | ||
105 | #define EMSGSIZE 90 /* Message too long */ | ||
106 | #define EPROTOTYPE 91 /* Protocol wrong type for socket */ | ||
107 | #define ENOPROTOOPT 92 /* Protocol not available */ | ||
108 | #define EPROTONOSUPPORT 93 /* Protocol not supported */ | ||
109 | #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ | ||
110 | #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ | ||
111 | #define EPFNOSUPPORT 96 /* Protocol family not supported */ | ||
112 | #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ | ||
113 | #define EADDRINUSE 98 /* Address already in use */ | ||
114 | #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ | ||
115 | #define ENETDOWN 100 /* Network is down */ | ||
116 | #define ENETUNREACH 101 /* Network is unreachable */ | ||
117 | #define ENETRESET 102 /* Network dropped connection because of reset */ | ||
118 | #define ECONNABORTED 103 /* Software caused connection abort */ | ||
119 | #define ECONNRESET 104 /* Connection reset by peer */ | ||
120 | #define ENOBUFS 105 /* No buffer space available */ | ||
121 | #define EISCONN 106 /* Transport endpoint is already connected */ | ||
122 | #define ENOTCONN 107 /* Transport endpoint is not connected */ | ||
123 | #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ | ||
124 | #define ETOOMANYREFS 109 /* Too many references: cannot splice */ | ||
125 | #define ETIMEDOUT 110 /* Connection timed out */ | ||
126 | #define ECONNREFUSED 111 /* Connection refused */ | ||
127 | #define EHOSTDOWN 112 /* Host is down */ | ||
128 | #define EHOSTUNREACH 113 /* No route to host */ | ||
129 | #define EALREADY 114 /* Operation already in progress */ | ||
130 | #define EINPROGRESS 115 /* Operation now in progress */ | ||
131 | #define ESTALE 116 /* Stale NFS file handle */ | ||
132 | #define EUCLEAN 117 /* Structure needs cleaning */ | ||
133 | #define ENOTNAM 118 /* Not a XENIX named type file */ | ||
134 | #define ENAVAIL 119 /* No XENIX semaphores available */ | ||
135 | #define EISNAM 120 /* Is a named type file */ | ||
136 | #define EREMOTEIO 121 /* Remote I/O error */ | ||
137 | #define EDQUOT 122 /* Quota exceeded */ | ||
138 | |||
139 | #define ENOMEDIUM 123 /* No medium found */ | ||
140 | #define EMEDIUMTYPE 124 /* Wrong medium type */ | ||
141 | 15 | ||
142 | #endif /* _XTENSA_ERRNO_H */ | 16 | #endif /* _XTENSA_ERRNO_H */ |
diff --git a/include/asm-xtensa/ipc.h b/include/asm-xtensa/ipc.h index d37bdb4d4c9c..a9eed4e21cb9 100644 --- a/include/asm-xtensa/ipc.h +++ b/include/asm-xtensa/ipc.h | |||
@@ -11,24 +11,6 @@ | |||
11 | #ifndef _XTENSA_IPC_H | 11 | #ifndef _XTENSA_IPC_H |
12 | #define _XTENSA_IPC_H | 12 | #define _XTENSA_IPC_H |
13 | 13 | ||
14 | struct ipc_kludge { | 14 | #include <asm-generic/ipc.h> |
15 | struct msgbuf __user *msgp; | ||
16 | long msgtyp; | ||
17 | }; | ||
18 | |||
19 | #define SEMOP 1 | ||
20 | #define SEMGET 2 | ||
21 | #define SEMCTL 3 | ||
22 | #define SEMTIMEDOP 4 | ||
23 | #define MSGSND 11 | ||
24 | #define MSGRCV 12 | ||
25 | #define MSGGET 13 | ||
26 | #define MSGCTL 14 | ||
27 | #define SHMAT 21 | ||
28 | #define SHMDT 22 | ||
29 | #define SHMGET 23 | ||
30 | #define SHMCTL 24 | ||
31 | |||
32 | #define IPCCALL(version,op) ((version)<<16 | (op)) | ||
33 | 15 | ||
34 | #endif /* _XTENSA_IPC_H */ | 16 | #endif /* _XTENSA_IPC_H */ |
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c index 4def882d0b31..a05cabd0fd10 100644 --- a/init/do_mounts_initrd.c +++ b/init/do_mounts_initrd.c | |||
@@ -86,7 +86,10 @@ static void __init handle_initrd(void) | |||
86 | printk("okay\n"); | 86 | printk("okay\n"); |
87 | else { | 87 | else { |
88 | int fd = sys_open("/dev/root.old", O_RDWR, 0); | 88 | int fd = sys_open("/dev/root.old", O_RDWR, 0); |
89 | printk("failed\n"); | 89 | if (error == -ENOENT) |
90 | printk("/initrd does not exist. Ignored.\n"); | ||
91 | else | ||
92 | printk("failed\n"); | ||
90 | printk(KERN_NOTICE "Unmounting old root\n"); | 93 | printk(KERN_NOTICE "Unmounting old root\n"); |
91 | sys_umount("/old", MNT_DETACH); | 94 | sys_umount("/old", MNT_DETACH); |
92 | printk(KERN_NOTICE "Trying to free ramdisk memory ... "); | 95 | printk(KERN_NOTICE "Trying to free ramdisk memory ... "); |
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 17a1189f1ff8..6be273851144 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -68,6 +68,7 @@ | |||
68 | #include <linux/personality.h> | 68 | #include <linux/personality.h> |
69 | #include <linux/sysctl.h> | 69 | #include <linux/sysctl.h> |
70 | #include <linux/audit.h> | 70 | #include <linux/audit.h> |
71 | #include <linux/string.h> | ||
71 | 72 | ||
72 | #include "avc.h" | 73 | #include "avc.h" |
73 | #include "objsec.h" | 74 | #include "objsec.h" |
@@ -1943,7 +1944,7 @@ static int selinux_sb_copy_data(struct file_system_type *type, void *orig, void | |||
1943 | } | 1944 | } |
1944 | } while (*in_end++); | 1945 | } while (*in_end++); |
1945 | 1946 | ||
1946 | copy_page(in_save, nosec_save); | 1947 | strcpy(in_save, nosec_save); |
1947 | free_page((unsigned long)nosec_save); | 1948 | free_page((unsigned long)nosec_save); |
1948 | out: | 1949 | out: |
1949 | return rc; | 1950 | return rc; |