diff options
| author | Linus Torvalds <torvalds@home.transmeta.com> | 2002-10-18 00:32:32 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.transmeta.com> | 2002-10-18 00:32:32 -0700 |
| commit | 367c46394099d2cd79ef899bc85337d158dcb5b5 (patch) | |
| tree | e85b9bc5c784a582c2fff3f7a16f7f0015c8978c /arch | |
| parent | a1bed4d5ff69bcf8fa484ad1ab5ba54a08b2593f (diff) | |
| parent | 3932252874162e2c7f7b87ba91f34155b67404a5 (diff) | |
Merge bk://linux-bt.bkbits.net/bt-2.5
into home.transmeta.com:/home/torvalds/v2.5/linux
Diffstat (limited to 'arch')
60 files changed, 1396 insertions, 924 deletions
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c index 4cb68c31b86e..2b291c31ff8b 100644 --- a/arch/arm/kernel/ecard.c +++ b/arch/arm/kernel/ecard.c @@ -1114,7 +1114,7 @@ int ecard_register_driver(struct ecard_driver *drv) void ecard_remove_driver(struct ecard_driver *drv) { - remove_driver(&drv->drv); + driver_unregister(&drv->drv); } static int ecard_match(struct device *_dev, struct device_driver *_drv) diff --git a/arch/i386/Makefile b/arch/i386/Makefile index 4df45365d6f0..dbd363bdb52f 100644 --- a/arch/i386/Makefile +++ b/arch/i386/Makefile @@ -88,6 +88,6 @@ install: vmlinux +@$(call makeboot,BOOTIMAGE=$(BOOTIMAGE) install) archclean: - +@$(call makeboot,clean) + +@$(call makeboot,subdirclean) archmrproper: diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile index 3369bfc67700..b06bab8ccd43 100644 --- a/arch/i386/boot/Makefile +++ b/arch/i386/boot/Makefile @@ -28,6 +28,8 @@ SVGA_MODE := -DSVGA_MODE=NORMAL_VGA EXTRA_TARGETS := vmlinux.bin bootsect bootsect.o \ setup setup.o zImage bzImage +subdir- := compressed + host-progs := tools/build # Default @@ -79,11 +81,6 @@ zlilo: $(BOOTIMAGE) install: $(BOOTIMAGE) sh $(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)" -clean: - @echo 'Cleaning up (boot)' - @rm -f $(host-progs) $(EXTRA_TARGETS) - +@$(call descend,$(obj)/compressed) clean - archhelp: @echo '* bzImage - Compressed kernel image (arch/$(ARCH)/boot/bzImage)' @echo ' install - Install kernel using' diff --git a/arch/i386/boot/compressed/Makefile b/arch/i386/boot/compressed/Makefile index 53af39a4408e..16383b2df2fb 100644 --- a/arch/i386/boot/compressed/Makefile +++ b/arch/i386/boot/compressed/Makefile @@ -24,7 +24,3 @@ LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE $(call if_changed,ld) - -clean: - @echo 'Cleaning up (boot/compressed)' - @rm -f $(EXTRA_TARGETS) diff --git a/arch/i386/config.in b/arch/i386/config.in index 1026d1a0a1f4..5777724de6f0 100644 --- a/arch/i386/config.in +++ b/arch/i386/config.in @@ -453,6 +453,7 @@ fi bool 'Kernel debugging' CONFIG_DEBUG_KERNEL if [ "$CONFIG_DEBUG_KERNEL" != "n" ]; then + bool ' Check for stack overflows' CONFIG_DEBUG_STACKOVERFLOW bool ' Debug memory allocations' CONFIG_DEBUG_SLAB bool ' Memory mapped I/O debugging' CONFIG_DEBUG_IOVIRT bool ' Magic SysRq key' CONFIG_MAGIC_SYSRQ diff --git a/arch/i386/kernel/bluesmoke.c b/arch/i386/kernel/bluesmoke.c index 5e5ef23f39b9..5941b9da5985 100644 --- a/arch/i386/kernel/bluesmoke.c +++ b/arch/i386/kernel/bluesmoke.c @@ -300,7 +300,6 @@ static void mce_checkregs (void *info) static void do_mce_timer(void *data) { - mce_checkregs(NULL); smp_call_function (mce_checkregs, NULL, 1, 1); } diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c index 3f95d0b1f189..df360f06616e 100644 --- a/arch/i386/kernel/cpu/amd.c +++ b/arch/i386/kernel/cpu/amd.c @@ -42,6 +42,21 @@ static void __init init_amd(struct cpuinfo_x86 *c) switch(c->x86) { + case 4: + /* + * General Systems BIOSen alias the cpu frequency registers + * of the Elan at 0x000df000. Unfortuantly, one of the Linux + * drivers subsequently pokes it, and changes the CPU speed. + * Workaround : Remove the unneeded alias. + */ +#define CBAR (0xfffc) /* Configuration Base Address (32-bit) */ +#define CBAR_ENB (0x80000000) +#define CBAR_KEY (0X000000CB) + if (c->x86_model==9 || c->x86_model == 10) { + if (inl (CBAR) & CBAR_ENB) + outl (0 | CBAR_KEY, CBAR); + } + case 5: if( c->x86_model < 6 ) { diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c index 5bc54a30c2f8..4bb71d80fb1f 100644 --- a/arch/i386/kernel/io_apic.c +++ b/arch/i386/kernel/io_apic.c @@ -856,7 +856,9 @@ void __init print_IO_APIC(void) printk(KERN_DEBUG "IO APIC #%d......\n", mp_ioapics[apic].mpc_apicid); printk(KERN_DEBUG ".... register #00: %08X\n", *(int *)®_00); printk(KERN_DEBUG "....... : physical APIC id: %02X\n", reg_00.ID); - if (reg_00.__reserved_1 || reg_00.__reserved_2) + printk(KERN_DEBUG "....... : Delivery Type: %X\n", reg_00.delivery_type); + printk(KERN_DEBUG "....... : LTS : %X\n", reg_00.LTS); + if (reg_00.__reserved_0 || reg_00.__reserved_1 || reg_00.__reserved_2) UNEXPECTED_IO_APIC(); printk(KERN_DEBUG ".... register #01: %08X\n", *(int *)®_01); diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c index 2ac7753a5f66..fdddbf524c01 100644 --- a/arch/i386/kernel/irq.c +++ b/arch/i386/kernel/irq.c @@ -328,8 +328,22 @@ asmlinkage unsigned int do_IRQ(struct pt_regs regs) irq_desc_t *desc = irq_desc + irq; struct irqaction * action; unsigned int status; + long esp; irq_enter(); + +#ifdef CONFIG_DEBUG_STACKOVERFLOW + /* Debugging check for stack overflow: is there less than 1KB free? */ + __asm__ __volatile__("andl %%esp,%0" : "=r" (esp) : "0" (8191)); + if (unlikely(esp < (sizeof(struct task_struct) + 1024))) { + extern void show_stack(unsigned long *); + + printk("do_IRQ: stack overflow: %ld\n", + esp - sizeof(struct task_struct)); + __asm__ __volatile__("movl %%esp,%0" : "=r" (esp)); + show_stack((void *)esp); + } +#endif kstat.irqs[cpu][irq]++; spin_lock(&desc->lock); desc->handler->ack(irq); diff --git a/arch/i386/kernel/microcode.c b/arch/i386/kernel/microcode.c index ccdebea64733..58201846cf7c 100644 --- a/arch/i386/kernel/microcode.c +++ b/arch/i386/kernel/microcode.c @@ -260,7 +260,7 @@ static void do_update_one(void *unused) if (microcode[i].rev < rev) { spin_unlock_irqrestore(µcode_update_lock, flags); - printk(KERN_ERR + printk(KERN_INFO "microcode: CPU%d not 'upgrading' to earlier revision" " %d (current=%d)\n", cpu_num, microcode[i].rev, rev); return; @@ -268,7 +268,7 @@ static void do_update_one(void *unused) /* notify the caller of success on this cpu */ req->err = 0; spin_unlock_irqrestore(µcode_update_lock, flags); - printk(KERN_ERR + printk(KERN_INFO "microcode: CPU%d already at revision" " %d (current=%d)\n", cpu_num, microcode[i].rev, rev); return; diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c index 5218fd2ea29a..ca8a9d54f116 100644 --- a/arch/i386/mm/init.c +++ b/arch/i386/mm/init.c @@ -482,7 +482,7 @@ void __init mem_init(void) datasize = (unsigned long) &_edata - (unsigned long) &_etext; initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; - printk("Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, %dk init, %ldk highmem)\n", + printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, %dk init, %ldk highmem)\n", (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), num_physpages << (PAGE_SHIFT-10), codesize >> 10, @@ -584,14 +584,14 @@ void free_initmem(void) free_page(addr); totalram_pages++; } - printk ("Freeing unused kernel memory: %dk freed\n", (&__init_end - &__init_begin) >> 10); + printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", (&__init_end - &__init_begin) >> 10); } #ifdef CONFIG_BLK_DEV_INITRD void free_initrd_mem(unsigned long start, unsigned long end) { if (start < end) - printk ("Freeing initrd memory: %ldk freed\n", (end - start) >> 10); + printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10); for (; start < end; start += PAGE_SIZE) { ClearPageReserved(virt_to_page(start)); set_page_count(virt_to_page(start), 1); diff --git a/arch/i386/pci/i386.c b/arch/i386/pci/i386.c index db71a8c73b5b..9cfc595855de 100644 --- a/arch/i386/pci/i386.c +++ b/arch/i386/pci/i386.c @@ -291,7 +291,7 @@ void pcibios_set_master(struct pci_dev *dev) lat = pcibios_max_latency; else return; - printk("PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat); + printk(KERN_DEBUG "PCI: Setting latency timer of device %s to %d\n", dev->slot_name, lat); pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat); } diff --git a/arch/i386/vmlinux.lds.S b/arch/i386/vmlinux.lds.S index 41e54abb9b5a..99301e99ae50 100644 --- a/arch/i386/vmlinux.lds.S +++ b/arch/i386/vmlinux.lds.S @@ -8,6 +8,7 @@ jiffies = jiffies_64; SECTIONS { . = 0xC0000000 + 0x100000; + /* read-only */ _text = .; /* Text and read-only data */ .text : { *(.text) @@ -29,16 +30,34 @@ SECTIONS __ksymtab : { *(__ksymtab) } __stop___ksymtab = .; + __start___kallsyms = .; /* All kernel symbols */ + __kallsyms : { *(__kallsyms) } + __stop___kallsyms = .; + + /* writeable */ .data : { /* Data */ *(.data) CONSTRUCTORS } + . = ALIGN(4096); + __nosave_begin = .; + .data_nosave : { *(.data.nosave) } + . = ALIGN(4096); + __nosave_end = .; + + . = ALIGN(4096); + .data.page_aligned : { *(.data.idt) } + + . = ALIGN(32); + .data.cacheline_aligned : { *(.data.cacheline_aligned) } + _edata = .; /* End of data section */ . = ALIGN(8192); /* init_task */ .data.init_task : { *(.data.init_task) } + /* will be freed after init */ . = ALIGN(4096); /* Init code and data */ __init_begin = .; .init.text : { *(.init.text) } @@ -64,23 +83,8 @@ SECTIONS __per_cpu_end = .; . = ALIGN(4096); __init_end = .; - - . = ALIGN(4096); - __nosave_begin = .; - .data_nosave : { *(.data.nosave) } - . = ALIGN(4096); - __nosave_end = .; - - . = ALIGN(4096); - .data.page_aligned : { *(.data.idt) } - - . = ALIGN(32); - .data.cacheline_aligned : { *(.data.cacheline_aligned) } - - __start___kallsyms = .; /* All kernel symbols */ - __kallsyms : { *(__kallsyms) } - __stop___kallsyms = .; - + /* freed after init ends here */ + __bss_start = .; /* BSS */ .bss : { *(.bss) } __bss_stop = .; diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c index c430e823ef08..5fa3e289b581 100644 --- a/arch/ia64/ia32/sys_ia32.c +++ b/arch/ia64/ia32/sys_ia32.c @@ -3763,12 +3763,15 @@ do_smb_super_data_conv(void *raw_data) struct smb_mount_data *s = (struct smb_mount_data *)raw_data; struct smb_mount_data32 *s32 = (struct smb_mount_data32 *)raw_data; + if (s32->version != SMB_MOUNT_OLDVERSION) + goto out; s->version = s32->version; s->mounted_uid = s32->mounted_uid; s->uid = s32->uid; s->gid = s32->gid; s->file_mode = s32->file_mode; s->dir_mode = s32->dir_mode; +out: return raw_data; } diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile index 8fc59afbc307..75467652ef37 100644 --- a/arch/ppc/Makefile +++ b/arch/ppc/Makefile @@ -64,7 +64,7 @@ drivers-$(CONFIG_8xx) += arch/ppc/8xx_io/ drivers-$(CONFIG_4xx) += arch/ppc/4xx_io/ drivers-$(CONFIG_8260) += arch/ppc/8260_io/ -MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot +makeboot = $(call descend,arch/ppc/boot,$(1)) BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd pImage vmlinux.sm @@ -74,14 +74,14 @@ AFLAGS_vmlinux.lds.o := -Upowerpc bzImage: zImage $(BOOT_TARGETS): vmlinux - @$(MAKEBOOT) $@ + +@$(call makeboot,$@) %_config: arch/ppc/configs/%_defconfig rm -f .config arch/ppc/defconfig cp -f arch/ppc/configs/$(@:config=defconfig) .config archclean: - @$(MAKEBOOT) clean + +@$(call makeboot,clean) archmrproper: diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile index 7fc8e3dac69e..a6a312b7ba26 100644 --- a/arch/ppc/boot/Makefile +++ b/arch/ppc/boot/Makefile @@ -10,25 +10,16 @@ # modified by Cort (cort@cs.nmt.edu) # -GZIP_FLAGS = -v9f - CFLAGS += -fno-builtin -D__BOOTER__ -I$(TOPDIR)/arch/$(ARCH)/boot/include AFLAGS += -D__BOOTER__ OBJCOPY_ARGS = -O elf32-powerpc -MKIMAGE := ./utils/mkimage.wrapper - -lib/lib.a: lib/zlib.c - $(MAKE) -C lib +subdir-y := simple +subdir-$(CONFIG_ALL_PPC) := openfirmware prep -images/vmlinux.gz: $(TOPDIR)/vmlinux - $(MAKE) -C images vmlinux.gz +HOSTCFLAGS += -Iarch/$(ARCH)/boot/include -# Subdirs and tools needed for each. Assume we always need to go into -# 'simple' unless told otherwise. -subdir-y := lib common simple -subdir-$(CONFIG_ALL_PPC) := openfirmware prep tools-$(CONFIG_ALL_PPC) := addnote mknote hack-coff mkprep tools-$(CONFIG_PPLUS) := mkbugboot mkprep tools-$(CONFIG_4xx) := mktree @@ -40,49 +31,24 @@ tools-$(CONFIG_PRPMC750) := mkbugboot mkprep tools-$(CONFIG_PRPMC800) := mkbugboot mkprep tools-$(CONFIG_SPRUCE) := mktree -# These are dirs we don't want to go into on BOOT_TARGETS. We have them for -# the 'depend' stage. -NONBOOT := lib common +all-tools := addnote mknote hack-coff mkprep mkbugboot mktree -# These are the subdirs we want to use -BOOTDIRS = $(filter-out $(NONBOOT), $(subdir-y)) +host-progs := $(addprefix utils/,$(tools-y)) -makeof1275: - $(MAKE) -C of1275 - -# This will make the tools we need. We do it like this to ensure that we use -# HOSTCC. -- Tom -maketools: - $(MAKE) -C utils $(tools-y) - -# The targets all boards support for boot images. -BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd +include $(TOPDIR)/Rules.make -$(BOOT_TARGETS): vmapus lib/lib.a images/vmlinux.gz makeof1275 maketools -ifneq ($(BOOTDIRS),) - for d in $(BOOTDIRS); do $(MAKE) -C $$d $@; done -endif +zImage zImage.initrd znetboot znetboot.initrd: $(subdir-y) -vmapus: $(TOPDIR)/vmlinux -ifdef CONFIG_APUS - $(STRIP) $(TOPDIR)/vmlinux -o images/vmapus - gzip $(GZIP_FLAGS) images/vmapus -endif +simple openfirmware prep: lib common images +openfirmware prep: of1275 -# Make an image for PPCBoot -pImage: images/vmlinux.gz - $(MKIMAGE) -A ppc -O linux -T kernel -C gzip -a 00000000 -e 00000000 \ - -n 'Linux-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)' \ - -d $< images/vmlinux.PPCBoot - ln -sf vmlinux.PPCBoot images/pImage +lib common of1275 images: FORCE + +@$(call descend,$(obj)/$@,) -vmlinux.sm: $(TOPDIR)/vmlinux utils/addSystemMap - ./utils/addSystemMap $(TOPDIR)/System.map $(TOPDIR)/vmlinux images/vmlinux.sm +openfirmware prep simple: FORCE + +@$(call descend,$(obj)/$@,$(MAKECMDGOALS)) -# These are subdirs with files not normally rm'ed. -- Tom -clean: - $(MAKE) -C images clean - $(MAKE) -C utils clean - $(MAKE) -C openfirmware clean +CLEAN_FILES += $(addprefix $(obj)/utils,$(all-tools)) -include $(TOPDIR)/Rules.make +clean: FORCE + +@$(call descend,$(obj)/images,clean) diff --git a/arch/ppc/boot/common/Makefile b/arch/ppc/boot/common/Makefile index 5295d53bb8a8..0b882179eef6 100644 --- a/arch/ppc/boot/common/Makefile +++ b/arch/ppc/boot/common/Makefile @@ -8,7 +8,12 @@ # Tom Rini January 2001 # -coffcrt0.o: - $(CC) $(AFLAGS) -DXCOFF -traditional -c -o coffcrt0.o crt0.S +L_TARGET := lib.a + +obj-y := string.o util.o misc-common.o +obj-$(CONFIG_ALL_PPC) += mpc10x_memory.o +obj-$(CONFIG_LOPEC) += mpc10x_memory.o +obj-$(CONFIG_PAL4) += cpc700_memory.o +obj-$(CONFIG_SERIAL_8250_CONSOLE) += ns16550.o include $(TOPDIR)/Rules.make diff --git a/arch/ppc/boot/images/Makefile b/arch/ppc/boot/images/Makefile index 8723f6c5519e..f37cc9e47a0f 100644 --- a/arch/ppc/boot/images/Makefile +++ b/arch/ppc/boot/images/Makefile @@ -2,11 +2,16 @@ # This dir holds all of the images for PPC machines. # Tom Rini January 2001 +all: $(obj)/vmlinux.gz + include $(TOPDIR)/Rules.make -vmlinux.gz: $(TOPDIR)/vmlinux - $(OBJCOPY) --strip-all -S -O binary $(TOPDIR)/vmlinux vmlinux - gzip -vf9 vmlinux +GZIP_FLAGS = -v9f + +$(obj)/vmlinux.gz: vmlinux + $(OBJCOPY) -S -O binary vmlinux $(obj)/vmlinux + gzip $(GZIP_FLAGS) $(obj)/vmlinux clean: - rm -f sImage vmapus vmlinux* miboot* zImage* zvmlinux* + rm -f $(obj)/sImage $(obj)/vmapus $(obj)/vmlinux* $(obj)/miboot* + rm -f $(obj)/zImage* z$(obj)/vmlinux* diff --git a/arch/ppc/boot/include/mpc10x.h b/arch/ppc/boot/include/mpc10x.h index e71b667a683e..bef99d1f6b18 100644 --- a/arch/ppc/boot/include/mpc10x.h +++ b/arch/ppc/boot/include/mpc10x.h @@ -58,7 +58,7 @@ #define MPC10X_MCTLR_EXT_MEM_START_2 0x8c /* Banks 4-7 */ #define MPC10X_MCTLR_MEM_END_1 0x90 /* Banks 0-3 */ -#define MPC10X_MCTLR_MEM_END_2i 0x94 /* Banks 4-7 */ +#define MPC10X_MCTLR_MEM_END_2 0x94 /* Banks 4-7 */ #define MPC10X_MCTLR_EXT_MEM_END_1 0x98 /* Banks 0-3 */ #define MPC10X_MCTLR_EXT_MEM_END_2 0x9c /* Banks 4-7 */ diff --git a/arch/ppc/boot/lib/Makefile b/arch/ppc/boot/lib/Makefile index f1bd994045f0..4984baf0ff96 100644 --- a/arch/ppc/boot/lib/Makefile +++ b/arch/ppc/boot/lib/Makefile @@ -4,6 +4,6 @@ L_TARGET := lib.a -obj-y := zlib.o +obj-y := zlib.o div64.o include $(TOPDIR)/Rules.make diff --git a/arch/ppc/boot/lib/div64.S b/arch/ppc/boot/lib/div64.S new file mode 100644 index 000000000000..3527569e9926 --- /dev/null +++ b/arch/ppc/boot/lib/div64.S @@ -0,0 +1,58 @@ +/* + * Divide a 64-bit unsigned number by a 32-bit unsigned number. + * This routine assumes that the top 32 bits of the dividend are + * non-zero to start with. + * On entry, r3 points to the dividend, which get overwritten with + * the 64-bit quotient, and r4 contains the divisor. + * On exit, r3 contains the remainder. + * + * Copyright (C) 2002 Paul Mackerras, IBM Corp. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include <asm/ppc_asm.h> +#include <asm/processor.h> + +_GLOBAL(__div64_32) + lwz r5,0(r3) # get the dividend into r5/r6 + lwz r6,4(r3) + cmplw r5,r4 + li r7,0 + li r8,0 + blt 1f + divwu r7,r5,r4 # if dividend.hi >= divisor, + mullw r0,r7,r4 # quotient.hi = dividend.hi / divisor + subf. r5,r0,r5 # dividend.hi %= divisor + beq 3f +1: mr r11,r5 # here dividend.hi != 0 + andis. r0,r5,0xc000 + bne 2f + cntlzw r0,r5 # we are shifting the dividend right + li r10,-1 # to make it < 2^32, and shifting + srw r10,r10,r0 # the divisor right the same amount, + add r9,r4,r10 # rounding up (so the estimate cannot + andc r11,r6,r10 # ever be too large, only too small) + andc r9,r9,r10 + or r11,r5,r11 + rotlw r9,r9,r0 + rotlw r11,r11,r0 + divwu r11,r11,r9 # then we divide the shifted quantities +2: mullw r10,r11,r4 # to get an estimate of the quotient, + mulhwu r9,r11,r4 # multiply the estimate by the divisor, + subfc r6,r10,r6 # take the product from the divisor, + add r8,r8,r11 # and add the estimate to the accumulated + subfe. r5,r9,r5 # quotient + bne 1b +3: cmplw r6,r4 + blt 4f + divwu r0,r6,r4 # perform the remaining 32-bit division + mullw r10,r0,r4 # and get the remainder + add r8,r8,r0 + subf r6,r10,r6 +4: stw r7,0(r3) # return the quotient in *r3 + stw r8,4(r3) + mr r3,r6 # return the remainder in r3 + blr diff --git a/arch/ppc/boot/of1275/Makefile b/arch/ppc/boot/of1275/Makefile index e855cb64b28f..1d3a1f8bef49 100644 --- a/arch/ppc/boot/of1275/Makefile +++ b/arch/ppc/boot/of1275/Makefile @@ -2,7 +2,7 @@ # Makefile of1275 stuff # -L_TARGET := of1275.a +L_TARGET := lib.a obj-y := claim.o enter.o exit.o finddevice.o getprop.o ofinit.o \ ofstdio.o read.o release.o write.o diff --git a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile index c34d71381350..210f162442e4 100644 --- a/arch/ppc/boot/openfirmware/Makefile +++ b/arch/ppc/boot/openfirmware/Makefile @@ -10,24 +10,37 @@ # Merged 'chrp' and 'pmac' into 'openfirmware', and cleaned up the # rules. +EXTRA_TARGETS := start.o misc.o crt0.o coffcrt0.o coffmain.o chrpmain.o \ + newworldmain.o common.o + +boot: zImage + +include $(TOPDIR)/Rules.make + +boot := arch/ppc/boot +common := $(boot)/common +utils := $(boot)/utils +bootlib := $(boot)/lib +of1275 := $(boot)/of1275 +images := $(boot)/images + OBJCOPY_ARGS = -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment -COFF_LD_ARGS = -T ../ld.script -e _start -Ttext 0x00500000 -Bstatic -CHRP_LD_ARGS = -T ../ld.script -e _start -Ttext 0x00400000 -NEWWORLD_LD_ARGS = -T ../ld.script -e _start -Ttext 0x01000000 +COFF_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x00700000 -Bstatic +CHRP_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x00800000 +NEWWORLD_LD_ARGS = -T $(boot)/ld.script -e _start -Ttext 0x01000000 -COMMONOBJS = start.o misc.o ../common/string.o common.o -COFFOBJS = ../common/coffcrt0.o $(COMMONOBJS) coffmain.o -CHRPOBJS = ../common/crt0.o $(COMMONOBJS) chrpmain.o -NEWWORLDOBJS = ../common/crt0.o $(COMMONOBJS) newworldmain.o +COMMONOBJS = $(obj)/start.o $(obj)/misc.o $(obj)/common.o +COFFOBJS = $(obj)/coffcrt0.o $(COMMONOBJS) $(obj)/coffmain.o +CHRPOBJS = $(obj)/crt0.o $(COMMONOBJS) $(obj)/chrpmain.o +NEWWORLDOBJS = $(obj)/crt0.o $(COMMONOBJS) $(obj)/newworldmain.o -EXTRA_TARGETS := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) -LIBS = $(TOPDIR)/lib/lib.a ../lib/lib.a ../of1275/of1275.a +LIBS = lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a -ADDNOTE := ../utils/addnote -MKNOTE := ../utils/mknote -SIZE := ../utils/size -OFFSET := ../utils/offset -HACKCOFF := ../utils/hack-coff +ADDNOTE := $(utils)/addnote +MKNOTE := $(utils)/mknote +SIZE := $(utils)/size +OFFSET := $(utils)/offset +HACKCOFF := $(utils)/hack-coff ifdef CONFIG_SMP END := .smp @@ -38,12 +51,12 @@ endif TFTPIMAGE=/tftpboot/zImage. -../common/coffcrt0.o: - $(MAKE) -C ../common coffcrt0.o +$(obj)/dummy.o: $(common)/dummy.c + $(CC) -c -o $@ $(common)/dummy.c -image.o: ../images/vmlinux.gz ../common/dummy.o - $(OBJCOPY) ../common/dummy.o $@ -R .comment \ - --add-section=.image=../images/vmlinux.gz \ +$(obj)/image.o: $(images)/vmlinux.gz $(obj)/dummy.o + $(OBJCOPY) $(obj)/dummy.o $@ -R .comment \ + --add-section=.image=$(images)/vmlinux.gz \ --set-section-flags=.image=contents,alloc,load,readonly,data ifdef CONFIG_XMON $(OBJCOPY) $@ $@ \ @@ -52,86 +65,93 @@ ifdef CONFIG_XMON endif # Place the ramdisk in the initrd image. -image-initrd.o: image.o ../images/ramdisk.image.gz - $(OBJCOPY) image.o $@ \ - --add-section=.ramdisk=../images/ramdisk.image.gz \ +$(obj)/image-initrd.o: $(obj)/image.o $(images)/ramdisk.image.gz + $(OBJCOPY) $(obj)/image.o $@ \ + --add-section=.ramdisk=$(images)/ramdisk.image.gz \ --set-section-flags=.ramdisk=contents,alloc,load,readonly,data # Create the note section for New-World PowerMacs. -note: $(MKNOTE) - $(MKNOTE) > note - -znetboot: vmlinux.coff vmlinux.elf-pmac zImage - cp ../images/vmlinux.coff $(TFTPIMAGE).pmac$(END) - cp ../images/vmlinux.elf-pmac $(TFTPIMAGE).pmac$(END)elf - cp ../images/zImage.chrp $(TFTPIMAGE).chrp$(END) - -znetboot.initrd: vmlinux.initrd.coff vmlinux.initrd.elf-pmac - cp ../images/vmlinux.initrd.coff $(TFTPIMAGE).pmac$(END) - cp ../images/vmlinux.initrd.elf-pmac $(TFTPIMAGE).pmac$(END).elf - cp ../images/zImage.initrd.chrp $(TFTPIMAGE).chrp$(END) +$(obj)/note: $(MKNOTE) + $(MKNOTE) > $(obj)/note + +znetboot: $(images)/vmlinux.coff $(images)/vmlinux.elf-pmac $(images)/zImage.chrp + cp $(images)/vmlinux.coff $(TFTPIMAGE).pmac$(END) + cp $(images)/vmlinux.elf-pmac $(TFTPIMAGE).pmac$(END)elf + cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) + +znetboot.initrd: $(images)/vmlinux.initrd.coff \ + $(images)/vmlinux.initrd.elf-pmac \ + $(images)/zImage.initrd.chrp + cp $(images)/vmlinux.initrd.coff $(TFTPIMAGE).pmac$(END) + cp $(images)/vmlinux.initrd.elf-pmac $(TFTPIMAGE).pmac$(END).elf + cp $(images)/zImage.initrd.chrp $(TFTPIMAGE).chrp$(END) + +$(images)/miboot.image: $(obj)/dummy.o $(images)/vmlinux.gz + $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=image=$(images)/vmlinux.gz \ + $(obj)/dummy.o $@ + +$(images)/miboot.initrd.image: $(images)/miboot.image $(images)/ramdisk.image.gz + $(OBJCOPY) $(OBJCOPY_ARGS) \ + --add-section=initrd=$(images)/ramdisk.image.gz \ + $(images)/miboot.image $@ -miboot.image: ../common/dummy.o ../images/vmlinux.gz - $(OBJCOPY) $(OBJCOPY_ARGS) --add-section=image=../images/vmlinux.gz \ - ../common/dummy.o ../images/$@ +$(obj)/coffcrt0.o: $(common)/crt0.S + $(CC) $(AFLAGS) -DXCOFF -traditional -c -o $@ $(common)/crt0.S -miboot.initrd.image: miboot.image ../images/ramdisk.image.gz - $(OBJCOPY) $(OBJCOPY_ARGS) \ - --add-section=initrd=../images/ramdisk.image.gz \ - ../images/miboot.image ../images/$@ +$(obj)/crt0.o: $(common)/crt0.S + $(CC) $(AFLAGS) -traditional -c -o $@ $(common)/crt0.S -coffboot: $(COFFOBJS) image.o $(LIBS) +$(obj)/coffboot: $(COFFOBJS) $(obj)/image.o $(LIBS) $(LD) -o $@ $(COFF_LD_ARGS) $^ $(OBJCOPY) $@ $@ -R .comment -R .ramdisk -coffboot.initrd: $(COFFOBJS) image-initrd.o $(LIBS) +$(obj)/coffboot.initrd: $(COFFOBJS) $(obj)/image-initrd.o $(LIBS) $(LD) -o $@ $(COFF_LD_ARGS) $^ $(OBJCOPY) $@ $@ -R .comment -vmlinux.coff: coffboot $(HACKCOFF) - $(OBJCOPY) $(OBJCOPY_ARGS) coffboot ../images/$@ - $(HACKCOFF) ../images/$@ - rm -f coffboot - ln -sf vmlinux.coff ../images/zImage.pmac - -vmlinux.initrd.coff: coffboot.initrd $(HACKCOFF) - $(OBJCOPY) $(OBJCOPY_ARGS) coffboot.initrd ../images/$@ - $(HACKCOFF) ../images/$@ - rm -f coffboot.initrd - ln -sf vmlinux.initrd.coff ../images/zImage.initrd.pmac - -vmlinux.elf-pmac: $(NEWWORLDOBJS) $(LIBS) image.o - $(LD) $(NEWWORLD_LD_ARGS) -o ../images/$@ $^ - -vmlinux.initrd.elf-pmac: $(NEWWORLDOBJS) $(LIBS) image-initrd.o - $(LD) $(NEWWORLD_LD_ARGS) -o ../images/$@ $^ - -zImage.chrp: $(CHRPOBJS) image.o $(LIBS) - $(LD) $(CHRP_LD_ARGS) -o ../images/$@ $^ - -zImage.initrd.chrp: $(CHRPOBJS) image-initrd.o $(LIBS) - $(LD) $(CHRP_LD_ARGS) -o ../images/$@ $^ - -zImage: vmlinux.coff vmlinux.elf-pmac zImage.chrp miboot.image $(ADDNOTE) \ - note - $(OBJCOPY) ../images/vmlinux.elf-pmac ../images/vmlinux.elf-pmac \ - --add-section=.note=note -R .comment -R .ramdisk - $(OBJCOPY) ../images/zImage.chrp ../images/zImage.chrp \ - -R .comment -R .ramdisk - cp ../images/zImage.chrp ../images/zImage.chrp-rs6k - $(ADDNOTE) ../images/zImage.chrp-rs6k - -zImage.initrd: vmlinux.initrd.coff vmlinux.initrd.elf-pmac zImage.initrd.chrp \ - miboot.initrd.image $(ADDNOTE) note - $(OBJCOPY) ../images/vmlinux.initrd.elf-pmac \ - ../images/vmlinux.initrd.elf-pmac --add-section=.note=note \ - -R .comment - $(OBJCOPY) ../images/zImage.initrd.chrp ../images/zImage.initrd.chrp \ - -R .comment - cp ../images/zImage.initrd.chrp ../images/zImage.initrd.chrp-rs6k - $(ADDNOTE) ../images/zImage.initrd.chrp-rs6k +$(images)/vmlinux.coff: $(obj)/coffboot + $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/coffboot $@ + $(HACKCOFF) $@ + ln -sf vmlinux.coff $(images)/zImage.pmac -clean: - rm -f note +$(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd + $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/coffboot.initrd $@ + $(HACKCOFF) $@ + ln -sf vmlinux.initrd.coff $(images)/zImage.initrd.pmac -include $(TOPDIR)/Rules.make +$(images)/vmlinux.elf-pmac: $(NEWWORLDOBJS) $(LIBS) $(obj)/image.o $(obj)/note + $(LD) $(NEWWORLD_LD_ARGS) -o $@ $(NEWWORLDOBJS) $(LIBS) $(obj)/image.o + $(OBJCOPY) $@ $@ \ + --add-section=.note=$(obj)/note -R .comment -R .ramdisk + +$(images)/vmlinux.initrd.elf-pmac: $(NEWWORLDOBJS) $(LIBS) \ + $(obj)/image-initrd.o $(obj)/note + $(LD) $(NEWWORLD_LD_ARGS) -o $@ $(NEWWORLDOBJS) $(LIBS) \ + $(obj)/image-initrd.o + $(OBJCOPY) $@ $@ \ + --add-section=.note=$(obj)/note -R .comment + +$(images)/zImage.chrp: $(CHRPOBJS) $(obj)/image.o $(LIBS) + $(LD) $(CHRP_LD_ARGS) -o $@ $^ + $(OBJCOPY) $@ $@ -R .comment -R .ramdisk + +$(images)/zImage.initrd.chrp: $(CHRPOBJS) $(obj)/image-initrd.o $(LIBS) + $(LD) $(CHRP_LD_ARGS) -o $@ $^ + $(OBJCOPY) $@ $@ -R .comment + +$(images)/zImage.chrp-rs6k: $(images)/zImage.chrp + cp $(images)/zImage.chrp $@ + $(ADDNOTE) $@ + +$(images)/zImage.initrd.chrp-rs6k: $(images)/zImage.initrd.chrp + cp $(images)/zImage.initrd.chrp $@ + $(ADDNOTE) $@ + +zImage: $(images)/vmlinux.coff $(images)/vmlinux.elf-pmac \ + $(images)/zImage.chrp $(images)/miboot.image + +zImage.initrd: $(images)/vmlinux.initrd.coff $(images)/vmlinux.initrd.elf-pmac\ + $(images)/zImage.initrd.chrp $(images)/miboot.initrd.image + +clean: + rm -f $(obj)/note $(obj)/image.o $(obj)/coffboot $(obj)/coffboot.initrd diff --git a/arch/ppc/boot/prep/Makefile b/arch/ppc/boot/prep/Makefile index e3617f80113f..b472f2bce21d 100644 --- a/arch/ppc/boot/prep/Makefile +++ b/arch/ppc/boot/prep/Makefile @@ -13,65 +13,79 @@ # modified by Cort (cort@cs.nmt.edu) # +boot: zImage + TFTPIMAGE = /tftpboot/zImage.prep ifeq ($(CONFIG_SMP),y) TFTPIMAGE = $(TFTPBOOT).smp endif -LD_ARGS = -T ../ld.script -Ttext 0x00800000 -Bstatic -boot-y := head.o ../simple/legacy.o misc.o \ - ../common/util.o ../common/string.o \ - ../common/misc-common.o \ - ../common/mpc10x_memory.o +LD_ARGS = -T $(boot)/ld.script -Ttext 0x00800000 -Bstatic OBJCOPY_ARGS = -O elf32-powerpc -LIBS = ../lib/lib.a +LIBS = $(common)/lib.a $(bootlib)/lib.a -boot-$(CONFIG_SERIAL_8250_CONSOLE) += ../common/ns16550.o +boot-y := head.o misc.o boot-$(CONFIG_VGA_CONSOLE) += vreset.o kbd.o -EXTRA_TARGETS := $(boot-y) +EXTRA_TARGETS := $(boot-y) ../simple/legacy.o + +include $(TOPDIR)/Rules.make + +boot := arch/ppc/boot +common := $(boot)/common +utils := $(boot)/utils +bootlib := $(boot)/lib +of1275 := $(boot)/of1275 +images := $(boot)/images +simple := $(boot)/simple + +OBJS := $(addprefix $(obj)/,$(boot-y)) $(simple)/legacy.o # Tools -MKPREP := ../utils/mkprep -SIZE := ../utils/size -OFFSET := ../utils/offset +MKPREP := $(utils)/mkprep +SIZE := $(utils)/size +OFFSET := $(utils)/offset # Extra include search dirs -CFLAGS_kbd.o += -I$(TOPDIR)/drivers/char +CFLAGS_kbd.o += -Idrivers/char -all: zImage +zImage: $(images)/zImage.prep +zImage.initrd: $(images)/zImage.initrd.prep -zImage: $(boot-y) $(LIBS) ../ld.script ../images/vmlinux.gz ../common/dummy.o \ - $(MKPREP) +$(obj)/dummy.o: $(common)/dummy.c + $(CC) -c -o $@ $(common)/dummy.c + +$(images)/zImage.prep: $(OBJS) $(LIBS) $(boot)/ld.script \ + $(images)/vmlinux.gz $(obj)/dummy.o $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ - --add-section=.image=../images/vmlinux.gz \ + --add-section=.image=$(images)/vmlinux.gz \ --set-section-flags=.image=contents,alloc,load,readonly,data \ - ../common/dummy.o image.o - $(LD) $(LD_ARGS) -o $@ $(boot-y) image.o $(LIBS) - $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab -R .stabstr - $(MKPREP) -pbp $@ ../images/$@.prep - rm -f $@ - -zImage.initrd: $(boot-y) $(LIBS) ../ld.script ../images/vmlinux.gz $(MKPREP) \ - ../common/dummy.o + $(obj)/dummy.o $(obj)/image.o + $(LD) $(LD_ARGS) -o $(obj)/zImage $(OBJS) $(obj)/image.o $(LIBS) + $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/zImage $(obj)/zImage \ + -R .comment -R .stab -R .stabstr + $(MKPREP) -pbp $(obj)/zImage $@ + rm -f $(obj)/zImage + +$(images)/zImage.initrd.prep: $(OBJS) $(LIBS) $(boot)/ld.script \ + $(images)/vmlinux.gz $(obj)/dummy.o $(OBJCOPY) $(OBJCOPY_ARGS) -R .comment \ - --add-section=.ramdisk=../images/ramdisk.image.gz \ + --add-section=.ramdisk=$(images)/ramdisk.image.gz \ --set-section-flags=.ramdisk=contents,alloc,load,readonly,data \ - --add-section=.image=../images/vmlinux.gz \ + --add-section=.image=$(images)/vmlinux.gz \ --set-section-flags=.image=contents,alloc,load,readonly,data \ - ../common/dummy.o image.o - $(LD) $(LD_ARGS) -o $@ $(boot-y) image.o $(LIBS) - $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab -R .stabstr - $(MKPREP) -pbp $@ ../images/$@.prep - rm -f $@ + $(obj)/dummy.o $(obj)/image.o + $(LD) $(LD_ARGS) -o $(obj)/zImage.initrd $(OBJS) $(obj)/image.o $(LIBS) + $(OBJCOPY) $(OBJCOPY_ARGS) $(obj)/zImage.initrd $(obj)/zImage.initrd \ + -R .comment -R .stab -R .stabstr + $(MKPREP) -pbp $(obj)/zImage.initrd $@ + rm -f $(obj)/zImage.initrd floppy: zImage - dd if=../images/zImage.prep of=/dev/fd0H1440 bs=64b + dd if=$(images)/zImage.prep of=/dev/fd0H1440 bs=64b znetboot : zImage - cp ../images/zImage.prep $(TFTPIMAGE) + cp $(images)/zImage.prep $(TFTPIMAGE) znetboot.initrd : zImage.initrd - cp ../images/zImage.initrd.prep $(TFTPIMAGE) - -include $(TOPDIR)/Rules.make + cp $(images)/zImage.initrd.prep $(TFTPIMAGE) diff --git a/arch/ppc/boot/prep/misc.c b/arch/ppc/boot/prep/misc.c index c92348aa6572..7f6680036cea 100644 --- a/arch/ppc/boot/prep/misc.c +++ b/arch/ppc/boot/prep/misc.c @@ -132,11 +132,6 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, vga_init((unsigned char *)0xC0000000); #endif /* CONFIG_VGA_CONSOLE */ - /* - * Find out how much memory we have. - */ - TotalMemory = get_mem_size(); - /* * Tell the user where we were loaded at and where we were relocated * to for debugging this process. @@ -215,6 +210,29 @@ decompress_kernel(unsigned long load_addr, int num_words, unsigned long cksum, puts("No residual data found.\n"); } + /* First, figure out what kind of host bridge we are on. If it's + * an MPC10x, we can ask it directly how much memory it has. + * Otherwise, see if the residual data has anything. This isn't + * the best way, but it can be the only way. If there's nothing, + * assume 32MB. -- Tom. + */ + /* See what our host bridge is. */ + pci_read_config_32(0x00, 0x00, &pci_viddid); + pci_did = (pci_viddid & 0xffff0000) >> 16; + /* See if we are on an MPC10x. */ + if (((pci_viddid & 0xffff) == PCI_VENDOR_ID_MOTOROLA) + && ((pci_did == PCI_DEVICE_ID_MOTOROLA_MPC105) + || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC106) + || (pci_did == PCI_DEVICE_ID_MOTOROLA_MPC107))) + TotalMemory = get_mem_size(); + /* If it's not, see if we have anything in the residual data. */ + else if (residual && residual->TotalMemory) + TotalMemory = residual->TotalMemory; + /* Fall back to hard-coding 32MB. */ + else + TotalMemory = 32*1024*1024; + + /* assume the chunk below 8M is free */ end_avail = (char *)0x00800000; diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile index a659b52cfb16..947d507774d9 100644 --- a/arch/ppc/boot/simple/Makefile +++ b/arch/ppc/boot/simple/Makefile @@ -24,9 +24,11 @@ # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. -# Normally, we use the 'misc-simple.c' file for decompress_kernel and +boot: zImage + +# Normally, we use the 'misc.c' file for decompress_kernel and # whatnot. Sometimes we need to override this however. -MISC := ../common/misc-simple.o +MISC := misc.o ifeq ($(CONFIG_IBM_OPENBIOS),y) ZIMAGE := zImage-TREE ZIMAGEINITRD := zImage.initrd-TREE @@ -38,6 +40,14 @@ ifeq ($(CONFIG_EMBEDDEDBOOT),y) TFTPIMAGE := /tftpboot/zImage.embedded MISC := misc-embedded.o endif +ifeq ($(CONFIG_EBONY),y) +ZIMAGE := zImage-TREE +ZIMAGEINITRD := zImage.initrd-TREE +EXTRA := direct.o +END := ebony +ENTRYPOINT := 0x01000000 +TFTPIMAGE := /tftpboot/zImage.$(END) +endif ifeq ($(CONFIG_EV64260),y) EXTRA := direct.o misc-ev64260.o TFTPIMAGE := /tftpboot/zImage.ev64260 @@ -72,11 +82,8 @@ endif ifeq ($(CONFIG_PPLUS),y) EXTRA := legacy.o endif -ifeq ($(CONFIG_LOPEC),y) -EXTRA += ../common/mpc10x_memory.o -endif ifeq ($(CONFIG_PAL4),y) -EXTRA := direct.o ../common/cpc700_memory.o +EXTRA := direct.o endif ifeq ($(CONFIG_PCORE)$(CONFIG_POWERPMC250),y) ZIMAGE := zImage-STRIPELF @@ -122,21 +129,25 @@ endif # Default linker args. Link at 0x00800000 or 0x00400000 by default, but # allow it to be overridden. ifeq ($(CONFIG_BOOT_LOAD_BOOL),y) -LD_ARGS := -T ../ld.script -Ttext $(CONFIG_BOOT_LOAD) \ - -Bstatic +LD_ARGS := -T $(boot)/ld.script \ + -Ttext $(CONFIG_BOOT_LOAD) -Bstatic else -LD_ARGS = -T ../ld.script -Ttext 0x00800000 -Bstatic -ifeq ($(CONFIG_8260)$(CONFIG_4xx)$(CONFIG_8xx),y) -LD_ARGS := -T ../ld.script -Ttext 0x00400000 -Bstatic +LD_ARGS = -T $(boot)/ld.script \ + -Ttext 0x00800000 -Bstatic +ifeq ($(CONFIG_8260)$(CONFIG_40x)$(CONFIG_8xx),y) +LD_ARGS := -T $(boot)/ld.script -Ttext 0x00400000 \ + -Bstatic +endif +ifeq ($(CONFIG_440),y) +LD_ARGS := -T $(boot)/ld.script -Ttext 0x01000000 \ + -Bstatic endif endif OBJCOPY_ARGS := -O elf32-powerpc -# head.o and ../common/relocate.o must be at the start. -boot-y := head.o ../common/relocate.o $(EXTRA) \ - $(MISC) ../common/misc-common.o \ - ../common/string.o ../common/util.o -boot-$(CONFIG_4xx) += embed_config.o +# head.o and relocate.o must be at the start. +boot-y := head.o relocate.o $(EXTRA) $(MISC) +boot-$(CONFIG_40x) += embed_config.o boot-$(CONFIG_8xx) += embed_config.o boot-$(CONFIG_8260) += embed_config.o boot-$(CONFIG_BSEIP) += iic.o @@ -149,84 +160,97 @@ boot-$(CONFIG_8xx) += m8xx_tty.o boot-$(CONFIG_8260) += m8260_tty.o boot-$(CONFIG_GT64260_CONSOLE) += gt64260_tty.o endif -boot-$(CONFIG_SERIAL_8250_CONSOLE) += ../common/ns16550.o + +boot := arch/ppc/boot +common := $(boot)/common +utils := $(boot)/utils +bootlib := $(boot)/lib +images := $(boot)/images EXTRA_TARGETS := $(boot-y) -LIBS := ../lib/lib.a +LIBS := $(common)/lib.a $(bootlib)/lib.a + +include $(TOPDIR)/Rules.make + +OBJS := $(addprefix $(obj)/,$(boot-y)) # Tools -MKBUGBOOT := ../utils/mkbugboot -MKPREP := ../utils/mkprep -MKTREE := ../utils/mktree +MKBUGBOOT := $(utils)/mkbugboot +MKPREP := $(utils)/mkprep +MKTREE := $(utils)/mktree + +$(obj)/dummy.o: $(common)/dummy.c + $(CC) -c -o $@ $(common)/dummy.c -zvmlinux: $(boot-y) $(LIBS) ../ld.script ../images/vmlinux.gz ../common/dummy.o +$(obj)/zvmlinux: $(OBJS) $(LIBS) $(boot)/ld.script $(images)/vmlinux.gz \ + $(obj)/dummy.o $(OBJCOPY) $(OBJCOPY_ARGS) \ - --add-section=.image=../images/vmlinux.gz \ + --add-section=.image=$(images)/vmlinux.gz \ --set-section-flags=.image=contents,alloc,load,readonly,data \ - ../common/dummy.o image.o - $(LD) $(LD_ARGS) -o $@ $(boot-y) image.o $(LIBS) - $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab -R .stabstr \ - -R .ramdisk -R .sysmap + $(obj)/dummy.o $(obj)/image.o + $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS) + $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \ + -R .stabstr -R .ramdisk -R .sysmap -zvmlinux.initrd: $(boot-y) $(LIBS) ../ld.script ../images/vmlinux.gz \ - ../common/dummy.o +$(obj)/zvmlinux.initrd: $(OBJS) $(LIBS) $(boot)/ld.script \ + $(images)/vmlinux.gz $(obj)/dummy.o $(OBJCOPY) $(OBJCOPY_ARGS) \ - --add-section=.ramdisk=../images/ramdisk.image.gz \ + --add-section=.ramdisk=$(images)/ramdisk.image.gz \ --set-section-flags=.ramdisk=contents,alloc,load,readonly,data \ - --add-section=.image=../images/vmlinux.gz \ + --add-section=.image=$(images)/vmlinux.gz \ --set-section-flags=.image=contents,alloc,load,readonly,data \ - ../common/dummy.o image.o - $(LD) $(LD_ARGS) -o $@ $(boot-y) image.o $(LIBS) - $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab -R .stabstr \ - -R .sysmap + $(obj)/dummy.o $(obj)/image.o + $(LD) $(LD_ARGS) -o $@ $(OBJS) $(obj)/image.o $(LIBS) + $(OBJCOPY) $(OBJCOPY_ARGS) $@ $@ -R .comment -R .stab \ + -R .stabstr -R .sysmap # Sort-of dummy rules, that let us format the image we want. -zImage: $(ZIMAGE) zvmlinux - cp -f zvmlinux ../images/zImage.elf - rm -f zvmlinux +zImage: $(images)/$(ZIMAGE) $(obj)/zvmlinux + cp -f $(obj)/zvmlinux $(images)/zImage.elf + rm -f $(obj)/zvmlinux -zImage.initrd: $(ZIMAGEINITRD) zvmlinux.initrd - cp -f zvmlinux.initrd ../images/zImage.initrd.elf - rm -f zvmlinux.initrd +zImage.initrd: $(images)/$(ZIMAGEINITRD) $(obj)/zvmlinux.initrd + cp -f $(obj)/zvmlinux.initrd $(images)/zImage.initrd.elf + rm -f $(obj)/zvmlinux.initrd znetboot: zImage ifneq ($(ZNETBOOT),) - cp ../images/$(ZNETBOOT) $(TFTPIMAGE) + cp $(images)/$(ZNETBOOT) $(TFTPIMAGE) else - cp ../images/zImage.* $(TFTPIMAGE) + cp $(images)/zImage.* $(TFTPIMAGE) endif znetboot.initrd: zImage.initrd ifneq ($(ZNETBOOTRD),) - cp ../images/$(ZNETBOOTRD) $(TFTPIMAGE) + cp $(images)/$(ZNETBOOTRD) $(TFTPIMAGE) else - cp ../images/zImage.* $(TFTPIMAGE) + cp $(images)/zImage.* $(TFTPIMAGE) endif -zImage-STRIPELF: zvmlinux - dd if=zvmlinux of=../images/zImage.$(END) skip=64 bs=1k +$(images)/zImage-STRIPELF: $(obj)/zvmlinux + dd if=$(obj)/zvmlinux of=$(images)/zImage.$(END) skip=64 bs=1k -zImage.initrd-STRIPELF: zvmlinux.initrd - dd if=zvmlinux.initrd of=../images/zImage.initrd.$(END) skip=64 bs=1k +$(images)/zImage.initrd-STRIPELF: $(obj)/zvmlinux.initrd + dd if=$(obj)/zvmlinux.initrd of=$(images)/zImage.initrd.$(END) \ + skip=64 bs=1k -zImage-TREE: zvmlinux - $(MKTREE) zvmlinux ../images/zImage.$(END) $(ENTRYPOINT) +$(images)/zImage-TREE: $(obj)/zvmlinux + $(MKTREE) $(obj)/zvmlinux $(images)/zImage.$(END) $(ENTRYPOINT) -zImage.initrd-TREE: zvmlinux.initrd - $(MKTREE) zvmlinux.initrd ../images/zImage.initrd.$(END) $(ENTRYPOINT) +$(images)/zImage.initrd-TREE: $(obj)/zvmlinux.initrd + $(MKTREE) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.$(END) \ + $(ENTRYPOINT) -zImage-MENF1: zvmlinux - $(MKPREP) -pbp zvmlinux ../images/zImage.menf1 +$(images)/zImage-MENF1: $(obj)/zvmlinux + $(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.menf1 -zImage.initrd-MENF1: zvmlinux.initrd - $(MKPREP) -pbp zvmlinux.initrd ../images/zImage.initrd.menf1 +$(images)/zImage.initrd-MENF1: $(obj)/zvmlinux.initrd + $(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.menf1 -zImage-PPLUS: zvmlinux $(MKPREP) $(MKBUGBOOT) - $(MKPREP) -pbp zvmlinux ../images/zImage.pplus - $(MKBUGBOOT) zvmlinux ../images/zImage.bugboot +$(images)/zImage-PPLUS: $(obj)/zvmlinux $(MKPREP) $(MKBUGBOOT) + $(MKPREP) -pbp $(obj)/zvmlinux $(images)/zImage.pplus + $(MKBUGBOOT) $(obj)/zvmlinux $(images)/zImage.bugboot -zImage.initrd-PPLUS: zvmlinux.initrd $(MKPREP) $(MKBUGBOOT) - $(MKPREP) -pbp zvmlinux.initrd ../images/zImage.initrd.pplus - $(MKBUGBOOT) zvmlinux.initrd ../images/zImage.initrd.bugboot - -include $(TOPDIR)/Rules.make +$(images)/zImage.initrd-PPLUS: $(obj)/zvmlinux.initrd $(MKPREP) $(MKBUGBOOT) + $(MKPREP) -pbp $(obj)/zvmlinux.initrd $(images)/zImage.initrd.pplus + $(MKBUGBOOT) $(obj)/zvmlinux.initrd $(images)/zImage.initrd.bugboot diff --git a/arch/ppc/boot/common/misc-simple.c b/arch/ppc/boot/simple/misc.c index 74693dc19a0a..74693dc19a0a 100644 --- a/arch/ppc/boot/common/misc-simple.c +++ b/arch/ppc/boot/simple/misc.c diff --git a/arch/ppc/boot/common/relocate.S b/arch/ppc/boot/simple/relocate.S index 9c49a9c09f80..9c49a9c09f80 100644 --- a/arch/ppc/boot/common/relocate.S +++ b/arch/ppc/boot/simple/relocate.S diff --git a/arch/ppc/config.in b/arch/ppc/config.in index 84f098ad2753..88f8dff3cd99 100644 --- a/arch/ppc/config.in +++ b/arch/ppc/config.in @@ -131,6 +131,7 @@ if [ "$CONFIG_6xx" = "y" -a "$CONFIG_8260" = "n" ]; then Motorola-Sandpoint CONFIG_SANDPOINT \ SBS-Adirondack CONFIG_ADIR \ SBS-K2 CONFIG_K2 \ + SBS-Palomar4 CONFIG_PAL4 \ Synergy-Gemini CONFIG_GEMINI \ Zynx-ZX4500 CONFIG_ZX4500" CHRP/PowerMac/PReP @@ -584,23 +585,31 @@ source lib/Config.in mainmenu_option next_comment comment 'Kernel hacking' -bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ -bool 'Spinlock debugging' CONFIG_DEBUG_SPINLOCK -bool 'Include kgdb kernel debugger' CONFIG_KGDB -if [ "$CONFIG_KGDB" = "y" ]; then - choice 'Serial Port' \ - "ttyS0 CONFIG_KGDB_TTYS0 \ - ttyS1 CONFIG_KGDB_TTYS1 \ - ttyS2 CONFIG_KGDB_TTYS2 \ - ttyS3 CONFIG_KGDB_TTYS3" ttyS1 -fi -bool 'Include xmon kernel debugger' CONFIG_XMON -bool 'Include BDI-2000 user context switcher' CONFIG_BDI_SWITCH -if [ "$CONFIG_KGDB" = "y" -o "$CONFIG_XMON" = "y" \ - -o "$CONFIG_BDI_SWITCH" = "y" ]; then - bool 'Add any additional compile options' CONFIG_MORE_COMPILE_OPTIONS - if [ "$CONFIG_MORE_COMPILE_OPTIONS" = "y" ]; then - string 'Additional compile arguments' CONFIG_COMPILE_OPTIONS "-g -ggdb" +bool 'Kernel debugging' CONFIG_DEBUG_KERNEL +if [ "$CONFIG_DEBUG_KERNEL" = "y" ]; then + bool ' Debug memory allocations' CONFIG_DEBUG_SLAB + bool ' Magic SysRq key' CONFIG_MAGIC_SYSRQ + bool ' Spinlock debugging' CONFIG_DEBUG_SPINLOCK + if [ "$CONFIG_HIGHMEM" = "y" ]; then + bool ' Highmem debugging' CONFIG_DEBUG_HIGHMEM + fi + bool ' Load all symbols for debugging/kksymoops' CONFIG_KALLSYMS + bool ' Include kgdb kernel debugger' CONFIG_KGDB + if [ "$CONFIG_KGDB" = "y" ]; then + choice ' Serial Port' \ + "ttyS0 CONFIG_KGDB_TTYS0 \ + ttyS1 CONFIG_KGDB_TTYS1 \ + ttyS2 CONFIG_KGDB_TTYS2 \ + ttyS3 CONFIG_KGDB_TTYS3" ttyS1 + fi + bool ' Include xmon kernel debugger' CONFIG_XMON + bool ' Include BDI-2000 user context switcher' CONFIG_BDI_SWITCH + if [ "$CONFIG_KGDB" = "y" -o "$CONFIG_XMON" = "y" \ + -o "$CONFIG_BDI_SWITCH" = "y" ]; then + bool ' Add any additional compile options' CONFIG_MORE_COMPILE_OPTIONS + if [ "$CONFIG_MORE_COMPILE_OPTIONS" = "y" ]; then + string ' Additional compile arguments' CONFIG_COMPILE_OPTIONS "-g -ggdb" + fi fi fi diff --git a/arch/ppc/kernel/indirect_pci.c b/arch/ppc/kernel/indirect_pci.c index e5db04a84a68..a012f65b3a4e 100644 --- a/arch/ppc/kernel/indirect_pci.c +++ b/arch/ppc/kernel/indirect_pci.c @@ -27,13 +27,18 @@ indirect_read_config(struct pci_bus *bus, unsigned int devfn, int offset, { struct pci_controller *hose = bus->sysdata; volatile unsigned char *cfg_data; + u8 cfg_type = 0; if (ppc_md.pci_exclude_device) if (ppc_md.pci_exclude_device(bus->number, devfn)) return PCIBIOS_DEVICE_NOT_FOUND; + + if (hose->set_cfg_type) + if (bus->number != hose->first_busno) + cfg_type = 1; out_be32(hose->cfg_addr, - ((offset & 0xfc) << 24) | (devfn << 16) + (((offset & 0xfc) | cfg_type) << 24) | (devfn << 16) | ((bus->number - hose->bus_offset) << 8) | 0x80); /* * Note: the caller has already checked that offset is @@ -60,13 +65,18 @@ indirect_write_config(struct pci_bus *bus, unsigned int devfn, int offset, { struct pci_controller *hose = bus->sysdata; volatile unsigned char *cfg_data; + u8 cfg_type = 0; if (ppc_md.pci_exclude_device) if (ppc_md.pci_exclude_device(bus->number, devfn)) return PCIBIOS_DEVICE_NOT_FOUND; + if (hose->set_cfg_type) + if (bus->number != hose->first_busno) + cfg_type = 1; + out_be32(hose->cfg_addr, - ((offset & 0xfc) << 24) | (devfn << 16) + (((offset & 0xfc) | cfg_type) << 24) | (devfn << 16) | ((bus->number - hose->bus_offset) << 8) | 0x80); /* * Note: the caller has already checked that offset is diff --git a/arch/ppc/kernel/misc.S b/arch/ppc/kernel/misc.S index edd62a0bcaf9..c25bc5824e58 100644 --- a/arch/ppc/kernel/misc.S +++ b/arch/ppc/kernel/misc.S @@ -752,21 +752,6 @@ _GLOBAL(copy_page) #endif /* CONFIG_PPC_ISERIES */ /* - * Atomic [test&set] exchange - * - * unsigned long xchg_u32(void *ptr, unsigned long val) - * Changes the memory location '*ptr' to be val and returns - * the previous value stored there. - */ -_GLOBAL(xchg_u32) - mr r5,r3 /* Save pointer */ -10: lwarx r3,0,r5 /* Fetch old value & reserve */ - PPC405_ERR77(0,r5) - stwcx. r4,0,r5 /* Update with new value */ - bne- 10b /* Retry if "reservation" (i.e. lock) lost */ - blr - -/* * void atomic_clear_mask(atomic_t mask, atomic_t *addr) * void atomic_set_mask(atomic_t mask, atomic_t *addr); */ diff --git a/arch/ppc/kernel/ppc_ksyms.c b/arch/ppc/kernel/ppc_ksyms.c index 78cacd63f7cf..ef796b2915f6 100644 --- a/arch/ppc/kernel/ppc_ksyms.c +++ b/arch/ppc/kernel/ppc_ksyms.c @@ -30,6 +30,8 @@ #include <linux/pmu.h> #include <asm/prom.h> #include <asm/system.h> +#define __KERNEL_SYSCALLS__ +#include <asm/unistd.h> #include <asm/pci-bridge.h> #include <asm/irq.h> #include <asm/pmac_feature.h> @@ -180,6 +182,10 @@ EXPORT_SYMBOL(consistent_free); EXPORT_SYMBOL(consistent_sync); #endif +EXPORT_SYMBOL(open); +EXPORT_SYMBOL(read); +EXPORT_SYMBOL(lseek); +EXPORT_SYMBOL(close); EXPORT_SYMBOL(start_thread); EXPORT_SYMBOL(kernel_thread); @@ -191,7 +197,6 @@ EXPORT_SYMBOL(flush_dcache_range); EXPORT_SYMBOL(flush_icache_user_range); EXPORT_SYMBOL(flush_icache_page); EXPORT_SYMBOL(flush_dcache_page); -EXPORT_SYMBOL(xchg_u32); #ifdef CONFIG_ALTIVEC EXPORT_SYMBOL(last_task_used_altivec); EXPORT_SYMBOL(giveup_altivec); diff --git a/arch/ppc/lib/Makefile b/arch/ppc/lib/Makefile index 6019aa16e6d4..1567db763078 100644 --- a/arch/ppc/lib/Makefile +++ b/arch/ppc/lib/Makefile @@ -4,7 +4,7 @@ export-objs := dec_and_lock.o -obj-y := checksum.o string.o strcase.o dec_and_lock.o +obj-y := checksum.o string.o strcase.o dec_and_lock.o div64.o obj-$(CONFIG_SMP) += locks.o diff --git a/arch/ppc/lib/div64.S b/arch/ppc/lib/div64.S new file mode 100644 index 000000000000..3527569e9926 --- /dev/null +++ b/arch/ppc/lib/div64.S @@ -0,0 +1,58 @@ +/* + * Divide a 64-bit unsigned number by a 32-bit unsigned number. + * This routine assumes that the top 32 bits of the dividend are + * non-zero to start with. + * On entry, r3 points to the dividend, which get overwritten with + * the 64-bit quotient, and r4 contains the divisor. + * On exit, r3 contains the remainder. + * + * Copyright (C) 2002 Paul Mackerras, IBM Corp. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include <asm/ppc_asm.h> +#include <asm/processor.h> + +_GLOBAL(__div64_32) + lwz r5,0(r3) # get the dividend into r5/r6 + lwz r6,4(r3) + cmplw r5,r4 + li r7,0 + li r8,0 + blt 1f + divwu r7,r5,r4 # if dividend.hi >= divisor, + mullw r0,r7,r4 # quotient.hi = dividend.hi / divisor + subf. r5,r0,r5 # dividend.hi %= divisor + beq 3f +1: mr r11,r5 # here dividend.hi != 0 + andis. r0,r5,0xc000 + bne 2f + cntlzw r0,r5 # we are shifting the dividend right + li r10,-1 # to make it < 2^32, and shifting + srw r10,r10,r0 # the divisor right the same amount, + add r9,r4,r10 # rounding up (so the estimate cannot + andc r11,r6,r10 # ever be too large, only too small) + andc r9,r9,r10 + or r11,r5,r11 + rotlw r9,r9,r0 + rotlw r11,r11,r0 + divwu r11,r11,r9 # then we divide the shifted quantities +2: mullw r10,r11,r4 # to get an estimate of the quotient, + mulhwu r9,r11,r4 # multiply the estimate by the divisor, + subfc r6,r10,r6 # take the product from the divisor, + add r8,r8,r11 # and add the estimate to the accumulated + subfe. r5,r9,r5 # quotient + bne 1b +3: cmplw r6,r4 + blt 4f + divwu r0,r6,r4 # perform the remaining 32-bit division + mullw r10,r0,r4 # and get the remainder + add r8,r8,r0 + subf r6,r10,r6 +4: stw r7,0(r3) # return the quotient in *r3 + stw r8,4(r3) + mr r3,r6 # return the remainder in r3 + blr diff --git a/arch/ppc/platforms/Makefile b/arch/ppc/platforms/Makefile index 2c2f72c81774..b90f75b8b0ab 100644 --- a/arch/ppc/platforms/Makefile +++ b/arch/ppc/platforms/Makefile @@ -37,6 +37,7 @@ obj-$(CONFIG_LOPEC) += lopec_setup.o lopec_pci.o obj-$(CONFIG_MCPN765) += mcpn765_setup.o mcpn765_pci.o obj-$(CONFIG_MENF1) += menf1_setup.o menf1_pci.o obj-$(CONFIG_MVME5100) += mvme5100_setup.o mvme5100_pci.o +obj-$(CONFIG_PAL4) += pal4_setup.o pal4_pci.o cpc700_pic.o obj-$(CONFIG_PCORE) += pcore_setup.o pcore_pci.o obj-$(CONFIG_POWERPMC250) += powerpmc250.o obj-$(CONFIG_PPLUS) += pplus_pci.o pplus_setup.o diff --git a/arch/ppc/platforms/pal4.h b/arch/ppc/platforms/pal4.h new file mode 100644 index 000000000000..ab111ff83ad6 --- /dev/null +++ b/arch/ppc/platforms/pal4.h @@ -0,0 +1,44 @@ +/* + * arch/ppc/platforms/pal4.h + * + * Definitions for SBS Palomar IV board + * + * Author: Dan Cox + * + * Copyright 2002 MontaVista Software Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __PPC_PLATFORMS_PAL4_H +#define __PPC_PLATFORMS_PAL4_H + +#define PAL4_NVRAM 0xfffc0000 +#define PAL4_NVRAM_SIZE 0x8000 + +#define PAL4_DRAM 0xfff80000 +#define PAL4_DRAM_BR_MASK 0xc0 +#define PAL4_DRAM_BR_SHIFT 6 +#define PAL4_DRAM_RESET 0x10 +#define PAL4_DRAM_EREADY 0x40 + +#define PAL4_MISC 0xfff80004 +#define PAL4_MISC_FB_MASK 0xc0 +#define PAL4_MISC_FLASH 0x20 /* StratFlash mapping: 1->0xff80, 0->0xfff0 */ +#define PAL4_MISC_MISC 0x08 +#define PAL4_MISC_BITF 0x02 +#define PAL4_MISC_NVKS 0x01 + +#define PAL4_L2 0xfff80008 +#define PAL4_L2_MASK 0x07 + +#define PAL4_PLDR 0xfff8000c + +/* Only two Ethernet devices on the board... */ +#define PAL4_ETH 31 +#define PAL4_INTA 20 + +#endif /* __PPC_PLATFORMS_PAL4_H */ diff --git a/arch/ppc/platforms/pal4_pci.c b/arch/ppc/platforms/pal4_pci.c new file mode 100644 index 000000000000..372e846f3e54 --- /dev/null +++ b/arch/ppc/platforms/pal4_pci.c @@ -0,0 +1,78 @@ +/* + * arch/ppc/platforms/pal4_pci.c + * + * PCI support for SBS Palomar IV + * + * Author: Dan Cox + * + * Copyright 2002 MontaVista Software Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/pci.h> + +#include <asm/byteorder.h> +#include <asm/machdep.h> +#include <asm/io.h> +#include <asm/pci-bridge.h> +#include <asm/uaccess.h> + +#include "cpc700.h" +#include "pal4.h" + +/* not much to this.... */ +static inline int __init +pal4_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin) +{ + if (idsel == 9) + return PAL4_ETH; + else + return PAL4_INTA + (idsel - 3); +} + +void __init +pal4_find_bridges(void) +{ + struct pci_controller *hose; + + hose = pcibios_alloc_controller(); + if (!hose) + return; + + hose->first_busno = 0; + hose->last_busno = 0xff; + hose->pci_mem_offset = 0; + + /* Could snatch these from the CPC700.... */ + pci_init_resource(&hose->io_resource, + 0x0, + 0x03ffffff, + IORESOURCE_IO, + "PCI host bridge"); + + pci_init_resource(&hose->mem_resources[0], + 0x90000000, + 0x9fffffff, + IORESOURCE_MEM, + "PCI host bridge"); + + hose->io_space.start = 0x00800000; + hose->io_space.end = 0x03ffffff; + hose->mem_space.start = 0x90000000; + hose->mem_space.end = 0x9fffffff; + hose->io_base_virt = (void *) 0xf8000000; + + setup_indirect_pci(hose, CPC700_PCI_CONFIG_ADDR, + CPC700_PCI_CONFIG_DATA); + + hose->last_busno = pciauto_bus_scan(hose, hose->first_busno); + + ppc_md.pci_swizzle = common_swizzle; + ppc_md.pci_map_irq = pal4_map_irq; +} diff --git a/arch/ppc/platforms/pal4_serial.h b/arch/ppc/platforms/pal4_serial.h new file mode 100644 index 000000000000..452486c3d226 --- /dev/null +++ b/arch/ppc/platforms/pal4_serial.h @@ -0,0 +1,41 @@ +/* + * arch/ppc/platforms/pal4_serial.h + * + * Definitions for SBS PalomarIV serial support + * + * Author: Dan Cox + * + * Copyright 2002 MontaVista Software Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#ifndef __PPC_PAL4_SERIAL_H +#define __PPC_PAL4_SERIAL_H + +#define CPC700_SERIAL_1 0xff600300 +#define CPC700_SERIAL_2 0xff600400 + +#define RS_TABLE_SIZE 2 +#define BASE_BAUD (33333333 / 4 / 16) + +#ifdef CONFIG_SERIAL_DETECT_IRQ +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST|ASYNC_AUTO_IRQ) +#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_AUTO_IRQ) +#else +#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF|ASYNC_SKIP_TEST) +#define STD_COM4_FLAGS (ASYNC_BOOT_AUTOCONF) +#endif + +#define SERIAL_PORT_DFNS \ + {0, BASE_BAUD, CPC700_SERIAL_1, 3, STD_COM_FLAGS, \ + iomem_base: (unsigned char *) CPC700_SERIAL_1, \ + io_type: SERIAL_IO_MEM}, /* ttyS0 */ \ + {0, BASE_BAUD, CPC700_SERIAL_2, 4, STD_COM_FLAGS, \ + iomem_base: (unsigned char *) CPC700_SERIAL_2, \ + io_type: SERIAL_IO_MEM} + +#endif diff --git a/arch/ppc/platforms/pal4_setup.c b/arch/ppc/platforms/pal4_setup.c new file mode 100644 index 000000000000..f4ad2252da2f --- /dev/null +++ b/arch/ppc/platforms/pal4_setup.c @@ -0,0 +1,176 @@ +/* + * arch/ppc/platforms/pal4_setup.c + * + * Board setup routines for the SBS PalomarIV. + * + * Author: Dan Cox + * + * Copyright 2002 MontaVista Software Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/config.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/types.h> +#include <linux/errno.h> +#include <linux/reboot.h> +#include <linux/time.h> +#include <linux/irq.h> +#include <linux/kdev_t.h> +#include <linux/blk.h> +#include <linux/console.h> +#include <linux/seq_file.h> +#include <linux/root_dev.h> + +#include <asm/io.h> +#include <asm/todc.h> +#include <asm/bootinfo.h> + +#include "cpc700.h" +#include "pal4.h" + +extern void pal4_find_bridges(void); + +unsigned int cpc700_irq_assigns[][2] = { + {1, 1}, /* IRQ 0: ECC correctable error */ + {1, 1}, /* IRQ 1: PCI write to memory range */ + {0, 1}, /* IRQ 2: PCI write to command register */ + {0, 1}, /* IRQ 3: UART 0 */ + {0, 1}, /* IRQ 4: UART 1 */ + {0, 1}, /* IRQ 5: ICC 0 */ + {0, 1}, /* IRQ 6: ICC 1 */ + {0, 1}, /* IRQ 7: GPT compare 0 */ + {0, 1}, /* IRQ 8: GPT compare 1 */ + {0, 1}, /* IRQ 9: GPT compare 2 */ + {0, 1}, /* IRQ 10: GPT compare 3 */ + {0, 1}, /* IRQ 11: GPT compare 4 */ + {0, 1}, /* IRQ 12: GPT capture 0 */ + {0, 1}, /* IRQ 13: GPT capture 1 */ + {0, 1}, /* IRQ 14: GPT capture 2 */ + {0, 1}, /* IRQ 15: GPT capture 3 */ + {0, 1}, /* IRQ 16: GPT capture 4 */ + {0, 0}, /* IRQ 17: reserved */ + {0, 0}, /* IRQ 18: reserved */ + {0, 0}, /* IRQ 19: reserved */ + {0, 0}, /* IRQ 20: reserved */ + {0, 1}, /* IRQ 21: Ethernet */ + {0, 0}, /* IRQ 22: reserved */ + {0, 0}, /* IRQ 23: reserved */ + {0, 0}, /* IRQ 24: resreved */ + {0, 0}, /* IRQ 25: reserved */ + {0, 0}, /* IRQ 26: reserved */ + {0, 0}, /* IRQ 27: reserved */ + {0, 0}, /* IRQ 28: reserved */ + {0, 0}, /* IRQ 29: reserved */ + {0, 0}, /* IRQ 30: reserved */ + {0, 0}, /* IRQ 31: reserved */ +}; + +static int +pal4_show_cpuinfo(struct seq_file *m) +{ + seq_printf(m, "board\t\t: SBS Palomar IV\n"); + + return 0; +} + +static void +pal4_restart(char *cmd) +{ + __cli(); + __asm__ __volatile__("lis 3,0xfff0\n \ + ori 3,3,0x100\n \ + mtspr 26,3\n \ + li 3,0\n \ + mtspr 27,3\n \ + rfi"); + + for(;;); +} + +static void +pal4_power_off(void) +{ + __cli(); + for(;;); +} + +static void +pal4_halt(void) +{ + pal4_power_off(); +} + +TODC_ALLOC(); + +static void __init +pal4_setup_arch(void) +{ + unsigned long l2; + + TODC_INIT(TODC_TYPE_MK48T37, 0, 0, + ioremap(PAL4_NVRAM, PAL4_NVRAM_SIZE), 8); + + pal4_find_bridges(); + +#ifdef CONFIG_BLK_DEV_INITRD + if (initrd_start) + ROOT_DEV = Root_RAM0; + else +#endif + ROOT_DEV = Root_NFS; + + /* The L2 gets disabled in the bootloader, but all the proper + bits should be present from the fw, so just re-enable it */ + l2 = _get_L2CR(); + if (!(l2 & L2CR_L2E)) { + /* presume that it was initially set if the size is + still present. */ + if (l2 ^ L2CR_L2SIZ_MASK) + _set_L2CR(l2 | L2CR_L2E); + else + printk("L2 not set by firmware; left disabled.\n"); + } +} + +static void __init +pal4_map_io(void) +{ + io_block_mapping(0xf0000000, 0xf0000000, 0x10000000, _PAGE_IO); +} + +void __init +platform_init(unsigned long r3, unsigned long r4, unsigned long r5, + unsigned long r6, unsigned long r7) +{ + parse_bootinfo(find_bootinfo()); + + isa_io_base = 0 /*PAL4_ISA_IO_BASE*/; + pci_dram_offset = 0 /*PAL4_PCI_SYS_MEM_BASE*/; + + ppc_md.setup_arch = pal4_setup_arch; + ppc_md.show_cpuinfo = pal4_show_cpuinfo; + + ppc_md.setup_io_mappings = pal4_map_io; + + ppc_md.init_IRQ = cpc700_init_IRQ; + ppc_md.get_irq = cpc700_get_irq; + + ppc_md.restart = pal4_restart; + ppc_md.halt = pal4_halt; + ppc_md.power_off = pal4_power_off; + + ppc_md.time_init = todc_time_init; + ppc_md.set_rtc_time = todc_set_rtc_time; + ppc_md.get_rtc_time = todc_get_rtc_time; + ppc_md.calibrate_decr = todc_calibrate_decr; + + ppc_md.nvram_read_val = todc_direct_read_val; + ppc_md.nvram_write_val = todc_direct_write_val; +} + diff --git a/arch/ppc/platforms/pcore_setup.c b/arch/ppc/platforms/pcore_setup.c index 14a01e866b07..06dcf811447e 100644 --- a/arch/ppc/platforms/pcore_setup.c +++ b/arch/ppc/platforms/pcore_setup.c @@ -168,13 +168,7 @@ pcore_init_IRQ(void) for ( i = 0 ; i < 16 ; i++ ) irq_desc[i].handler = &i8259_pic; - i8259_init(NULL); -} - -static int -pcore_get_irq(struct pt_regs *regs) -{ - return i8259_poll(); + i8259_init(0); } /* @@ -184,22 +178,16 @@ static __inline__ void pcore_set_bat(void) { unsigned long bat3u, bat3l; - static int mapping_set = 0; - - if (!mapping_set) { - __asm__ __volatile__( - " lis %0,0xf000\n \ - ori %1,%0,0x002a\n \ - ori %0,%0,0x1ffe\n \ - mtspr 0x21e,%0\n \ - mtspr 0x21f,%1\n \ - isync\n \ - sync " - : "=r" (bat3u), "=r" (bat3l)); - - mapping_set = 1; - } - return; + + __asm__ __volatile__( + " lis %0,0xf000\n \ + ori %1,%0,0x002a\n \ + ori %0,%0,0x1ffe\n \ + mtspr 0x21e,%0\n \ + mtspr 0x21f,%1\n \ + isync\n \ + sync " + : "=r" (bat3u), "=r" (bat3l)); } static unsigned long __init @@ -233,7 +221,7 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5, ppc_md.setup_arch = pcore_setup_arch; ppc_md.show_cpuinfo = pcore_show_cpuinfo; ppc_md.init_IRQ = pcore_init_IRQ; - ppc_md.get_irq = pcore_get_irq; + ppc_md.get_irq = i8259_irq; ppc_md.find_end_of_memory = pcore_find_end_of_memory; ppc_md.setup_io_mappings = pcore_map_io; diff --git a/arch/ppc/vmlinux.lds.S b/arch/ppc/vmlinux.lds.S index cc8b249ddd13..a934f99f3274 100644 --- a/arch/ppc/vmlinux.lds.S +++ b/arch/ppc/vmlinux.lds.S @@ -87,9 +87,9 @@ SECTIONS . = ALIGN(4096); __init_begin = .; - .text.init : { *(.text.init) } - .data.init : { - *(.data.init); + .init.text : { *(.init.text) } + .init.data : { + *(.init.data); __vtop_table_begin = .; *(.vtop_fixup); __vtop_table_end = .; @@ -99,7 +99,7 @@ SECTIONS } . = ALIGN(16); __setup_start = .; - .setup.init : { *(.setup.init) } + .init.setup : { *(.init.setup) } __setup_end = .; __initcall_start = .; .initcall.init : { @@ -121,29 +121,29 @@ SECTIONS . = ALIGN(4096); __pmac_begin = .; - .text.pmac : { *(.text.pmac) } - .data.pmac : { *(.data.pmac) } + .pmac.text : { *(.pmac.text) } + .pmac.data : { *(.pmac.data) } . = ALIGN(4096); __pmac_end = .; . = ALIGN(4096); __prep_begin = .; - .text.prep : { *(.text.prep) } - .data.prep : { *(.data.prep) } + .prep.text : { *(.prep.text) } + .prep.data : { *(.prep.data) } . = ALIGN(4096); __prep_end = .; . = ALIGN(4096); __chrp_begin = .; - .text.chrp : { *(.text.chrp) } - .data.chrp : { *(.data.chrp) } + .chrp.text : { *(.chrp.text) } + .chrp.data : { *(.chrp.data) } . = ALIGN(4096); __chrp_end = .; . = ALIGN(4096); __openfirmware_begin = .; - .text.openfirmware : { *(.text.openfirmware) } - .data.openfirmware : { *(.data.openfirmware) } + .openfirmware.text : { *(.openfirmware.text) } + .openfirmware.data : { *(.openfirmware.data) } . = ALIGN(4096); __openfirmware_end = .; diff --git a/arch/ppc64/kernel/sys_ppc32.c b/arch/ppc64/kernel/sys_ppc32.c index 4da5a00d54d3..045ddbe964f0 100644 --- a/arch/ppc64/kernel/sys_ppc32.c +++ b/arch/ppc64/kernel/sys_ppc32.c @@ -333,12 +333,15 @@ static void *do_smb_super_data_conv(void *raw_data) struct smb_mount_data *s = (struct smb_mount_data *)raw_data; struct smb_mount_data32 *s32 = (struct smb_mount_data32 *)raw_data; + if (s32->version != SMB_MOUNT_OLDVERSION) + goto out; s->version = s32->version; s->mounted_uid = s32->mounted_uid; s->uid = s32->uid; s->gid = s32->gid; s->file_mode = s32->file_mode; s->dir_mode = s32->dir_mode; +out: return raw_data; } diff --git a/arch/s390x/kernel/linux32.c b/arch/s390x/kernel/linux32.c index 4d52a49cccf8..8490920b29b3 100644 --- a/arch/s390x/kernel/linux32.c +++ b/arch/s390x/kernel/linux32.c @@ -1563,12 +1563,15 @@ static void *do_smb_super_data_conv(void *raw_data) struct smb_mount_data *s = (struct smb_mount_data *)raw_data; struct smb_mount_data32 *s32 = (struct smb_mount_data32 *)raw_data; + if (s32->version != SMB_MOUNT_OLDVERSION) + goto out; s->version = s32->version; s->mounted_uid = low2highuid(s32->mounted_uid); s->uid = low2highuid(s32->uid); s->gid = low2highgid(s32->gid); s->file_mode = s32->file_mode; s->dir_mode = s32->dir_mode; +out: return raw_data; } diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile index 9aab951ad642..24dcb2ca05b8 100644 --- a/arch/sparc/Makefile +++ b/arch/sparc/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.49 2001/07/27 09:42:22 davem Exp $ +# # sparc/Makefile # # Makefile for the architecture dependent flags and dependencies on the @@ -47,16 +47,24 @@ image: vmlinux $(MAKE) -C arch/sparc/boot image archclean: + rm -f arch/sparc/kernel/include rm -f $(TOPDIR)/vmlinux.aout -$(MAKE) -C arch/sparc/boot clean archmrproper: rm -f $(TOPDIR)/include/asm-sparc/asm_offsets.h -prepare: check_asm +prepare: include/asm-$(ARCH)/asm_offsets.h + +arch/$(ARCH)/kernel/asm-offsets.s: include/asm include/linux/version.h \ + include/config/MARKER + +include/asm-$(ARCH)/asm_offsets.h.tmp: arch/$(ARCH)/kernel/asm-offsets.s + @$(generate-asm-offsets.h) < $< > $@ -check_asm: include/linux/version.h include/asm include/config/MARKER - $(MAKE) -C arch/sparc/kernel check_asm +include/asm-$(ARCH)/asm_offsets.h: include/asm-$(ARCH)/asm_offsets.h.tmp + @echo -n ' Generating $@' + @$(update-if-changed) tftpboot.img: $(MAKE) -C arch/sparc/boot tftpboot.img diff --git a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile index dbe551f3cd63..ebc035a23e29 100644 --- a/arch/sparc/boot/Makefile +++ b/arch/sparc/boot/Makefile @@ -23,7 +23,7 @@ clean: rm -f btfixupprep piggyback tftpboot.img btfix.o btfix.s image BTOBJS := $(HEAD) $(init-y) -BTLIBS := $(core-y) $(LIBS) $(drivers-y) $(net-y) +BTLIBS := $(core-y) $(libs-y) $(drivers-y) $(net-y) # Actual linking image: btfix.o diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile index 69bab606ea3f..6adecbe49035 100644 --- a/arch/sparc/kernel/Makefile +++ b/arch/sparc/kernel/Makefile @@ -28,95 +28,3 @@ obj-y += sys_sunos.o sunos_ioctl.o endif include $(TOPDIR)/Rules.make - -HPATH := $(objtree)/include - -check_asm: FORCE - @if [ ! -r $(HPATH)/asm/asm_offsets.h ] ; then \ - touch $(HPATH)/asm/asm_offsets.h ; \ - fi - @echo "/* Automatically generated. Do not edit. */" > asm_offsets.h - @echo "#ifndef __ASM_OFFSETS_H__" >> asm_offsets.h - @echo "#define __ASM_OFFSETS_H__" >> asm_offsets.h - @echo "" >> asm_offsets.h - @echo "#include <linux/config.h>" >> asm_offsets.h - @echo "" >> asm_offsets.h - @echo "#ifndef CONFIG_SMP" >> asm_offsets.h - @echo "" >> asm_offsets.h - @echo "#include <linux/config.h>" > tmp.c - @echo "#undef CONFIG_SMP" >> tmp.c - @echo "#include <linux/sched.h>" >> tmp.c - $(CPP) $(CPPFLAGS) tmp.c -o tmp.i - @echo "/* Automatically generated. Do not edit. */" > check_asm_data.c - @echo "#include <linux/config.h>" >> check_asm_data.c - @echo "#undef CONFIG_SMP" >> check_asm_data.c - @echo "#include <linux/sched.h>" >> check_asm_data.c - @echo "unsigned int check_asm_data[] = {" >> check_asm_data.c - $(SH) ./check_asm.sh -data task tmp.i check_asm_data.c - $(SH) ./check_asm.sh -data mm tmp.i check_asm_data.c - $(SH) ./check_asm.sh -data thread tmp.i check_asm_data.c - @echo '};' >> check_asm_data.c - $(CC) $(CFLAGS) -S -o check_asm_data.s check_asm_data.c - @echo "/* Automatically generated. Do not edit. */" > check_asm.c - @echo 'extern int printf(const char *fmt, ...);' >>check_asm.c - @echo "unsigned int check_asm_data[] = {" >> check_asm.c - $(SH) ./check_asm.sh -ints check_asm_data.s check_asm.c - @echo "};" >> check_asm.c - @echo 'int main(void) {' >> check_asm.c - @echo 'int i = 0;' >> check_asm.c - $(SH) ./check_asm.sh -printf task tmp.i check_asm.c - $(SH) ./check_asm.sh -printf mm tmp.i check_asm.c - $(SH) ./check_asm.sh -printf thread tmp.i check_asm.c - @echo 'return 0; }' >> check_asm.c - @rm -f tmp.[ci] check_asm_data.[cs] - $(HOSTCC) -o check_asm check_asm.c - ./check_asm >> asm_offsets.h - @rm -f check_asm check_asm.c - @echo "" >> asm_offsets.h - @echo "#else /* CONFIG_SMP */" >> asm_offsets.h - @echo "" >> asm_offsets.h - @echo "#include <linux/config.h>" > tmp.c - @echo "#undef CONFIG_SMP" >> tmp.c - @echo "#define CONFIG_SMP 1" >> tmp.c - @echo "#include <linux/sched.h>" >> tmp.c - $(CPP) $(CPPFLAGS) tmp.c -o tmp.i - @echo "/* Automatically generated. Do not edit. */" > check_asm_data.c - @echo "#include <linux/config.h>" >> check_asm_data.c - @echo "#undef CONFIG_SMP" >> check_asm_data.c - @echo "#define CONFIG_SMP 1" >> check_asm_data.c - @echo "#include <linux/sched.h>" >> check_asm_data.c - @echo "unsigned int check_asm_data[] = {" >> check_asm_data.c - $(SH) ./check_asm.sh -data task tmp.i check_asm_data.c - $(SH) ./check_asm.sh -data mm tmp.i check_asm_data.c - $(SH) ./check_asm.sh -data thread tmp.i check_asm_data.c - @echo '};' >> check_asm_data.c - $(CC) $(CFLAGS) -S -o check_asm_data.s check_asm_data.c - @echo "/* Automatically generated. Do not edit. */" > check_asm.c - @echo 'extern int printf(const char *fmt, ...);' >>check_asm.c - @echo "unsigned int check_asm_data[] = {" >> check_asm.c - $(SH) ./check_asm.sh -ints check_asm_data.s check_asm.c - @echo "};" >> check_asm.c - @echo 'int main(void) {' >> check_asm.c - @echo 'int i = 0;' >> check_asm.c - $(SH) ./check_asm.sh -printf task tmp.i check_asm.c - $(SH) ./check_asm.sh -printf mm tmp.i check_asm.c - $(SH) ./check_asm.sh -printf thread tmp.i check_asm.c - @echo 'return 0; }' >> check_asm.c - @rm -f tmp.[ci] check_asm_data.[cs] - $(HOSTCC) -o check_asm check_asm.c - ./check_asm >> asm_offsets.h - @rm -f check_asm check_asm.c - @echo "" >> asm_offsets.h - @echo "#endif /* CONFIG_SMP */" >> asm_offsets.h - @echo "" >> asm_offsets.h - @echo "#endif /* __ASM_OFFSETS_H__ */" >> asm_offsets.h - @if test -r $(HPATH)/asm/asm_offsets.h; then \ - if cmp -s asm_offsets.h $(HPATH)/asm/asm_offsets.h; then \ - echo $(HPATH)/asm/asm_offsets.h is unchanged; \ - rm -f asm_offsets.h; \ - else \ - mv -f asm_offsets.h $(HPATH)/asm/asm_offsets.h; \ - fi; \ - else \ - mv -f asm_offsets.h $(HPATH)/asm/asm_offsets.h; \ - fi diff --git a/arch/sparc/kernel/asm-offsets.c b/arch/sparc/kernel/asm-offsets.c new file mode 100644 index 000000000000..fa2e8a95ca45 --- /dev/null +++ b/arch/sparc/kernel/asm-offsets.c @@ -0,0 +1,53 @@ +/* + * This program is used to generate definitions needed by + * assembly language modules. + * + * We use the technique used in the OSF Mach kernel code: + * generate asm statements containing #defines, + * compile this file to assembler, and then extract the + * #defines from the assembly-language output. + * + * On sparc, thread_info data is static and TI_XXX offsets are computed by hand. + */ + +#include <linux/config.h> +#include <linux/sched.h> +// #include <linux/mm.h> + +#define DEFINE(sym, val) \ + asm volatile("\n->" #sym " %0 " #val : : "i" (val)) + +#define BLANK() asm volatile("\n->" : : ) + +int foo(void) +{ + DEFINE(AOFF_task_thread, offsetof(struct task_struct, thread)); + DEFINE(AOFF_task_ptrace, offsetof(struct task_struct, ptrace)); + DEFINE(AOFF_task_blocked, offsetof(struct task_struct, blocked)); + BLANK(); + /* XXX This is the stuff for sclow.S, kill it. */ + DEFINE(AOFF_task_pid, offsetof(struct task_struct, pid)); + DEFINE(AOFF_task_uid, offsetof(struct task_struct, uid)); + DEFINE(AOFF_task_gid, offsetof(struct task_struct, gid)); + DEFINE(AOFF_task_euid, offsetof(struct task_struct, euid)); + DEFINE(AOFF_task_egid, offsetof(struct task_struct, egid)); + /* DEFINE(THREAD_INFO, offsetof(struct task_struct, thread_info)); */ + DEFINE(ASIZ_task_uid, sizeof(current->uid)); + DEFINE(ASIZ_task_gid, sizeof(current->gid)); + DEFINE(ASIZ_task_euid, sizeof(current->euid)); + DEFINE(ASIZ_task_egid, sizeof(current->egid)); + BLANK(); + DEFINE(AOFF_thread_fork_kpsr, + offsetof(struct thread_struct, fork_kpsr)); + BLANK(); + DEFINE(AOFF_thread_w_saved, offsetof(struct thread_struct, w_saved)); + DEFINE(AOFF_thread_rwbuf_stkptrs, + offsetof(struct thread_struct, rwbuf_stkptrs)); + DEFINE(AOFF_thread_reg_window, + offsetof(struct thread_struct, reg_window)); + BLANK(); + DEFINE(AOFF_mm_context, offsetof(struct mm_struct, context)); + + /* DEFINE(NUM_USER_SEGMENTS, TASK_SIZE>>28); */ + return 0; +} diff --git a/arch/sparc/kernel/check_asm.sh b/arch/sparc/kernel/check_asm.sh deleted file mode 100755 index a4d5e6d95708..000000000000 --- a/arch/sparc/kernel/check_asm.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -case $1 in - -printf) - sed -n -e '/^#/d;/struct[ ]*'$2'_struct[ ]*{/,/};/p' < $3 | sed '/struct[ ]*'$2'_struct[ ]*{/d;/:[0-9]*[ ]*;/d;/^[ ]*$/d;/};/d;s/^[ ]*//;s/volatile[ ]*//;s/\(unsigned\|signed\|struct\)[ ]*//;s/\(\[\|__attribute__\).*;[ ]*$//;s/(\*//;s/)(.*)//;s/;[ ]*$//;s/^[^ ]*[ ]*//;s/,/\ -/g' | sed 's/^[ *]*//;s/[ ]*$//;s/^.*$/printf ("#define AOFF_'$2'_\0 0x%08x\\n", check_asm_data[i++]); printf("#define ASIZ_'$2'_\0 0x%08x\\n", check_asm_data[i++]);/' >> $4 - echo "printf (\"#define ASIZ_$2\\t0x%08x\\n\", check_asm_data[i++]);" >> $4 - ;; - -data) - sed -n -e '/^#/d;/struct[ ]*'$2'_struct[ ]*{/,/};/p' < $3 | sed '/struct[ ]*'$2'_struct[ ]*{/d;/:[0-9]*[ ]*;/d;/^[ ]*$/d;/};/d;s/^[ ]*//;s/volatile[ ]*//;s/\(unsigned\|signed\|struct\)[ ]*//;s/\(\[\|__attribute__\).*;[ ]*$//;s/(\*//;s/)(.*)//;s/;[ ]*$//;s/^[^ ]*[ ]*//;s/,/\ -/g' | sed 's/^[ *]*//;s/[ ]*$//;s/^.*$/ ((char *)\&((struct '$2'_struct *)0)->\0) - ((char *)((struct '$2'_struct *)0)), sizeof(((struct '$2'_struct *)0)->\0),/' >> $4 - echo " sizeof(struct $2_struct)," >> $4 - ;; - -ints) - sed -n -e '/check_asm_data:/,/\.size/p' <$2 | sed -e 's/check_asm_data://' -e 's/\.size.*//' -e 's/\.ident.*//' -e 's/\.global.*//' -e 's/\.long[ ]\([0-9]*\)/\1,/' >>$3 ;; - *) - exit 1 - ;; -esac -exit 0 diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S index 0e3396ed5cfd..2e6d220cd8f0 100644 --- a/arch/sparc/kernel/entry.S +++ b/arch/sparc/kernel/entry.S @@ -17,6 +17,7 @@ #include <asm/kgdb.h> #include <asm/contregs.h> #include <asm/ptrace.h> +#include <asm/asm_offsets.h> #include <asm/psr.h> #include <asm/cprefix.h> #include <asm/vaddrs.h> diff --git a/arch/sparc/kernel/etrap.S b/arch/sparc/kernel/etrap.S index 4a98b3ca42b9..fc4979449d07 100644 --- a/arch/sparc/kernel/etrap.S +++ b/arch/sparc/kernel/etrap.S @@ -12,6 +12,7 @@ #include <asm/page.h> #include <asm/psr.h> #include <asm/ptrace.h> +#include <asm/asm_offsets.h> #include <asm/winmacro.h> #include <asm/asmmacro.h> #include <asm/thread_info.h> diff --git a/arch/sparc/kernel/rtrap.S b/arch/sparc/kernel/rtrap.S index 814be2e57645..19251358f3d9 100644 --- a/arch/sparc/kernel/rtrap.S +++ b/arch/sparc/kernel/rtrap.S @@ -7,6 +7,7 @@ #include <asm/cprefix.h> #include <asm/page.h> #include <asm/ptrace.h> +#include <asm/asm_offsets.h> #include <asm/psr.h> #include <asm/asi.h> #include <asm/smp.h> diff --git a/arch/sparc/kernel/sclow.S b/arch/sparc/kernel/sclow.S index 1ad511f4f4dc..594783abc295 100644 --- a/arch/sparc/kernel/sclow.S +++ b/arch/sparc/kernel/sclow.S @@ -36,18 +36,6 @@ LABEL(sunosnop): CC_AND_RETT -#if 0 -/* Not SMP safe */ - .globl LABEL(sunosgetpid) -LABEL(sunosgetpid): - LOAD_CURRENT(l4, l5) - ld [%l4 + TI_TASK], %l4 - ld [%l4 + AOFF_task_pid], %i0 - ld [%l4 + AOFF_task_p_opptr], %l5 - ld [%l5 + AOFF_task_pid], %i1 - CC_AND_RETT -#endif - #if (ASIZ_task_uid == 2 && ASIZ_task_euid == 2) .globl LABEL(sunosgetuid) LABEL(sunosgetuid): diff --git a/arch/sparc/kernel/wof.S b/arch/sparc/kernel/wof.S index fb107aadadd3..f7aff720df94 100644 --- a/arch/sparc/kernel/wof.S +++ b/arch/sparc/kernel/wof.S @@ -8,6 +8,7 @@ #include <asm/contregs.h> #include <asm/page.h> #include <asm/ptrace.h> +#include <asm/asm_offsets.h> #include <asm/psr.h> #include <asm/smp.h> #include <asm/asi.h> diff --git a/arch/sparc/kernel/wuf.S b/arch/sparc/kernel/wuf.S index 7b924013a396..221f61e69613 100644 --- a/arch/sparc/kernel/wuf.S +++ b/arch/sparc/kernel/wuf.S @@ -8,6 +8,7 @@ #include <asm/contregs.h> #include <asm/page.h> #include <asm/ptrace.h> +#include <asm/asm_offsets.h> #include <asm/psr.h> #include <asm/smp.h> #include <asm/asi.h> diff --git a/arch/sparc/vmlinux.lds.S b/arch/sparc/vmlinux.lds.S index f02a3045400c..6403f5398d5d 100644 --- a/arch/sparc/vmlinux.lds.S +++ b/arch/sparc/vmlinux.lds.S @@ -38,12 +38,12 @@ SECTIONS . = ALIGN(4096); __init_begin = .; - .text.init : { *(.text.init) } + .init.text : { *(.init.text) } __init_text_end = .; - .data.init : { *(.data.init) } + .init.data : { *(.init.data) } . = ALIGN(16); __setup_start = .; - .setup_init : { *(.setup.init) } + .init.setup : { *(.init.setup) } __setup_end = .; __initcall_start = .; .initcall.init : { diff --git a/arch/sparc64/kernel/sys_sparc32.c b/arch/sparc64/kernel/sys_sparc32.c index 9b62bbe3a655..388b557b015c 100644 --- a/arch/sparc64/kernel/sys_sparc32.c +++ b/arch/sparc64/kernel/sys_sparc32.c @@ -1582,6 +1582,8 @@ static void *do_smb_super_data_conv(void *raw_data) struct smb_mount_data news, *s = &news; struct smb_mount_data32 *s32 = (struct smb_mount_data32 *)raw_data; + if (s32->version != SMB_MOUNT_OLDVERSION) + goto out; s->version = s32->version; s->mounted_uid = low2highuid(s32->mounted_uid); s->uid = low2highuid(s32->uid); @@ -1589,6 +1591,7 @@ static void *do_smb_super_data_conv(void *raw_data) s->file_mode = s32->file_mode; s->dir_mode = s32->dir_mode; memcpy(raw_data, s, sizeof(struct smb_mount_data)); +out: return raw_data; } diff --git a/arch/sparc64/vmlinux.lds.S b/arch/sparc64/vmlinux.lds.S index dd256448c7b2..50baaf6f3c4c 100644 --- a/arch/sparc64/vmlinux.lds.S +++ b/arch/sparc64/vmlinux.lds.S @@ -40,11 +40,11 @@ SECTIONS __stop___kallsyms = .; . = ALIGN(8192); __init_begin = .; - .text.init : { *(.text.init) } - .data.init : { *(.data.init) } + .init.text : { *(.init.text) } + .init.data : { *(.init.data) } . = ALIGN(16); __setup_start = .; - .setup_init : { *(.setup.init) } + .init.setup : { *(.init.setup) } __setup_end = .; __initcall_start = .; .initcall.init : { diff --git a/arch/um/Makefile b/arch/um/Makefile index f4265f94529b..dd28bfdb90b9 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -70,7 +70,7 @@ LDFLAGS_vmlinux = -r $(ARCH_DIR)/main.o vmlinux: $(ARCH_DIR)/main.o -$(ARCH_DIR)/uml.lds.s : $(ARCH_DIR)/uml.lds.S +$(ARCH_DIR)/uml.lds.s : $(ARCH_DIR)/uml.lds.S scripts FORCE $(call if_changed_dep,as_s_S) AFLAGS_uml.lds.o = -U$(SUBARCH) -DSTART=$$(($(TOP_ADDR) - $(SIZE))) \ diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 68c8e1ca81d1..f961e21e68fb 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -51,22 +51,19 @@ static int ubd_open(struct inode * inode, struct file * filp); static int ubd_release(struct inode * inode, struct file * file); static int ubd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg); -static int ubd_revalidate(kdev_t rdev); +static int ubd_revalidate(struct gendisk *disk); #define MAX_DEV (8) -#define MAX_MINOR (MAX_DEV << UBD_SHIFT) - -#define DEVICE_NR(n) (minor(n) >> UBD_SHIFT) static struct block_device_operations ubd_blops = { - .open = ubd_open, - .release = ubd_release, - .ioctl = ubd_ioctl, - .revalidate = ubd_revalidate, + .open = ubd_open, + .release = ubd_release, + .ioctl = ubd_ioctl, + .revalidate_disk= ubd_revalidate, }; /* Protected by the queue_lock */ -static request_queue_t *ubd_queue; +static request_queue_t ubd_queue; /* Protected by ubd_lock */ static int fake_major = 0; @@ -347,30 +344,31 @@ int thread_fd = -1; */ int intr_count = 0; -static void ubd_finish(int error) +static void ubd_finish(struct request *req, int error) { int nsect; if(error){ spin_lock(&ubd_io_lock); - end_request(CURRENT, 0); + end_request(req, 0); spin_unlock(&ubd_io_lock); return; } - nsect = CURRENT->current_nr_sectors; - CURRENT->sector += nsect; - CURRENT->buffer += nsect << 9; - CURRENT->errors = 0; - CURRENT->nr_sectors -= nsect; - CURRENT->current_nr_sectors = 0; + nsect = req->current_nr_sectors; + req->sector += nsect; + req->buffer += nsect << 9; + req->errors = 0; + req->nr_sectors -= nsect; + req->current_nr_sectors = 0; spin_lock(&ubd_io_lock); - end_request(CURRENT, 1); + end_request(req, 1); spin_unlock(&ubd_io_lock); } static void ubd_handler(void) { struct io_thread_req req; + struct request *rq = elv_next_request(&ubd_queue); int n; do_ubd = NULL; @@ -380,18 +378,18 @@ static void ubd_handler(void) printk(KERN_ERR "Pid %d - spurious interrupt in ubd_handler, " "errno = %d\n", os_getpid(), -n); spin_lock(&ubd_io_lock); - end_request(CURRENT, 0); + end_request(rq, 0); spin_unlock(&ubd_io_lock); return; } - if((req.offset != ((__u64) (CURRENT->sector)) << 9) || - (req.length != (CURRENT->current_nr_sectors) << 9)) + if((req.offset != ((__u64) (rq->sector)) << 9) || + (req.length != (rq->current_nr_sectors) << 9)) panic("I/O op mismatch"); - ubd_finish(req.error); + ubd_finish(rq, req.error); reactivate_fd(thread_fd, UBD_IRQ); - do_ubd_request(ubd_queue); + do_ubd_request(&ubd_queue); } static void ubd_intr(int irq, void *dev, struct pt_regs *unused) @@ -483,9 +481,13 @@ static int ubd_add(int n) goto out_unregister; ubd_dev[n].fake = fake; + fake_disk->private_data = &ubd_dev[n]; + fake_disk->queue = &ubd_queue; add_disk(fake_disk); } + disk->private_data = &ubd_dev[n]; + disk->queue = &ubd_queue; add_disk(disk); make_ide_entries(disk->disk_name); return(0); @@ -574,11 +576,6 @@ static int ubd_mc_init(void) __initcall(ubd_mc_init); -static request_queue_t *ubd_get_queue(kdev_t device) -{ - return(ubd_queue); -} - int ubd_init(void) { int i; @@ -588,9 +585,8 @@ int ubd_init(void) printk(KERN_ERR "ubd: unable to get major %d\n", MAJOR_NR); return -1; } - ubd_queue = BLK_DEFAULT_QUEUE(MAJOR_NR); - blk_init_queue(ubd_queue, do_ubd_request, &ubd_io_lock); - elevator_init(ubd_queue, &elevator_noop); + blk_init_queue(&ubd_queue, do_ubd_request, &ubd_io_lock); + elevator_init(&ubd_queue, &elevator_noop); if(fake_major != 0){ char name[sizeof("ubd_nnn\0")]; @@ -601,7 +597,6 @@ int ubd_init(void) fake_major); return -1; } - blk_dev[fake_major].queue = ubd_get_queue; } for(i = 0; i < MAX_DEV; i++) ubd_add(i); @@ -698,8 +693,8 @@ static int ubd_open_dev(struct ubd *dev) static int ubd_open(struct inode *inode, struct file *filp) { - int n = DEVICE_NR(inode->i_rdev); - struct ubd *dev = &ubd_dev[n]; + struct gendisk *disk = inode->i_bdev->bd_disk; + struct ubd *dev = disk->private_data; int err; if(dev->is_dir == 1) goto out; @@ -709,8 +704,8 @@ static int ubd_open(struct inode *inode, struct file *filp) err = ubd_open_dev(dev); if(err){ - printk(KERN_ERR "ubd%d: Can't open \"%s\": " - "errno = %d\n", n, dev->file, -err); + printk(KERN_ERR "%s: Can't open \"%s\": " + "errno = %d\n", disk->disk_name, dev->file, -err); goto out; } } @@ -725,9 +720,10 @@ static int ubd_open(struct inode *inode, struct file *filp) static int ubd_release(struct inode * inode, struct file * file) { - int n = DEVICE_NR(inode->i_rdev); - if(--ubd_dev[n].count == 0) - ubd_close(&ubd_dev[n]); + struct gendisk *disk = inode->i_bdev->bd_disk; + struct ubd *dev = disk->private_data; + if(dev->count == 0) + ubd_close(dev); return(0); } @@ -771,15 +767,13 @@ void cowify_req(struct io_thread_req *req, struct ubd *dev) static int prepare_request(struct request *req, struct io_thread_req *io_req) { - struct ubd *dev; + struct gendisk *disk = req->rq_disk; + struct ubd *dev = disk->private_data; __u64 block; - int nsect, min, n; + int nsect; - if(req->rq_status == RQ_INACTIVE) return(1); + if (req->rq_status == RQ_INACTIVE) return(1); - min = minor(req->rq_dev); - n = min >> UBD_SHIFT; - dev = &ubd_dev[n]; if(dev->is_dir){ strcpy(req->buffer, "HOSTFS:"); strcat(req->buffer, dev->file); @@ -790,7 +784,7 @@ static int prepare_request(struct request *req, struct io_thread_req *io_req) } if((rq_data_dir(req) == WRITE) && !dev->openflags.w){ - printk("Write attempted on readonly ubd device %d\n", n); + printk("Write attempted on readonly ubd device %s\n", disk->disk_name); spin_lock(&ubd_io_lock); end_request(req, 0); spin_unlock(&ubd_io_lock); @@ -829,7 +823,7 @@ static void do_ubd_request(request_queue_t *q) err = prepare_request(req, &io_req); if(!err){ do_io(&io_req); - ubd_finish(io_req.error); + ubd_finish(req, io_req.error); } } } @@ -852,21 +846,15 @@ static int ubd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg) { struct hd_geometry *loc = (struct hd_geometry *) arg; + struct ubd *dev = inode->i_bdev->bd_disk->private_data; + int err; struct ubd *dev; - int n, min, err; struct hd_driveid ubd_id = { .cyls = 0, .heads = 128, .sectors = 32, }; - - if(!inode) return(-EINVAL); - min = minor(inode->i_rdev); - n = min >> UBD_SHIFT; - if(n > MAX_DEV) - return(-EINVAL); - dev = &ubd_dev[n]; switch (cmd) { struct hd_geometry g; struct cdrom_volctrl volume; @@ -880,7 +868,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file, case HDIO_SET_UNMASKINTR: if(!capable(CAP_SYS_ADMIN)) return(-EACCES); - if((arg > 1) || (min & ((1 << UBD_SHIFT) - 1))) + if((arg > 1) || inode->i_bdev->bd_contains != inode->i_bdev) return(-EINVAL); return(0); @@ -900,7 +888,7 @@ static int ubd_ioctl(struct inode * inode, struct file * file, case HDIO_SET_MULTCOUNT: if(!capable(CAP_SYS_ADMIN)) return(-EACCES); - if(min & ((1 << UBD_SHIFT) - 1)) + if (inode->i_bdev->bd_contains != inode->i_bdev) return(-EINVAL); return(0); @@ -925,14 +913,11 @@ static int ubd_ioctl(struct inode * inode, struct file * file, return(-EINVAL); } -static int ubd_revalidate(kdev_t rdev) +static int ubd_revalidate(struct gendisk *disk) { __u64 size; - int n, err; - struct ubd *dev; - - n = minor(rdev) >> UBD_SHIFT; - dev = &ubd_dev[n]; + int err; + struct ubd *dev = disk->private_data; err = 0; spin_lock(&ubd_lock); @@ -941,9 +926,7 @@ static int ubd_revalidate(kdev_t rdev) err = ubd_file_size(dev, &size); if (!err) { - set_capacity(ubd_gendisk[n], size / 512); - if(fake_major != 0) - set_capacity(fake_gendisk[n], size / 512); + set_capacity(disk, size / 512); dev->size = size; } out: diff --git a/arch/x86_64/kernel/mtrr.c b/arch/x86_64/kernel/mtrr.c index 47c35bd43a5d..9d478fa81f6b 100644 --- a/arch/x86_64/kernel/mtrr.c +++ b/arch/x86_64/kernel/mtrr.c @@ -1,7 +1,7 @@ /* x86-64 MTRR (Memory Type Range Register) driver. Based largely upon arch/i386/kernel/mtrr.c - Copyright (C) 1997-2000 Richard Gooch + Copyright (C) 1997-2000 Richard Gooch Copyright (C) 2002 Dave Jones. This library is free software; you can redistribute it and/or @@ -20,7 +20,7 @@ (For earlier history, see arch/i386/kernel/mtrr.c) v2.00 September 2001 Dave Jones <davej@suse.de> - Initial rewrite for x86-64. + Initial rewrite for x86-64. Removal of non-Intel style MTRR code. v2.01 June 2002 Dave Jones <davej@suse.de> Removal of redundant abstraction layer. @@ -84,7 +84,7 @@ typedef u8 mtrr_type; -#define LINE_SIZE 80 +#define LINE_SIZE 80 #ifdef CONFIG_SMP #define set_mtrr(reg,base,size,type) set_mtrr_smp (reg, base, size, type) @@ -124,42 +124,42 @@ static void set_mtrr_prepare (struct set_mtrr_context *ctxt) local_irq_save(ctxt->flags); local_irq_disable(); - /* Save value of CR4 and clear Page Global Enable (bit 7) */ + /* Save value of CR4 and clear Page Global Enable (bit 7) */ if (cpu_has_pge) { ctxt->cr4val = read_cr4(); write_cr4(ctxt->cr4val & ~(1UL << 7)); - } + } - /* Disable and flush caches. Note that wbinvd flushes the TLBs as - a side-effect */ + /* Disable and flush caches. Note that wbinvd flushes the TLBs as + a side-effect */ cr0 = read_cr0() | 0x40000000; - wbinvd(); + wbinvd(); write_cr0(cr0); - wbinvd(); + wbinvd(); - /* Disable MTRRs, and set the default type to uncached */ + /* Disable MTRRs, and set the default type to uncached */ rdmsr(MSR_MTRRdefType, ctxt->deftype_lo, ctxt->deftype_hi); wrmsr(MSR_MTRRdefType, ctxt->deftype_lo & 0xf300UL, ctxt->deftype_hi); } -/* Restore the processor after a set_mtrr_prepare */ +/* Restore the processor after a set_mtrr_prepare */ static void set_mtrr_done (struct set_mtrr_context *ctxt) { - /* Flush caches and TLBs */ - wbinvd(); + /* Flush caches and TLBs */ + wbinvd(); - /* Restore MTRRdefType */ + /* Restore MTRRdefType */ wrmsr(MSR_MTRRdefType, ctxt->deftype_lo, ctxt->deftype_hi); - /* Enable caches */ + /* Enable caches */ write_cr0(read_cr0() & 0xbfffffff); - /* Restore value of CR4 */ + /* Restore value of CR4 */ if (cpu_has_pge) write_cr4 (ctxt->cr4val); - /* Re-enable interrupts locally (if enabled previously) */ + /* Re-enable interrupts locally (if enabled previously) */ local_irq_restore(ctxt->flags); } @@ -193,21 +193,21 @@ static void get_mtrr (unsigned int reg, u64 *base, u32 *size, mtrr_type * type) rdmsr (MSR_MTRRphysMask(reg), mask_lo, mask_hi); if ((mask_lo & 0x800) == 0) { - /* Invalid (i.e. free) range */ - *base = 0; - *size = 0; - *type = 0; - return; - } + /* Invalid (i.e. free) range */ + *base = 0; + *size = 0; + *type = 0; + return; + } rdmsr (MSR_MTRRphysBase(reg), base_lo, base_hi); - /* Work out the shifted address mask. */ + /* Work out the shifted address mask. */ newsize = (u64) mask_hi << 32 | (mask_lo & ~0x800); newsize = ~newsize+1; *size = (u32) newsize >> PAGE_SHIFT; - *base = base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT; - *type = base_lo & 0xff; + *base = base_hi << (32 - PAGE_SHIFT) | base_lo >> PAGE_SHIFT; + *type = base_lo & 0xff; } @@ -224,7 +224,7 @@ static void get_mtrr (unsigned int reg, u64 *base, u32 *size, mtrr_type * type) static void set_mtrr_up (unsigned int reg, u64 base, u32 size, mtrr_type type, int do_safe) { - struct set_mtrr_context ctxt; + struct set_mtrr_context ctxt; u64 base64; u64 size64; @@ -232,8 +232,8 @@ static void set_mtrr_up (unsigned int reg, u64 base, set_mtrr_prepare (&ctxt); if (size == 0) { - /* The invalid bit is kept in the mask, so we simply clear the - relevant mask register to disable a range. */ + /* The invalid bit is kept in the mask, so we simply clear the + relevant mask register to disable a range. */ wrmsr (MSR_MTRRphysMask(reg), 0, 0); } else { base64 = (base << PAGE_SHIFT) & size_and_mask; @@ -242,7 +242,7 @@ static void set_mtrr_up (unsigned int reg, u64 base, size64 = ~((size << PAGE_SHIFT) - 1); size64 = size64 & size_and_mask; wrmsr (MSR_MTRRphysMask(reg), (u32) (size64 | 0x800), (u32) (size64 >> 32)); - } + } if (do_safe) set_mtrr_done (&ctxt); } @@ -259,7 +259,7 @@ struct mtrr_var_range { /* Get the MSR pair relating to a var range */ static void __init get_mtrr_var_range (unsigned int index, - struct mtrr_var_range *vr) + struct mtrr_var_range *vr) { rdmsr (MSR_MTRRphysBase(index), vr->base_lo, vr->base_hi); rdmsr (MSR_MTRRphysMask(index), vr->mask_lo, vr->mask_hi); @@ -272,35 +272,35 @@ static int __init set_mtrr_var_range_testing (unsigned int index, struct mtrr_var_range *vr) { u32 lo, hi; - int changed = FALSE; + int changed = FALSE; rdmsr (MSR_MTRRphysBase(index), lo, hi); if ((vr->base_lo & 0xfffff0ff) != (lo & 0xfffff0ff) || (vr->base_hi & 0x000fffff) != (hi & 0x000fffff)) { wrmsr (MSR_MTRRphysBase(index), vr->base_lo, vr->base_hi); - changed = TRUE; - } + changed = TRUE; + } rdmsr (MSR_MTRRphysMask(index), lo, hi); if ((vr->mask_lo & 0xfffff800) != (lo & 0xfffff800) || (vr->mask_hi & 0x000fffff) != (hi & 0x000fffff)) { wrmsr (MSR_MTRRphysMask(index), vr->mask_lo, vr->mask_hi); - changed = TRUE; - } - return changed; + changed = TRUE; + } + return changed; } static void __init get_fixed_ranges (mtrr_type * frs) { u32 *p = (u32 *) frs; - int i; + int i; rdmsr (MSR_MTRRfix64K_00000, p[0], p[1]); - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) rdmsr (MSR_MTRRfix16K_80000 + i, p[2 + i * 2], p[3 + i * 2]); - for (i = 0; i < 8; i++) + for (i = 0; i < 8; i++) rdmsr (MSR_MTRRfix4K_C0000 + i, p[6 + i * 2], p[7 + i * 2]); } @@ -308,8 +308,8 @@ static void __init get_fixed_ranges (mtrr_type * frs) static int __init set_fixed_ranges_testing (mtrr_type * frs) { u32 *p = (u32 *) frs; - int changed = FALSE; - int i; + int changed = FALSE; + int i; u32 lo, hi; printk (KERN_INFO "mtrr: rdmsr 64K_00000\n"); @@ -317,8 +317,8 @@ static int __init set_fixed_ranges_testing (mtrr_type * frs) if (p[0] != lo || p[1] != hi) { printk (KERN_INFO "mtrr: Writing %x:%x to 64K MSR. lohi were %x:%x\n", p[0], p[1], lo, hi); wrmsr (MSR_MTRRfix64K_00000, p[0], p[1]); - changed = TRUE; - } + changed = TRUE; + } printk (KERN_INFO "mtrr: rdmsr 16K_80000\n"); for (i = 0; i < 2; i++) { @@ -326,9 +326,9 @@ static int __init set_fixed_ranges_testing (mtrr_type * frs) if (p[2 + i * 2] != lo || p[3 + i * 2] != hi) { printk (KERN_INFO "mtrr: Writing %x:%x to 16K MSR%d. lohi were %x:%x\n", p[2 + i * 2], p[3 + i * 2], i, lo, hi ); wrmsr (MSR_MTRRfix16K_80000 + i, p[2 + i * 2], p[3 + i * 2]); - changed = TRUE; + changed = TRUE; + } } - } printk (KERN_INFO "mtrr: rdmsr 4K_C0000\n"); for (i = 0; i < 8; i++) { @@ -337,18 +337,18 @@ static int __init set_fixed_ranges_testing (mtrr_type * frs) if (p[6 + i * 2] != lo || p[7 + i * 2] != hi) { printk (KERN_INFO "mtrr: Writing %x:%x to 4K MSR%d. lohi were %x:%x\n", p[6 + i * 2], p[7 + i * 2], i, lo, hi); wrmsr (MSR_MTRRfix4K_C0000 + i, p[6 + i * 2], p[7 + i * 2]); - changed = TRUE; + changed = TRUE; + } } - } - return changed; + return changed; } struct mtrr_state { - unsigned int num_var_ranges; - struct mtrr_var_range *var_ranges; - mtrr_type fixed_ranges[NUM_FIXED_RANGES]; - mtrr_type def_type; + unsigned int num_var_ranges; + struct mtrr_var_range *var_ranges; + mtrr_type fixed_ranges[NUM_FIXED_RANGES]; + mtrr_type def_type; unsigned char enabled; }; @@ -356,23 +356,23 @@ struct mtrr_state { /* Grab all of the MTRR state for this CPU into *state */ static void __init get_mtrr_state (struct mtrr_state *state) { - unsigned int nvrs, i; - struct mtrr_var_range *vrs; + unsigned int nvrs, i; + struct mtrr_var_range *vrs; u32 lo, dummy; nvrs = state->num_var_ranges = get_num_var_ranges(); - vrs = state->var_ranges - = kmalloc (nvrs * sizeof (struct mtrr_var_range), GFP_KERNEL); - if (vrs == NULL) - nvrs = state->num_var_ranges = 0; + vrs = state->var_ranges + = kmalloc (nvrs * sizeof (struct mtrr_var_range), GFP_KERNEL); + if (vrs == NULL) + nvrs = state->num_var_ranges = 0; - for (i = 0; i < nvrs; i++) - get_mtrr_var_range (i, &vrs[i]); - get_fixed_ranges (state->fixed_ranges); + for (i = 0; i < nvrs; i++) + get_mtrr_var_range (i, &vrs[i]); + get_fixed_ranges (state->fixed_ranges); rdmsr (MSR_MTRRdefType, lo, dummy); - state->def_type = (lo & 0xff); - state->enabled = (lo & 0xc00) >> 10; + state->def_type = (lo & 0xff); + state->enabled = (lo & 0xc00) >> 10; } @@ -392,26 +392,26 @@ static void __init finalize_mtrr_state (struct mtrr_state *state) * [RETURNS] 0 if no changes made, else a mask indication what was changed. */ static u64 __init set_mtrr_state (struct mtrr_state *state, - struct set_mtrr_context *ctxt) + struct set_mtrr_context *ctxt) { - unsigned int i; + unsigned int i; u64 change_mask = 0; - for (i = 0; i < state->num_var_ranges; i++) + for (i = 0; i < state->num_var_ranges; i++) if (set_mtrr_var_range_testing (i, &state->var_ranges[i])) - change_mask |= MTRR_CHANGE_MASK_VARIABLE; + change_mask |= MTRR_CHANGE_MASK_VARIABLE; if (set_fixed_ranges_testing (state->fixed_ranges)) - change_mask |= MTRR_CHANGE_MASK_FIXED; - /* Set_mtrr_restore restores the old value of MTRRdefType, - so to set it we fiddle with the saved value */ + change_mask |= MTRR_CHANGE_MASK_FIXED; + /* Set_mtrr_restore restores the old value of MTRRdefType, + so to set it we fiddle with the saved value */ if ((ctxt->deftype_lo & 0xff) != state->def_type || ((ctxt->deftype_lo & 0xc00) >> 10) != state->enabled) { - ctxt->deftype_lo |= (state->def_type | state->enabled << 10); - change_mask |= MTRR_CHANGE_MASK_DEFTYPE; - } + ctxt->deftype_lo |= (state->def_type | state->enabled << 10); + change_mask |= MTRR_CHANGE_MASK_DEFTYPE; + } - return change_mask; + return change_mask; } @@ -422,8 +422,8 @@ static volatile int wait_barrier_cache_enable = FALSE; struct set_mtrr_data { u64 smp_base; u32 smp_size; - unsigned int smp_reg; - mtrr_type smp_type; + unsigned int smp_reg; + mtrr_type smp_type; }; /* @@ -431,67 +431,67 @@ struct set_mtrr_data { */ static void ipi_handler (void *info) { - struct set_mtrr_data *data = info; - struct set_mtrr_context ctxt; + struct set_mtrr_data *data = info; + struct set_mtrr_context ctxt; set_mtrr_prepare (&ctxt); - /* Notify master that I've flushed and disabled my cache */ - atomic_dec (&undone_count); + /* Notify master that I've flushed and disabled my cache */ + atomic_dec (&undone_count); while (wait_barrier_execute) barrier (); - /* The master has cleared me to execute */ + /* The master has cleared me to execute */ set_mtrr_up (data->smp_reg, data->smp_base, data->smp_size, - data->smp_type, FALSE); + data->smp_type, FALSE); - /* Notify master CPU that I've executed the function */ - atomic_dec (&undone_count); + /* Notify master CPU that I've executed the function */ + atomic_dec (&undone_count); - /* Wait for master to clear me to enable cache and return */ + /* Wait for master to clear me to enable cache and return */ while (wait_barrier_cache_enable) barrier (); - set_mtrr_done (&ctxt); + set_mtrr_done (&ctxt); } static void set_mtrr_smp (unsigned int reg, u64 base, u32 size, mtrr_type type) { - struct set_mtrr_data data; - struct set_mtrr_context ctxt; - - data.smp_reg = reg; - data.smp_base = base; - data.smp_size = size; - data.smp_type = type; - wait_barrier_execute = TRUE; - wait_barrier_cache_enable = TRUE; + struct set_mtrr_data data; + struct set_mtrr_context ctxt; + + data.smp_reg = reg; + data.smp_base = base; + data.smp_size = size; + data.smp_type = type; + wait_barrier_execute = TRUE; + wait_barrier_cache_enable = TRUE; atomic_set (&undone_count, num_online_cpus() - 1); - /* Start the ball rolling on other CPUs */ - if (smp_call_function (ipi_handler, &data, 1, 0) != 0) - panic ("mtrr: timed out waiting for other CPUs\n"); + /* Start the ball rolling on other CPUs */ + if (smp_call_function (ipi_handler, &data, 1, 0) != 0) + panic ("mtrr: timed out waiting for other CPUs\n"); - /* Flush and disable the local CPU's cache */ + /* Flush and disable the local CPU's cache */ set_mtrr_prepare (&ctxt); - /* Wait for all other CPUs to flush and disable their caches */ + /* Wait for all other CPUs to flush and disable their caches */ while (atomic_read (&undone_count) > 0) barrier (); /* Set up for completion wait and then release other CPUs to change MTRRs */ atomic_set (&undone_count, num_online_cpus() - 1); - wait_barrier_execute = FALSE; + wait_barrier_execute = FALSE; set_mtrr_up (reg, base, size, type, FALSE); - /* Now wait for other CPUs to complete the function */ + /* Now wait for other CPUs to complete the function */ while (atomic_read (&undone_count) > 0) barrier (); - /* Now all CPUs should have finished the function. Release the barrier to - allow them to re-enable their caches and return from their interrupt, - then enable the local cache and return */ - wait_barrier_cache_enable = FALSE; - set_mtrr_done (&ctxt); + /* Now all CPUs should have finished the function. Release the barrier to + allow them to re-enable their caches and return from their interrupt, + then enable the local cache and return */ + wait_barrier_cache_enable = FALSE; + set_mtrr_done (&ctxt); } @@ -500,44 +500,44 @@ static void __init mtrr_state_warn (u32 mask) { if (!mask) return; - if (mask & MTRR_CHANGE_MASK_FIXED) - printk ("mtrr: your CPUs had inconsistent fixed MTRR settings\n"); - if (mask & MTRR_CHANGE_MASK_VARIABLE) - printk ("mtrr: your CPUs had inconsistent variable MTRR settings\n"); - if (mask & MTRR_CHANGE_MASK_DEFTYPE) - printk ("mtrr: your CPUs had inconsistent MTRRdefType settings\n"); - printk ("mtrr: probably your BIOS does not setup all CPUs\n"); + if (mask & MTRR_CHANGE_MASK_FIXED) + printk ("mtrr: your CPUs had inconsistent fixed MTRR settings\n"); + if (mask & MTRR_CHANGE_MASK_VARIABLE) + printk ("mtrr: your CPUs had inconsistent variable MTRR settings\n"); + if (mask & MTRR_CHANGE_MASK_DEFTYPE) + printk ("mtrr: your CPUs had inconsistent MTRRdefType settings\n"); + printk ("mtrr: probably your BIOS does not setup all CPUs\n"); } -#endif /* CONFIG_SMP */ +#endif /* CONFIG_SMP */ static inline char * attrib_to_str (int x) { - return (x <= 6) ? mtrr_strings[x] : "?"; + return (x <= 6) ? mtrr_strings[x] : "?"; } static void __init init_table (void) { - int i, max; + int i, max; - max = get_num_var_ranges (); + max = get_num_var_ranges (); if ((usage_table = kmalloc (max * sizeof *usage_table, GFP_KERNEL))==NULL) { - printk ("mtrr: could not allocate\n"); - return; - } + printk ("mtrr: could not allocate\n"); + return; + } for (i = 0; i < max; i++) usage_table[i] = 1; #ifdef USERSPACE_INTERFACE if ((ascii_buffer = kmalloc (max * LINE_SIZE, GFP_KERNEL)) == NULL) { - printk ("mtrr: could not allocate\n"); - return; - } - ascii_buf_bytes = 0; - compute_ascii (); + printk ("mtrr: could not allocate\n"); + return; + } + ascii_buf_bytes = 0; + compute_ascii (); #endif } @@ -548,18 +548,18 @@ static void __init init_table (void) */ static int get_free_region(void) { - int i, max; - mtrr_type ltype; + int i, max; + mtrr_type ltype; u64 lbase; u32 lsize; - max = get_num_var_ranges (); + max = get_num_var_ranges (); for (i = 0; i < max; ++i) { get_mtrr (i, &lbase, &lsize, <ype); if (lsize == 0) return i; - } - return -ENOSPC; + } + return -ENOSPC; } @@ -597,16 +597,16 @@ static int get_free_region(void) int mtrr_add_page (u64 base, u32 size, unsigned int type, char increment) { - int i, max; - mtrr_type ltype; + int i, max; + mtrr_type ltype; u64 lbase, last; u32 lsize; if (base + size < 0x100) { printk (KERN_WARNING "mtrr: cannot set region below 1 MiB (0x%Lx000,0x%x000)\n", - base, size); - return -EINVAL; + base, size); + return -EINVAL; } #if defined(__x86_64__) && defined(CONFIG_AGP) @@ -621,7 +621,7 @@ int mtrr_add_page (u64 base, u32 size, unsigned int type, char increment) #endif /* Check upper bits of base and last are equal and lower bits are 0 - for base and 1 for last */ + for base and 1 for last */ last = base + size - 1; for (lbase = base; !(lbase & 1) && (last & 1); lbase = lbase >> 1, last = last >> 1) ; @@ -630,35 +630,36 @@ int mtrr_add_page (u64 base, u32 size, unsigned int type, char increment) printk (KERN_WARNING "mtrr: base(0x%Lx000) is not aligned on a size(0x%x000) boundary\n", base, size); - return -EINVAL; - } + return -EINVAL; + } if (type >= MTRR_NUM_TYPES) { - printk ("mtrr: type: %u illegal\n", type); - return -EINVAL; - } + printk ("mtrr: type: %u illegal\n", type); + return -EINVAL; + } - /* If the type is WC, check that this processor supports it */ + /* If the type is WC, check that this processor supports it */ if ((type == MTRR_TYPE_WRCOMB) && !have_wrcomb()) { printk (KERN_WARNING "mtrr: your processor doesn't support write-combining\n"); - return -ENOSYS; - } + return -ENOSYS; + } if (base & (size_or_mask>>PAGE_SHIFT)) { printk (KERN_WARNING "mtrr: base(%lx) exceeds the MTRR width(%lx)\n", - base, (size_or_mask>>PAGE_SHIFT)); + (unsigned long) base, + (unsigned long) (size_or_mask>>PAGE_SHIFT)); return -EINVAL; } if (size & (size_or_mask>>PAGE_SHIFT)) { printk (KERN_WARNING "mtrr: size exceeds the MTRR width\n"); - return -EINVAL; - } + return -EINVAL; + } - increment = increment ? 1 : 0; - max = get_num_var_ranges (); - /* Search for existing MTRR */ + increment = increment ? 1 : 0; + max = get_num_var_ranges (); + /* Search for existing MTRR */ down (&mtrr_lock); for (i = 0; i < max; ++i) { get_mtrr (i, &lbase, &lsize, <ype); @@ -667,15 +668,15 @@ int mtrr_add_page (u64 base, u32 size, unsigned int type, char increment) if ((base < lbase) && (base + size <= lbase)) continue; - /* At this point we know there is some kind of overlap/enclosure */ + /* At this point we know there is some kind of overlap/enclosure */ if ((base < lbase) || (base + size > lbase + lsize)) { up (&mtrr_lock); printk (KERN_WARNING "mtrr: 0x%Lx000,0x%x000 overlaps existing" " 0x%Lx000,0x%x000\n", base, size, lbase, lsize); - return -EINVAL; - } - /* New region is enclosed by an existing region */ + return -EINVAL; + } + /* New region is enclosed by an existing region */ if (ltype != type) { if (type == MTRR_TYPE_UNCACHABLE) continue; @@ -685,26 +686,26 @@ int mtrr_add_page (u64 base, u32 size, unsigned int type, char increment) base, size, attrib_to_str (ltype), attrib_to_str (type)); - return -EINVAL; - } + return -EINVAL; + } if (increment) ++usage_table[i]; - compute_ascii (); + compute_ascii (); up (&mtrr_lock); - return i; - } - /* Search for an empty MTRR */ + return i; + } + /* Search for an empty MTRR */ i = get_free_region(); if (i < 0) { up (&mtrr_lock); - printk ("mtrr: no more MTRRs available\n"); - return i; - } - set_mtrr (i, base, size, type); - usage_table[i] = 1; - compute_ascii (); + printk ("mtrr: no more MTRRs available\n"); + return i; + } + set_mtrr (i, base, size, type); + usage_table[i] = 1; + compute_ascii (); up (&mtrr_lock); - return i; + return i; } @@ -744,10 +745,10 @@ int mtrr_add_page (u64 base, u32 size, unsigned int type, char increment) int mtrr_add (u64 base, u32 size, unsigned int type, char increment) { if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { - printk ("mtrr: size and base must be multiples of 4 kiB\n"); + printk ("mtrr: size and base must be multiples of 4 kiB\n"); printk ("mtrr: size: 0x%x base: 0x%Lx\n", size, base); - return -EINVAL; - } + return -EINVAL; + } return mtrr_add_page (base >> PAGE_SHIFT, size >> PAGE_SHIFT, type, increment); } @@ -767,56 +768,56 @@ int mtrr_add (u64 base, u32 size, unsigned int type, char increment) * On success the register is returned, on failure a negative error * code. */ - + int mtrr_del_page (int reg, u64 base, u32 size) { - int i, max; - mtrr_type ltype; + int i, max; + mtrr_type ltype; u64 lbase; u32 lsize; - max = get_num_var_ranges (); + max = get_num_var_ranges (); down (&mtrr_lock); if (reg < 0) { - /* Search for existing MTRR */ + /* Search for existing MTRR */ for (i = 0; i < max; ++i) { get_mtrr (i, &lbase, &lsize, <ype); if (lbase == base && lsize == size) { - reg = i; - break; - } - } + reg = i; + break; + } + } if (reg < 0) { up (&mtrr_lock); printk ("mtrr: no MTRR for %Lx000,%x000 found\n", base, size); - return -EINVAL; + return -EINVAL; + } } - } if (reg >= max) { up (&mtrr_lock); - printk ("mtrr: register: %d too big\n", reg); - return -EINVAL; - } + printk ("mtrr: register: %d too big\n", reg); + return -EINVAL; + } get_mtrr (reg, &lbase, &lsize, <ype); if (lsize < 1) { up (&mtrr_lock); - printk ("mtrr: MTRR %d not used\n", reg); - return -EINVAL; - } + printk ("mtrr: MTRR %d not used\n", reg); + return -EINVAL; + } if (usage_table[reg] < 1) { up (&mtrr_lock); - printk ("mtrr: reg: %d has count=0\n", reg); - return -EINVAL; - } + printk ("mtrr: reg: %d has count=0\n", reg); + return -EINVAL; + } if (--usage_table[reg] < 1) set_mtrr (reg, 0, 0, 0); - compute_ascii (); + compute_ascii (); up (&mtrr_lock); - return reg; + return reg; } @@ -834,14 +835,14 @@ int mtrr_del_page (int reg, u64 base, u32 size) * On success the register is returned, on failure a negative error * code. */ - + int mtrr_del (int reg, u64 base, u32 size) { if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { - printk ("mtrr: size and base must be multiples of 4 kiB\n"); + printk ("mtrr: size and base must be multiples of 4 kiB\n"); printk ("mtrr: size: 0x%x base: 0x%Lx\n", size, base); - return -EINVAL; - } + return -EINVAL; + } return mtrr_del_page (reg, base >> PAGE_SHIFT, size >> PAGE_SHIFT); } @@ -851,64 +852,64 @@ int mtrr_del (int reg, u64 base, u32 size) static int mtrr_file_add (u64 base, u32 size, unsigned int type, struct file *file, int page) { - int reg, max; - unsigned int *fcount = file->private_data; + int reg, max; + unsigned int *fcount = file->private_data; - max = get_num_var_ranges (); + max = get_num_var_ranges (); if (fcount == NULL) { if ((fcount = kmalloc (max * sizeof *fcount, GFP_KERNEL)) == NULL) { - printk ("mtrr: could not allocate\n"); - return -ENOMEM; + printk ("mtrr: could not allocate\n"); + return -ENOMEM; + } + memset (fcount, 0, max * sizeof *fcount); + file->private_data = fcount; } - memset (fcount, 0, max * sizeof *fcount); - file->private_data = fcount; - } - if (!page) { + if (!page) { if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { printk ("mtrr: size and base must be multiples of 4 kiB\n"); printk ("mtrr: size: 0x%x base: 0x%Lx\n", size, base); - return -EINVAL; + return -EINVAL; + } + base >>= PAGE_SHIFT; + size >>= PAGE_SHIFT; } - base >>= PAGE_SHIFT; - size >>= PAGE_SHIFT; - } - reg = mtrr_add_page (base, size, type, 1); + reg = mtrr_add_page (base, size, type, 1); if (reg >= 0) ++fcount[reg]; - return reg; + return reg; } static int mtrr_file_del (u64 base, u32 size, - struct file *file, int page) + struct file *file, int page) { - int reg; - unsigned int *fcount = file->private_data; + int reg; + unsigned int *fcount = file->private_data; - if (!page) { + if (!page) { if ((base & (PAGE_SIZE - 1)) || (size & (PAGE_SIZE - 1))) { printk ("mtrr: size and base must be multiples of 4 kiB\n"); printk ("mtrr: size: 0x%x base: 0x%Lx\n", size, base); - return -EINVAL; + return -EINVAL; + } + base >>= PAGE_SHIFT; + size >>= PAGE_SHIFT; } - base >>= PAGE_SHIFT; - size >>= PAGE_SHIFT; - } - reg = mtrr_del_page (-1, base, size); + reg = mtrr_del_page (-1, base, size); if (reg < 0) return reg; if (fcount == NULL) return reg; if (fcount[reg] < 1) return -EINVAL; - --fcount[reg]; - return reg; + --fcount[reg]; + return reg; } @@ -924,8 +925,8 @@ static ssize_t mtrr_read (struct file *file, char *buf, size_t len, if (copy_to_user (buf, ascii_buffer + *ppos, len)) return -EFAULT; - *ppos += len; - return len; + *ppos += len; + return len; } @@ -939,240 +940,240 @@ static ssize_t mtrr_write (struct file *file, const char *buf, int i, err, reg; u64 base; u32 size; - char *ptr; - char line[LINE_SIZE]; + char *ptr; + char line[LINE_SIZE]; if (!capable(CAP_SYS_ADMIN)) return -EPERM; - /* Can't seek (pwrite) on this device */ + /* Can't seek (pwrite) on this device */ if (ppos != &file->f_pos) return -ESPIPE; - memset (line, 0, LINE_SIZE); + memset (line, 0, LINE_SIZE); if (len > LINE_SIZE) len = LINE_SIZE; if (copy_from_user (line, buf, len - 1)) return -EFAULT; - ptr = line + strlen (line) - 1; + ptr = line + strlen (line) - 1; if (*ptr == '\n') *ptr = '\0'; if (!strncmp (line, "disable=", 8)) { - reg = simple_strtoul (line + 8, &ptr, 0); - err = mtrr_del_page (reg, 0, 0); + reg = simple_strtoul (line + 8, &ptr, 0); + err = mtrr_del_page (reg, 0, 0); if (err < 0) return err; - return len; - } + return len; + } if (strncmp (line, "base=", 5)) { - printk ("mtrr: no \"base=\" in line: \"%s\"\n", line); - return -EINVAL; - } + printk ("mtrr: no \"base=\" in line: \"%s\"\n", line); + return -EINVAL; + } - base = simple_strtoull (line + 5, &ptr, 0); + base = simple_strtoull (line + 5, &ptr, 0); for (; isspace (*ptr); ++ptr) ; if (strncmp (ptr, "size=", 5)) { - printk ("mtrr: no \"size=\" in line: \"%s\"\n", line); - return -EINVAL; - } + printk ("mtrr: no \"size=\" in line: \"%s\"\n", line); + return -EINVAL; + } - size = simple_strtoull (ptr + 5, &ptr, 0); + size = simple_strtoull (ptr + 5, &ptr, 0); if ((base & 0xfff) || (size & 0xfff)) { - printk ("mtrr: size and base must be multiples of 4 kiB\n"); + printk ("mtrr: size and base must be multiples of 4 kiB\n"); printk ("mtrr: size: 0x%x base: 0x%Lx\n", size, base); - return -EINVAL; - } + return -EINVAL; + } for (; isspace (*ptr); ++ptr) ; if (strncmp (ptr, "type=", 5)) { - printk ("mtrr: no \"type=\" in line: \"%s\"\n", line); - return -EINVAL; - } - ptr += 5; + printk ("mtrr: no \"type=\" in line: \"%s\"\n", line); + return -EINVAL; + } + ptr += 5; for (; isspace (*ptr); ++ptr) ; for (i = 0; i < MTRR_NUM_TYPES; ++i) { if (strcmp (ptr, mtrr_strings[i])) continue; - base >>= PAGE_SHIFT; - size >>= PAGE_SHIFT; + base >>= PAGE_SHIFT; + size >>= PAGE_SHIFT; err = mtrr_add_page ((u64) base, size, i, 1); if (err < 0) return err; - return len; - } - printk ("mtrr: illegal type: \"%s\"\n", ptr); - return -EINVAL; + return len; + } + printk ("mtrr: illegal type: \"%s\"\n", ptr); + return -EINVAL; } static int mtrr_ioctl (struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg) { - int err; - mtrr_type type; - struct mtrr_sentry sentry; - struct mtrr_gentry gentry; + int err; + mtrr_type type; + struct mtrr_sentry sentry; + struct mtrr_gentry gentry; switch (cmd) { - default: - return -ENOIOCTLCMD; + default: + return -ENOIOCTLCMD; - case MTRRIOC_ADD_ENTRY: + case MTRRIOC_ADD_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; + return -EFAULT; err = mtrr_file_add (sentry.base, sentry.size, sentry.type, file, 0); if (err < 0) return err; - break; + break; - case MTRRIOC_SET_ENTRY: + case MTRRIOC_SET_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; - err = mtrr_add (sentry.base, sentry.size, sentry.type, 0); + return -EFAULT; + err = mtrr_add (sentry.base, sentry.size, sentry.type, 0); if (err < 0) return err; - break; + break; - case MTRRIOC_DEL_ENTRY: + case MTRRIOC_DEL_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; - err = mtrr_file_del (sentry.base, sentry.size, file, 0); + return -EFAULT; + err = mtrr_file_del (sentry.base, sentry.size, file, 0); if (err < 0) return err; - break; + break; - case MTRRIOC_KILL_ENTRY: + case MTRRIOC_KILL_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; - err = mtrr_del (-1, sentry.base, sentry.size); + return -EFAULT; + err = mtrr_del (-1, sentry.base, sentry.size); if (err < 0) return err; - break; + break; - case MTRRIOC_GET_ENTRY: + case MTRRIOC_GET_ENTRY: if (copy_from_user (&gentry, (void *) arg, sizeof gentry)) - return -EFAULT; + return -EFAULT; if (gentry.regnum >= get_num_var_ranges ()) return -EINVAL; get_mtrr (gentry.regnum, (u64*) &gentry.base, &gentry.size, &type); - /* Hide entries that go above 4GB */ + /* Hide entries that go above 4GB */ if (gentry.base + gentry.size > 0x100000 || gentry.size == 0x100000) - gentry.base = gentry.size = gentry.type = 0; - else { - gentry.base <<= PAGE_SHIFT; - gentry.size <<= PAGE_SHIFT; - gentry.type = type; - } + gentry.base = gentry.size = gentry.type = 0; + else { + gentry.base <<= PAGE_SHIFT; + gentry.size <<= PAGE_SHIFT; + gentry.type = type; + } if (copy_to_user ((void *) arg, &gentry, sizeof gentry)) - return -EFAULT; - break; + return -EFAULT; + break; - case MTRRIOC_ADD_PAGE_ENTRY: + case MTRRIOC_ADD_PAGE_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; + return -EFAULT; err = mtrr_file_add (sentry.base, sentry.size, sentry.type, file, 1); if (err < 0) return err; - break; + break; - case MTRRIOC_SET_PAGE_ENTRY: + case MTRRIOC_SET_PAGE_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; - err = mtrr_add_page (sentry.base, sentry.size, sentry.type, 0); + return -EFAULT; + err = mtrr_add_page (sentry.base, sentry.size, sentry.type, 0); if (err < 0) return err; - break; + break; - case MTRRIOC_DEL_PAGE_ENTRY: + case MTRRIOC_DEL_PAGE_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; - err = mtrr_file_del (sentry.base, sentry.size, file, 1); + return -EFAULT; + err = mtrr_file_del (sentry.base, sentry.size, file, 1); if (err < 0) return err; - break; + break; - case MTRRIOC_KILL_PAGE_ENTRY: + case MTRRIOC_KILL_PAGE_ENTRY: if (!capable(CAP_SYS_ADMIN)) return -EPERM; if (copy_from_user (&sentry, (void *) arg, sizeof sentry)) - return -EFAULT; - err = mtrr_del_page (-1, sentry.base, sentry.size); + return -EFAULT; + err = mtrr_del_page (-1, sentry.base, sentry.size); if (err < 0) return err; - break; + break; - case MTRRIOC_GET_PAGE_ENTRY: + case MTRRIOC_GET_PAGE_ENTRY: if (copy_from_user (&gentry, (void *) arg, sizeof gentry)) - return -EFAULT; + return -EFAULT; if (gentry.regnum >= get_num_var_ranges ()) return -EINVAL; get_mtrr (gentry.regnum, (u64*) &gentry.base, &gentry.size, &type); - gentry.type = type; + gentry.type = type; if (copy_to_user ((void *) arg, &gentry, sizeof gentry)) - return -EFAULT; - break; - } - return 0; + return -EFAULT; + break; + } + return 0; } static int mtrr_close (struct inode *ino, struct file *file) { - int i, max; - unsigned int *fcount = file->private_data; + int i, max; + unsigned int *fcount = file->private_data; if (fcount == NULL) return 0; lock_kernel (); - max = get_num_var_ranges (); + max = get_num_var_ranges (); for (i = 0; i < max; ++i) { while (fcount[i] > 0) { if (mtrr_del (i, 0, 0) < 0) printk ("mtrr: reg %d not used\n", i); - --fcount[i]; + --fcount[i]; + } } - } unlock_kernel (); - kfree (fcount); - file->private_data = NULL; - return 0; + kfree (fcount); + file->private_data = NULL; + return 0; } static struct file_operations mtrr_fops = { .owner = THIS_MODULE, - .read = mtrr_read, - .write = mtrr_write, + .read = mtrr_read, + .write = mtrr_write, .ioctl = mtrr_ioctl, .release = mtrr_close, }; @@ -1185,38 +1186,38 @@ static devfs_handle_t devfs_handle; static void compute_ascii (void) { - char factor; - int i, max; - mtrr_type type; + char factor; + int i, max; + mtrr_type type; u64 base; u32 size; - ascii_buf_bytes = 0; - max = get_num_var_ranges (); + ascii_buf_bytes = 0; + max = get_num_var_ranges (); for (i = 0; i < max; i++) { get_mtrr (i, &base, &size, &type); if (size == 0) usage_table[i] = 0; else { if (size < (0x100000 >> PAGE_SHIFT)) { - /* less than 1MB */ - factor = 'K'; - size <<= PAGE_SHIFT - 10; + /* less than 1MB */ + factor = 'K'; + size <<= PAGE_SHIFT - 10; } else { - factor = 'M'; - size >>= 20 - PAGE_SHIFT; - } + factor = 'M'; + size >>= 20 - PAGE_SHIFT; + } sprintf (ascii_buffer + ascii_buf_bytes, "reg%02i: base=0x%05Lx000 (%4iMB), size=%4i%cB: %s, count=%d\n", i, base, (u32) base >> (20 - PAGE_SHIFT), size, factor, - attrib_to_str (type), usage_table[i]); + attrib_to_str (type), usage_table[i]); ascii_buf_bytes += strlen (ascii_buffer + ascii_buf_bytes); + } } - } - devfs_set_file_size (devfs_handle, ascii_buf_bytes); + devfs_set_file_size (devfs_handle, ascii_buf_bytes); #ifdef CONFIG_PROC_FS - if (proc_root_mtrr) - proc_root_mtrr->size = ascii_buf_bytes; + if (proc_root_mtrr) + proc_root_mtrr->size = ascii_buf_bytes; #endif } @@ -1225,7 +1226,7 @@ static void compute_ascii (void) EXPORT_SYMBOL (mtrr_add); EXPORT_SYMBOL (mtrr_del); - + static void __init mtrr_setup (void) { printk ("mtrr: v%s)\n", MTRR_VERSION); @@ -1234,7 +1235,7 @@ static void __init mtrr_setup (void) /* Query the width (in bits) of the physical addressable memory on the Hammer family. */ if ((cpuid_eax (0x80000000) >= 0x80000008)) { - u32 phys_addr; + u32 phys_addr; phys_addr = cpuid_eax (0x80000008) & 0xff; size_or_mask = ~((1L << phys_addr) - 1); /* @@ -1263,30 +1264,30 @@ void __init mtrr_init_secondary_cpu (void) { u64 mask; int count; - struct set_mtrr_context ctxt; + struct set_mtrr_context ctxt; - /* Note that this is not ideal, since the cache is only flushed/disabled - for this CPU while the MTRRs are changed, but changing this requires - more invasive changes to the way the kernel boots */ + /* Note that this is not ideal, since the cache is only flushed/disabled + for this CPU while the MTRRs are changed, but changing this requires + more invasive changes to the way the kernel boots */ set_mtrr_prepare (&ctxt); - mask = set_mtrr_state (&smp_mtrr_state, &ctxt); - set_mtrr_done (&ctxt); + mask = set_mtrr_state (&smp_mtrr_state, &ctxt); + set_mtrr_done (&ctxt); - /* Use the atomic bitops to update the global mask */ + /* Use the atomic bitops to update the global mask */ for (count = 0; count < sizeof mask * 8; ++count) { if (mask & 0x01) set_bit (count, &smp_changes_mask); - mask >>= 1; - } + mask >>= 1; + } } -#endif /* CONFIG_SMP */ +#endif /* CONFIG_SMP */ int __init mtrr_init (void) { #ifdef CONFIG_SMP - /* mtrr_setup() should already have been called from mtrr_init_boot_cpu() */ + /* mtrr_setup() should already have been called from mtrr_init_boot_cpu() */ finalize_mtrr_state (&smp_mtrr_state); mtrr_state_warn (smp_changes_mask); @@ -1295,17 +1296,17 @@ int __init mtrr_init (void) #endif #ifdef CONFIG_PROC_FS - proc_root_mtrr = create_proc_entry ("mtrr", S_IWUSR | S_IRUGO, &proc_root); - if (proc_root_mtrr) { - proc_root_mtrr->owner = THIS_MODULE; - proc_root_mtrr->proc_fops = &mtrr_fops; - } + proc_root_mtrr = create_proc_entry ("mtrr", S_IWUSR | S_IRUGO, &proc_root); + if (proc_root_mtrr) { + proc_root_mtrr->owner = THIS_MODULE; + proc_root_mtrr->proc_fops = &mtrr_fops; + } #endif #ifdef CONFIG_DEVFS_FS - devfs_handle = devfs_register (NULL, "cpu/mtrr", DEVFS_FL_DEFAULT, 0, 0, - S_IFREG | S_IRUGO | S_IWUSR, - &mtrr_fops, NULL); + devfs_handle = devfs_register (NULL, "cpu/mtrr", DEVFS_FL_DEFAULT, 0, 0, + S_IFREG | S_IRUGO | S_IWUSR, + &mtrr_fops, NULL); #endif - init_table (); - return 0; + init_table (); + return 0; } |
