aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2008-02-03 02:29:41 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2008-02-03 02:30:32 -0500
commitc1f3ee120bb61045b1c0a3ead620d1d65af47130 (patch)
tree908430bf2b47fe8e96ac623ae7ab6dd5698d0938 /include
parente619a75ff6201b567a539e787aa9af9bc63a3187 (diff)
parent9135f1901ee6449dfe338adf6e40e9c2025b8150 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'include')
-rw-r--r--include/acpi/acpi_bus.h2
-rw-r--r--include/acpi/acpixf.h2
-rw-r--r--include/acpi/processor.h1
-rw-r--r--include/acpi/reboot.h9
-rw-r--r--include/asm-alpha/agp.h1
-rw-r--r--include/asm-alpha/io_trivial.h12
-rw-r--r--include/asm-alpha/socket.h2
-rw-r--r--include/asm-alpha/tlbflush.h1
-rw-r--r--include/asm-arm/arch-at91/at91_lcdc.h148
-rw-r--r--include/asm-arm/arch-at91/at91_pmc.h9
-rw-r--r--include/asm-arm/arch-at91/at91_rtt.h8
-rw-r--r--include/asm-arm/arch-at91/at91_twi.h11
-rw-r--r--include/asm-arm/arch-at91/at91cap9.h121
-rw-r--r--include/asm-arm/arch-at91/at91cap9_matrix.h132
-rw-r--r--include/asm-arm/arch-at91/at91sam9260_matrix.h2
-rw-r--r--include/asm-arm/arch-at91/at91sam9263_matrix.h2
-rw-r--r--include/asm-arm/arch-at91/at91sam9rl_matrix.h2
-rw-r--r--include/asm-arm/arch-at91/board.h47
-rw-r--r--include/asm-arm/arch-at91/cpu.h9
-rw-r--r--include/asm-arm/arch-at91/entry-macro.S2
-rw-r--r--include/asm-arm/arch-at91/hardware.h2
-rw-r--r--include/asm-arm/arch-at91/timex.h5
-rw-r--r--include/asm-arm/arch-davinci/gpio.h3
-rw-r--r--include/asm-arm/arch-ep93xx/gpio.h58
-rw-r--r--include/asm-arm/arch-ep93xx/irqs.h6
-rw-r--r--include/asm-arm/arch-ixp23xx/irqs.h2
-rw-r--r--include/asm-arm/arch-ixp4xx/io.h16
-rw-r--r--include/asm-arm/arch-ixp4xx/platform.h11
-rw-r--r--include/asm-arm/arch-ks8695/regs-gpio.h2
-rw-r--r--include/asm-arm/arch-msm/board.h37
-rw-r--r--include/asm-arm/arch-msm/debug-macro.S40
-rw-r--r--include/asm-arm/arch-msm/dma.h151
-rw-r--r--include/asm-arm/arch-msm/entry-macro.S38
-rw-r--r--include/asm-arm/arch-msm/hardware.h18
-rw-r--r--include/asm-arm/arch-msm/io.h33
-rw-r--r--include/asm-arm/arch-msm/irqs.h89
-rw-r--r--include/asm-arm/arch-msm/memory.h27
-rw-r--r--include/asm-arm/arch-msm/msm_iomap.h104
-rw-r--r--include/asm-arm/arch-msm/system.h23
-rw-r--r--include/asm-arm/arch-msm/timex.h20
-rw-r--r--include/asm-arm/arch-msm/uncompress.h36
-rw-r--r--include/asm-arm/arch-msm/vmalloc.h22
-rw-r--r--include/asm-arm/arch-omap/board-innovator.h2
-rw-r--r--include/asm-arm/arch-omap/eac.h1
-rw-r--r--include/asm-arm/arch-omap/omap-alsa.h1
-rw-r--r--include/asm-arm/arch-orion/debug-macro.S17
-rw-r--r--include/asm-arm/arch-orion/dma.h1
-rw-r--r--include/asm-arm/arch-orion/entry-macro.S31
-rw-r--r--include/asm-arm/arch-orion/gpio.h28
-rw-r--r--include/asm-arm/arch-orion/hardware.h24
-rw-r--r--include/asm-arm/arch-orion/io.h27
-rw-r--r--include/asm-arm/arch-orion/irqs.h61
-rw-r--r--include/asm-arm/arch-orion/memory.h15
-rw-r--r--include/asm-arm/arch-orion/orion.h143
-rw-r--r--include/asm-arm/arch-orion/platform.h25
-rw-r--r--include/asm-arm/arch-orion/system.h31
-rw-r--r--include/asm-arm/arch-orion/timex.h12
-rw-r--r--include/asm-arm/arch-orion/uncompress.h44
-rw-r--r--include/asm-arm/arch-orion/vmalloc.h5
-rw-r--r--include/asm-arm/arch-pxa/audio.h1
-rw-r--r--include/asm-arm/arch-pxa/colibri.h19
-rw-r--r--include/asm-arm/arch-pxa/corgi.h1
-rw-r--r--include/asm-arm/arch-pxa/hardware.h24
-rw-r--r--include/asm-arm/arch-pxa/i2c.h6
-rw-r--r--include/asm-arm/arch-pxa/irqs.h30
-rw-r--r--include/asm-arm/arch-pxa/littleton.h6
-rw-r--r--include/asm-arm/arch-pxa/magician.h111
-rw-r--r--include/asm-arm/arch-pxa/mfp-pxa300.h5
-rw-r--r--include/asm-arm/arch-pxa/mfp-pxa320.h5
-rw-r--r--include/asm-arm/arch-pxa/mfp-pxa3xx.h252
-rw-r--r--include/asm-arm/arch-pxa/mfp.h403
-rw-r--r--include/asm-arm/arch-pxa/mmc.h2
-rw-r--r--include/asm-arm/arch-pxa/pcm027.h75
-rw-r--r--include/asm-arm/arch-pxa/pcm990_baseboard.h275
-rw-r--r--include/asm-arm/arch-pxa/pxa-regs.h376
-rw-r--r--include/asm-arm/arch-pxa/pxa2xx-regs.h84
-rw-r--r--include/asm-arm/arch-pxa/pxa2xx_spi.h24
-rw-r--r--include/asm-arm/arch-pxa/pxa3xx-regs.h86
-rw-r--r--include/asm-arm/arch-pxa/regs-ssp.h112
-rw-r--r--include/asm-arm/arch-pxa/sharpsl.h2
-rw-r--r--include/asm-arm/arch-pxa/spitz.h2
-rw-r--r--include/asm-arm/arch-pxa/ssp.h36
-rw-r--r--include/asm-arm/arch-pxa/uncompress.h14
-rw-r--r--include/asm-arm/arch-pxa/zylonite.h9
-rw-r--r--include/asm-arm/arch-s3c2410/debug-macro.S2
-rw-r--r--include/asm-arm/arch-s3c2410/dma.h1
-rw-r--r--include/asm-arm/arch-s3c2410/hardware.h28
-rw-r--r--include/asm-arm/arch-s3c2410/irqs.h3
-rw-r--r--include/asm-arm/arch-s3c2410/regs-clock.h2
-rw-r--r--include/asm-arm/arch-s3c2410/regs-dsc.h2
-rw-r--r--include/asm-arm/arch-s3c2410/regs-gpio.h6
-rw-r--r--include/asm-arm/arch-s3c2410/regs-mem.h6
-rw-r--r--include/asm-arm/arch-s3c2410/regs-power.h3
-rw-r--r--include/asm-arm/arch-s3c2410/spi-gpio.h2
-rw-r--r--include/asm-arm/arch-s3c2410/system.h20
-rw-r--r--include/asm-arm/bitops.h2
-rw-r--r--include/asm-arm/cacheflush.h8
-rw-r--r--include/asm-arm/flat.h3
-rw-r--r--include/asm-arm/fpstate.h9
-rw-r--r--include/asm-arm/hardware/iop3xx.h2
-rw-r--r--include/asm-arm/kprobes.h79
-rw-r--r--include/asm-arm/mach/udc_pxa2xx.h2
-rw-r--r--include/asm-arm/pgtable.h2
-rw-r--r--include/asm-arm/plat-s3c/regs-nand.h2
-rw-r--r--include/asm-arm/plat-s3c24xx/dma.h5
-rw-r--r--include/asm-arm/plat-s3c24xx/irq.h2
-rw-r--r--include/asm-arm/plat-s3c24xx/regs-s3c2412-iis.h72
-rw-r--r--include/asm-arm/plat-s3c24xx/regs-spi.h32
-rw-r--r--include/asm-arm/proc-fns.h8
-rw-r--r--include/asm-arm/socket.h2
-rw-r--r--include/asm-arm/system.h13
-rw-r--r--include/asm-arm/traps.h9
-rw-r--r--include/asm-arm/vfp.h34
-rw-r--r--include/asm-arm/vfpmacros.h18
-rw-r--r--include/asm-arm26/irq_regs.h1
-rw-r--r--include/asm-avr32/arch-at32ap/at32ap700x.h (renamed from include/asm-avr32/arch-at32ap/at32ap7000.h)6
-rw-r--r--include/asm-avr32/arch-at32ap/cpu.h3
-rw-r--r--include/asm-avr32/arch-at32ap/io.h4
-rw-r--r--include/asm-avr32/cacheflush.h19
-rw-r--r--include/asm-avr32/irq.h5
-rw-r--r--include/asm-avr32/kdebug.h1
-rw-r--r--include/asm-avr32/ocd.h597
-rw-r--r--include/asm-avr32/processor.h17
-rw-r--r--include/asm-avr32/ptrace.h19
-rw-r--r--include/asm-avr32/setup.h2
-rw-r--r--include/asm-avr32/socket.h2
-rw-r--r--include/asm-avr32/sysreg.h4
-rw-r--r--include/asm-avr32/system.h4
-rw-r--r--include/asm-avr32/thread_info.h26
-rw-r--r--include/asm-blackfin/bfin-global.h6
-rw-r--r--include/asm-blackfin/bfin5xx_spi.h3
-rw-r--r--include/asm-blackfin/cplb-mpu.h61
-rw-r--r--include/asm-blackfin/cplb.h4
-rw-r--r--include/asm-blackfin/cplbinit.h39
-rw-r--r--include/asm-blackfin/delay.h66
-rw-r--r--include/asm-blackfin/dma.h6
-rw-r--r--include/asm-blackfin/fixed_code.h4
-rw-r--r--include/asm-blackfin/gpio.h84
-rw-r--r--include/asm-blackfin/gptimers.h2
-rw-r--r--include/asm-blackfin/io.h1
-rw-r--r--include/asm-blackfin/mach-bf527/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf527/defBF52x_base.h86
-rw-r--r--include/asm-blackfin/mach-bf527/dma.h7
-rw-r--r--include/asm-blackfin/mach-bf527/irq.h4
-rw-r--r--include/asm-blackfin/mach-bf527/mem_map.h3
-rw-r--r--include/asm-blackfin/mach-bf527/portmux.h2
-rw-r--r--include/asm-blackfin/mach-bf533/anomaly.h12
-rw-r--r--include/asm-blackfin/mach-bf533/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf533/irq.h4
-rw-r--r--include/asm-blackfin/mach-bf533/mem_map.h4
-rw-r--r--include/asm-blackfin/mach-bf533/portmux.h4
-rw-r--r--include/asm-blackfin/mach-bf537/anomaly.h14
-rw-r--r--include/asm-blackfin/mach-bf537/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf537/irq.h4
-rw-r--r--include/asm-blackfin/mach-bf537/mem_map.h3
-rw-r--r--include/asm-blackfin/mach-bf537/portmux.h2
-rw-r--r--include/asm-blackfin/mach-bf548/anomaly.h54
-rw-r--r--include/asm-blackfin/mach-bf548/bf548.h34
-rw-r--r--include/asm-blackfin/mach-bf548/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf548/cdefBF54x_base.h33
-rw-r--r--include/asm-blackfin/mach-bf548/defBF542.h4
-rw-r--r--include/asm-blackfin/mach-bf548/defBF544.h2
-rw-r--r--include/asm-blackfin/mach-bf548/defBF548.h6
-rw-r--r--include/asm-blackfin/mach-bf548/defBF549.h2
-rw-r--r--include/asm-blackfin/mach-bf548/defBF54x_base.h55
-rw-r--r--include/asm-blackfin/mach-bf548/irq.h8
-rw-r--r--include/asm-blackfin/mach-bf548/mem_init.h62
-rw-r--r--include/asm-blackfin/mach-bf548/mem_map.h18
-rw-r--r--include/asm-blackfin/mach-bf548/portmux.h16
-rw-r--r--include/asm-blackfin/mach-bf561/anomaly.h18
-rw-r--r--include/asm-blackfin/mach-bf561/bf561.h19
-rw-r--r--include/asm-blackfin/mach-bf561/bfin_serial_5xx.h2
-rw-r--r--include/asm-blackfin/mach-bf561/defBF561.h18
-rw-r--r--include/asm-blackfin/mach-bf561/irq.h4
-rw-r--r--include/asm-blackfin/mach-bf561/mem_map.h7
-rw-r--r--include/asm-blackfin/mach-bf561/portmux.h2
-rw-r--r--include/asm-blackfin/mach-common/def_LPBlackfin.h8
-rw-r--r--include/asm-blackfin/mmu.h4
-rw-r--r--include/asm-blackfin/mmu_context.h62
-rw-r--r--include/asm-blackfin/page_offset.h2
-rw-r--r--include/asm-blackfin/socket.h3
-rw-r--r--include/asm-blackfin/string.h2
-rw-r--r--include/asm-blackfin/traps.h100
-rw-r--r--include/asm-blackfin/uaccess.h2
-rw-r--r--include/asm-blackfin/unistd.h3
-rw-r--r--include/asm-cris/arch-v10/ide.h5
-rw-r--r--include/asm-cris/arch-v32/ide.h5
-rw-r--r--include/asm-cris/atomic.h2
-rw-r--r--include/asm-cris/checksum.h2
-rw-r--r--include/asm-cris/ethernet.h3
-rw-r--r--include/asm-cris/fasttimer.h16
-rw-r--r--include/asm-cris/hardirq.h1
-rw-r--r--include/asm-cris/page.h7
-rw-r--r--include/asm-cris/posix_types.h1
-rw-r--r--include/asm-cris/socket.h2
-rw-r--r--include/asm-cris/termbits.h13
-rw-r--r--include/asm-cris/thread_info.h9
-rw-r--r--include/asm-cris/tlb.h2
-rw-r--r--include/asm-cris/unistd.h40
-rw-r--r--include/asm-frv/ide.h6
-rw-r--r--include/asm-frv/irq.h3
-rw-r--r--include/asm-frv/socket.h2
-rw-r--r--include/asm-generic/bitops/ext2-non-atomic.h2
-rw-r--r--include/asm-generic/bitops/le.h4
-rw-r--r--include/asm-generic/bug.h17
-rw-r--r--include/asm-generic/percpu.h97
-rw-r--r--include/asm-generic/resource.h7
-rw-r--r--include/asm-generic/tlb.h1
-rw-r--r--include/asm-generic/vmlinux.lds.h90
-rw-r--r--include/asm-h8300/socket.h2
-rw-r--r--include/asm-h8300/timex.h2
-rw-r--r--include/asm-ia64/acpi.h3
-rw-r--r--include/asm-ia64/agp.h1
-rw-r--r--include/asm-ia64/bitops.h17
-rw-r--r--include/asm-ia64/gcc_intrin.h7
-rw-r--r--include/asm-ia64/hw_irq.h2
-rw-r--r--include/asm-ia64/intel_intrin.h3
-rw-r--r--include/asm-ia64/iosapic.h2
-rw-r--r--include/asm-ia64/pal.h5
-rw-r--r--include/asm-ia64/percpu.h57
-rw-r--r--include/asm-ia64/smp.h1
-rw-r--r--include/asm-ia64/sn/bte.h31
-rw-r--r--include/asm-ia64/sn/xp.h27
-rw-r--r--include/asm-ia64/sn/xpc.h10
-rw-r--r--include/asm-ia64/socket.h2
-rw-r--r--include/asm-ia64/tlbflush.h6
-rw-r--r--include/asm-m32r/signal.h2
-rw-r--r--include/asm-m32r/socket.h2
-rw-r--r--include/asm-m32r/thread_info.h11
-rw-r--r--include/asm-m32r/unistd.h66
-rw-r--r--include/asm-m68k/bitops.h2
-rw-r--r--include/asm-m68k/socket.h2
-rw-r--r--include/asm-m68knommu/bitops.h2
-rw-r--r--include/asm-m68knommu/cacheflush.h2
-rw-r--r--include/asm-m68knommu/mcfcache.h2
-rw-r--r--include/asm-m68knommu/mcfuart.h3
-rw-r--r--include/asm-m68knommu/unistd.h4
-rw-r--r--include/asm-mips/8253pit.h10
-rw-r--r--include/asm-mips/addrspace.h2
-rw-r--r--include/asm-mips/asm.h8
-rw-r--r--include/asm-mips/bootinfo.h105
-rw-r--r--include/asm-mips/bugs.h25
-rw-r--r--include/asm-mips/cacheops.h2
-rw-r--r--include/asm-mips/cpu-features.h6
-rw-r--r--include/asm-mips/cpu-info.h6
-rw-r--r--include/asm-mips/cpu.h4
-rw-r--r--include/asm-mips/delay.h23
-rw-r--r--include/asm-mips/dma.h8
-rw-r--r--include/asm-mips/fixmap.h10
-rw-r--r--include/asm-mips/futex.h6
-rw-r--r--include/asm-mips/fw/cfe/cfe_api.h87
-rw-r--r--include/asm-mips/fw/cfe/cfe_error.h19
-rw-r--r--include/asm-mips/i8253.h17
-rw-r--r--include/asm-mips/ip32/ip32_ints.h4
-rw-r--r--include/asm-mips/jmr3927/jmr3927.h9
-rw-r--r--include/asm-mips/jmr3927/tx3927.h4
-rw-r--r--include/asm-mips/jmr3927/txx927.h37
-rw-r--r--include/asm-mips/lasat/lasatint.h5
-rw-r--r--include/asm-mips/mach-au1x00/au1000.h30
-rw-r--r--include/asm-mips/mach-au1x00/au1100_mmc.h7
-rw-r--r--include/asm-mips/mach-au1x00/au1xxx_ide.h1
-rw-r--r--include/asm-mips/mach-au1x00/timex.h13
-rw-r--r--include/asm-mips/mach-cobalt/cobalt.h15
-rw-r--r--include/asm-mips/mach-cobalt/irq.h3
-rw-r--r--include/asm-mips/mach-generic/timex.h13
-rw-r--r--include/asm-mips/mach-ip28/cpu-feature-overrides.h50
-rw-r--r--include/asm-mips/mach-ip28/ds1286.h4
-rw-r--r--include/asm-mips/mach-ip28/spaces.h22
-rw-r--r--include/asm-mips/mach-ip28/war.h (renamed from include/asm-mips/mach-qemu/war.h)8
-rw-r--r--include/asm-mips/mach-jazz/timex.h16
-rw-r--r--include/asm-mips/mach-lasat/irq.h13
-rw-r--r--include/asm-mips/mach-qemu/cpu-feature-overrides.h32
-rw-r--r--include/asm-mips/mach-qemu/timex.h16
-rw-r--r--include/asm-mips/mach-rm/timex.h13
-rw-r--r--include/asm-mips/mips-boards/generic.h6
-rw-r--r--include/asm-mips/mipsprom.h2
-rw-r--r--include/asm-mips/pmc-sierra/msp71xx/msp_regs.h4
-rw-r--r--include/asm-mips/r4kcache.h7
-rw-r--r--include/asm-mips/sgi/ioc.h4
-rw-r--r--include/asm-mips/sibyte/board.h6
-rw-r--r--include/asm-mips/sibyte/sb1250.h2
-rw-r--r--include/asm-mips/sibyte/swarm.h18
-rw-r--r--include/asm-mips/smp-ops.h56
-rw-r--r--include/asm-mips/smp.h64
-rw-r--r--include/asm-mips/smtc_ipi.h6
-rw-r--r--include/asm-mips/sni.h159
-rw-r--r--include/asm-mips/socket.h2
-rw-r--r--include/asm-mips/stackframe.h9
-rw-r--r--include/asm-mips/system.h10
-rw-r--r--include/asm-mips/time.h45
-rw-r--r--include/asm-mips/timex.h27
-rw-r--r--include/asm-mips/topology.h16
-rw-r--r--include/asm-mips/tx4927/tx4927_pci.h4
-rw-r--r--include/asm-mips/tx4938/tx4938.h1
-rw-r--r--include/asm-mips/txx9tmr.h67
-rw-r--r--include/asm-mips/uaccess.h13
-rw-r--r--include/asm-mips/war.h62
-rw-r--r--include/asm-parisc/agp.h1
-rw-r--r--include/asm-parisc/pdc.h3
-rw-r--r--include/asm-parisc/socket.h2
-rw-r--r--include/asm-powerpc/8xx_immap.h2
-rw-r--r--include/asm-powerpc/agp.h1
-rw-r--r--include/asm-powerpc/bitops.h4
-rw-r--r--include/asm-powerpc/cpm.h74
-rw-r--r--include/asm-powerpc/cpm1.h (renamed from include/asm-powerpc/commproc.h)84
-rw-r--r--include/asm-powerpc/cpm2.h64
-rw-r--r--include/asm-powerpc/cputable.h35
-rw-r--r--include/asm-powerpc/cputhreads.h71
-rw-r--r--include/asm-powerpc/dcr-native.h30
-rw-r--r--include/asm-powerpc/dcr-regs.h71
-rw-r--r--include/asm-powerpc/dma-mapping.h10
-rw-r--r--include/asm-powerpc/firmware.h2
-rw-r--r--include/asm-powerpc/ide.h3
-rw-r--r--include/asm-powerpc/immap_86xx.h25
-rw-r--r--include/asm-powerpc/immap_qe.h34
-rw-r--r--include/asm-powerpc/io.h5
-rw-r--r--include/asm-powerpc/iommu.h3
-rw-r--r--include/asm-powerpc/ipic.h12
-rw-r--r--include/asm-powerpc/irq.h212
-rw-r--r--include/asm-powerpc/iseries/hv_lp_event.h2
-rw-r--r--include/asm-powerpc/kexec.h3
-rw-r--r--include/asm-powerpc/lmb.h1
-rw-r--r--include/asm-powerpc/machdep.h58
-rw-r--r--include/asm-powerpc/mmu-hash64.h7
-rw-r--r--include/asm-powerpc/mpc52xx.h16
-rw-r--r--include/asm-powerpc/mpc52xx_psc.h3
-rw-r--r--include/asm-powerpc/mpc8260.h1
-rw-r--r--include/asm-powerpc/mpc8xx.h20
-rw-r--r--include/asm-powerpc/mpic.h20
-rw-r--r--include/asm-powerpc/nvram.h11
-rw-r--r--include/asm-powerpc/of_platform.h14
-rw-r--r--include/asm-powerpc/page_32.h4
-rw-r--r--include/asm-powerpc/pasemi_dma.h467
-rw-r--r--include/asm-powerpc/pci-bridge.h204
-rw-r--r--include/asm-powerpc/pci.h29
-rw-r--r--include/asm-powerpc/percpu.h48
-rw-r--r--include/asm-powerpc/pgalloc-64.h5
-rw-r--r--include/asm-powerpc/pgtable-64k.h39
-rw-r--r--include/asm-powerpc/pgtable-ppc32.h18
-rw-r--r--include/asm-powerpc/ppc-pci.h4
-rw-r--r--include/asm-powerpc/prom.h4
-rw-r--r--include/asm-powerpc/ps3.h74
-rw-r--r--include/asm-powerpc/ptrace.h10
-rw-r--r--include/asm-powerpc/qe.h156
-rw-r--r--include/asm-powerpc/reg.h7
-rw-r--r--include/asm-powerpc/reg_booke.h18
-rw-r--r--include/asm-powerpc/setjmp.h18
-rw-r--r--include/asm-powerpc/smu.h142
-rw-r--r--include/asm-powerpc/socket.h2
-rw-r--r--include/asm-powerpc/sparsemem.h5
-rw-r--r--include/asm-powerpc/spu.h32
-rw-r--r--include/asm-powerpc/spu_csa.h13
-rw-r--r--include/asm-powerpc/spu_priv1.h15
-rw-r--r--include/asm-powerpc/systbl.h3
-rw-r--r--include/asm-powerpc/system.h2
-rw-r--r--include/asm-powerpc/time.h28
-rw-r--r--include/asm-powerpc/tlbflush.h12
-rw-r--r--include/asm-powerpc/udbg.h1
-rw-r--r--include/asm-powerpc/unistd.h3
-rw-r--r--include/asm-powerpc/vdso_datapage.h8
-rw-r--r--include/asm-ppc/8xx_immap.h2
-rw-r--r--include/asm-ppc/cpm1.h (renamed from include/asm-ppc/commproc.h)14
-rw-r--r--include/asm-ppc/cpm2.h2
-rw-r--r--include/asm-ppc/immap_85xx.h126
-rw-r--r--include/asm-ppc/mmu.h6
-rw-r--r--include/asm-ppc/mmu_context.h5
-rw-r--r--include/asm-ppc/mpc52xx_psc.h3
-rw-r--r--include/asm-ppc/mpc83xx.h107
-rw-r--r--include/asm-ppc/mpc85xx.h192
-rw-r--r--include/asm-ppc/pgtable.h46
-rw-r--r--include/asm-ppc/ppc_sys.h4
-rw-r--r--include/asm-ppc/ppcboot.h8
-rw-r--r--include/asm-ppc/reg_booke.h30
-rw-r--r--include/asm-ppc/serial.h4
-rw-r--r--include/asm-s390/airq.h19
-rw-r--r--include/asm-s390/bitops.h2
-rw-r--r--include/asm-s390/cio.h4
-rw-r--r--include/asm-s390/dasd.h2
-rw-r--r--include/asm-s390/ipl.h8
-rw-r--r--include/asm-s390/mmu_context.h27
-rw-r--r--include/asm-s390/percpu.h62
-rw-r--r--include/asm-s390/pgtable.h54
-rw-r--r--include/asm-s390/processor.h4
-rw-r--r--include/asm-s390/ptrace.h8
-rw-r--r--include/asm-s390/qdio.h2
-rw-r--r--include/asm-s390/rwsem.h4
-rw-r--r--include/asm-s390/sclp.h20
-rw-r--r--include/asm-s390/smp.h5
-rw-r--r--include/asm-s390/socket.h2
-rw-r--r--include/asm-s390/spinlock.h32
-rw-r--r--include/asm-s390/spinlock_types.h1
-rw-r--r--include/asm-s390/system.h5
-rw-r--r--include/asm-s390/tlbflush.h32
-rw-r--r--include/asm-s390/zcrypt.h2
-rw-r--r--include/asm-sh/Kbuild5
-rw-r--r--include/asm-sh/addrspace.h43
-rw-r--r--include/asm-sh/atomic-grb.h169
-rw-r--r--include/asm-sh/atomic.h10
-rw-r--r--include/asm-sh/auxvec.h18
-rw-r--r--include/asm-sh/bitops-grb.h169
-rw-r--r--include/asm-sh/bitops-irq.h91
-rw-r--r--include/asm-sh/bitops.h117
-rw-r--r--include/asm-sh/bug.h9
-rw-r--r--include/asm-sh/bugs.h17
-rw-r--r--include/asm-sh/byteorder.h45
-rw-r--r--include/asm-sh/cache.h8
-rw-r--r--include/asm-sh/cacheflush.h24
-rw-r--r--include/asm-sh/checksum.h216
-rw-r--r--include/asm-sh/checksum_32.h215
-rw-r--r--include/asm-sh/checksum_64.h (renamed from include/asm-sh64/checksum.h)18
-rw-r--r--include/asm-sh/cmpxchg-grb.h70
-rw-r--r--include/asm-sh/cmpxchg-irq.h40
-rw-r--r--include/asm-sh/cpu-sh2/addrspace.h7
-rw-r--r--include/asm-sh/cpu-sh2/cache.h8
-rw-r--r--include/asm-sh/cpu-sh2/rtc.h8
-rw-r--r--include/asm-sh/cpu-sh2a/addrspace.h11
-rw-r--r--include/asm-sh/cpu-sh2a/cache.h11
-rw-r--r--include/asm-sh/cpu-sh2a/freq.h2
-rw-r--r--include/asm-sh/cpu-sh2a/rtc.h8
-rw-r--r--include/asm-sh/cpu-sh3/addrspace.h7
-rw-r--r--include/asm-sh/cpu-sh3/cache.h8
-rw-r--r--include/asm-sh/cpu-sh3/dma.h4
-rw-r--r--include/asm-sh/cpu-sh3/freq.h5
-rw-r--r--include/asm-sh/cpu-sh3/gpio.h3
-rw-r--r--include/asm-sh/cpu-sh3/mmu_context.h3
-rw-r--r--include/asm-sh/cpu-sh3/rtc.h8
-rw-r--r--include/asm-sh/cpu-sh3/timer.h9
-rw-r--r--include/asm-sh/cpu-sh3/ubc.h3
-rw-r--r--include/asm-sh/cpu-sh4/addrspace.h6
-rw-r--r--include/asm-sh/cpu-sh4/cache.h5
-rw-r--r--include/asm-sh/cpu-sh4/fpu.h32
-rw-r--r--include/asm-sh/cpu-sh4/freq.h3
-rw-r--r--include/asm-sh/cpu-sh4/mmu_context.h10
-rw-r--r--include/asm-sh/cpu-sh4/rtc.h8
-rw-r--r--include/asm-sh/cpu-sh5/addrspace.h11
-rw-r--r--include/asm-sh/cpu-sh5/cache.h (renamed from include/asm-sh64/cache.h)80
-rw-r--r--include/asm-sh/cpu-sh5/cacheflush.h (renamed from include/asm-sh64/cacheflush.h)23
-rw-r--r--include/asm-sh/cpu-sh5/dma.h6
-rw-r--r--include/asm-sh/cpu-sh5/irq.h (renamed from include/asm-sh64/irq.h)43
-rw-r--r--include/asm-sh/cpu-sh5/mmu_context.h27
-rw-r--r--include/asm-sh/cpu-sh5/registers.h (renamed from include/asm-sh64/registers.h)16
-rw-r--r--include/asm-sh/cpu-sh5/rtc.h8
-rw-r--r--include/asm-sh/cpu-sh5/timer.h4
-rw-r--r--include/asm-sh/delay.h8
-rw-r--r--include/asm-sh/dma-mapping.h56
-rw-r--r--include/asm-sh/elf.h75
-rw-r--r--include/asm-sh/fixmap.h5
-rw-r--r--include/asm-sh/flat.h2
-rw-r--r--include/asm-sh/fpu.h46
-rw-r--r--include/asm-sh/hd64461.h28
-rw-r--r--include/asm-sh/hs7751rvoip.h54
-rw-r--r--include/asm-sh/hw_irq.h12
-rw-r--r--include/asm-sh/io.h68
-rw-r--r--include/asm-sh/irq.h2
-rw-r--r--include/asm-sh/irqflags.h97
-rw-r--r--include/asm-sh/irqflags_32.h99
-rw-r--r--include/asm-sh/irqflags_64.h85
-rw-r--r--include/asm-sh/machvec.h5
-rw-r--r--include/asm-sh/microdev.h4
-rw-r--r--include/asm-sh/mmu_context.h87
-rw-r--r--include/asm-sh/mmu_context_32.h47
-rw-r--r--include/asm-sh/mmu_context_64.h75
-rw-r--r--include/asm-sh/module.h4
-rw-r--r--include/asm-sh/page.h114
-rw-r--r--include/asm-sh/param.h6
-rw-r--r--include/asm-sh/pci.h5
-rw-r--r--include/asm-sh/pgtable.h516
-rw-r--r--include/asm-sh/pgtable_32.h474
-rw-r--r--include/asm-sh/pgtable_64.h (renamed from include/asm-sh64/pgtable.h)253
-rw-r--r--include/asm-sh/posix_types.h129
-rw-r--r--include/asm-sh/posix_types_32.h122
-rw-r--r--include/asm-sh/posix_types_64.h (renamed from include/asm-sh64/posix_types.h)0
-rw-r--r--include/asm-sh/processor.h262
-rw-r--r--include/asm-sh/processor_32.h215
-rw-r--r--include/asm-sh/processor_64.h (renamed from include/asm-sh64/processor.h)78
-rw-r--r--include/asm-sh/ptrace.h31
-rw-r--r--include/asm-sh/r7780rp.h33
-rw-r--r--include/asm-sh/rtc.h2
-rw-r--r--include/asm-sh/scatterlist.h2
-rw-r--r--include/asm-sh/sdk7780.h81
-rw-r--r--include/asm-sh/sections.h1
-rw-r--r--include/asm-sh/setup.h14
-rw-r--r--include/asm-sh/sigcontext.h16
-rw-r--r--include/asm-sh/socket.h2
-rw-r--r--include/asm-sh/spi.h13
-rw-r--r--include/asm-sh/stat.h63
-rw-r--r--include/asm-sh/string.h136
-rw-r--r--include/asm-sh/string_32.h131
-rw-r--r--include/asm-sh/string_64.h (renamed from include/asm-sh64/string.h)18
-rw-r--r--include/asm-sh/system.h173
-rw-r--r--include/asm-sh/system_32.h99
-rw-r--r--include/asm-sh/system_64.h40
-rw-r--r--include/asm-sh/thread_info.h10
-rw-r--r--include/asm-sh/tlb.h10
-rw-r--r--include/asm-sh/tlb_64.h (renamed from include/asm-sh64/tlb.h)45
-rw-r--r--include/asm-sh/types.h6
-rw-r--r--include/asm-sh/uaccess.h576
-rw-r--r--include/asm-sh/uaccess_32.h510
-rw-r--r--include/asm-sh/uaccess_64.h (renamed from include/asm-sh64/uaccess.h)28
-rw-r--r--include/asm-sh/unistd.h379
-rw-r--r--include/asm-sh/unistd_32.h376
-rw-r--r--include/asm-sh/unistd_64.h (renamed from include/asm-sh64/unistd.h)18
-rw-r--r--include/asm-sh/user.h7
-rw-r--r--include/asm-sh/vga.h6
-rw-r--r--include/asm-sh/voyagergx.h341
-rw-r--r--include/asm-sh64/Kbuild1
-rw-r--r--include/asm-sh64/a.out.h38
-rw-r--r--include/asm-sh64/atomic.h158
-rw-r--r--include/asm-sh64/auxvec.h4
-rw-r--r--include/asm-sh64/bitops.h155
-rw-r--r--include/asm-sh64/bug.h19
-rw-r--r--include/asm-sh64/bugs.h38
-rw-r--r--include/asm-sh64/byteorder.h49
-rw-r--r--include/asm-sh64/cayman.h20
-rw-r--r--include/asm-sh64/cpumask.h6
-rw-r--r--include/asm-sh64/cputime.h6
-rw-r--r--include/asm-sh64/current.h28
-rw-r--r--include/asm-sh64/delay.h11
-rw-r--r--include/asm-sh64/device.h7
-rw-r--r--include/asm-sh64/div64.h6
-rw-r--r--include/asm-sh64/dma-mapping.h193
-rw-r--r--include/asm-sh64/dma.h41
-rw-r--r--include/asm-sh64/elf.h107
-rw-r--r--include/asm-sh64/emergency-restart.h6
-rw-r--r--include/asm-sh64/errno.h6
-rw-r--r--include/asm-sh64/fb.h19
-rw-r--r--include/asm-sh64/fcntl.h1
-rw-r--r--include/asm-sh64/futex.h6
-rw-r--r--include/asm-sh64/gpio.h8
-rw-r--r--include/asm-sh64/hardirq.h18
-rw-r--r--include/asm-sh64/hardware.h22
-rw-r--r--include/asm-sh64/hw_irq.h15
-rw-r--r--include/asm-sh64/ide.h29
-rw-r--r--include/asm-sh64/io.h196
-rw-r--r--include/asm-sh64/ioctl.h1
-rw-r--r--include/asm-sh64/ioctls.h116
-rw-r--r--include/asm-sh64/ipcbuf.h40
-rw-r--r--include/asm-sh64/irq_regs.h1
-rw-r--r--include/asm-sh64/kdebug.h1
-rw-r--r--include/asm-sh64/keyboard.h70
-rw-r--r--include/asm-sh64/kmap_types.h7
-rw-r--r--include/asm-sh64/linkage.h7
-rw-r--r--include/asm-sh64/local.h7
-rw-r--r--include/asm-sh64/mc146818rtc.h7
-rw-r--r--include/asm-sh64/mman.h6
-rw-r--r--include/asm-sh64/mmu.h7
-rw-r--r--include/asm-sh64/mmu_context.h208
-rw-r--r--include/asm-sh64/module.h20
-rw-r--r--include/asm-sh64/msgbuf.h42
-rw-r--r--include/asm-sh64/mutex.h9
-rw-r--r--include/asm-sh64/namei.h24
-rw-r--r--include/asm-sh64/page.h119
-rw-r--r--include/asm-sh64/param.h42
-rw-r--r--include/asm-sh64/pci.h111
-rw-r--r--include/asm-sh64/percpu.h6
-rw-r--r--include/asm-sh64/pgalloc.h125
-rw-r--r--include/asm-sh64/platform.h64
-rw-r--r--include/asm-sh64/poll.h8
-rw-r--r--include/asm-sh64/ptrace.h37
-rw-r--r--include/asm-sh64/resource.h6
-rw-r--r--include/asm-sh64/scatterlist.h28
-rw-r--r--include/asm-sh64/sci.h1
-rw-r--r--include/asm-sh64/sections.h7
-rw-r--r--include/asm-sh64/segment.h6
-rw-r--r--include/asm-sh64/semaphore-helper.h101
-rw-r--r--include/asm-sh64/semaphore.h119
-rw-r--r--include/asm-sh64/sembuf.h36
-rw-r--r--include/asm-sh64/serial.h31
-rw-r--r--include/asm-sh64/setup.h22
-rw-r--r--include/asm-sh64/shmbuf.h53
-rw-r--r--include/asm-sh64/shmparam.h12
-rw-r--r--include/asm-sh64/sigcontext.h30
-rw-r--r--include/asm-sh64/siginfo.h6
-rw-r--r--include/asm-sh64/signal.h159
-rw-r--r--include/asm-sh64/smp.h15
-rw-r--r--include/asm-sh64/socket.h6
-rw-r--r--include/asm-sh64/sockios.h25
-rw-r--r--include/asm-sh64/spinlock.h17
-rw-r--r--include/asm-sh64/stat.h88
-rw-r--r--include/asm-sh64/statfs.h6
-rw-r--r--include/asm-sh64/system.h190
-rw-r--r--include/asm-sh64/termbits.h6
-rw-r--r--include/asm-sh64/termios.h99
-rw-r--r--include/asm-sh64/thread_info.h91
-rw-r--r--include/asm-sh64/timex.h31
-rw-r--r--include/asm-sh64/tlbflush.h27
-rw-r--r--include/asm-sh64/topology.h6
-rw-r--r--include/asm-sh64/types.h74
-rw-r--r--include/asm-sh64/ucontext.h23
-rw-r--r--include/asm-sh64/unaligned.h17
-rw-r--r--include/asm-sh64/user.h70
-rw-r--r--include/asm-sparc/socket.h2
-rw-r--r--include/asm-sparc/unistd.h9
-rw-r--r--include/asm-sparc64/agp.h1
-rw-r--r--include/asm-sparc64/dma-mapping.h12
-rw-r--r--include/asm-sparc64/futex.h6
-rw-r--r--include/asm-sparc64/hypervisor.h4
-rw-r--r--include/asm-sparc64/pci.h4
-rw-r--r--include/asm-sparc64/percpu.h38
-rw-r--r--include/asm-sparc64/socket.h1
-rw-r--r--include/asm-sparc64/system.h4
-rw-r--r--include/asm-sparc64/uaccess.h6
-rw-r--r--include/asm-sparc64/vio.h4
-rw-r--r--include/asm-um/asm.h6
-rw-r--r--include/asm-um/linkage.h1
-rw-r--r--include/asm-um/nops.h6
-rw-r--r--include/asm-um/pgtable-3level.h2
-rw-r--r--include/asm-um/unistd.h1
-rw-r--r--include/asm-v850/socket.h2
-rw-r--r--include/asm-x86/Kbuild5
-rw-r--r--include/asm-x86/acpi.h174
-rw-r--r--include/asm-x86/acpi_32.h143
-rw-r--r--include/asm-x86/acpi_64.h153
-rw-r--r--include/asm-x86/agp.h9
-rw-r--r--include/asm-x86/alternative.h162
-rw-r--r--include/asm-x86/alternative_32.h154
-rw-r--r--include/asm-x86/alternative_64.h159
-rw-r--r--include/asm-x86/apic.h141
-rw-r--r--include/asm-x86/apic_32.h126
-rw-r--r--include/asm-x86/apic_64.h102
-rw-r--r--include/asm-x86/apicdef.h412
-rw-r--r--include/asm-x86/apicdef_32.h375
-rw-r--r--include/asm-x86/apicdef_64.h392
-rw-r--r--include/asm-x86/arch_hooks.h5
-rw-r--r--include/asm-x86/asm.h32
-rw-r--r--include/asm-x86/bitops.h316
-rw-r--r--include/asm-x86/bitops_32.h324
-rw-r--r--include/asm-x86/bitops_64.h297
-rw-r--r--include/asm-x86/bootparam.h5
-rw-r--r--include/asm-x86/bug.h3
-rw-r--r--include/asm-x86/bugs.h3
-rw-r--r--include/asm-x86/byteorder.h4
-rw-r--r--include/asm-x86/cacheflush.h35
-rw-r--r--include/asm-x86/calling.h194
-rw-r--r--include/asm-x86/checksum_64.h2
-rw-r--r--include/asm-x86/cmpxchg_32.h122
-rw-r--r--include/asm-x86/compat.h2
-rw-r--r--include/asm-x86/cpu.h5
-rw-r--r--include/asm-x86/cpufeature.h208
-rw-r--r--include/asm-x86/cpufeature_32.h176
-rw-r--r--include/asm-x86/cpufeature_64.h30
-rw-r--r--include/asm-x86/desc.h380
-rw-r--r--include/asm-x86/desc_32.h244
-rw-r--r--include/asm-x86/desc_64.h203
-rw-r--r--include/asm-x86/desc_defs.h47
-rw-r--r--include/asm-x86/dma.h318
-rw-r--r--include/asm-x86/dma_32.h297
-rw-r--r--include/asm-x86/dma_64.h304
-rw-r--r--include/asm-x86/dmi.h10
-rw-r--r--include/asm-x86/ds.h72
-rw-r--r--include/asm-x86/e820.h6
-rw-r--r--include/asm-x86/e820_32.h9
-rw-r--r--include/asm-x86/e820_64.h18
-rw-r--r--include/asm-x86/efi.h97
-rw-r--r--include/asm-x86/elf.h212
-rw-r--r--include/asm-x86/emergency-restart.h12
-rw-r--r--include/asm-x86/fixmap_32.h24
-rw-r--r--include/asm-x86/fixmap_64.h6
-rw-r--r--include/asm-x86/fpu32.h10
-rw-r--r--include/asm-x86/futex.h138
-rw-r--r--include/asm-x86/futex_32.h135
-rw-r--r--include/asm-x86/futex_64.h125
-rw-r--r--include/asm-x86/gart.h34
-rw-r--r--include/asm-x86/geode.h12
-rw-r--r--include/asm-x86/gpio.h6
-rw-r--r--include/asm-x86/hpet.h9
-rw-r--r--include/asm-x86/hw_irq_32.h16
-rw-r--r--include/asm-x86/hw_irq_64.h2
-rw-r--r--include/asm-x86/i387.h361
-rw-r--r--include/asm-x86/i387_32.h151
-rw-r--r--include/asm-x86/i387_64.h209
-rw-r--r--include/asm-x86/i8253.h3
-rw-r--r--include/asm-x86/i8259.h20
-rw-r--r--include/asm-x86/ia32.h6
-rw-r--r--include/asm-x86/ia32_unistd.h2
-rw-r--r--include/asm-x86/ide.h2
-rw-r--r--include/asm-x86/idle.h1
-rw-r--r--include/asm-x86/io_32.h35
-rw-r--r--include/asm-x86/io_64.h57
-rw-r--r--include/asm-x86/io_apic.h158
-rw-r--r--include/asm-x86/io_apic_32.h155
-rw-r--r--include/asm-x86/io_apic_64.h138
-rw-r--r--include/asm-x86/iommu.h4
-rw-r--r--include/asm-x86/irqflags.h246
-rw-r--r--include/asm-x86/irqflags_32.h176
-rw-r--r--include/asm-x86/irqflags_64.h156
-rw-r--r--include/asm-x86/k8.h1
-rw-r--r--include/asm-x86/kdebug.h11
-rw-r--r--include/asm-x86/kexec.h169
-rw-r--r--include/asm-x86/kexec_32.h99
-rw-r--r--include/asm-x86/kexec_64.h94
-rw-r--r--include/asm-x86/kprobes.h103
-rw-r--r--include/asm-x86/kprobes_32.h94
-rw-r--r--include/asm-x86/kprobes_64.h90
-rw-r--r--include/asm-x86/kvm.h191
-rw-r--r--include/asm-x86/kvm_host.h611
-rw-r--r--include/asm-x86/kvm_para.h105
-rw-r--r--include/asm-x86/kvm_x86_emulate.h186
-rw-r--r--include/asm-x86/lguest.h16
-rw-r--r--include/asm-x86/lguest_hcall.h9
-rw-r--r--include/asm-x86/linkage.h26
-rw-r--r--include/asm-x86/linkage_32.h15
-rw-r--r--include/asm-x86/linkage_64.h6
-rw-r--r--include/asm-x86/local.h243
-rw-r--r--include/asm-x86/local_32.h233
-rw-r--r--include/asm-x86/local_64.h222
-rw-r--r--include/asm-x86/mach-bigsmp/mach_apic.h12
-rw-r--r--include/asm-x86/mach-default/apm.h2
-rw-r--r--include/asm-x86/mach-default/io_ports.h25
-rw-r--r--include/asm-x86/mach-default/mach_apic.h18
-rw-r--r--include/asm-x86/mach-default/mach_reboot.h2
-rw-r--r--include/asm-x86/mach-default/mach_time.h111
-rw-r--r--include/asm-x86/mach-default/mach_timer.h2
-rw-r--r--include/asm-x86/mach-default/mach_traps.h2
-rw-r--r--include/asm-x86/mach-es7000/mach_apic.h10
-rw-r--r--include/asm-x86/mach-es7000/mach_mpparse.h6
-rw-r--r--include/asm-x86/mach-generic/gpio.h15
-rw-r--r--include/asm-x86/mach-numaq/mach_apic.h10
-rw-r--r--include/asm-x86/mach-rdc321x/gpio.h56
-rw-r--r--include/asm-x86/mach-rdc321x/rdc321x_defs.h6
-rw-r--r--include/asm-x86/mach-summit/mach_apic.h18
-rw-r--r--include/asm-x86/mach-voyager/setup_arch.h4
-rw-r--r--include/asm-x86/math_emu.h5
-rw-r--r--include/asm-x86/mc146818rtc.h101
-rw-r--r--include/asm-x86/mc146818rtc_32.h97
-rw-r--r--include/asm-x86/mc146818rtc_64.h29
-rw-r--r--include/asm-x86/mce.h18
-rw-r--r--include/asm-x86/mmsegment.h8
-rw-r--r--include/asm-x86/mmu.h8
-rw-r--r--include/asm-x86/mmu_context_32.h2
-rw-r--r--include/asm-x86/mmu_context_64.h13
-rw-r--r--include/asm-x86/mmzone_32.h3
-rw-r--r--include/asm-x86/mmzone_64.h12
-rw-r--r--include/asm-x86/module.h81
-rw-r--r--include/asm-x86/module_32.h75
-rw-r--r--include/asm-x86/module_64.h10
-rw-r--r--include/asm-x86/mpspec.h116
-rw-r--r--include/asm-x86/mpspec_32.h81
-rw-r--r--include/asm-x86/mpspec_64.h233
-rw-r--r--include/asm-x86/mpspec_def.h87
-rw-r--r--include/asm-x86/msr-index.h15
-rw-r--r--include/asm-x86/msr.h295
-rw-r--r--include/asm-x86/mtrr.h14
-rw-r--r--include/asm-x86/mutex_32.h7
-rw-r--r--include/asm-x86/nmi_32.h3
-rw-r--r--include/asm-x86/nmi_64.h5
-rw-r--r--include/asm-x86/nops.h90
-rw-r--r--include/asm-x86/numa_32.h14
-rw-r--r--include/asm-x86/numa_64.h12
-rw-r--r--include/asm-x86/page.h190
-rw-r--r--include/asm-x86/page_32.h247
-rw-r--r--include/asm-x86/page_64.h110
-rw-r--r--include/asm-x86/paravirt.h615
-rw-r--r--include/asm-x86/pci.h17
-rw-r--r--include/asm-x86/pci_64.h3
-rw-r--r--include/asm-x86/pda.h73
-rw-r--r--include/asm-x86/percpu.h145
-rw-r--r--include/asm-x86/percpu_32.h154
-rw-r--r--include/asm-x86/percpu_64.h68
-rw-r--r--include/asm-x86/pgalloc_32.h71
-rw-r--r--include/asm-x86/pgtable-2level.h45
-rw-r--r--include/asm-x86/pgtable-3level.h88
-rw-r--r--include/asm-x86/pgtable.h359
-rw-r--r--include/asm-x86/pgtable_32.h291
-rw-r--r--include/asm-x86/pgtable_64.h260
-rw-r--r--include/asm-x86/processor.h841
-rw-r--r--include/asm-x86/processor_32.h786
-rw-r--r--include/asm-x86/processor_64.h452
-rw-r--r--include/asm-x86/proto.h69
-rw-r--r--include/asm-x86/ptrace-abi.h62
-rw-r--r--include/asm-x86/ptrace.h220
-rw-r--r--include/asm-x86/resume-trace.h23
-rw-r--r--include/asm-x86/resume-trace_32.h13
-rw-r--r--include/asm-x86/resume-trace_64.h13
-rw-r--r--include/asm-x86/rio.h4
-rw-r--r--include/asm-x86/rwlock.h1
-rw-r--r--include/asm-x86/rwsem.h14
-rw-r--r--include/asm-x86/scatterlist.h34
-rw-r--r--include/asm-x86/scatterlist_32.h28
-rw-r--r--include/asm-x86/scatterlist_64.h29
-rw-r--r--include/asm-x86/segment.h203
-rw-r--r--include/asm-x86/segment_32.h148
-rw-r--r--include/asm-x86/segment_64.h53
-rw-r--r--include/asm-x86/semaphore_32.h8
-rw-r--r--include/asm-x86/setup.h11
-rw-r--r--include/asm-x86/sigcontext.h42
-rw-r--r--include/asm-x86/sigcontext32.h22
-rw-r--r--include/asm-x86/signal.h11
-rw-r--r--include/asm-x86/smp_32.h119
-rw-r--r--include/asm-x86/smp_64.h137
-rw-r--r--include/asm-x86/socket.h2
-rw-r--r--include/asm-x86/sparsemem.h35
-rw-r--r--include/asm-x86/sparsemem_32.h31
-rw-r--r--include/asm-x86/sparsemem_64.h26
-rw-r--r--include/asm-x86/spinlock.h295
-rw-r--r--include/asm-x86/spinlock_32.h221
-rw-r--r--include/asm-x86/spinlock_64.h167
-rw-r--r--include/asm-x86/spinlock_types.h2
-rw-r--r--include/asm-x86/stacktrace.h5
-rw-r--r--include/asm-x86/suspend_32.h4
-rw-r--r--include/asm-x86/suspend_64.h11
-rw-r--r--include/asm-x86/system.h413
-rw-r--r--include/asm-x86/system_32.h320
-rw-r--r--include/asm-x86/system_64.h156
-rw-r--r--include/asm-x86/thread_info_32.h20
-rw-r--r--include/asm-x86/thread_info_64.h39
-rw-r--r--include/asm-x86/time.h26
-rw-r--r--include/asm-x86/timer.h23
-rw-r--r--include/asm-x86/timex.h2
-rw-r--r--include/asm-x86/tlbflush.h157
-rw-r--r--include/asm-x86/tlbflush_32.h168
-rw-r--r--include/asm-x86/tlbflush_64.h100
-rw-r--r--include/asm-x86/topology.h187
-rw-r--r--include/asm-x86/topology_32.h121
-rw-r--r--include/asm-x86/topology_64.h71
-rw-r--r--include/asm-x86/tsc.h40
-rw-r--r--include/asm-x86/uaccess_64.h2
-rw-r--r--include/asm-x86/unistd_32.h2
-rw-r--r--include/asm-x86/user_32.h24
-rw-r--r--include/asm-x86/user_64.h41
-rw-r--r--include/asm-x86/vdso.h28
-rw-r--r--include/asm-x86/vsyscall.h2
-rw-r--r--include/asm-x86/vsyscall32.h20
-rw-r--r--include/asm-x86/xor_32.h2
-rw-r--r--include/asm-x86/xor_64.h2
-rw-r--r--include/asm-xtensa/socket.h2
-rw-r--r--include/crypto/aead.h105
-rw-r--r--include/crypto/aes.h31
-rw-r--r--include/crypto/algapi.h31
-rw-r--r--include/crypto/authenc.h27
-rw-r--r--include/crypto/ctr.h20
-rw-r--r--include/crypto/des.h19
-rw-r--r--include/crypto/internal/aead.h80
-rw-r--r--include/crypto/internal/skcipher.h110
-rw-r--r--include/crypto/scatterwalk.h119
-rw-r--r--include/crypto/sha.h12
-rw-r--r--include/crypto/skcipher.h110
-rw-r--r--include/linux/Kbuild19
-rw-r--r--include/linux/acpi.h12
-rw-r--r--include/linux/acpi_pmtmr.h2
-rw-r--r--include/linux/apm_bios.h6
-rw-r--r--include/linux/aspm.h44
-rw-r--r--include/linux/ata.h156
-rw-r--r--include/linux/atmbr2684.h51
-rw-r--r--include/linux/atmdev.h4
-rw-r--r--include/linux/attribute_container.h1
-rw-r--r--include/linux/audit.h15
-rw-r--r--include/linux/blkdev.h136
-rw-r--r--include/linux/blktrace_api.h12
-rw-r--r--include/linux/bootmem.h1
-rw-r--r--include/linux/buffer_head.h2
-rw-r--r--include/linux/can.h111
-rw-r--r--include/linux/can/Kbuild3
-rw-r--r--include/linux/can/bcm.h65
-rw-r--r--include/linux/can/core.h64
-rw-r--r--include/linux/can/error.h93
-rw-r--r--include/linux/can/raw.h31
-rw-r--r--include/linux/cdrom.h17
-rw-r--r--include/linux/cgroup_subsys.h13
-rw-r--r--include/linux/clocksource.h3
-rw-r--r--include/linux/compat.h15
-rw-r--r--include/linux/compiler-gcc3.h2
-rw-r--r--include/linux/compiler-gcc4.h1
-rw-r--r--include/linux/compiler.h9
-rw-r--r--include/linux/completion.h1
-rw-r--r--include/linux/connector.h5
-rw-r--r--include/linux/const.h5
-rw-r--r--include/linux/cpu.h21
-rw-r--r--include/linux/cpu_acct.h14
-rw-r--r--include/linux/cpuidle.h1
-rw-r--r--include/linux/cpumask.h6
-rw-r--r--include/linux/crypto.h103
-rw-r--r--include/linux/dccp.h91
-rw-r--r--include/linux/debug_locks.h5
-rw-r--r--include/linux/device-mapper.h2
-rw-r--r--include/linux/device.h363
-rw-r--r--include/linux/dlm.h140
-rw-r--r--include/linux/dlmconstants.h159
-rw-r--r--include/linux/dmaengine.h3
-rw-r--r--include/linux/dmi.h4
-rw-r--r--include/linux/elevator.h2
-rw-r--r--include/linux/elf.h1
-rw-r--r--include/linux/elfnote.h2
-rw-r--r--include/linux/eventpoll.h7
-rw-r--r--include/linux/ext2_fs.h7
-rw-r--r--include/linux/ext3_fs.h20
-rw-r--r--include/linux/ext4_fs.h198
-rw-r--r--include/linux/ext4_fs_extents.h25
-rw-r--r--include/linux/ext4_fs_i.h25
-rw-r--r--include/linux/ext4_fs_sb.h55
-rw-r--r--include/linux/f75375s.h21
-rw-r--r--include/linux/fs.h21
-rw-r--r--include/linux/fuse.h5
-rw-r--r--include/linux/futex.h20
-rw-r--r--include/linux/genhd.h37
-rw-r--r--include/linux/hardirq.h6
-rw-r--r--include/linux/hdreg.h68
-rw-r--r--include/linux/hdsmart.h2
-rw-r--r--include/linux/hid.h18
-rw-r--r--include/linux/hpet.h5
-rw-r--r--include/linux/hrtimer.h14
-rw-r--r--include/linux/hugetlb.h12
-rw-r--r--include/linux/hw_random.h2
-rw-r--r--include/linux/i2c-id.h69
-rw-r--r--include/linux/i2c.h131
-rw-r--r--include/linux/i2c/tps65010.h (renamed from include/asm-arm/arch-omap/tps65010.h)8
-rw-r--r--include/linux/ide.h475
-rw-r--r--include/linux/ieee80211.h155
-rw-r--r--include/linux/if.h5
-rw-r--r--include/linux/if_addrlabel.h32
-rw-r--r--include/linux/if_arp.h1
-rw-r--r--include/linux/if_bonding.h3
-rw-r--r--include/linux/if_ether.h8
-rw-r--r--include/linux/if_frad.h2
-rw-r--r--include/linux/if_shaper.h51
-rw-r--r--include/linux/if_tr.h3
-rw-r--r--include/linux/if_tun.h4
-rw-r--r--include/linux/if_tunnel.h3
-rw-r--r--include/linux/if_vlan.h67
-rw-r--r--include/linux/in.h68
-rw-r--r--include/linux/inet_lro.h3
-rw-r--r--include/linux/inetdevice.h25
-rw-r--r--include/linux/init.h130
-rw-r--r--include/linux/init_ohci1394_dma.h4
-rw-r--r--include/linux/init_task.h16
-rw-r--r--include/linux/input.h10
-rw-r--r--include/linux/interrupt.h1
-rw-r--r--include/linux/iocontext.h95
-rw-r--r--include/linux/ioport.h2
-rw-r--r--include/linux/ioprio.h13
-rw-r--r--include/linux/ipmi_smi.h2
-rw-r--r--include/linux/ipv6.h12
-rw-r--r--include/linux/irq.h7
-rw-r--r--include/linux/jbd.h2
-rw-r--r--include/linux/jbd2.h135
-rw-r--r--include/linux/jiffies.h6
-rw-r--r--include/linux/kallsyms.h1
-rw-r--r--include/linux/kd.h2
-rw-r--r--include/linux/kernel.h7
-rw-r--r--include/linux/key.h2
-rw-r--r--include/linux/kobject.h184
-rw-r--r--include/linux/kprobes.h10
-rw-r--r--include/linux/kref.h1
-rw-r--r--include/linux/kvm.h203
-rw-r--r--include/linux/kvm_host.h299
-rw-r--r--include/linux/kvm_para.h82
-rw-r--r--include/linux/kvm_types.h54
-rw-r--r--include/linux/latencytop.h44
-rw-r--r--include/linux/leds.h3
-rw-r--r--include/linux/libata.h250
-rw-r--r--include/linux/linkage.h8
-rw-r--r--include/linux/lockd/bind.h19
-rw-r--r--include/linux/lockd/lockd.h9
-rw-r--r--include/linux/lockd/xdr.h4
-rw-r--r--include/linux/m41t00.h50
-rw-r--r--include/linux/mc146818rtc.h3
-rw-r--r--include/linux/mm.h32
-rw-r--r--include/linux/mmc/host.h4
-rw-r--r--include/linux/module.h45
-rw-r--r--include/linux/moduleparam.h4
-rw-r--r--include/linux/mroute.h12
-rw-r--r--include/linux/mutex.h5
-rw-r--r--include/linux/mv643xx.h10
-rw-r--r--include/linux/mv643xx_eth.h6
-rw-r--r--include/linux/mv643xx_i2c.h22
-rw-r--r--include/linux/net.h19
-rw-r--r--include/linux/netdevice.h32
-rw-r--r--include/linux/netfilter.h165
-rw-r--r--include/linux/netfilter/Kbuild22
-rw-r--r--include/linux/netfilter/nf_conntrack_common.h8
-rw-r--r--include/linux/netfilter/nf_conntrack_h323.h6
-rw-r--r--include/linux/netfilter/nf_conntrack_pptp.h2
-rw-r--r--include/linux/netfilter/nf_conntrack_sctp.h1
-rw-r--r--include/linux/netfilter/nf_conntrack_sip.h6
-rw-r--r--include/linux/netfilter/nfnetlink_conntrack.h11
-rw-r--r--include/linux/netfilter/nfnetlink_log.h1
-rw-r--r--include/linux/netfilter/x_tables.h86
-rw-r--r--include/linux/netfilter/xt_CONNMARK.h5
-rw-r--r--include/linux/netfilter/xt_DSCP.h5
-rw-r--r--include/linux/netfilter/xt_MARK.h4
-rw-r--r--include/linux/netfilter/xt_RATEEST.h13
-rw-r--r--include/linux/netfilter/xt_TCPOPTSTRIP.h13
-rw-r--r--include/linux/netfilter/xt_connlimit.h11
-rw-r--r--include/linux/netfilter/xt_connmark.h5
-rw-r--r--include/linux/netfilter/xt_conntrack.h38
-rw-r--r--include/linux/netfilter/xt_dscp.h6
-rw-r--r--include/linux/netfilter/xt_hashlimit.h39
-rw-r--r--include/linux/netfilter/xt_iprange.h17
-rw-r--r--include/linux/netfilter/xt_mark.h5
-rw-r--r--include/linux/netfilter/xt_owner.h16
-rw-r--r--include/linux/netfilter/xt_policy.h23
-rw-r--r--include/linux/netfilter/xt_quota.h2
-rw-r--r--include/linux/netfilter/xt_rateest.h35
-rw-r--r--include/linux/netfilter/xt_statistic.h1
-rw-r--r--include/linux/netfilter/xt_string.h2
-rw-r--r--include/linux/netfilter_arp/arp_tables.h55
-rw-r--r--include/linux/netfilter_bridge.h3
-rw-r--r--include/linux/netfilter_ipv4.h2
-rw-r--r--include/linux/netfilter_ipv4/Kbuild28
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h89
-rw-r--r--include/linux/netfilter_ipv4/ipt_CLUSTERIP.h1
-rw-r--r--include/linux/netfilter_ipv4/ipt_addrtype.h14
-rw-r--r--include/linux/netfilter_ipv4/ipt_iprange.h6
-rw-r--r--include/linux/netfilter_ipv6.h3
-rw-r--r--include/linux/netfilter_ipv6/Kbuild2
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h86
-rw-r--r--include/linux/netlink.h7
-rw-r--r--include/linux/netpoll.h9
-rw-r--r--include/linux/nfs_fs.h84
-rw-r--r--include/linux/nfs_fs_sb.h17
-rw-r--r--include/linux/nfs_mount.h2
-rw-r--r--include/linux/nfs_page.h13
-rw-r--r--include/linux/nfs_xdr.h21
-rw-r--r--include/linux/nfsd/Kbuild1
-rw-r--r--include/linux/nfsd/auth.h27
-rw-r--r--include/linux/nfsd/cache.h4
-rw-r--r--include/linux/nfsd/export.h2
-rw-r--r--include/linux/nfsd/nfsd.h5
-rw-r--r--include/linux/nfsd/syscall.h1
-rw-r--r--include/linux/nfsd/xdr.h14
-rw-r--r--include/linux/nfsd/xdr3.h16
-rw-r--r--include/linux/nfsd/xdr4.h2
-rw-r--r--include/linux/nfsd_idmap.h11
-rw-r--r--include/linux/nl80211.h154
-rw-r--r--include/linux/notifier.h6
-rw-r--r--include/linux/of.h12
-rw-r--r--include/linux/of_device.h2
-rw-r--r--include/linux/pagemap.h14
-rw-r--r--include/linux/pata_platform.h9
-rw-r--r--include/linux/pci-acpi.h11
-rw-r--r--include/linux/pci.h383
-rw-r--r--include/linux/pci_hotplug.h2
-rw-r--r--include/linux/pci_ids.h32
-rw-r--r--include/linux/pci_regs.h8
-rw-r--r--include/linux/pcounter.h74
-rw-r--r--include/linux/pda_power.h1
-rw-r--r--include/linux/percpu.h20
-rw-r--r--include/linux/pfkeyv2.h6
-rw-r--r--include/linux/phy.h3
-rw-r--r--include/linux/phy_fixed.h51
-rw-r--r--include/linux/pid_namespace.h23
-rw-r--r--include/linux/pkt_cls.h50
-rw-r--r--include/linux/pkt_sched.h7
-rw-r--r--include/linux/pktcdvd.h2
-rw-r--r--include/linux/platform_device.h2
-rw-r--r--include/linux/pm.h9
-rw-r--r--include/linux/pm_legacy.h6
-rw-r--r--include/linux/pmu.h36
-rw-r--r--include/linux/pnp.h4
-rw-r--r--include/linux/power_supply.h13
-rw-r--r--include/linux/proc_fs.h9
-rw-r--r--include/linux/ptrace.h76
-rw-r--r--include/linux/quicklist.h8
-rw-r--r--include/linux/rcuclassic.h164
-rw-r--r--include/linux/rcupdate.h173
-rw-r--r--include/linux/rcupreempt.h86
-rw-r--r--include/linux/rcupreempt_trace.h99
-rw-r--r--include/linux/regset.h368
-rw-r--r--include/linux/rfkill.h2
-rw-r--r--include/linux/rtc.h5
-rw-r--r--include/linux/rtnetlink.h17
-rw-r--r--include/linux/scatterlist.h191
-rw-r--r--include/linux/sched.h190
-rw-r--r--include/linux/screen_info.h2
-rw-r--r--include/linux/security.h59
-rw-r--r--include/linux/selinux.h47
-rw-r--r--include/linux/seq_file.h13
-rw-r--r--include/linux/serial_core.h2
-rw-r--r--include/linux/skbuff.h19
-rw-r--r--include/linux/slab.h5
-rw-r--r--include/linux/slab_def.h3
-rw-r--r--include/linux/smp.h9
-rw-r--r--include/linux/smp_lock.h14
-rw-r--r--include/linux/snmp.h32
-rw-r--r--include/linux/socket.h3
-rw-r--r--include/linux/spinlock.h6
-rw-r--r--include/linux/spinlock_types.h4
-rw-r--r--include/linux/spinlock_up.h2
-rw-r--r--include/linux/splice.h1
-rw-r--r--include/linux/ssb/ssb.h97
-rw-r--r--include/linux/ssb/ssb_regs.h83
-rw-r--r--include/linux/stacktrace.h3
-rw-r--r--include/linux/string.h12
-rw-r--r--include/linux/sunrpc/cache.h4
-rw-r--r--include/linux/sunrpc/clnt.h15
-rw-r--r--include/linux/sunrpc/debug.h7
-rw-r--r--include/linux/sunrpc/msg_prot.h39
-rw-r--r--include/linux/sunrpc/rpc_rdma.h32
-rw-r--r--include/linux/sunrpc/sched.h59
-rw-r--r--include/linux/sunrpc/svc.h10
-rw-r--r--include/linux/sunrpc/svc_rdma.h262
-rw-r--r--include/linux/sunrpc/svc_xprt.h159
-rw-r--r--include/linux/sunrpc/svcsock.h43
-rw-r--r--include/linux/sunrpc/xdr.h3
-rw-r--r--include/linux/sunrpc/xprt.h14
-rw-r--r--include/linux/sunrpc/xprtsock.h6
-rw-r--r--include/linux/suspend.h59
-rw-r--r--include/linux/suspend_ioctls.h32
-rw-r--r--include/linux/sysctl.h36
-rw-r--r--include/linux/sysdev.h1
-rw-r--r--include/linux/sysfs.h2
-rw-r--r--include/linux/tc_act/Kbuild1
-rw-r--r--include/linux/tcp.h11
-rw-r--r--include/linux/thread_info.h28
-rw-r--r--include/linux/ticable.h44
-rw-r--r--include/linux/tick.h10
-rw-r--r--include/linux/tifm.h2
-rw-r--r--include/linux/time.h1
-rw-r--r--include/linux/timer.h6
-rw-r--r--include/linux/timex.h1
-rw-r--r--include/linux/topology.h5
-rw-r--r--include/linux/tty.h8
-rw-r--r--include/linux/types.h4
-rw-r--r--include/linux/uio_driver.h6
-rw-r--r--include/linux/usb.h211
-rw-r--r--include/linux/usb/Kbuild11
-rw-r--r--include/linux/usb/audio.h14
-rw-r--r--include/linux/usb/cdc.h16
-rw-r--r--include/linux/usb/g_printer.h31
-rw-r--r--include/linux/usb/gadget.h123
-rw-r--r--include/linux/usb/gadgetfs.h27
-rw-r--r--include/linux/usb/iowarrior.h25
-rw-r--r--include/linux/usb/isp116x.h2
-rw-r--r--include/linux/usb/midi.h26
-rw-r--r--include/linux/usb/net2280.h32
-rw-r--r--include/linux/usb/otg.h2
-rw-r--r--include/linux/usb/rndis_host.h274
-rw-r--r--include/linux/usb/serial.h160
-rw-r--r--include/linux/usb/sl811.h6
-rw-r--r--include/linux/usb/usbnet.h214
-rw-r--r--include/linux/usb_usual.h10
-rw-r--r--include/linux/usbdevice_fs.h5
-rw-r--r--include/linux/veth.h (renamed from include/net/veth.h)0
-rw-r--r--include/linux/virtio_ring.h21
-rw-r--r--include/linux/wait.h52
-rw-r--r--include/linux/wireless.h13
-rw-r--r--include/linux/workqueue.h14
-rw-r--r--include/linux/writeback.h1
-rw-r--r--include/linux/xfrm.h14
-rw-r--r--include/media/cs5345.h39
-rw-r--r--include/media/cx2341x.h2
-rw-r--r--include/media/cx25840.h19
-rw-r--r--include/media/ir-common.h3
-rw-r--r--include/media/m52790.h93
-rw-r--r--include/media/saa7146_vv.h1
-rw-r--r--include/media/tuner.h5
-rw-r--r--include/media/v4l2-chip-ident.h6
-rw-r--r--include/media/v4l2-common.h18
-rw-r--r--include/media/v4l2-i2c-drv-legacy.h140
-rw-r--r--include/media/v4l2-i2c-drv.h68
-rw-r--r--include/media/v4l2-int-device.h5
-rw-r--r--include/media/videobuf-core.h22
-rw-r--r--include/net/act_api.h8
-rw-r--r--include/net/addrconf.h44
-rw-r--r--include/net/af_unix.h11
-rw-r--r--include/net/arp.h11
-rw-r--r--include/net/ax25.h2
-rw-r--r--include/net/bluetooth/rfcomm.h4
-rw-r--r--include/net/cfg80211.h167
-rw-r--r--include/net/checksum.h25
-rw-r--r--include/net/dsfield.h6
-rw-r--r--include/net/dst.h30
-rw-r--r--include/net/esp.h54
-rw-r--r--include/net/fib_rules.h12
-rw-r--r--include/net/flow.h1
-rw-r--r--include/net/gen_stats.h6
-rw-r--r--include/net/ieee80211.h14
-rw-r--r--include/net/if_inet6.h11
-rw-r--r--include/net/inet6_hashtables.h17
-rw-r--r--include/net/inet_common.h4
-rw-r--r--include/net/inet_ecn.h8
-rw-r--r--include/net/inet_frag.h33
-rw-r--r--include/net/inet_hashtables.h187
-rw-r--r--include/net/inet_timewait_sock.h14
-rw-r--r--include/net/inetpeer.h2
-rw-r--r--include/net/ip.h30
-rw-r--r--include/net/ip6_fib.h27
-rw-r--r--include/net/ip6_route.h4
-rw-r--r--include/net/ip6_tunnel.h2
-rw-r--r--include/net/ip_fib.h88
-rw-r--r--include/net/ip_vs.h47
-rw-r--r--include/net/ipip.h5
-rw-r--r--include/net/ipv6.h43
-rw-r--r--include/net/irda/discovery.h2
-rw-r--r--include/net/irda/irda_device.h13
-rw-r--r--include/net/mac80211.h298
-rw-r--r--include/net/neighbour.h25
-rw-r--r--include/net/net_namespace.h73
-rw-r--r--include/net/netevent.h2
-rw-r--r--include/net/netfilter/ipv6/nf_conntrack_ipv6.h4
-rw-r--r--include/net/netfilter/nf_conntrack.h23
-rw-r--r--include/net/netfilter/nf_conntrack_core.h18
-rw-r--r--include/net/netfilter/nf_conntrack_expect.h6
-rw-r--r--include/net/netfilter/nf_conntrack_helper.h8
-rw-r--r--include/net/netfilter/nf_conntrack_l3proto.h9
-rw-r--r--include/net/netfilter/nf_conntrack_l4proto.h25
-rw-r--r--include/net/netfilter/nf_conntrack_tuple.h34
-rw-r--r--include/net/netfilter/nf_log.h59
-rw-r--r--include/net/netfilter/nf_nat.h5
-rw-r--r--include/net/netfilter/nf_nat_protocol.h18
-rw-r--r--include/net/netfilter/nf_queue.h34
-rw-r--r--include/net/netfilter/xt_rateest.h17
-rw-r--r--include/net/netlabel.h99
-rw-r--r--include/net/netlink.h18
-rw-r--r--include/net/netns/ipv4.h37
-rw-r--r--include/net/netns/ipv6.h40
-rw-r--r--include/net/netns/packet.h15
-rw-r--r--include/net/netns/unix.h13
-rw-r--r--include/net/netns/x_tables.h10
-rw-r--r--include/net/pkt_cls.h19
-rw-r--r--include/net/pkt_sched.h2
-rw-r--r--include/net/protocol.h2
-rw-r--r--include/net/raw.h39
-rw-r--r--include/net/rawv6.h19
-rw-r--r--include/net/request_sock.h18
-rw-r--r--include/net/route.h25
-rw-r--r--include/net/sch_generic.h11
-rw-r--r--include/net/sctp/auth.h2
-rw-r--r--include/net/sctp/checksum.h78
-rw-r--r--include/net/sctp/command.h1
-rw-r--r--include/net/sctp/constants.h48
-rw-r--r--include/net/sctp/sctp.h15
-rw-r--r--include/net/sctp/structs.h70
-rw-r--r--include/net/sctp/user.h2
-rw-r--r--include/net/snmp.h28
-rw-r--r--include/net/sock.h236
-rw-r--r--include/net/tcp.h137
-rw-r--r--include/net/transp_v6.h20
-rw-r--r--include/net/udp.h36
-rw-r--r--include/net/udplite.h3
-rw-r--r--include/net/xfrm.h307
-rw-r--r--include/pcmcia/cs_types.h2
-rw-r--r--include/rdma/ib_mad.h4
-rw-r--r--include/rdma/ib_verbs.h4
-rw-r--r--include/rdma/rdma_user_cm.h13
-rw-r--r--include/scsi/iscsi_if.h20
-rw-r--r--include/scsi/iscsi_proto.h14
-rw-r--r--include/scsi/libiscsi.h82
-rw-r--r--include/scsi/libsas.h30
-rw-r--r--include/scsi/sas.h13
-rw-r--r--include/scsi/scsi.h20
-rw-r--r--include/scsi/scsi_cmnd.h62
-rw-r--r--include/scsi/scsi_device.h41
-rw-r--r--include/scsi/scsi_eh.h9
-rw-r--r--include/scsi/scsi_host.h17
-rw-r--r--include/scsi/scsi_transport_iscsi.h10
-rw-r--r--include/scsi/scsi_transport_sas.h16
-rw-r--r--include/scsi/sd.h1
-rw-r--r--include/sound/ad1848.h2
-rw-r--r--include/sound/ainstr_fm.h134
-rw-r--r--include/sound/ainstr_gf1.h229
-rw-r--r--include/sound/ainstr_iw.h384
-rw-r--r--include/sound/ainstr_simple.h159
-rw-r--r--include/sound/ak4xxx-adda.h2
-rw-r--r--include/sound/asequencer.h242
-rw-r--r--include/sound/asound.h34
-rw-r--r--include/sound/asound_fm.h19
-rw-r--r--include/sound/core.h10
-rw-r--r--include/sound/cs4231-regs.h2
-rw-r--r--include/sound/cs46xx.h3
-rw-r--r--include/sound/driver.h52
-rw-r--r--include/sound/emu10k1.h231
-rw-r--r--include/sound/gus.h63
-rw-r--r--include/sound/info.h2
-rw-r--r--include/sound/opl3.h78
-rw-r--r--include/sound/pcm.h18
-rw-r--r--include/sound/seq_instr.h110
-rw-r--r--include/sound/soc-dapm.h29
-rw-r--r--include/sound/soc.h67
-rw-r--r--include/sound/tea575x-tuner.h1
-rw-r--r--include/sound/trident.h22
-rw-r--r--include/sound/version.h4
-rw-r--r--include/xen/page.h6
1273 files changed, 33331 insertions, 28770 deletions
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 7b74b60a68a4..fb7171b1bd22 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -319,7 +319,7 @@ struct acpi_bus_event {
319 u32 data; 319 u32 data;
320}; 320};
321 321
322extern struct kset acpi_subsys; 322extern struct kobject *acpi_kobj;
323extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int); 323extern int acpi_bus_generate_netlink_event(const char*, const char*, u8, int);
324/* 324/*
325 * External Functions 325 * External Functions
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 9512f0456ad1..b729e64d0d4c 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -335,6 +335,8 @@ acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state);
335 335
336acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void); 336acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void);
337 337
338acpi_status acpi_leave_sleep_state_prep(u8 sleep_state);
339
338acpi_status acpi_leave_sleep_state(u8 sleep_state); 340acpi_status acpi_leave_sleep_state(u8 sleep_state);
339 341
340#endif /* __ACXFACE_H__ */ 342#endif /* __ACXFACE_H__ */
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index 26d79f6db8a0..76411b1fc4fd 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -78,7 +78,6 @@ struct acpi_processor_cx {
78struct acpi_processor_power { 78struct acpi_processor_power {
79 struct cpuidle_device dev; 79 struct cpuidle_device dev;
80 struct acpi_processor_cx *state; 80 struct acpi_processor_cx *state;
81 struct acpi_processor_cx *bm_state;
82 unsigned long bm_check_timestamp; 81 unsigned long bm_check_timestamp;
83 u32 default_state; 82 u32 default_state;
84 u32 bm_activity; 83 u32 bm_activity;
diff --git a/include/acpi/reboot.h b/include/acpi/reboot.h
new file mode 100644
index 000000000000..8857f57e0b78
--- /dev/null
+++ b/include/acpi/reboot.h
@@ -0,0 +1,9 @@
1
2/*
3 * Dummy placeholder to make the EFI patches apply to the x86 tree.
4 * Andrew/Len, please just kill this file if you encounter it.
5 */
6#ifndef acpi_reboot
7# define acpi_reboot() do { } while (0)
8#endif
9
diff --git a/include/asm-alpha/agp.h b/include/asm-alpha/agp.h
index ef855a3bc0f5..26c179135293 100644
--- a/include/asm-alpha/agp.h
+++ b/include/asm-alpha/agp.h
@@ -7,7 +7,6 @@
7 7
8#define map_page_into_agp(page) 8#define map_page_into_agp(page)
9#define unmap_page_from_agp(page) 9#define unmap_page_from_agp(page)
10#define flush_agp_mappings()
11#define flush_agp_cache() mb() 10#define flush_agp_cache() mb()
12 11
13/* Convert a physical address to an address suitable for the GART. */ 12/* Convert a physical address to an address suitable for the GART. */
diff --git a/include/asm-alpha/io_trivial.h b/include/asm-alpha/io_trivial.h
index b10d1aa4cdd1..1c77f10b4b36 100644
--- a/include/asm-alpha/io_trivial.h
+++ b/include/asm-alpha/io_trivial.h
@@ -72,25 +72,29 @@ IO_CONCAT(__IO_PREFIX,writew)(u16 b, volatile void __iomem *a)
72__EXTERN_INLINE u8 72__EXTERN_INLINE u8
73IO_CONCAT(__IO_PREFIX,readb)(const volatile void __iomem *a) 73IO_CONCAT(__IO_PREFIX,readb)(const volatile void __iomem *a)
74{ 74{
75 return IO_CONCAT(__IO_PREFIX,ioread8)((void __iomem *)a); 75 void __iomem *addr = (void __iomem *)a;
76 return IO_CONCAT(__IO_PREFIX,ioread8)(addr);
76} 77}
77 78
78__EXTERN_INLINE u16 79__EXTERN_INLINE u16
79IO_CONCAT(__IO_PREFIX,readw)(const volatile void __iomem *a) 80IO_CONCAT(__IO_PREFIX,readw)(const volatile void __iomem *a)
80{ 81{
81 return IO_CONCAT(__IO_PREFIX,ioread16)((void __iomem *)a); 82 void __iomem *addr = (void __iomem *)a;
83 return IO_CONCAT(__IO_PREFIX,ioread16)(addr);
82} 84}
83 85
84__EXTERN_INLINE void 86__EXTERN_INLINE void
85IO_CONCAT(__IO_PREFIX,writeb)(u8 b, volatile void __iomem *a) 87IO_CONCAT(__IO_PREFIX,writeb)(u8 b, volatile void __iomem *a)
86{ 88{
87 IO_CONCAT(__IO_PREFIX,iowrite8)(b, (void __iomem *)a); 89 void __iomem *addr = (void __iomem *)a;
90 IO_CONCAT(__IO_PREFIX,iowrite8)(b, addr);
88} 91}
89 92
90__EXTERN_INLINE void 93__EXTERN_INLINE void
91IO_CONCAT(__IO_PREFIX,writew)(u16 b, volatile void __iomem *a) 94IO_CONCAT(__IO_PREFIX,writew)(u16 b, volatile void __iomem *a)
92{ 95{
93 IO_CONCAT(__IO_PREFIX,iowrite16)(b, (void __iomem *)a); 96 void __iomem *addr = (void __iomem *)a;
97 IO_CONCAT(__IO_PREFIX,iowrite16)(b, addr);
94} 98}
95#endif 99#endif
96 100
diff --git a/include/asm-alpha/socket.h b/include/asm-alpha/socket.h
index 1fede7f92860..08c979319929 100644
--- a/include/asm-alpha/socket.h
+++ b/include/asm-alpha/socket.h
@@ -60,4 +60,6 @@
60#define SO_SECURITY_ENCRYPTION_TRANSPORT 20 60#define SO_SECURITY_ENCRYPTION_TRANSPORT 20
61#define SO_SECURITY_ENCRYPTION_NETWORK 21 61#define SO_SECURITY_ENCRYPTION_NETWORK 21
62 62
63#define SO_MARK 36
64
63#endif /* _ASM_SOCKET_H */ 65#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-alpha/tlbflush.h b/include/asm-alpha/tlbflush.h
index eefab3fb51ae..b9e9147226f7 100644
--- a/include/asm-alpha/tlbflush.h
+++ b/include/asm-alpha/tlbflush.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/mm.h> 4#include <linux/mm.h>
5#include <asm/compiler.h> 5#include <asm/compiler.h>
6#include <asm/pgalloc.h>
6 7
7#ifndef __EXTERN_INLINE 8#ifndef __EXTERN_INLINE
8#define __EXTERN_INLINE extern inline 9#define __EXTERN_INLINE extern inline
diff --git a/include/asm-arm/arch-at91/at91_lcdc.h b/include/asm-arm/arch-at91/at91_lcdc.h
deleted file mode 100644
index ab040a40d37b..000000000000
--- a/include/asm-arm/arch-at91/at91_lcdc.h
+++ /dev/null
@@ -1,148 +0,0 @@
1/*
2 * include/asm-arm/arch-at91/at91_lcdc.h
3 *
4 * LCD Controller (LCDC).
5 * Based on AT91SAM9261 datasheet revision E.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 */
12
13#ifndef AT91_LCDC_H
14#define AT91_LCDC_H
15
16#define AT91_LCDC_DMABADDR1 0x00 /* DMA Base Address Register 1 */
17#define AT91_LCDC_DMABADDR2 0x04 /* DMA Base Address Register 2 */
18#define AT91_LCDC_DMAFRMPT1 0x08 /* DMA Frame Pointer Register 1 */
19#define AT91_LCDC_DMAFRMPT2 0x0c /* DMA Frame Pointer Register 2 */
20#define AT91_LCDC_DMAFRMADD1 0x10 /* DMA Frame Address Register 1 */
21#define AT91_LCDC_DMAFRMADD2 0x14 /* DMA Frame Address Register 2 */
22
23#define AT91_LCDC_DMAFRMCFG 0x18 /* DMA Frame Configuration Register */
24#define AT91_LCDC_FRSIZE (0x7fffff << 0) /* Frame Size */
25#define AT91_LCDC_BLENGTH (0x7f << 24) /* Burst Length */
26
27#define AT91_LCDC_DMACON 0x1c /* DMA Control Register */
28#define AT91_LCDC_DMAEN (0x1 << 0) /* DMA Enable */
29#define AT91_LCDC_DMARST (0x1 << 1) /* DMA Reset */
30#define AT91_LCDC_DMABUSY (0x1 << 2) /* DMA Busy */
31
32#define AT91_LCDC_LCDCON1 0x0800 /* LCD Control Register 1 */
33#define AT91_LCDC_BYPASS (1 << 0) /* Bypass lcd_dotck divider */
34#define AT91_LCDC_CLKVAL (0x1ff << 12) /* Clock Divider */
35#define AT91_LCDC_LINCNT (0x7ff << 21) /* Line Counter */
36
37#define AT91_LCDC_LCDCON2 0x0804 /* LCD Control Register 2 */
38#define AT91_LCDC_DISTYPE (3 << 0) /* Display Type */
39#define AT91_LCDC_DISTYPE_STNMONO (0 << 0)
40#define AT91_LCDC_DISTYPE_STNCOLOR (1 << 0)
41#define AT91_LCDC_DISTYPE_TFT (2 << 0)
42#define AT91_LCDC_SCANMOD (1 << 2) /* Scan Mode */
43#define AT91_LCDC_SCANMOD_SINGLE (0 << 2)
44#define AT91_LCDC_SCANMOD_DUAL (1 << 2)
45#define AT91_LCDC_IFWIDTH (3 << 3) /*Interface Width */
46#define AT91_LCDC_IFWIDTH_4 (0 << 3)
47#define AT91_LCDC_IFWIDTH_8 (1 << 3)
48#define AT91_LCDC_IFWIDTH_16 (2 << 3)
49#define AT91_LCDC_PIXELSIZE (7 << 5) /* Bits per pixel */
50#define AT91_LCDC_PIXELSIZE_1 (0 << 5)
51#define AT91_LCDC_PIXELSIZE_2 (1 << 5)
52#define AT91_LCDC_PIXELSIZE_4 (2 << 5)
53#define AT91_LCDC_PIXELSIZE_8 (3 << 5)
54#define AT91_LCDC_PIXELSIZE_16 (4 << 5)
55#define AT91_LCDC_PIXELSIZE_24 (5 << 5)
56#define AT91_LCDC_INVVD (1 << 8) /* LCD Data polarity */
57#define AT91_LCDC_INVVD_NORMAL (0 << 8)
58#define AT91_LCDC_INVVD_INVERTED (1 << 8)
59#define AT91_LCDC_INVFRAME (1 << 9 ) /* LCD VSync polarity */
60#define AT91_LCDC_INVFRAME_NORMAL (0 << 9)
61#define AT91_LCDC_INVFRAME_INVERTED (1 << 9)
62#define AT91_LCDC_INVLINE (1 << 10) /* LCD HSync polarity */
63#define AT91_LCDC_INVLINE_NORMAL (0 << 10)
64#define AT91_LCDC_INVLINE_INVERTED (1 << 10)
65#define AT91_LCDC_INVCLK (1 << 11) /* LCD dotclk polarity */
66#define AT91_LCDC_INVCLK_NORMAL (0 << 11)
67#define AT91_LCDC_INVCLK_INVERTED (1 << 11)
68#define AT91_LCDC_INVDVAL (1 << 12) /* LCD dval polarity */
69#define AT91_LCDC_INVDVAL_NORMAL (0 << 12)
70#define AT91_LCDC_INVDVAL_INVERTED (1 << 12)
71#define AT91_LCDC_CLKMOD (1 << 15) /* LCD dotclk mode */
72#define AT91_LCDC_CLKMOD_ACTIVEDISPLAY (0 << 15)
73#define AT91_LCDC_CLKMOD_ALWAYSACTIVE (1 << 15)
74#define AT91_LCDC_MEMOR (1 << 31) /* Memory Ordering Format */
75#define AT91_LCDC_MEMOR_BIG (0 << 31)
76#define AT91_LCDC_MEMOR_LITTLE (1 << 31)
77
78#define AT91_LCDC_TIM1 0x0808 /* LCD Timing Register 1 */
79#define AT91_LCDC_VFP (0xff << 0) /* Vertical Front Porch */
80#define AT91_LCDC_VBP (0xff << 8) /* Vertical Back Porch */
81#define AT91_LCDC_VPW (0x3f << 16) /* Vertical Synchronization Pulse Width */
82#define AT91_LCDC_VHDLY (0xf << 24) /* Vertical to Horizontal Delay */
83
84#define AT91_LCDC_TIM2 0x080c /* LCD Timing Register 2 */
85#define AT91_LCDC_HBP (0xff << 0) /* Horizontal Back Porch */
86#define AT91_LCDC_HPW (0x3f << 8) /* Horizontal Synchronization Pulse Width */
87#define AT91_LCDC_HFP (0x7ff << 21) /* Horizontal Front Porch */
88
89#define AT91_LCDC_LCDFRMCFG 0x0810 /* LCD Frame Configuration Register */
90#define AT91_LCDC_LINEVAL (0x7ff << 0) /* Vertical Size of LCD Module */
91#define AT91_LCDC_HOZVAL (0x7ff << 21) /* Horizontal Size of LCD Module */
92
93#define AT91_LCDC_FIFO 0x0814 /* LCD FIFO Register */
94#define AT91_LCDC_FIFOTH (0xffff) /* FIFO Threshold */
95
96#define AT91_LCDC_DP1_2 0x081c /* Dithering Pattern DP1_2 Register */
97#define AT91_LCDC_DP4_7 0x0820 /* Dithering Pattern DP4_7 Register */
98#define AT91_LCDC_DP3_5 0x0824 /* Dithering Pattern DP3_5 Register */
99#define AT91_LCDC_DP2_3 0x0828 /* Dithering Pattern DP2_3 Register */
100#define AT91_LCDC_DP5_7 0x082c /* Dithering Pattern DP5_7 Register */
101#define AT91_LCDC_DP3_4 0x0830 /* Dithering Pattern DP3_4 Register */
102#define AT91_LCDC_DP4_5 0x0834 /* Dithering Pattern DP4_5 Register */
103#define AT91_LCDC_DP6_7 0x0838 /* Dithering Pattern DP6_7 Register */
104#define AT91_LCDC_DP1_2_VAL (0xff)
105#define AT91_LCDC_DP4_7_VAL (0xfffffff)
106#define AT91_LCDC_DP3_5_VAL (0xfffff)
107#define AT91_LCDC_DP2_3_VAL (0xfff)
108#define AT91_LCDC_DP5_7_VAL (0xfffffff)
109#define AT91_LCDC_DP3_4_VAL (0xffff)
110#define AT91_LCDC_DP4_5_VAL (0xfffff)
111#define AT91_LCDC_DP6_7_VAL (0xfffffff)
112
113#define AT91_LCDC_PWRCON 0x083c /* Power Control Register */
114#define AT91_LCDC_PWR (1 << 0) /* LCD Module Power Control */
115#define AT91_LCDC_GUARDT (0x7f << 1) /* Delay in Frame Period */
116#define AT91_LCDC_BUSY (1 << 31) /* LCD Busy */
117
118#define AT91_LCDC_CONTRAST_CTR 0x0840 /* Contrast Control Register */
119#define AT91_LCDC_PS (3 << 0) /* Contrast Counter Prescaler */
120#define AT91_LCDC_PS_DIV1 (0 << 0)
121#define AT91_LCDC_PS_DIV2 (1 << 0)
122#define AT91_LCDC_PS_DIV4 (2 << 0)
123#define AT91_LCDC_PS_DIV8 (3 << 0)
124#define AT91_LCDC_POL (1 << 2) /* Polarity of output Pulse */
125#define AT91_LCDC_POL_NEGATIVE (0 << 2)
126#define AT91_LCDC_POL_POSITIVE (1 << 2)
127#define AT91_LCDC_ENA (1 << 3) /* PWM generator Control */
128#define AT91_LCDC_ENA_PWMDISABLE (0 << 3)
129#define AT91_LCDC_ENA_PWMENABLE (1 << 3)
130
131#define AT91_LCDC_CONTRAST_VAL 0x0844 /* Contrast Value Register */
132#define AT91_LCDC_CVAL (0xff) /* PWM compare value */
133
134#define AT91_LCDC_IER 0x0848 /* Interrupt Enable Register */
135#define AT91_LCDC_IDR 0x084c /* Interrupt Disable Register */
136#define AT91_LCDC_IMR 0x0850 /* Interrupt Mask Register */
137#define AT91_LCDC_ISR 0x0854 /* Interrupt Enable Register */
138#define AT91_LCDC_ICR 0x0858 /* Interrupt Clear Register */
139#define AT91_LCDC_LNI (1 << 0) /* Line Interrupt */
140#define AT91_LCDC_LSTLNI (1 << 1) /* Last Line Interrupt */
141#define AT91_LCDC_EOFI (1 << 2) /* DMA End Of Frame Interrupt */
142#define AT91_LCDC_UFLWI (1 << 4) /* FIFO Underflow Interrupt */
143#define AT91_LCDC_OWRI (1 << 5) /* FIFO Overwrite Interrupt */
144#define AT91_LCDC_MERI (1 << 6) /* DMA Memory Error Interrupt */
145
146#define AT91_LCDC_LUT_(n) (0x0c00 + ((n)*4)) /* Palette Entry 0..255 */
147
148#endif
diff --git a/include/asm-arm/arch-at91/at91_pmc.h b/include/asm-arm/arch-at91/at91_pmc.h
index 33ff5b6798ee..52cd8e5dabc9 100644
--- a/include/asm-arm/arch-at91/at91_pmc.h
+++ b/include/asm-arm/arch-at91/at91_pmc.h
@@ -25,6 +25,7 @@
25#define AT91RM9200_PMC_MCKUDP (1 << 2) /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */ 25#define AT91RM9200_PMC_MCKUDP (1 << 2) /* USB Device Port Master Clock Automatic Disable on Suspend [AT91RM9200 only] */
26#define AT91RM9200_PMC_UHP (1 << 4) /* USB Host Port Clock [AT91RM9200 only] */ 26#define AT91RM9200_PMC_UHP (1 << 4) /* USB Host Port Clock [AT91RM9200 only] */
27#define AT91SAM926x_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91SAM926x only] */ 27#define AT91SAM926x_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91SAM926x only] */
28#define AT91CAP9_PMC_UHP (1 << 6) /* USB Host Port Clock [AT91CAP9 only] */
28#define AT91SAM926x_PMC_UDP (1 << 7) /* USB Devcice Port Clock [AT91SAM926x only] */ 29#define AT91SAM926x_PMC_UDP (1 << 7) /* USB Devcice Port Clock [AT91SAM926x only] */
29#define AT91_PMC_PCK0 (1 << 8) /* Programmable Clock 0 */ 30#define AT91_PMC_PCK0 (1 << 8) /* Programmable Clock 0 */
30#define AT91_PMC_PCK1 (1 << 9) /* Programmable Clock 1 */ 31#define AT91_PMC_PCK1 (1 << 9) /* Programmable Clock 1 */
@@ -37,7 +38,9 @@
37#define AT91_PMC_PCDR (AT91_PMC + 0x14) /* Peripheral Clock Disable Register */ 38#define AT91_PMC_PCDR (AT91_PMC + 0x14) /* Peripheral Clock Disable Register */
38#define AT91_PMC_PCSR (AT91_PMC + 0x18) /* Peripheral Clock Status Register */ 39#define AT91_PMC_PCSR (AT91_PMC + 0x18) /* Peripheral Clock Status Register */
39 40
40#define AT91_CKGR_MOR (AT91_PMC + 0x20) /* Main Oscillator Register */ 41#define AT91_CKGR_UCKR (AT91_PMC + 0x1C) /* UTMI Clock Register [SAM9RL, CAP9] */
42
43#define AT91_CKGR_MOR (AT91_PMC + 0x20) /* Main Oscillator Register [not on SAM9RL] */
41#define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */ 44#define AT91_PMC_MOSCEN (1 << 0) /* Main Oscillator Enable */
42#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass [AT91SAM926x only] */ 45#define AT91_PMC_OSCBYPASS (1 << 1) /* Oscillator Bypass [AT91SAM926x only] */
43#define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */ 46#define AT91_PMC_OSCOUNT (0xff << 8) /* Main Oscillator Start-up Time */
@@ -52,6 +55,10 @@
52#define AT91_PMC_PLLCOUNT (0x3f << 8) /* PLL Counter */ 55#define AT91_PMC_PLLCOUNT (0x3f << 8) /* PLL Counter */
53#define AT91_PMC_OUT (3 << 14) /* PLL Clock Frequency Range */ 56#define AT91_PMC_OUT (3 << 14) /* PLL Clock Frequency Range */
54#define AT91_PMC_MUL (0x7ff << 16) /* PLL Multiplier */ 57#define AT91_PMC_MUL (0x7ff << 16) /* PLL Multiplier */
58#define AT91_PMC_USBDIV (3 << 28) /* USB Divisor (PLLB only) */
59#define AT91_PMC_USBDIV_1 (0 << 28)
60#define AT91_PMC_USBDIV_2 (1 << 28)
61#define AT91_PMC_USBDIV_4 (2 << 28)
55#define AT91_PMC_USB96M (1 << 28) /* Divider by 2 Enable (PLLB only) */ 62#define AT91_PMC_USB96M (1 << 28) /* Divider by 2 Enable (PLLB only) */
56 63
57#define AT91_PMC_MCKR (AT91_PMC + 0x30) /* Master Clock Register */ 64#define AT91_PMC_MCKR (AT91_PMC + 0x30) /* Master Clock Register */
diff --git a/include/asm-arm/arch-at91/at91_rtt.h b/include/asm-arm/arch-at91/at91_rtt.h
index bae1103fbbb2..39a32633b275 100644
--- a/include/asm-arm/arch-at91/at91_rtt.h
+++ b/include/asm-arm/arch-at91/at91_rtt.h
@@ -13,19 +13,19 @@
13#ifndef AT91_RTT_H 13#ifndef AT91_RTT_H
14#define AT91_RTT_H 14#define AT91_RTT_H
15 15
16#define AT91_RTT_MR (AT91_RTT + 0x00) /* Real-time Mode Register */ 16#define AT91_RTT_MR 0x00 /* Real-time Mode Register */
17#define AT91_RTT_RTPRES (0xffff << 0) /* Real-time Timer Prescaler Value */ 17#define AT91_RTT_RTPRES (0xffff << 0) /* Real-time Timer Prescaler Value */
18#define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */ 18#define AT91_RTT_ALMIEN (1 << 16) /* Alarm Interrupt Enable */
19#define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */ 19#define AT91_RTT_RTTINCIEN (1 << 17) /* Real Time Timer Increment Interrupt Enable */
20#define AT91_RTT_RTTRST (1 << 18) /* Real Time Timer Restart */ 20#define AT91_RTT_RTTRST (1 << 18) /* Real Time Timer Restart */
21 21
22#define AT91_RTT_AR (AT91_RTT + 0x04) /* Real-time Alarm Register */ 22#define AT91_RTT_AR 0x04 /* Real-time Alarm Register */
23#define AT91_RTT_ALMV (0xffffffff) /* Alarm Value */ 23#define AT91_RTT_ALMV (0xffffffff) /* Alarm Value */
24 24
25#define AT91_RTT_VR (AT91_RTT + 0x08) /* Real-time Value Register */ 25#define AT91_RTT_VR 0x08 /* Real-time Value Register */
26#define AT91_RTT_CRTV (0xffffffff) /* Current Real-time Value */ 26#define AT91_RTT_CRTV (0xffffffff) /* Current Real-time Value */
27 27
28#define AT91_RTT_SR (AT91_RTT + 0x0c) /* Real-time Status Register */ 28#define AT91_RTT_SR 0x0c /* Real-time Status Register */
29#define AT91_RTT_ALMS (1 << 0) /* Real-time Alarm Status */ 29#define AT91_RTT_ALMS (1 << 0) /* Real-time Alarm Status */
30#define AT91_RTT_RTTINC (1 << 1) /* Real-time Timer Increment */ 30#define AT91_RTT_RTTINC (1 << 1) /* Real-time Timer Increment */
31 31
diff --git a/include/asm-arm/arch-at91/at91_twi.h b/include/asm-arm/arch-at91/at91_twi.h
index ca9a90733456..f9f2e3cd95c5 100644
--- a/include/asm-arm/arch-at91/at91_twi.h
+++ b/include/asm-arm/arch-at91/at91_twi.h
@@ -21,6 +21,8 @@
21#define AT91_TWI_STOP (1 << 1) /* Send a Stop Condition */ 21#define AT91_TWI_STOP (1 << 1) /* Send a Stop Condition */
22#define AT91_TWI_MSEN (1 << 2) /* Master Transfer Enable */ 22#define AT91_TWI_MSEN (1 << 2) /* Master Transfer Enable */
23#define AT91_TWI_MSDIS (1 << 3) /* Master Transfer Disable */ 23#define AT91_TWI_MSDIS (1 << 3) /* Master Transfer Disable */
24#define AT91_TWI_SVEN (1 << 4) /* Slave Transfer Enable [SAM9260 only] */
25#define AT91_TWI_SVDIS (1 << 5) /* Slave Transfer Disable [SAM9260 only] */
24#define AT91_TWI_SWRST (1 << 7) /* Software Reset */ 26#define AT91_TWI_SWRST (1 << 7) /* Software Reset */
25 27
26#define AT91_TWI_MMR 0x04 /* Master Mode Register */ 28#define AT91_TWI_MMR 0x04 /* Master Mode Register */
@@ -32,6 +34,9 @@
32#define AT91_TWI_MREAD (1 << 12) /* Master Read Direction */ 34#define AT91_TWI_MREAD (1 << 12) /* Master Read Direction */
33#define AT91_TWI_DADR (0x7f << 16) /* Device Address */ 35#define AT91_TWI_DADR (0x7f << 16) /* Device Address */
34 36
37#define AT91_TWI_SMR 0x08 /* Slave Mode Register [SAM9260 only] */
38#define AT91_TWI_SADR (0x7f << 16) /* Slave Address */
39
35#define AT91_TWI_IADR 0x0c /* Internal Address Register */ 40#define AT91_TWI_IADR 0x0c /* Internal Address Register */
36 41
37#define AT91_TWI_CWGR 0x10 /* Clock Waveform Generator Register */ 42#define AT91_TWI_CWGR 0x10 /* Clock Waveform Generator Register */
@@ -43,9 +48,15 @@
43#define AT91_TWI_TXCOMP (1 << 0) /* Transmission Complete */ 48#define AT91_TWI_TXCOMP (1 << 0) /* Transmission Complete */
44#define AT91_TWI_RXRDY (1 << 1) /* Receive Holding Register Ready */ 49#define AT91_TWI_RXRDY (1 << 1) /* Receive Holding Register Ready */
45#define AT91_TWI_TXRDY (1 << 2) /* Transmit Holding Register Ready */ 50#define AT91_TWI_TXRDY (1 << 2) /* Transmit Holding Register Ready */
51#define AT91_TWI_SVREAD (1 << 3) /* Slave Read [SAM9260 only] */
52#define AT91_TWI_SVACC (1 << 4) /* Slave Access [SAM9260 only] */
53#define AT91_TWI_GACC (1 << 5) /* General Call Access [SAM9260 only] */
46#define AT91_TWI_OVRE (1 << 6) /* Overrun Error [AT91RM9200 only] */ 54#define AT91_TWI_OVRE (1 << 6) /* Overrun Error [AT91RM9200 only] */
47#define AT91_TWI_UNRE (1 << 7) /* Underrun Error [AT91RM9200 only] */ 55#define AT91_TWI_UNRE (1 << 7) /* Underrun Error [AT91RM9200 only] */
48#define AT91_TWI_NACK (1 << 8) /* Not Acknowledged */ 56#define AT91_TWI_NACK (1 << 8) /* Not Acknowledged */
57#define AT91_TWI_ARBLST (1 << 9) /* Arbitration Lost [SAM9260 only] */
58#define AT91_TWI_SCLWS (1 << 10) /* Clock Wait State [SAM9260 only] */
59#define AT91_TWI_EOSACC (1 << 11) /* End of Slave Address [SAM9260 only] */
49 60
50#define AT91_TWI_IER 0x24 /* Interrupt Enable Register */ 61#define AT91_TWI_IER 0x24 /* Interrupt Enable Register */
51#define AT91_TWI_IDR 0x28 /* Interrupt Disable Register */ 62#define AT91_TWI_IDR 0x28 /* Interrupt Disable Register */
diff --git a/include/asm-arm/arch-at91/at91cap9.h b/include/asm-arm/arch-at91/at91cap9.h
new file mode 100644
index 000000000000..73e1fcf4a0aa
--- /dev/null
+++ b/include/asm-arm/arch-at91/at91cap9.h
@@ -0,0 +1,121 @@
1/*
2 * include/asm-arm/arch-at91/at91cap9.h
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2007 Atmel Corporation.
7 *
8 * Common definitions.
9 * Based on AT91CAP9 datasheet revision B (Preliminary).
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#ifndef AT91CAP9_H
18#define AT91CAP9_H
19
20/*
21 * Peripheral identifiers/interrupts.
22 */
23#define AT91_ID_FIQ 0 /* Advanced Interrupt Controller (FIQ) */
24#define AT91_ID_SYS 1 /* System Peripherals */
25#define AT91CAP9_ID_PIOABCD 2 /* Parallel IO Controller A, B, C and D */
26#define AT91CAP9_ID_MPB0 3 /* MP Block Peripheral 0 */
27#define AT91CAP9_ID_MPB1 4 /* MP Block Peripheral 1 */
28#define AT91CAP9_ID_MPB2 5 /* MP Block Peripheral 2 */
29#define AT91CAP9_ID_MPB3 6 /* MP Block Peripheral 3 */
30#define AT91CAP9_ID_MPB4 7 /* MP Block Peripheral 4 */
31#define AT91CAP9_ID_US0 8 /* USART 0 */
32#define AT91CAP9_ID_US1 9 /* USART 1 */
33#define AT91CAP9_ID_US2 10 /* USART 2 */
34#define AT91CAP9_ID_MCI0 11 /* Multimedia Card Interface 0 */
35#define AT91CAP9_ID_MCI1 12 /* Multimedia Card Interface 1 */
36#define AT91CAP9_ID_CAN 13 /* CAN */
37#define AT91CAP9_ID_TWI 14 /* Two-Wire Interface */
38#define AT91CAP9_ID_SPI0 15 /* Serial Peripheral Interface 0 */
39#define AT91CAP9_ID_SPI1 16 /* Serial Peripheral Interface 0 */
40#define AT91CAP9_ID_SSC0 17 /* Serial Synchronous Controller 0 */
41#define AT91CAP9_ID_SSC1 18 /* Serial Synchronous Controller 1 */
42#define AT91CAP9_ID_AC97C 19 /* AC97 Controller */
43#define AT91CAP9_ID_TCB 20 /* Timer Counter 0, 1 and 2 */
44#define AT91CAP9_ID_PWMC 21 /* Pulse Width Modulation Controller */
45#define AT91CAP9_ID_EMAC 22 /* Ethernet */
46#define AT91CAP9_ID_AESTDES 23 /* Advanced Encryption Standard, Triple DES */
47#define AT91CAP9_ID_ADC 24 /* Analog-to-Digital Converter */
48#define AT91CAP9_ID_ISI 25 /* Image Sensor Interface */
49#define AT91CAP9_ID_LCDC 26 /* LCD Controller */
50#define AT91CAP9_ID_DMA 27 /* DMA Controller */
51#define AT91CAP9_ID_UDPHS 28 /* USB High Speed Device Port */
52#define AT91CAP9_ID_UHP 29 /* USB Host Port */
53#define AT91CAP9_ID_IRQ0 30 /* Advanced Interrupt Controller (IRQ0) */
54#define AT91CAP9_ID_IRQ1 31 /* Advanced Interrupt Controller (IRQ1) */
55
56/*
57 * User Peripheral physical base addresses.
58 */
59#define AT91CAP9_BASE_UDPHS 0xfff78000
60#define AT91CAP9_BASE_TCB0 0xfff7c000
61#define AT91CAP9_BASE_TC0 0xfff7c000
62#define AT91CAP9_BASE_TC1 0xfff7c040
63#define AT91CAP9_BASE_TC2 0xfff7c080
64#define AT91CAP9_BASE_MCI0 0xfff80000
65#define AT91CAP9_BASE_MCI1 0xfff84000
66#define AT91CAP9_BASE_TWI 0xfff88000
67#define AT91CAP9_BASE_US0 0xfff8c000
68#define AT91CAP9_BASE_US1 0xfff90000
69#define AT91CAP9_BASE_US2 0xfff94000
70#define AT91CAP9_BASE_SSC0 0xfff98000
71#define AT91CAP9_BASE_SSC1 0xfff9c000
72#define AT91CAP9_BASE_AC97C 0xfffa0000
73#define AT91CAP9_BASE_SPI0 0xfffa4000
74#define AT91CAP9_BASE_SPI1 0xfffa8000
75#define AT91CAP9_BASE_CAN 0xfffac000
76#define AT91CAP9_BASE_PWMC 0xfffb8000
77#define AT91CAP9_BASE_EMAC 0xfffbc000
78#define AT91CAP9_BASE_ADC 0xfffc0000
79#define AT91CAP9_BASE_ISI 0xfffc4000
80#define AT91_BASE_SYS 0xffffe200
81
82/*
83 * System Peripherals (offset from AT91_BASE_SYS)
84 */
85#define AT91_ECC (0xffffe200 - AT91_BASE_SYS)
86#define AT91_BCRAMC (0xffffe400 - AT91_BASE_SYS)
87#define AT91_DDRSDRC (0xffffe600 - AT91_BASE_SYS)
88#define AT91_SMC (0xffffe800 - AT91_BASE_SYS)
89#define AT91_MATRIX (0xffffea00 - AT91_BASE_SYS)
90#define AT91_CCFG (0xffffeb10 - AT91_BASE_SYS)
91#define AT91_DMA (0xffffec00 - AT91_BASE_SYS)
92#define AT91_DBGU (0xffffee00 - AT91_BASE_SYS)
93#define AT91_AIC (0xfffff000 - AT91_BASE_SYS)
94#define AT91_PIOA (0xfffff200 - AT91_BASE_SYS)
95#define AT91_PIOB (0xfffff400 - AT91_BASE_SYS)
96#define AT91_PIOC (0xfffff600 - AT91_BASE_SYS)
97#define AT91_PIOD (0xfffff800 - AT91_BASE_SYS)
98#define AT91_PMC (0xfffffc00 - AT91_BASE_SYS)
99#define AT91_RSTC (0xfffffd00 - AT91_BASE_SYS)
100#define AT91_SHDC (0xfffffd10 - AT91_BASE_SYS)
101#define AT91_RTT (0xfffffd20 - AT91_BASE_SYS)
102#define AT91_PIT (0xfffffd30 - AT91_BASE_SYS)
103#define AT91_WDT (0xfffffd40 - AT91_BASE_SYS)
104#define AT91_GPBR (0xfffffd50 - AT91_BASE_SYS)
105
106/*
107 * Internal Memory.
108 */
109#define AT91CAP9_SRAM_BASE 0x00100000 /* Internal SRAM base address */
110#define AT91CAP9_SRAM_SIZE (32 * SZ_1K) /* Internal SRAM size (32Kb) */
111
112#define AT91CAP9_ROM_BASE 0x00400000 /* Internal ROM base address */
113#define AT91CAP9_ROM_SIZE (32 * SZ_1K) /* Internal ROM size (32Kb) */
114
115#define AT91CAP9_LCDC_BASE 0x00500000 /* LCD Controller */
116#define AT91CAP9_UDPHS_BASE 0x00600000 /* USB High Speed Device Port */
117#define AT91CAP9_UHP_BASE 0x00700000 /* USB Host controller */
118
119#define CONFIG_DRAM_BASE AT91_CHIPSELECT_6
120
121#endif
diff --git a/include/asm-arm/arch-at91/at91cap9_matrix.h b/include/asm-arm/arch-at91/at91cap9_matrix.h
new file mode 100644
index 000000000000..a641686b6c3d
--- /dev/null
+++ b/include/asm-arm/arch-at91/at91cap9_matrix.h
@@ -0,0 +1,132 @@
1/*
2 * include/asm-arm/arch-at91/at91cap9_matrix.h
3 *
4 * Copyright (C) 2007 Stelian Pop <stelian.pop@leadtechdesign.com>
5 * Copyright (C) 2007 Lead Tech Design <www.leadtechdesign.com>
6 * Copyright (C) 2006 Atmel Corporation.
7 *
8 * Memory Controllers (MATRIX, EBI) - System peripherals registers.
9 * Based on AT91CAP9 datasheet revision B (Preliminary).
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 */
16
17#ifndef AT91CAP9_MATRIX_H
18#define AT91CAP9_MATRIX_H
19
20#define AT91_MATRIX_MCFG0 (AT91_MATRIX + 0x00) /* Master Configuration Register 0 */
21#define AT91_MATRIX_MCFG1 (AT91_MATRIX + 0x04) /* Master Configuration Register 1 */
22#define AT91_MATRIX_MCFG2 (AT91_MATRIX + 0x08) /* Master Configuration Register 2 */
23#define AT91_MATRIX_MCFG3 (AT91_MATRIX + 0x0C) /* Master Configuration Register 3 */
24#define AT91_MATRIX_MCFG4 (AT91_MATRIX + 0x10) /* Master Configuration Register 4 */
25#define AT91_MATRIX_MCFG5 (AT91_MATRIX + 0x14) /* Master Configuration Register 5 */
26#define AT91_MATRIX_MCFG6 (AT91_MATRIX + 0x18) /* Master Configuration Register 6 */
27#define AT91_MATRIX_MCFG7 (AT91_MATRIX + 0x1C) /* Master Configuration Register 7 */
28#define AT91_MATRIX_MCFG8 (AT91_MATRIX + 0x20) /* Master Configuration Register 8 */
29#define AT91_MATRIX_MCFG9 (AT91_MATRIX + 0x24) /* Master Configuration Register 9 */
30#define AT91_MATRIX_MCFG10 (AT91_MATRIX + 0x28) /* Master Configuration Register 10 */
31#define AT91_MATRIX_MCFG11 (AT91_MATRIX + 0x2C) /* Master Configuration Register 11 */
32#define AT91_MATRIX_ULBT (7 << 0) /* Undefined Length Burst Type */
33#define AT91_MATRIX_ULBT_INFINITE (0 << 0)
34#define AT91_MATRIX_ULBT_SINGLE (1 << 0)
35#define AT91_MATRIX_ULBT_FOUR (2 << 0)
36#define AT91_MATRIX_ULBT_EIGHT (3 << 0)
37#define AT91_MATRIX_ULBT_SIXTEEN (4 << 0)
38
39#define AT91_MATRIX_SCFG0 (AT91_MATRIX + 0x40) /* Slave Configuration Register 0 */
40#define AT91_MATRIX_SCFG1 (AT91_MATRIX + 0x44) /* Slave Configuration Register 1 */
41#define AT91_MATRIX_SCFG2 (AT91_MATRIX + 0x48) /* Slave Configuration Register 2 */
42#define AT91_MATRIX_SCFG3 (AT91_MATRIX + 0x4C) /* Slave Configuration Register 3 */
43#define AT91_MATRIX_SCFG4 (AT91_MATRIX + 0x50) /* Slave Configuration Register 4 */
44#define AT91_MATRIX_SCFG5 (AT91_MATRIX + 0x54) /* Slave Configuration Register 5 */
45#define AT91_MATRIX_SCFG6 (AT91_MATRIX + 0x58) /* Slave Configuration Register 6 */
46#define AT91_MATRIX_SCFG7 (AT91_MATRIX + 0x5C) /* Slave Configuration Register 7 */
47#define AT91_MATRIX_SCFG8 (AT91_MATRIX + 0x60) /* Slave Configuration Register 8 */
48#define AT91_MATRIX_SCFG9 (AT91_MATRIX + 0x64) /* Slave Configuration Register 9 */
49#define AT91_MATRIX_SLOT_CYCLE (0xff << 0) /* Maximum Number of Allowed Cycles for a Burst */
50#define AT91_MATRIX_DEFMSTR_TYPE (3 << 16) /* Default Master Type */
51#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
52#define AT91_MATRIX_DEFMSTR_TYPE_LAST (1 << 16)
53#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
54#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */
55#define AT91_MATRIX_ARBT (3 << 24) /* Arbitration Type */
56#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
57#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
58
59#define AT91_MATRIX_PRAS0 (AT91_MATRIX + 0x80) /* Priority Register A for Slave 0 */
60#define AT91_MATRIX_PRBS0 (AT91_MATRIX + 0x84) /* Priority Register B for Slave 0 */
61#define AT91_MATRIX_PRAS1 (AT91_MATRIX + 0x88) /* Priority Register A for Slave 1 */
62#define AT91_MATRIX_PRBS1 (AT91_MATRIX + 0x8C) /* Priority Register B for Slave 1 */
63#define AT91_MATRIX_PRAS2 (AT91_MATRIX + 0x90) /* Priority Register A for Slave 2 */
64#define AT91_MATRIX_PRBS2 (AT91_MATRIX + 0x94) /* Priority Register B for Slave 2 */
65#define AT91_MATRIX_PRAS3 (AT91_MATRIX + 0x98) /* Priority Register A for Slave 3 */
66#define AT91_MATRIX_PRBS3 (AT91_MATRIX + 0x9C) /* Priority Register B for Slave 3 */
67#define AT91_MATRIX_PRAS4 (AT91_MATRIX + 0xA0) /* Priority Register A for Slave 4 */
68#define AT91_MATRIX_PRBS4 (AT91_MATRIX + 0xA4) /* Priority Register B for Slave 4 */
69#define AT91_MATRIX_PRAS5 (AT91_MATRIX + 0xA8) /* Priority Register A for Slave 5 */
70#define AT91_MATRIX_PRBS5 (AT91_MATRIX + 0xAC) /* Priority Register B for Slave 5 */
71#define AT91_MATRIX_PRAS6 (AT91_MATRIX + 0xB0) /* Priority Register A for Slave 6 */
72#define AT91_MATRIX_PRBS6 (AT91_MATRIX + 0xB4) /* Priority Register B for Slave 6 */
73#define AT91_MATRIX_PRAS7 (AT91_MATRIX + 0xB8) /* Priority Register A for Slave 7 */
74#define AT91_MATRIX_PRBS7 (AT91_MATRIX + 0xBC) /* Priority Register B for Slave 7 */
75#define AT91_MATRIX_PRAS8 (AT91_MATRIX + 0xC0) /* Priority Register A for Slave 8 */
76#define AT91_MATRIX_PRBS8 (AT91_MATRIX + 0xC4) /* Priority Register B for Slave 8 */
77#define AT91_MATRIX_PRAS9 (AT91_MATRIX + 0xC8) /* Priority Register A for Slave 9 */
78#define AT91_MATRIX_PRBS9 (AT91_MATRIX + 0xCC) /* Priority Register B for Slave 9 */
79#define AT91_MATRIX_M0PR (3 << 0) /* Master 0 Priority */
80#define AT91_MATRIX_M1PR (3 << 4) /* Master 1 Priority */
81#define AT91_MATRIX_M2PR (3 << 8) /* Master 2 Priority */
82#define AT91_MATRIX_M3PR (3 << 12) /* Master 3 Priority */
83#define AT91_MATRIX_M4PR (3 << 16) /* Master 4 Priority */
84#define AT91_MATRIX_M5PR (3 << 20) /* Master 5 Priority */
85#define AT91_MATRIX_M6PR (3 << 24) /* Master 6 Priority */
86#define AT91_MATRIX_M7PR (3 << 28) /* Master 7 Priority */
87#define AT91_MATRIX_M8PR (3 << 0) /* Master 8 Priority (in Register B) */
88#define AT91_MATRIX_M9PR (3 << 4) /* Master 9 Priority (in Register B) */
89#define AT91_MATRIX_M10PR (3 << 8) /* Master 10 Priority (in Register B) */
90#define AT91_MATRIX_M11PR (3 << 12) /* Master 11 Priority (in Register B) */
91
92#define AT91_MATRIX_MRCR (AT91_MATRIX + 0x100) /* Master Remap Control Register */
93#define AT91_MATRIX_RCB0 (1 << 0) /* Remap Command for AHB Master 0 (ARM926EJ-S Instruction Master) */
94#define AT91_MATRIX_RCB1 (1 << 1) /* Remap Command for AHB Master 1 (ARM926EJ-S Data Master) */
95#define AT91_MATRIX_RCB2 (1 << 2)
96#define AT91_MATRIX_RCB3 (1 << 3)
97#define AT91_MATRIX_RCB4 (1 << 4)
98#define AT91_MATRIX_RCB5 (1 << 5)
99#define AT91_MATRIX_RCB6 (1 << 6)
100#define AT91_MATRIX_RCB7 (1 << 7)
101#define AT91_MATRIX_RCB8 (1 << 8)
102#define AT91_MATRIX_RCB9 (1 << 9)
103#define AT91_MATRIX_RCB10 (1 << 10)
104#define AT91_MATRIX_RCB11 (1 << 11)
105
106#define AT91_MPBS0_SFR (AT91_MATRIX + 0x114) /* MPBlock Slave 0 Special Function Register */
107#define AT91_MPBS1_SFR (AT91_MATRIX + 0x11C) /* MPBlock Slave 1 Special Function Register */
108
109#define AT91_MATRIX_EBICSA (AT91_MATRIX + 0x120) /* EBI Chip Select Assignment Register */
110#define AT91_MATRIX_EBI_CS1A (1 << 1) /* Chip Select 1 Assignment */
111#define AT91_MATRIX_EBI_CS1A_SMC (0 << 1)
112#define AT91_MATRIX_EBI_CS1A_BCRAMC (1 << 1)
113#define AT91_MATRIX_EBI_CS3A (1 << 3) /* Chip Select 3 Assignment */
114#define AT91_MATRIX_EBI_CS3A_SMC (0 << 3)
115#define AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA (1 << 3)
116#define AT91_MATRIX_EBI_CS4A (1 << 4) /* Chip Select 4 Assignment */
117#define AT91_MATRIX_EBI_CS4A_SMC (0 << 4)
118#define AT91_MATRIX_EBI_CS4A_SMC_CF1 (1 << 4)
119#define AT91_MATRIX_EBI_CS5A (1 << 5) /* Chip Select 5 Assignment */
120#define AT91_MATRIX_EBI_CS5A_SMC (0 << 5)
121#define AT91_MATRIX_EBI_CS5A_SMC_CF2 (1 << 5)
122#define AT91_MATRIX_EBI_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
123#define AT91_MATRIX_EBI_DQSPDC (1 << 9) /* Data Qualifier Strobe Pull-Down Configuration */
124#define AT91_MATRIX_EBI_VDDIOMSEL (1 << 16) /* Memory voltage selection */
125#define AT91_MATRIX_EBI_VDDIOMSEL_1_8V (0 << 16)
126#define AT91_MATRIX_EBI_VDDIOMSEL_3_3V (1 << 16)
127
128#define AT91_MPBS2_SFR (AT91_MATRIX + 0x12C) /* MPBlock Slave 2 Special Function Register */
129#define AT91_MPBS3_SFR (AT91_MATRIX + 0x130) /* MPBlock Slave 3 Special Function Register */
130#define AT91_APB_SFR (AT91_MATRIX + 0x134) /* APB Bridge Special Function Register */
131
132#endif
diff --git a/include/asm-arm/arch-at91/at91sam9260_matrix.h b/include/asm-arm/arch-at91/at91sam9260_matrix.h
index aacb1e976422..a8e9fec6c735 100644
--- a/include/asm-arm/arch-at91/at91sam9260_matrix.h
+++ b/include/asm-arm/arch-at91/at91sam9260_matrix.h
@@ -67,7 +67,7 @@
67#define AT91_MATRIX_CS4A (1 << 4) /* Chip Select 4 Assignment */ 67#define AT91_MATRIX_CS4A (1 << 4) /* Chip Select 4 Assignment */
68#define AT91_MATRIX_CS4A_SMC (0 << 4) 68#define AT91_MATRIX_CS4A_SMC (0 << 4)
69#define AT91_MATRIX_CS4A_SMC_CF1 (1 << 4) 69#define AT91_MATRIX_CS4A_SMC_CF1 (1 << 4)
70#define AT91_MATRIX_CS5A (1 << 5 ) /* Chip Select 5 Assignment */ 70#define AT91_MATRIX_CS5A (1 << 5) /* Chip Select 5 Assignment */
71#define AT91_MATRIX_CS5A_SMC (0 << 5) 71#define AT91_MATRIX_CS5A_SMC (0 << 5)
72#define AT91_MATRIX_CS5A_SMC_CF2 (1 << 5) 72#define AT91_MATRIX_CS5A_SMC_CF2 (1 << 5)
73#define AT91_MATRIX_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */ 73#define AT91_MATRIX_DBPUC (1 << 8) /* Data Bus Pull-up Configuration */
diff --git a/include/asm-arm/arch-at91/at91sam9263_matrix.h b/include/asm-arm/arch-at91/at91sam9263_matrix.h
index 6fc6e4be624e..72f6e668e414 100644
--- a/include/asm-arm/arch-at91/at91sam9263_matrix.h
+++ b/include/asm-arm/arch-at91/at91sam9263_matrix.h
@@ -44,7 +44,7 @@
44#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 44#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
45#define AT91_MATRIX_DEFMSTR_TYPE_LAST (1 << 16) 45#define AT91_MATRIX_DEFMSTR_TYPE_LAST (1 << 16)
46#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16) 46#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
47#define AT91_MATRIX_FIXED_DEFMSTR (7 << 18) /* Fixed Index of Default Master */ 47#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */
48#define AT91_MATRIX_ARBT (3 << 24) /* Arbitration Type */ 48#define AT91_MATRIX_ARBT (3 << 24) /* Arbitration Type */
49#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 49#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
50#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 50#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
diff --git a/include/asm-arm/arch-at91/at91sam9rl_matrix.h b/include/asm-arm/arch-at91/at91sam9rl_matrix.h
index b15f11b7c08d..84224174e6a1 100644
--- a/include/asm-arm/arch-at91/at91sam9rl_matrix.h
+++ b/include/asm-arm/arch-at91/at91sam9rl_matrix.h
@@ -38,7 +38,7 @@
38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16) 38#define AT91_MATRIX_DEFMSTR_TYPE_NONE (0 << 16)
39#define AT91_MATRIX_DEFMSTR_TYPE_LAST (1 << 16) 39#define AT91_MATRIX_DEFMSTR_TYPE_LAST (1 << 16)
40#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16) 40#define AT91_MATRIX_DEFMSTR_TYPE_FIXED (2 << 16)
41#define AT91_MATRIX_FIXED_DEFMSTR (7 << 18) /* Fixed Index of Default Master */ 41#define AT91_MATRIX_FIXED_DEFMSTR (0xf << 18) /* Fixed Index of Default Master */
42#define AT91_MATRIX_ARBT (3 << 24) /* Arbitration Type */ 42#define AT91_MATRIX_ARBT (3 << 24) /* Arbitration Type */
43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24) 43#define AT91_MATRIX_ARBT_ROUND_ROBIN (0 << 24)
44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24) 44#define AT91_MATRIX_ARBT_FIXED_PRIORITY (1 << 24)
diff --git a/include/asm-arm/arch-at91/board.h b/include/asm-arm/arch-at91/board.h
index d96b10fd449f..dc189f01c5b3 100644
--- a/include/asm-arm/arch-at91/board.h
+++ b/include/asm-arm/arch-at91/board.h
@@ -33,12 +33,15 @@
33 33
34#include <linux/mtd/partitions.h> 34#include <linux/mtd/partitions.h>
35#include <linux/device.h> 35#include <linux/device.h>
36#include <linux/i2c.h>
37#include <linux/leds.h>
36#include <linux/spi/spi.h> 38#include <linux/spi/spi.h>
37 39
38 /* USB Device */ 40 /* USB Device */
39struct at91_udc_data { 41struct at91_udc_data {
40 u8 vbus_pin; /* high == host powering us */ 42 u8 vbus_pin; /* high == host powering us */
41 u8 pullup_pin; /* high == D+ pulled up */ 43 u8 pullup_pin; /* active == D+ pulled up */
44 u8 pullup_active_low; /* true == pullup_pin is active low */
42}; 45};
43extern void __init at91_add_device_udc(struct at91_udc_data *data); 46extern void __init at91_add_device_udc(struct at91_udc_data *data);
44 47
@@ -70,7 +73,7 @@ struct at91_eth_data {
70}; 73};
71extern void __init at91_add_device_eth(struct at91_eth_data *data); 74extern void __init at91_add_device_eth(struct at91_eth_data *data);
72 75
73#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9263) 76#if defined(CONFIG_ARCH_AT91SAM9260) || defined(CONFIG_ARCH_AT91SAM9263) || defined(CONFIG_ARCH_AT91CAP9)
74#define eth_platform_data at91_eth_data 77#define eth_platform_data at91_eth_data
75#endif 78#endif
76 79
@@ -94,19 +97,29 @@ struct at91_nand_data {
94extern void __init at91_add_device_nand(struct at91_nand_data *data); 97extern void __init at91_add_device_nand(struct at91_nand_data *data);
95 98
96 /* I2C*/ 99 /* I2C*/
97extern void __init at91_add_device_i2c(void); 100extern void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices);
98 101
99 /* SPI */ 102 /* SPI */
100extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices); 103extern void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices);
101 104
102 /* Serial */ 105 /* Serial */
106#define ATMEL_UART_CTS 0x01
107#define ATMEL_UART_RTS 0x02
108#define ATMEL_UART_DSR 0x04
109#define ATMEL_UART_DTR 0x08
110#define ATMEL_UART_DCD 0x10
111#define ATMEL_UART_RI 0x20
112
113extern void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins);
114extern void __init at91_set_serial_console(unsigned portnr);
115
103struct at91_uart_config { 116struct at91_uart_config {
104 unsigned short console_tty; /* tty number of serial console */ 117 unsigned short console_tty; /* tty number of serial console */
105 unsigned short nr_tty; /* number of serial tty's */ 118 unsigned short nr_tty; /* number of serial tty's */
106 short tty_map[]; /* map UART to tty number */ 119 short tty_map[]; /* map UART to tty number */
107}; 120};
108extern struct platform_device *atmel_default_console_device; 121extern struct platform_device *atmel_default_console_device;
109extern void __init at91_init_serial(struct at91_uart_config *config); 122extern void __init __deprecated at91_init_serial(struct at91_uart_config *config);
110 123
111struct atmel_uart_data { 124struct atmel_uart_data {
112 short use_dma_tx; /* use transmit DMA? */ 125 short use_dma_tx; /* use transmit DMA? */
@@ -115,6 +128,23 @@ struct atmel_uart_data {
115}; 128};
116extern void __init at91_add_device_serial(void); 129extern void __init at91_add_device_serial(void);
117 130
131/*
132 * SSC -- accessed through ssc_request(id). Drivers don't bind to SSC
133 * platform devices. Their SSC ID is part of their configuration data,
134 * along with information about which SSC signals they should use.
135 */
136#define ATMEL_SSC_TK 0x01
137#define ATMEL_SSC_TF 0x02
138#define ATMEL_SSC_TD 0x04
139#define ATMEL_SSC_TX (ATMEL_SSC_TK | ATMEL_SSC_TF | ATMEL_SSC_TD)
140
141#define ATMEL_SSC_RK 0x10
142#define ATMEL_SSC_RF 0x20
143#define ATMEL_SSC_RD 0x40
144#define ATMEL_SSC_RX (ATMEL_SSC_RK | ATMEL_SSC_RF | ATMEL_SSC_RD)
145
146extern void __init at91_add_device_ssc(unsigned id, unsigned pins);
147
118 /* LCD Controller */ 148 /* LCD Controller */
119struct atmel_lcdfb_info; 149struct atmel_lcdfb_info;
120extern void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data); 150extern void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data);
@@ -125,9 +155,14 @@ struct atmel_ac97_data {
125}; 155};
126extern void __init at91_add_device_ac97(struct atmel_ac97_data *data); 156extern void __init at91_add_device_ac97(struct atmel_ac97_data *data);
127 157
158 /* ISI */
159extern void __init at91_add_device_isi(void);
160
128 /* LEDs */ 161 /* LEDs */
129extern u8 at91_leds_cpu;
130extern u8 at91_leds_timer;
131extern void __init at91_init_leds(u8 cpu_led, u8 timer_led); 162extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
163extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
164
165/* FIXME: this needs a better location, but gets stuff building again */
166extern int at91_suspend_entering_slow_clock(void);
132 167
133#endif 168#endif
diff --git a/include/asm-arm/arch-at91/cpu.h b/include/asm-arm/arch-at91/cpu.h
index 080cbb401a87..7145166826a2 100644
--- a/include/asm-arm/arch-at91/cpu.h
+++ b/include/asm-arm/arch-at91/cpu.h
@@ -21,13 +21,13 @@
21#define ARCH_ID_AT91SAM9260 0x019803a0 21#define ARCH_ID_AT91SAM9260 0x019803a0
22#define ARCH_ID_AT91SAM9261 0x019703a0 22#define ARCH_ID_AT91SAM9261 0x019703a0
23#define ARCH_ID_AT91SAM9263 0x019607a0 23#define ARCH_ID_AT91SAM9263 0x019607a0
24#define ARCH_ID_AT91SAM9RL64 0x019b03a0
25#define ARCH_ID_AT91CAP9 0x039A03A0
24 26
25#define ARCH_ID_AT91SAM9XE128 0x329973a0 27#define ARCH_ID_AT91SAM9XE128 0x329973a0
26#define ARCH_ID_AT91SAM9XE256 0x329a93a0 28#define ARCH_ID_AT91SAM9XE256 0x329a93a0
27#define ARCH_ID_AT91SAM9XE512 0x329aa3a0 29#define ARCH_ID_AT91SAM9XE512 0x329aa3a0
28 30
29#define ARCH_ID_AT91SAM9RL64 0x019b03a0
30
31#define ARCH_ID_AT91M40800 0x14080044 31#define ARCH_ID_AT91M40800 0x14080044
32#define ARCH_ID_AT91R40807 0x44080746 32#define ARCH_ID_AT91R40807 0x44080746
33#define ARCH_ID_AT91M40807 0x14080745 33#define ARCH_ID_AT91M40807 0x14080745
@@ -81,6 +81,11 @@ static inline unsigned long at91_arch_identify(void)
81#define cpu_is_at91sam9rl() (0) 81#define cpu_is_at91sam9rl() (0)
82#endif 82#endif
83 83
84#ifdef CONFIG_ARCH_AT91CAP9
85#define cpu_is_at91cap9() (at91_cpu_identify() == ARCH_ID_AT91CAP9)
86#else
87#define cpu_is_at91cap9() (0)
88#endif
84 89
85/* 90/*
86 * Since this is ARM, we will never run on any AVR32 CPU. But these 91 * Since this is ARM, we will never run on any AVR32 CPU. But these
diff --git a/include/asm-arm/arch-at91/entry-macro.S b/include/asm-arm/arch-at91/entry-macro.S
index cc1d850a0788..1005eee6219b 100644
--- a/include/asm-arm/arch-at91/entry-macro.S
+++ b/include/asm-arm/arch-at91/entry-macro.S
@@ -17,13 +17,13 @@
17 .endm 17 .endm
18 18
19 .macro get_irqnr_preamble, base, tmp 19 .macro get_irqnr_preamble, base, tmp
20 ldr \base, =(AT91_VA_BASE_SYS + AT91_AIC) @ base virtual address of AIC peripheral
20 .endm 21 .endm
21 22
22 .macro arch_ret_to_user, tmp1, tmp2 23 .macro arch_ret_to_user, tmp1, tmp2
23 .endm 24 .endm
24 25
25 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp 26 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
26 ldr \base, =(AT91_VA_BASE_SYS + AT91_AIC) @ base virtual address of AIC peripheral
27 ldr \irqnr, [\base, #(AT91_AIC_IVR - AT91_AIC)] @ read IRQ vector register: de-asserts nIRQ to processor (and clears interrupt) 27 ldr \irqnr, [\base, #(AT91_AIC_IVR - AT91_AIC)] @ read IRQ vector register: de-asserts nIRQ to processor (and clears interrupt)
28 ldr \irqstat, [\base, #(AT91_AIC_ISR - AT91_AIC)] @ read interrupt source number 28 ldr \irqstat, [\base, #(AT91_AIC_ISR - AT91_AIC)] @ read interrupt source number
29 teq \irqstat, #0 @ ISR is 0 when no current interrupt, or spurious interrupt 29 teq \irqstat, #0 @ ISR is 0 when no current interrupt, or spurious interrupt
diff --git a/include/asm-arm/arch-at91/hardware.h b/include/asm-arm/arch-at91/hardware.h
index 8f1cdd38a969..2c826d8247a3 100644
--- a/include/asm-arm/arch-at91/hardware.h
+++ b/include/asm-arm/arch-at91/hardware.h
@@ -26,6 +26,8 @@
26#include <asm/arch/at91sam9263.h> 26#include <asm/arch/at91sam9263.h>
27#elif defined(CONFIG_ARCH_AT91SAM9RL) 27#elif defined(CONFIG_ARCH_AT91SAM9RL)
28#include <asm/arch/at91sam9rl.h> 28#include <asm/arch/at91sam9rl.h>
29#elif defined(CONFIG_ARCH_AT91CAP9)
30#include <asm/arch/at91cap9.h>
29#elif defined(CONFIG_ARCH_AT91X40) 31#elif defined(CONFIG_ARCH_AT91X40)
30#include <asm/arch/at91x40.h> 32#include <asm/arch/at91x40.h>
31#else 33#else
diff --git a/include/asm-arm/arch-at91/timex.h b/include/asm-arm/arch-at91/timex.h
index a310698fb4da..f1933b0fa43f 100644
--- a/include/asm-arm/arch-at91/timex.h
+++ b/include/asm-arm/arch-at91/timex.h
@@ -42,6 +42,11 @@
42#define AT91SAM9_MASTER_CLOCK 100000000 42#define AT91SAM9_MASTER_CLOCK 100000000
43#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16) 43#define CLOCK_TICK_RATE (AT91SAM9_MASTER_CLOCK/16)
44 44
45#elif defined(CONFIG_ARCH_AT91CAP9)
46
47#define AT91CAP9_MASTER_CLOCK 100000000
48#define CLOCK_TICK_RATE (AT91CAP9_MASTER_CLOCK/16)
49
45#elif defined(CONFIG_ARCH_AT91X40) 50#elif defined(CONFIG_ARCH_AT91X40)
46 51
47#define AT91X40_MASTER_CLOCK 40000000 52#define AT91X40_MASTER_CLOCK 40000000
diff --git a/include/asm-arm/arch-davinci/gpio.h b/include/asm-arm/arch-davinci/gpio.h
index ea24a0e0bfd6..ff8de30b2fb3 100644
--- a/include/asm-arm/arch-davinci/gpio.h
+++ b/include/asm-arm/arch-davinci/gpio.h
@@ -13,6 +13,9 @@
13#ifndef __DAVINCI_GPIO_H 13#ifndef __DAVINCI_GPIO_H
14#define __DAVINCI_GPIO_H 14#define __DAVINCI_GPIO_H
15 15
16#include <linux/io.h>
17#include <asm/hardware.h>
18
16/* 19/*
17 * basic gpio routines 20 * basic gpio routines
18 * 21 *
diff --git a/include/asm-arm/arch-ep93xx/gpio.h b/include/asm-arm/arch-ep93xx/gpio.h
index 1ee14a14cba0..9b1864bbd9a8 100644
--- a/include/asm-arm/arch-ep93xx/gpio.h
+++ b/include/asm-arm/arch-ep93xx/gpio.h
@@ -5,16 +5,6 @@
5#ifndef __ASM_ARCH_GPIO_H 5#ifndef __ASM_ARCH_GPIO_H
6#define __ASM_ARCH_GPIO_H 6#define __ASM_ARCH_GPIO_H
7 7
8#define GPIO_IN 0
9#define GPIO_OUT 1
10
11#define EP93XX_GPIO_LOW 0
12#define EP93XX_GPIO_HIGH 1
13
14extern void gpio_line_config(int line, int direction);
15extern int gpio_line_get(int line);
16extern void gpio_line_set(int line, int value);
17
18/* GPIO port A. */ 8/* GPIO port A. */
19#define EP93XX_GPIO_LINE_A(x) ((x) + 0) 9#define EP93XX_GPIO_LINE_A(x) ((x) + 0)
20#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0) 10#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0)
@@ -38,7 +28,7 @@ extern void gpio_line_set(int line, int value);
38#define EP93XX_GPIO_LINE_EGPIO15 EP93XX_GPIO_LINE_B(7) 28#define EP93XX_GPIO_LINE_EGPIO15 EP93XX_GPIO_LINE_B(7)
39 29
40/* GPIO port C. */ 30/* GPIO port C. */
41#define EP93XX_GPIO_LINE_C(x) ((x) + 16) 31#define EP93XX_GPIO_LINE_C(x) ((x) + 40)
42#define EP93XX_GPIO_LINE_ROW0 EP93XX_GPIO_LINE_C(0) 32#define EP93XX_GPIO_LINE_ROW0 EP93XX_GPIO_LINE_C(0)
43#define EP93XX_GPIO_LINE_ROW1 EP93XX_GPIO_LINE_C(1) 33#define EP93XX_GPIO_LINE_ROW1 EP93XX_GPIO_LINE_C(1)
44#define EP93XX_GPIO_LINE_ROW2 EP93XX_GPIO_LINE_C(2) 34#define EP93XX_GPIO_LINE_ROW2 EP93XX_GPIO_LINE_C(2)
@@ -71,7 +61,7 @@ extern void gpio_line_set(int line, int value);
71#define EP93XX_GPIO_LINE_IDEDA2 EP93XX_GPIO_LINE_E(7) 61#define EP93XX_GPIO_LINE_IDEDA2 EP93XX_GPIO_LINE_E(7)
72 62
73/* GPIO port F. */ 63/* GPIO port F. */
74#define EP93XX_GPIO_LINE_F(x) ((x) + 40) 64#define EP93XX_GPIO_LINE_F(x) ((x) + 16)
75#define EP93XX_GPIO_LINE_WP EP93XX_GPIO_LINE_F(0) 65#define EP93XX_GPIO_LINE_WP EP93XX_GPIO_LINE_F(0)
76#define EP93XX_GPIO_LINE_MCCD1 EP93XX_GPIO_LINE_F(1) 66#define EP93XX_GPIO_LINE_MCCD1 EP93XX_GPIO_LINE_F(1)
77#define EP93XX_GPIO_LINE_MCCD2 EP93XX_GPIO_LINE_F(2) 67#define EP93XX_GPIO_LINE_MCCD2 EP93XX_GPIO_LINE_F(2)
@@ -103,5 +93,49 @@ extern void gpio_line_set(int line, int value);
103#define EP93XX_GPIO_LINE_DD6 EP93XX_GPIO_LINE_H(6) 93#define EP93XX_GPIO_LINE_DD6 EP93XX_GPIO_LINE_H(6)
104#define EP93XX_GPIO_LINE_DD7 EP93XX_GPIO_LINE_H(7) 94#define EP93XX_GPIO_LINE_DD7 EP93XX_GPIO_LINE_H(7)
105 95
96/* maximum value for gpio line identifiers */
97#define EP93XX_GPIO_LINE_MAX EP93XX_GPIO_LINE_H(7)
98
99/* maximum value for irq capable line identifiers */
100#define EP93XX_GPIO_LINE_MAX_IRQ EP93XX_GPIO_LINE_F(7)
101
102/* new generic GPIO API - see Documentation/gpio.txt */
103
104static inline int gpio_request(unsigned gpio, const char *label)
105{
106 if (gpio > EP93XX_GPIO_LINE_MAX)
107 return -EINVAL;
108 return 0;
109}
110
111static inline void gpio_free(unsigned gpio)
112{
113}
114
115int gpio_direction_input(unsigned gpio);
116int gpio_direction_output(unsigned gpio, int value);
117int gpio_get_value(unsigned gpio);
118void gpio_set_value(unsigned gpio, int value);
119
120#include <asm-generic/gpio.h> /* cansleep wrappers */
121
122/*
123 * Map GPIO A0..A7 (0..7) to irq 64..71,
124 * B0..B7 (7..15) to irq 72..79, and
125 * F0..F7 (16..24) to irq 80..87.
126 */
127
128static inline int gpio_to_irq(unsigned gpio)
129{
130 if (gpio <= EP93XX_GPIO_LINE_MAX_IRQ)
131 return 64 + gpio;
132
133 return -EINVAL;
134}
135
136static inline int irq_to_gpio(unsigned irq)
137{
138 return irq - gpio_to_irq(0);
139}
106 140
107#endif 141#endif
diff --git a/include/asm-arm/arch-ep93xx/irqs.h b/include/asm-arm/arch-ep93xx/irqs.h
index 2a8c63638c5e..53d4a68bfc88 100644
--- a/include/asm-arm/arch-ep93xx/irqs.h
+++ b/include/asm-arm/arch-ep93xx/irqs.h
@@ -67,12 +67,6 @@
67#define IRQ_EP93XX_SAI 60 67#define IRQ_EP93XX_SAI 60
68#define EP93XX_VIC2_VALID_IRQ_MASK 0x1fffffff 68#define EP93XX_VIC2_VALID_IRQ_MASK 0x1fffffff
69 69
70/*
71 * Map GPIO A0..A7 to irq 64..71, B0..B7 to 72..79, and
72 * F0..F7 to 80..87.
73 */
74#define IRQ_EP93XX_GPIO(x) (64 + (((x) + (((x) >> 2) & 8)) & 0x1f))
75
76#define NR_EP93XX_IRQS (64 + 24) 70#define NR_EP93XX_IRQS (64 + 24)
77 71
78#define EP93XX_BOARD_IRQ(x) (NR_EP93XX_IRQS + (x)) 72#define EP93XX_BOARD_IRQ(x) (NR_EP93XX_IRQS + (x))
diff --git a/include/asm-arm/arch-ixp23xx/irqs.h b/include/asm-arm/arch-ixp23xx/irqs.h
index e69639585721..27c580898958 100644
--- a/include/asm-arm/arch-ixp23xx/irqs.h
+++ b/include/asm-arm/arch-ixp23xx/irqs.h
@@ -153,7 +153,7 @@
153 */ 153 */
154#define NR_IXP23XX_MACH_IRQS 32 154#define NR_IXP23XX_MACH_IRQS 32
155 155
156#define NR_IRQS NR_IXP23XX_IRQS + NR_IXP23XX_MACH_IRQS 156#define NR_IRQS (NR_IXP23XX_IRQS + NR_IXP23XX_MACH_IRQS)
157 157
158#define IXP23XX_MACH_IRQ(irq) (NR_IXP23XX_IRQ + (irq)) 158#define IXP23XX_MACH_IRQ(irq) (NR_IXP23XX_IRQ + (irq))
159 159
diff --git a/include/asm-arm/arch-ixp4xx/io.h b/include/asm-arm/arch-ixp4xx/io.h
index eeeea90cd5a9..9c5d2357aff3 100644
--- a/include/asm-arm/arch-ixp4xx/io.h
+++ b/include/asm-arm/arch-ixp4xx/io.h
@@ -61,13 +61,13 @@ __ixp4xx_ioremap(unsigned long addr, size_t size, unsigned int mtype)
61 if((addr < PCIBIOS_MIN_MEM) || (addr > 0x4fffffff)) 61 if((addr < PCIBIOS_MIN_MEM) || (addr > 0x4fffffff))
62 return __arm_ioremap(addr, size, mtype); 62 return __arm_ioremap(addr, size, mtype);
63 63
64 return (void *)addr; 64 return (void __iomem *)addr;
65} 65}
66 66
67static inline void 67static inline void
68__ixp4xx_iounmap(void __iomem *addr) 68__ixp4xx_iounmap(void __iomem *addr)
69{ 69{
70 if ((u32)addr >= VMALLOC_START) 70 if ((__force u32)addr >= VMALLOC_START)
71 __iounmap(addr); 71 __iounmap(addr);
72} 72}
73 73
@@ -141,9 +141,9 @@ __ixp4xx_writesw(volatile void __iomem *bus_addr, const u16 *vaddr, int count)
141static inline void 141static inline void
142__ixp4xx_writel(u32 value, volatile void __iomem *p) 142__ixp4xx_writel(u32 value, volatile void __iomem *p)
143{ 143{
144 u32 addr = (u32)p; 144 u32 addr = (__force u32)p;
145 if (addr >= VMALLOC_START) { 145 if (addr >= VMALLOC_START) {
146 __raw_writel(value, addr); 146 __raw_writel(value, p);
147 return; 147 return;
148 } 148 }
149 149
@@ -208,11 +208,11 @@ __ixp4xx_readsw(const volatile void __iomem *bus_addr, u16 *vaddr, u32 count)
208static inline unsigned long 208static inline unsigned long
209__ixp4xx_readl(const volatile void __iomem *p) 209__ixp4xx_readl(const volatile void __iomem *p)
210{ 210{
211 u32 addr = (u32)p; 211 u32 addr = (__force u32)p;
212 u32 data; 212 u32 data;
213 213
214 if (addr >= VMALLOC_START) 214 if (addr >= VMALLOC_START)
215 return __raw_readl(addr); 215 return __raw_readl(p);
216 216
217 if (ixp4xx_pci_read(addr, NP_CMD_MEMREAD, &data)) 217 if (ixp4xx_pci_read(addr, NP_CMD_MEMREAD, &data))
218 return 0xffffffff; 218 return 0xffffffff;
@@ -438,7 +438,7 @@ __ixp4xx_ioread32(const void __iomem *addr)
438 return (unsigned int)__ixp4xx_inl(port & PIO_MASK); 438 return (unsigned int)__ixp4xx_inl(port & PIO_MASK);
439 else { 439 else {
440#ifndef CONFIG_IXP4XX_INDIRECT_PCI 440#ifndef CONFIG_IXP4XX_INDIRECT_PCI
441 return le32_to_cpu(__raw_readl((u32)port)); 441 return le32_to_cpu((__force __le32)__raw_readl(addr));
442#else 442#else
443 return (unsigned int)__ixp4xx_readl(addr); 443 return (unsigned int)__ixp4xx_readl(addr);
444#endif 444#endif
@@ -523,7 +523,7 @@ __ixp4xx_iowrite32(u32 value, void __iomem *addr)
523 __ixp4xx_outl(value, port & PIO_MASK); 523 __ixp4xx_outl(value, port & PIO_MASK);
524 else 524 else
525#ifndef CONFIG_IXP4XX_INDIRECT_PCI 525#ifndef CONFIG_IXP4XX_INDIRECT_PCI
526 __raw_writel(cpu_to_le32(value), port); 526 __raw_writel((u32 __force)cpu_to_le32(value), addr);
527#else 527#else
528 __ixp4xx_writel(value, addr); 528 __ixp4xx_writel(value, addr);
529#endif 529#endif
diff --git a/include/asm-arm/arch-ixp4xx/platform.h b/include/asm-arm/arch-ixp4xx/platform.h
index 2a44d3d67980..2ce28e3fd325 100644
--- a/include/asm-arm/arch-ixp4xx/platform.h
+++ b/include/asm-arm/arch-ixp4xx/platform.h
@@ -76,17 +76,6 @@ extern unsigned long ixp4xx_exp_bus_size;
76#define IXP4XX_UART_XTAL 14745600 76#define IXP4XX_UART_XTAL 14745600
77 77
78/* 78/*
79 * The IXP4xx chips do not have an I2C unit, so GPIO lines are just
80 * used to
81 * Used as platform_data to provide GPIO pin information to the ixp42x
82 * I2C driver.
83 */
84struct ixp4xx_i2c_pins {
85 unsigned long sda_pin;
86 unsigned long scl_pin;
87};
88
89/*
90 * This structure provide a means for the board setup code 79 * This structure provide a means for the board setup code
91 * to give information to th pata_ixp4xx driver. It is 80 * to give information to th pata_ixp4xx driver. It is
92 * passed as platform_data. 81 * passed as platform_data.
diff --git a/include/asm-arm/arch-ks8695/regs-gpio.h b/include/asm-arm/arch-ks8695/regs-gpio.h
index 57fcf9fc82e4..6b95d77aea19 100644
--- a/include/asm-arm/arch-ks8695/regs-gpio.h
+++ b/include/asm-arm/arch-ks8695/regs-gpio.h
@@ -49,5 +49,7 @@
49#define IOPC_TM_FALLING (4) /* Falling Edge Detection */ 49#define IOPC_TM_FALLING (4) /* Falling Edge Detection */
50#define IOPC_TM_EDGE (6) /* Both Edge Detection */ 50#define IOPC_TM_EDGE (6) /* Both Edge Detection */
51 51
52/* Port Data Register */
53#define IOPD_(x) (1 << (x)) /* Signal Level of GPIO Pin x */
52 54
53#endif 55#endif
diff --git a/include/asm-arm/arch-msm/board.h b/include/asm-arm/arch-msm/board.h
new file mode 100644
index 000000000000..763051f8ba14
--- /dev/null
+++ b/include/asm-arm/arch-msm/board.h
@@ -0,0 +1,37 @@
1/* linux/include/asm-arm/arch-msm/board.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef __ASM_ARCH_MSM_BOARD_H
18#define __ASM_ARCH_MSM_BOARD_H
19
20#include <linux/types.h>
21
22/* platform device data structures */
23
24struct msm_mddi_platform_data
25{
26 void (*panel_power)(int on);
27 unsigned has_vsync_irq:1;
28};
29
30/* common init routines for use by arch/arm/mach-msm/board-*.c */
31
32void __init msm_add_devices(void);
33void __init msm_map_common_io(void);
34void __init msm_init_irq(void);
35void __init msm_init_gpio(void);
36
37#endif
diff --git a/include/asm-arm/arch-msm/debug-macro.S b/include/asm-arm/arch-msm/debug-macro.S
new file mode 100644
index 000000000000..393d5272e506
--- /dev/null
+++ b/include/asm-arm/arch-msm/debug-macro.S
@@ -0,0 +1,40 @@
1/* include/asm-arm/arch-msm7200/debug-macro.S
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <asm/hardware.h>
18#include <asm/arch/msm_iomap.h>
19
20 .macro addruart,rx
21 @ see if the MMU is enabled and select appropriate base address
22 mrc p15, 0, \rx, c1, c0
23 tst \rx, #1
24 ldreq \rx, =MSM_UART1_PHYS
25 ldrne \rx, =MSM_UART1_BASE
26 .endm
27
28 .macro senduart,rd,rx
29 str \rd, [\rx, #0x0C]
30 .endm
31
32 .macro waituart,rd,rx
33 @ wait for TX_READY
341: ldr \rd, [\rx, #0x08]
35 tst \rd, #0x04
36 beq 1b
37 .endm
38
39 .macro busyuart,rd,rx
40 .endm
diff --git a/include/asm-arm/arch-msm/dma.h b/include/asm-arm/arch-msm/dma.h
new file mode 100644
index 000000000000..e4b565b27b35
--- /dev/null
+++ b/include/asm-arm/arch-msm/dma.h
@@ -0,0 +1,151 @@
1/* linux/include/asm-arm/arch-msm/dma.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __ASM_ARCH_MSM_DMA_H
17
18#include <linux/list.h>
19#include <asm/arch/msm_iomap.h>
20
21struct msm_dmov_cmd {
22 struct list_head list;
23 unsigned int cmdptr;
24 void (*complete_func)(struct msm_dmov_cmd *cmd, unsigned int result);
25/* void (*user_result_func)(struct msm_dmov_cmd *cmd); */
26};
27
28void msm_dmov_enqueue_cmd(unsigned id, struct msm_dmov_cmd *cmd);
29void msm_dmov_stop_cmd(unsigned id, struct msm_dmov_cmd *cmd);
30int msm_dmov_exec_cmd(unsigned id, unsigned int cmdptr);
31/* int msm_dmov_exec_cmd_etc(unsigned id, unsigned int cmdptr, int timeout, int interruptible); */
32
33
34
35#define DMOV_SD0(off, ch) (MSM_DMOV_BASE + 0x0000 + (off) + ((ch) << 2))
36#define DMOV_SD1(off, ch) (MSM_DMOV_BASE + 0x0400 + (off) + ((ch) << 2))
37#define DMOV_SD2(off, ch) (MSM_DMOV_BASE + 0x0800 + (off) + ((ch) << 2))
38#define DMOV_SD3(off, ch) (MSM_DMOV_BASE + 0x0C00 + (off) + ((ch) << 2))
39
40/* only security domain 3 is available to the ARM11
41 * SD0 -> mARM trusted, SD1 -> mARM nontrusted, SD2 -> aDSP, SD3 -> aARM
42 */
43
44#define DMOV_CMD_PTR(ch) DMOV_SD3(0x000, ch)
45#define DMOV_CMD_LIST (0 << 29) /* does not work */
46#define DMOV_CMD_PTR_LIST (1 << 29) /* works */
47#define DMOV_CMD_INPUT_CFG (2 << 29) /* untested */
48#define DMOV_CMD_OUTPUT_CFG (3 << 29) /* untested */
49#define DMOV_CMD_ADDR(addr) ((addr) >> 3)
50
51#define DMOV_RSLT(ch) DMOV_SD3(0x040, ch)
52#define DMOV_RSLT_VALID (1 << 31) /* 0 == host has empties result fifo */
53#define DMOV_RSLT_ERROR (1 << 3)
54#define DMOV_RSLT_FLUSH (1 << 2)
55#define DMOV_RSLT_DONE (1 << 1) /* top pointer done */
56#define DMOV_RSLT_USER (1 << 0) /* command with FR force result */
57
58#define DMOV_FLUSH0(ch) DMOV_SD3(0x080, ch)
59#define DMOV_FLUSH1(ch) DMOV_SD3(0x0C0, ch)
60#define DMOV_FLUSH2(ch) DMOV_SD3(0x100, ch)
61#define DMOV_FLUSH3(ch) DMOV_SD3(0x140, ch)
62#define DMOV_FLUSH4(ch) DMOV_SD3(0x180, ch)
63#define DMOV_FLUSH5(ch) DMOV_SD3(0x1C0, ch)
64
65#define DMOV_STATUS(ch) DMOV_SD3(0x200, ch)
66#define DMOV_STATUS_RSLT_COUNT(n) (((n) >> 29))
67#define DMOV_STATUS_CMD_COUNT(n) (((n) >> 27) & 3)
68#define DMOV_STATUS_RSLT_VALID (1 << 1)
69#define DMOV_STATUS_CMD_PTR_RDY (1 << 0)
70
71#define DMOV_ISR DMOV_SD3(0x380, 0)
72
73#define DMOV_CONFIG(ch) DMOV_SD3(0x300, ch)
74#define DMOV_CONFIG_FORCE_TOP_PTR_RSLT (1 << 2)
75#define DMOV_CONFIG_FORCE_FLUSH_RSLT (1 << 1)
76#define DMOV_CONFIG_IRQ_EN (1 << 0)
77
78/* channel assignments */
79
80#define DMOV_NAND_CHAN 7
81#define DMOV_NAND_CRCI_CMD 5
82#define DMOV_NAND_CRCI_DATA 4
83
84#define DMOV_SDC1_CHAN 8
85#define DMOV_SDC1_CRCI 6
86
87#define DMOV_SDC2_CHAN 8
88#define DMOV_SDC2_CRCI 7
89
90#define DMOV_TSIF_CHAN 10
91#define DMOV_TSIF_CRCI 10
92
93#define DMOV_USB_CHAN 11
94
95/* no client rate control ifc (eg, ram) */
96#define DMOV_NONE_CRCI 0
97
98
99/* If the CMD_PTR register has CMD_PTR_LIST selected, the data mover
100 * is going to walk a list of 32bit pointers as described below. Each
101 * pointer points to a *array* of dmov_s, etc structs. The last pointer
102 * in the list is marked with CMD_PTR_LP. The last struct in each array
103 * is marked with CMD_LC (see below).
104 */
105#define CMD_PTR_ADDR(addr) ((addr) >> 3)
106#define CMD_PTR_LP (1 << 31) /* last pointer */
107#define CMD_PTR_PT (3 << 29) /* ? */
108
109/* Single Item Mode */
110typedef struct {
111 unsigned cmd;
112 unsigned src;
113 unsigned dst;
114 unsigned len;
115} dmov_s;
116
117/* Scatter/Gather Mode */
118typedef struct {
119 unsigned cmd;
120 unsigned src_dscr;
121 unsigned dst_dscr;
122 unsigned _reserved;
123} dmov_sg;
124
125/* bits for the cmd field of the above structures */
126
127#define CMD_LC (1 << 31) /* last command */
128#define CMD_FR (1 << 22) /* force result -- does not work? */
129#define CMD_OCU (1 << 21) /* other channel unblock */
130#define CMD_OCB (1 << 20) /* other channel block */
131#define CMD_TCB (1 << 19) /* ? */
132#define CMD_DAH (1 << 18) /* destination address hold -- does not work?*/
133#define CMD_SAH (1 << 17) /* source address hold -- does not work? */
134
135#define CMD_MODE_SINGLE (0 << 0) /* dmov_s structure used */
136#define CMD_MODE_SG (1 << 0) /* untested */
137#define CMD_MODE_IND_SG (2 << 0) /* untested */
138#define CMD_MODE_BOX (3 << 0) /* untested */
139
140#define CMD_DST_SWAP_BYTES (1 << 14) /* exchange each byte n with byte n+1 */
141#define CMD_DST_SWAP_SHORTS (1 << 15) /* exchange each short n with short n+1 */
142#define CMD_DST_SWAP_WORDS (1 << 16) /* exchange each word n with word n+1 */
143
144#define CMD_SRC_SWAP_BYTES (1 << 11) /* exchange each byte n with byte n+1 */
145#define CMD_SRC_SWAP_SHORTS (1 << 12) /* exchange each short n with short n+1 */
146#define CMD_SRC_SWAP_WORDS (1 << 13) /* exchange each word n with word n+1 */
147
148#define CMD_DST_CRCI(n) (((n) & 15) << 7)
149#define CMD_SRC_CRCI(n) (((n) & 15) << 3)
150
151#endif
diff --git a/include/asm-arm/arch-msm/entry-macro.S b/include/asm-arm/arch-msm/entry-macro.S
new file mode 100644
index 000000000000..ee24aece4cb0
--- /dev/null
+++ b/include/asm-arm/arch-msm/entry-macro.S
@@ -0,0 +1,38 @@
1/* include/asm-arm/arch-msm7200/entry-macro.S
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#include <asm/arch/msm_iomap.h>
18
19 .macro disable_fiq
20 .endm
21
22 .macro get_irqnr_preamble, base, tmp
23 @ enable imprecise aborts
24 cpsie a
25 mov \base, #MSM_VIC_BASE
26 .endm
27
28 .macro arch_ret_to_user, tmp1, tmp2
29 .endm
30
31 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
32 @ 0xD0 has irq# or old irq# if the irq has been handled
33 @ 0xD4 has irq# or -1 if none pending *but* if you just
34 @ read 0xD4 you never get the first irq for some reason
35 ldr \irqnr, [\base, #0xD0]
36 ldr \irqnr, [\base, #0xD4]
37 cmp \irqnr, #0xffffffff
38 .endm
diff --git a/include/asm-arm/arch-msm/hardware.h b/include/asm-arm/arch-msm/hardware.h
new file mode 100644
index 000000000000..89af2b70182f
--- /dev/null
+++ b/include/asm-arm/arch-msm/hardware.h
@@ -0,0 +1,18 @@
1/* linux/include/asm-arm/arch-msm/hardware.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __ASM_ARCH_MSM_HARDWARE_H
17
18#endif
diff --git a/include/asm-arm/arch-msm/io.h b/include/asm-arm/arch-msm/io.h
new file mode 100644
index 000000000000..4645ae26b62a
--- /dev/null
+++ b/include/asm-arm/arch-msm/io.h
@@ -0,0 +1,33 @@
1/* include/asm-arm/arch-msm/io.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __ASM_ARM_ARCH_IO_H
17#define __ASM_ARM_ARCH_IO_H
18
19#define IO_SPACE_LIMIT 0xffffffff
20
21#define __arch_ioremap __msm_ioremap
22#define __arch_iounmap __iounmap
23
24void __iomem *__msm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype);
25
26static inline void __iomem *__io(unsigned long addr)
27{
28 return (void __iomem *)addr;
29}
30#define __io(a) __io(a)
31#define __mem_pci(a) (a)
32
33#endif
diff --git a/include/asm-arm/arch-msm/irqs.h b/include/asm-arm/arch-msm/irqs.h
new file mode 100644
index 000000000000..565430cfaa7e
--- /dev/null
+++ b/include/asm-arm/arch-msm/irqs.h
@@ -0,0 +1,89 @@
1/* linux/include/asm-arm/arch-msm/irqs.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef __ASM_ARCH_MSM_IRQS_H
18
19/* MSM ARM11 Interrupt Numbers */
20/* See 80-VE113-1 A, pp219-221 */
21
22#define INT_A9_M2A_0 0
23#define INT_A9_M2A_1 1
24#define INT_A9_M2A_2 2
25#define INT_A9_M2A_3 3
26#define INT_A9_M2A_4 4
27#define INT_A9_M2A_5 5
28#define INT_A9_M2A_6 6
29#define INT_GP_TIMER_EXP 7
30#define INT_DEBUG_TIMER_EXP 8
31#define INT_UART1 9
32#define INT_UART2 10
33#define INT_UART3 11
34#define INT_UART1_RX 12
35#define INT_UART2_RX 13
36#define INT_UART3_RX 14
37#define INT_USB_OTG 15
38#define INT_MDDI_PRI 16
39#define INT_MDDI_EXT 17
40#define INT_MDDI_CLIENT 18
41#define INT_MDP 19
42#define INT_GRAPHICS 20
43#define INT_ADM_AARM 21
44#define INT_ADSP_A11 22
45#define INT_ADSP_A9_A11 23
46#define INT_SDC1_0 24
47#define INT_SDC1_1 25
48#define INT_SDC2_0 26
49#define INT_SDC2_1 27
50#define INT_KEYSENSE 28
51#define INT_TCHSCRN_SSBI 29
52#define INT_TCHSCRN1 30
53#define INT_TCHSCRN2 31
54
55#define INT_GPIO_GROUP1 (32 + 0)
56#define INT_GPIO_GROUP2 (32 + 1)
57#define INT_PWB_I2C (32 + 2)
58#define INT_SOFTRESET (32 + 3)
59#define INT_NAND_WR_ER_DONE (32 + 4)
60#define INT_NAND_OP_DONE (32 + 5)
61#define INT_PBUS_ARM11 (32 + 6)
62#define INT_AXI_MPU_SMI (32 + 7)
63#define INT_AXI_MPU_EBI1 (32 + 8)
64#define INT_AD_HSSD (32 + 9)
65#define INT_ARM11_PMU (32 + 10)
66#define INT_ARM11_DMA (32 + 11)
67#define INT_TSIF_IRQ (32 + 12)
68#define INT_UART1DM_IRQ (32 + 13)
69#define INT_UART1DM_RX (32 + 14)
70#define INT_USB_HS (32 + 15)
71#define INT_SDC3_0 (32 + 16)
72#define INT_SDC3_1 (32 + 17)
73#define INT_SDC4_0 (32 + 18)
74#define INT_SDC4_1 (32 + 19)
75#define INT_UART2DM_RX (32 + 20)
76#define INT_UART2DM_IRQ (32 + 21)
77
78/* 22-31 are reserved */
79
80#define MSM_IRQ_BIT(irq) (1 << ((irq) & 31))
81
82#define NR_MSM_IRQS 64
83#define NR_GPIO_IRQS 122
84#define NR_BOARD_IRQS 64
85#define NR_IRQS (NR_MSM_IRQS + NR_GPIO_IRQS + NR_BOARD_IRQS)
86
87#define MSM_GPIO_TO_INT(n) (NR_MSM_IRQS + (n))
88
89#endif
diff --git a/include/asm-arm/arch-msm/memory.h b/include/asm-arm/arch-msm/memory.h
new file mode 100644
index 000000000000..b5ce0e9ac86d
--- /dev/null
+++ b/include/asm-arm/arch-msm/memory.h
@@ -0,0 +1,27 @@
1/* linux/include/asm-arm/arch-msm/memory.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __ASM_ARCH_MEMORY_H
17#define __ASM_ARCH_MEMORY_H
18
19/* physical offset of RAM */
20#define PHYS_OFFSET UL(0x10000000)
21
22/* bus address and physical addresses are identical */
23#define __virt_to_bus(x) __virt_to_phys(x)
24#define __bus_to_virt(x) __phys_to_virt(x)
25
26#endif
27
diff --git a/include/asm-arm/arch-msm/msm_iomap.h b/include/asm-arm/arch-msm/msm_iomap.h
new file mode 100644
index 000000000000..b8955cc26fec
--- /dev/null
+++ b/include/asm-arm/arch-msm/msm_iomap.h
@@ -0,0 +1,104 @@
1/* linux/include/asm-arm/arch-msm/msm_iomap.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 *
16 * The MSM peripherals are spread all over across 768MB of physical
17 * space, which makes just having a simple IO_ADDRESS macro to slide
18 * them into the right virtual location rough. Instead, we will
19 * provide a master phys->virt mapping for peripherals here.
20 *
21 */
22
23#ifndef __ASM_ARCH_MSM_IOMAP_H
24#define __ASM_ARCH_MSM_IOMAP_H
25
26#include <asm/sizes.h>
27
28/* Physical base address and size of peripherals.
29 * Ordered by the virtual base addresses they will be mapped at.
30 *
31 * MSM_VIC_BASE must be an value that can be loaded via a "mov"
32 * instruction, otherwise entry-macro.S will not compile.
33 *
34 * If you add or remove entries here, you'll want to edit the
35 * msm_io_desc array in arch/arm/mach-msm/io.c to reflect your
36 * changes.
37 *
38 */
39
40#define MSM_VIC_BASE 0xE0000000
41#define MSM_VIC_PHYS 0xC0000000
42#define MSM_VIC_SIZE SZ_4K
43
44#define MSM_CSR_BASE 0xE0001000
45#define MSM_CSR_PHYS 0xC0100000
46#define MSM_CSR_SIZE SZ_4K
47
48#define MSM_GPT_PHYS MSM_CSR_PHYS
49#define MSM_GPT_BASE MSM_CSR_BASE
50#define MSM_GPT_SIZE SZ_4K
51
52#define MSM_DMOV_BASE 0xE0002000
53#define MSM_DMOV_PHYS 0xA9700000
54#define MSM_DMOV_SIZE SZ_4K
55
56#define MSM_UART1_BASE 0xE0003000
57#define MSM_UART1_PHYS 0xA9A00000
58#define MSM_UART1_SIZE SZ_4K
59
60#define MSM_UART2_BASE 0xE0004000
61#define MSM_UART2_PHYS 0xA9B00000
62#define MSM_UART2_SIZE SZ_4K
63
64#define MSM_UART3_BASE 0xE0005000
65#define MSM_UART3_PHYS 0xA9C00000
66#define MSM_UART3_SIZE SZ_4K
67
68#define MSM_I2C_BASE 0xE0006000
69#define MSM_I2C_PHYS 0xA9900000
70#define MSM_I2C_SIZE SZ_4K
71
72#define MSM_GPIO1_BASE 0xE0007000
73#define MSM_GPIO1_PHYS 0xA9200000
74#define MSM_GPIO1_SIZE SZ_4K
75
76#define MSM_GPIO2_BASE 0xE0008000
77#define MSM_GPIO2_PHYS 0xA9300000
78#define MSM_GPIO2_SIZE SZ_4K
79
80#define MSM_HSUSB_BASE 0xE0009000
81#define MSM_HSUSB_PHYS 0xA0800000
82#define MSM_HSUSB_SIZE SZ_4K
83
84#define MSM_CLK_CTL_BASE 0xE000A000
85#define MSM_CLK_CTL_PHYS 0xA8600000
86#define MSM_CLK_CTL_SIZE SZ_4K
87
88#define MSM_PMDH_BASE 0xE000B000
89#define MSM_PMDH_PHYS 0xAA600000
90#define MSM_PMDH_SIZE SZ_4K
91
92#define MSM_EMDH_BASE 0xE000C000
93#define MSM_EMDH_PHYS 0xAA700000
94#define MSM_EMDH_SIZE SZ_4K
95
96#define MSM_MDP_BASE 0xE0010000
97#define MSM_MDP_PHYS 0xAA200000
98#define MSM_MDP_SIZE 0x000F0000
99
100#define MSM_SHARED_RAM_BASE 0xE0100000
101#define MSM_SHARED_RAM_PHYS 0x01F00000
102#define MSM_SHARED_RAM_SIZE SZ_1M
103
104#endif
diff --git a/include/asm-arm/arch-msm/system.h b/include/asm-arm/arch-msm/system.h
new file mode 100644
index 000000000000..7c5544bdd0c7
--- /dev/null
+++ b/include/asm-arm/arch-msm/system.h
@@ -0,0 +1,23 @@
1/* linux/include/asm-arm/arch-msm/system.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#include <asm/hardware.h>
17
18void arch_idle(void);
19
20static inline void arch_reset(char mode)
21{
22 for (;;) ; /* depends on IPC w/ other core */
23}
diff --git a/include/asm-arm/arch-msm/timex.h b/include/asm-arm/arch-msm/timex.h
new file mode 100644
index 000000000000..154b23fb3599
--- /dev/null
+++ b/include/asm-arm/arch-msm/timex.h
@@ -0,0 +1,20 @@
1/* linux/include/asm-arm/arch-msm/timex.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __ASM_ARCH_MSM_TIMEX_H
17
18#define CLOCK_TICK_RATE 1000000
19
20#endif
diff --git a/include/asm-arm/arch-msm/uncompress.h b/include/asm-arm/arch-msm/uncompress.h
new file mode 100644
index 000000000000..e91ed786ffec
--- /dev/null
+++ b/include/asm-arm/arch-msm/uncompress.h
@@ -0,0 +1,36 @@
1/* linux/include/asm-arm/arch-msm/uncompress.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __ASM_ARCH_MSM_UNCOMPRESS_H
17
18#include "hardware.h"
19
20static void putc(int c)
21{
22}
23
24static inline void flush(void)
25{
26}
27
28static inline void arch_decomp_setup(void)
29{
30}
31
32static inline void arch_decomp_wdog(void)
33{
34}
35
36#endif
diff --git a/include/asm-arm/arch-msm/vmalloc.h b/include/asm-arm/arch-msm/vmalloc.h
new file mode 100644
index 000000000000..60f8d910e825
--- /dev/null
+++ b/include/asm-arm/arch-msm/vmalloc.h
@@ -0,0 +1,22 @@
1/* linux/include/asm-arm/arch-msm/vmalloc.h
2 *
3 * Copyright (C) 2007 Google, Inc.
4 *
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 */
15
16#ifndef __ASM_ARCH_MSM_VMALLOC_H
17#define __ASM_ARCH_MSM_VMALLOC_H
18
19#define VMALLOC_END (PAGE_OFFSET + 0x10000000)
20
21#endif
22
diff --git a/include/asm-arm/arch-omap/board-innovator.h b/include/asm-arm/arch-omap/board-innovator.h
index b3cf33441f6e..56d2c98e143c 100644
--- a/include/asm-arm/arch-omap/board-innovator.h
+++ b/include/asm-arm/arch-omap/board-innovator.h
@@ -37,7 +37,7 @@
37#define OMAP1510P1_EMIFF_PRI_VALUE 0x00 37#define OMAP1510P1_EMIFF_PRI_VALUE 0x00
38 38
39#define NR_FPGA_IRQS 24 39#define NR_FPGA_IRQS 24
40#define NR_IRQS IH_BOARD_BASE + NR_FPGA_IRQS 40#define NR_IRQS (IH_BOARD_BASE + NR_FPGA_IRQS)
41 41
42#ifndef __ASSEMBLY__ 42#ifndef __ASSEMBLY__
43void fpga_write(unsigned char val, int reg); 43void fpga_write(unsigned char val, int reg);
diff --git a/include/asm-arm/arch-omap/eac.h b/include/asm-arm/arch-omap/eac.h
index 6662cb02bafc..ccee3b0700b3 100644
--- a/include/asm-arm/arch-omap/eac.h
+++ b/include/asm-arm/arch-omap/eac.h
@@ -31,7 +31,6 @@
31#include <asm/arch/hardware.h> 31#include <asm/arch/hardware.h>
32#include <asm/irq.h> 32#include <asm/irq.h>
33 33
34#include <sound/driver.h>
35#include <sound/core.h> 34#include <sound/core.h>
36 35
37/* master codec clock source */ 36/* master codec clock source */
diff --git a/include/asm-arm/arch-omap/omap-alsa.h b/include/asm-arm/arch-omap/omap-alsa.h
index fcaf44c14714..faa0ed23d4ba 100644
--- a/include/asm-arm/arch-omap/omap-alsa.h
+++ b/include/asm-arm/arch-omap/omap-alsa.h
@@ -40,7 +40,6 @@
40#ifndef __OMAP_ALSA_H 40#ifndef __OMAP_ALSA_H
41#define __OMAP_ALSA_H 41#define __OMAP_ALSA_H
42 42
43#include <sound/driver.h>
44#include <asm/arch/dma.h> 43#include <asm/arch/dma.h>
45#include <sound/core.h> 44#include <sound/core.h>
46#include <sound/pcm.h> 45#include <sound/pcm.h>
diff --git a/include/asm-arm/arch-orion/debug-macro.S b/include/asm-arm/arch-orion/debug-macro.S
new file mode 100644
index 000000000000..e2a80641f214
--- /dev/null
+++ b/include/asm-arm/arch-orion/debug-macro.S
@@ -0,0 +1,17 @@
1/*
2 * linux/include/asm-arm/arch-orion/debug-macro.S
3 *
4 * Debugging macro include header
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9*/
10
11 .macro addruart,rx
12 mov \rx, #0xf1000000
13 orr \rx, \rx, #0x00012000
14 .endm
15
16#define UART_SHIFT 2
17#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-orion/dma.h b/include/asm-arm/arch-orion/dma.h
new file mode 100644
index 000000000000..40a8c178f10d
--- /dev/null
+++ b/include/asm-arm/arch-orion/dma.h
@@ -0,0 +1 @@
/* empty */
diff --git a/include/asm-arm/arch-orion/entry-macro.S b/include/asm-arm/arch-orion/entry-macro.S
new file mode 100644
index 000000000000..b76075a7e44b
--- /dev/null
+++ b/include/asm-arm/arch-orion/entry-macro.S
@@ -0,0 +1,31 @@
1/*
2 * include/asm-arm/arch-orion/entry-macro.S
3 *
4 * Low-level IRQ helper macros for Orion platforms
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#include <asm/arch/orion.h>
12
13 .macro disable_fiq
14 .endm
15
16 .macro arch_ret_to_user, tmp1, tmp2
17 .endm
18
19 .macro get_irqnr_preamble, base, tmp
20 ldr \base, =MAIN_IRQ_CAUSE
21 .endm
22
23 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
24 ldr \irqstat, [\base, #0] @ main cause
25 ldr \tmp, [\base, #(MAIN_IRQ_MASK - MAIN_IRQ_CAUSE)] @ main mask
26 mov \irqnr, #0 @ default irqnr
27 @ find cause bits that are unmasked
28 ands \irqstat, \irqstat, \tmp @ clear Z flag if any
29 clzne \irqnr, \irqstat @ calc irqnr
30 rsbne \irqnr, \irqnr, #31
31 .endm
diff --git a/include/asm-arm/arch-orion/gpio.h b/include/asm-arm/arch-orion/gpio.h
new file mode 100644
index 000000000000..d66284f9a14c
--- /dev/null
+++ b/include/asm-arm/arch-orion/gpio.h
@@ -0,0 +1,28 @@
1/*
2 * include/asm-arm/arch-orion/gpio.h
3 *
4 * This file is licensed under the terms of the GNU General Public
5 * License version 2. This program is licensed "as is" without any
6 * warranty of any kind, whether express or implied.
7 */
8
9extern int gpio_request(unsigned pin, const char *label);
10extern void gpio_free(unsigned pin);
11extern int gpio_direction_input(unsigned pin);
12extern int gpio_direction_output(unsigned pin, int value);
13extern int gpio_get_value(unsigned pin);
14extern void gpio_set_value(unsigned pin, int value);
15extern void orion_gpio_set_blink(unsigned pin, int blink);
16extern void gpio_display(void); /* debug */
17
18static inline int gpio_to_irq(int pin)
19{
20 return pin + IRQ_ORION_GPIO_START;
21}
22
23static inline int irq_to_gpio(int irq)
24{
25 return irq - IRQ_ORION_GPIO_START;
26}
27
28#include <asm-generic/gpio.h> /* cansleep wrappers */
diff --git a/include/asm-arm/arch-orion/hardware.h b/include/asm-arm/arch-orion/hardware.h
new file mode 100644
index 000000000000..8a12d213fbdc
--- /dev/null
+++ b/include/asm-arm/arch-orion/hardware.h
@@ -0,0 +1,24 @@
1/*
2 * include/asm-arm/arch-orion/hardware.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 */
9
10#ifndef __ASM_ARCH_HARDWARE_H__
11#define __ASM_ARCH_HARDWARE_H__
12
13#include "orion.h"
14
15#define PCI_MEMORY_VADDR ORION_PCI_SYS_MEM_BASE
16#define PCI_IO_VADDR ORION_PCI_SYS_IO_BASE
17
18#define pcibios_assign_all_busses() 1
19
20#define PCIBIOS_MIN_IO 0x1000
21#define PCIBIOS_MIN_MEM 0x01000000
22#define PCIMEM_BASE PCI_MEMORY_VADDR /* mem base for VGA */
23
24#endif /* _ASM_ARCH_HARDWARE_H */
diff --git a/include/asm-arm/arch-orion/io.h b/include/asm-arm/arch-orion/io.h
new file mode 100644
index 000000000000..e0b8c39b9167
--- /dev/null
+++ b/include/asm-arm/arch-orion/io.h
@@ -0,0 +1,27 @@
1/*
2 * include/asm-arm/arch-orion/io.h
3 *
4 * Tzachi Perelstein <tzachi@marvell.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#ifndef __ASM_ARM_ARCH_IO_H
12#define __ASM_ARM_ARCH_IO_H
13
14#include "orion.h"
15
16#define IO_SPACE_LIMIT 0xffffffff
17#define IO_SPACE_REMAP ORION_PCI_SYS_IO_BASE
18
19static inline void __iomem *__io(unsigned long addr)
20{
21 return (void __iomem *)addr;
22}
23
24#define __io(a) __io(a)
25#define __mem_pci(a) (a)
26
27#endif
diff --git a/include/asm-arm/arch-orion/irqs.h b/include/asm-arm/arch-orion/irqs.h
new file mode 100644
index 000000000000..eea65ca6076a
--- /dev/null
+++ b/include/asm-arm/arch-orion/irqs.h
@@ -0,0 +1,61 @@
1/*
2 * include/asm-arm/arch-orion/irqs.h
3 *
4 * IRQ definitions for Orion SoC
5 *
6 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
7 *
8 * This file is licensed under the terms of the GNU General Public
9 * License version 2. This program is licensed "as is" without any
10 * warranty of any kind, whether express or implied.
11 */
12
13#ifndef __ASM_ARCH_IRQS_H__
14#define __ASM_ARCH_IRQS_H__
15
16#include "orion.h" /* need GPIO_MAX */
17
18/*
19 * Orion Main Interrupt Controller
20 */
21#define IRQ_ORION_BRIDGE 0
22#define IRQ_ORION_DOORBELL_H2C 1
23#define IRQ_ORION_DOORBELL_C2H 2
24#define IRQ_ORION_UART0 3
25#define IRQ_ORION_UART1 4
26#define IRQ_ORION_I2C 5
27#define IRQ_ORION_GPIO_0_7 6
28#define IRQ_ORION_GPIO_8_15 7
29#define IRQ_ORION_GPIO_16_23 8
30#define IRQ_ORION_GPIO_24_31 9
31#define IRQ_ORION_PCIE0_ERR 10
32#define IRQ_ORION_PCIE0_INT 11
33#define IRQ_ORION_USB1_CTRL 12
34#define IRQ_ORION_DEV_BUS_ERR 14
35#define IRQ_ORION_PCI_ERR 15
36#define IRQ_ORION_USB_BR_ERR 16
37#define IRQ_ORION_USB0_CTRL 17
38#define IRQ_ORION_ETH_RX 18
39#define IRQ_ORION_ETH_TX 19
40#define IRQ_ORION_ETH_MISC 20
41#define IRQ_ORION_ETH_SUM 21
42#define IRQ_ORION_ETH_ERR 22
43#define IRQ_ORION_IDMA_ERR 23
44#define IRQ_ORION_IDMA_0 24
45#define IRQ_ORION_IDMA_1 25
46#define IRQ_ORION_IDMA_2 26
47#define IRQ_ORION_IDMA_3 27
48#define IRQ_ORION_CESA 28
49#define IRQ_ORION_SATA 29
50#define IRQ_ORION_XOR0 30
51#define IRQ_ORION_XOR1 31
52
53/*
54 * Orion General Purpose Pins
55 */
56#define IRQ_ORION_GPIO_START 32
57#define NR_GPIO_IRQS GPIO_MAX
58
59#define NR_IRQS (IRQ_ORION_GPIO_START + NR_GPIO_IRQS)
60
61#endif /* __ASM_ARCH_IRQS_H__ */
diff --git a/include/asm-arm/arch-orion/memory.h b/include/asm-arm/arch-orion/memory.h
new file mode 100644
index 000000000000..d954dba87ced
--- /dev/null
+++ b/include/asm-arm/arch-orion/memory.h
@@ -0,0 +1,15 @@
1/*
2 * include/asm-arm/arch-orion/memory.h
3 *
4 * Marvell Orion memory definitions
5 */
6
7#ifndef __ASM_ARCH_MMU_H
8#define __ASM_ARCH_MMU_H
9
10#define PHYS_OFFSET UL(0x00000000)
11
12#define __virt_to_bus(x) __virt_to_phys(x)
13#define __bus_to_virt(x) __phys_to_virt(x)
14
15#endif
diff --git a/include/asm-arm/arch-orion/orion.h b/include/asm-arm/arch-orion/orion.h
new file mode 100644
index 000000000000..f787f752e58c
--- /dev/null
+++ b/include/asm-arm/arch-orion/orion.h
@@ -0,0 +1,143 @@
1/*
2 * include/asm-arm/arch-orion/orion.h
3 *
4 * Generic definitions of Orion SoC flavors:
5 * Orion-1, Orion-NAS, Orion-VoIP, and Orion-2.
6 *
7 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#ifndef __ASM_ARCH_ORION_H__
15#define __ASM_ARCH_ORION_H__
16
17/*******************************************************************************
18 * Orion Address Map
19 * Use the same mapping (1:1 virtual:physical) of internal registers and
20 * PCI system (PCI+PCIE) for all machines.
21 * Each machine defines the rest of its mapping (e.g. device bus flashes)
22 ******************************************************************************/
23#define ORION_REGS_BASE 0xf1000000
24#define ORION_REGS_SIZE SZ_1M
25
26#define ORION_PCI_SYS_MEM_BASE 0xe0000000
27#define ORION_PCIE_MEM_BASE ORION_PCI_SYS_MEM_BASE
28#define ORION_PCIE_MEM_SIZE SZ_128M
29#define ORION_PCI_MEM_BASE (ORION_PCIE_MEM_BASE + ORION_PCIE_MEM_SIZE)
30#define ORION_PCI_MEM_SIZE SZ_128M
31
32#define ORION_PCI_SYS_IO_BASE 0xf2000000
33#define ORION_PCIE_IO_BASE ORION_PCI_SYS_IO_BASE
34#define ORION_PCIE_IO_SIZE SZ_1M
35#define ORION_PCIE_IO_REMAP (ORION_PCIE_IO_BASE - ORION_PCI_SYS_IO_BASE)
36#define ORION_PCI_IO_BASE (ORION_PCIE_IO_BASE + ORION_PCIE_IO_SIZE)
37#define ORION_PCI_IO_SIZE SZ_1M
38#define ORION_PCI_IO_REMAP (ORION_PCI_IO_BASE - ORION_PCI_SYS_IO_BASE)
39/* Relevant only for Orion-NAS */
40#define ORION_PCIE_WA_BASE 0xf0000000
41#define ORION_PCIE_WA_SIZE SZ_16M
42
43/*******************************************************************************
44 * Supported Devices & Revisions
45 ******************************************************************************/
46/* Orion-1 (88F5181) */
47#define MV88F5181_DEV_ID 0x5181
48#define MV88F5181_REV_B1 3
49/* Orion-NAS (88F5182) */
50#define MV88F5182_DEV_ID 0x5182
51#define MV88F5182_REV_A2 2
52/* Orion-2 (88F5281) */
53#define MV88F5281_DEV_ID 0x5281
54#define MV88F5281_REV_D1 5
55#define MV88F5281_REV_D2 6
56
57/*******************************************************************************
58 * Orion Registers Map
59 ******************************************************************************/
60#define ORION_DDR_REG_BASE (ORION_REGS_BASE | 0x00000)
61#define ORION_DEV_BUS_REG_BASE (ORION_REGS_BASE | 0x10000)
62#define ORION_BRIDGE_REG_BASE (ORION_REGS_BASE | 0x20000)
63#define ORION_PCI_REG_BASE (ORION_REGS_BASE | 0x30000)
64#define ORION_PCIE_REG_BASE (ORION_REGS_BASE | 0x40000)
65#define ORION_USB0_REG_BASE (ORION_REGS_BASE | 0x50000)
66#define ORION_ETH_REG_BASE (ORION_REGS_BASE | 0x70000)
67#define ORION_SATA_REG_BASE (ORION_REGS_BASE | 0x80000)
68#define ORION_USB1_REG_BASE (ORION_REGS_BASE | 0xa0000)
69
70#define ORION_DDR_REG(x) (ORION_DDR_REG_BASE | (x))
71#define ORION_DEV_BUS_REG(x) (ORION_DEV_BUS_REG_BASE | (x))
72#define ORION_BRIDGE_REG(x) (ORION_BRIDGE_REG_BASE | (x))
73#define ORION_PCI_REG(x) (ORION_PCI_REG_BASE | (x))
74#define ORION_PCIE_REG(x) (ORION_PCIE_REG_BASE | (x))
75#define ORION_USB0_REG(x) (ORION_USB0_REG_BASE | (x))
76#define ORION_USB1_REG(x) (ORION_USB1_REG_BASE | (x))
77#define ORION_ETH_REG(x) (ORION_ETH_REG_BASE | (x))
78#define ORION_SATA_REG(x) (ORION_SATA_REG_BASE | (x))
79
80/*******************************************************************************
81 * Device Bus Registers
82 ******************************************************************************/
83#define MPP_0_7_CTRL ORION_DEV_BUS_REG(0x000)
84#define MPP_8_15_CTRL ORION_DEV_BUS_REG(0x004)
85#define MPP_16_19_CTRL ORION_DEV_BUS_REG(0x050)
86#define MPP_DEV_CTRL ORION_DEV_BUS_REG(0x008)
87#define MPP_RESET_SAMPLE ORION_DEV_BUS_REG(0x010)
88#define GPIO_OUT ORION_DEV_BUS_REG(0x100)
89#define GPIO_IO_CONF ORION_DEV_BUS_REG(0x104)
90#define GPIO_BLINK_EN ORION_DEV_BUS_REG(0x108)
91#define GPIO_IN_POL ORION_DEV_BUS_REG(0x10c)
92#define GPIO_DATA_IN ORION_DEV_BUS_REG(0x110)
93#define GPIO_EDGE_CAUSE ORION_DEV_BUS_REG(0x114)
94#define GPIO_EDGE_MASK ORION_DEV_BUS_REG(0x118)
95#define GPIO_LEVEL_MASK ORION_DEV_BUS_REG(0x11c)
96#define DEV_BANK_0_PARAM ORION_DEV_BUS_REG(0x45c)
97#define DEV_BANK_1_PARAM ORION_DEV_BUS_REG(0x460)
98#define DEV_BANK_2_PARAM ORION_DEV_BUS_REG(0x464)
99#define DEV_BANK_BOOT_PARAM ORION_DEV_BUS_REG(0x46c)
100#define DEV_BUS_CTRL ORION_DEV_BUS_REG(0x4c0)
101#define DEV_BUS_INT_CAUSE ORION_DEV_BUS_REG(0x4d0)
102#define DEV_BUS_INT_MASK ORION_DEV_BUS_REG(0x4d4)
103#define I2C_BASE ORION_DEV_BUS_REG(0x1000)
104#define UART0_BASE ORION_DEV_BUS_REG(0x2000)
105#define UART1_BASE ORION_DEV_BUS_REG(0x2100)
106#define GPIO_MAX 32
107
108/***************************************************************************
109 * Orion CPU Bridge Registers
110 **************************************************************************/
111#define CPU_CONF ORION_BRIDGE_REG(0x100)
112#define CPU_CTRL ORION_BRIDGE_REG(0x104)
113#define CPU_RESET_MASK ORION_BRIDGE_REG(0x108)
114#define CPU_SOFT_RESET ORION_BRIDGE_REG(0x10c)
115#define POWER_MNG_CTRL_REG ORION_BRIDGE_REG(0x11C)
116#define BRIDGE_CAUSE ORION_BRIDGE_REG(0x110)
117#define BRIDGE_MASK ORION_BRIDGE_REG(0x114)
118#define MAIN_IRQ_CAUSE ORION_BRIDGE_REG(0x200)
119#define MAIN_IRQ_MASK ORION_BRIDGE_REG(0x204)
120#define TIMER_CTRL ORION_BRIDGE_REG(0x300)
121#define TIMER_VAL(x) ORION_BRIDGE_REG(0x314 + ((x) * 8))
122#define TIMER_VAL_RELOAD(x) ORION_BRIDGE_REG(0x310 + ((x) * 8))
123
124#ifndef __ASSEMBLY__
125
126/*******************************************************************************
127 * Helpers to access Orion registers
128 ******************************************************************************/
129#include <asm/types.h>
130#include <asm/io.h>
131
132#define orion_read(r) __raw_readl(r)
133#define orion_write(r, val) __raw_writel(val, r)
134
135/*
136 * These are not preempt safe. Locks, if needed, must be taken care by caller.
137 */
138#define orion_setbits(r, mask) orion_write((r), orion_read(r) | (mask))
139#define orion_clrbits(r, mask) orion_write((r), orion_read(r) & ~(mask))
140
141#endif /* __ASSEMBLY__ */
142
143#endif /* __ASM_ARCH_ORION_H__ */
diff --git a/include/asm-arm/arch-orion/platform.h b/include/asm-arm/arch-orion/platform.h
new file mode 100644
index 000000000000..143c38e2fa0b
--- /dev/null
+++ b/include/asm-arm/arch-orion/platform.h
@@ -0,0 +1,25 @@
1/*
2 * asm-arm/arch-orion/platform.h
3 *
4 * Tzachi Perelstein <tzachi@marvell.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#ifndef __ASM_ARCH_PLATFORM_H__
12#define __ASM_ARCH_PLATFORM_H__
13
14/*
15 * Device bus NAND private data
16 */
17struct orion_nand_data {
18 struct mtd_partition *parts;
19 u32 nr_parts;
20 u8 ale; /* address line number connected to ALE */
21 u8 cle; /* address line number connected to CLE */
22 u8 width; /* buswidth */
23};
24
25#endif
diff --git a/include/asm-arm/arch-orion/system.h b/include/asm-arm/arch-orion/system.h
new file mode 100644
index 000000000000..17704c68f90e
--- /dev/null
+++ b/include/asm-arm/arch-orion/system.h
@@ -0,0 +1,31 @@
1/*
2 * include/asm-arm/arch-orion/system.h
3 *
4 * Tzachi Perelstein <tzachi@marvell.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#ifndef __ASM_ARCH_SYSTEM_H
12#define __ASM_ARCH_SYSTEM_H
13
14#include <asm/arch/hardware.h>
15#include <asm/arch/orion.h>
16
17static inline void arch_idle(void)
18{
19 cpu_do_idle();
20}
21
22static inline void arch_reset(char mode)
23{
24 /*
25 * Enable and issue soft reset
26 */
27 orion_setbits(CPU_RESET_MASK, (1 << 2));
28 orion_setbits(CPU_SOFT_RESET, 1);
29}
30
31#endif
diff --git a/include/asm-arm/arch-orion/timex.h b/include/asm-arm/arch-orion/timex.h
new file mode 100644
index 000000000000..26c2c91eecf0
--- /dev/null
+++ b/include/asm-arm/arch-orion/timex.h
@@ -0,0 +1,12 @@
1/*
2 * include/asm-arm/arch-orion/timex.h
3 *
4 * Tzachi Perelstein <tzachi@marvell.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#define ORION_TCLK 166666667
12#define CLOCK_TICK_RATE ORION_TCLK
diff --git a/include/asm-arm/arch-orion/uncompress.h b/include/asm-arm/arch-orion/uncompress.h
new file mode 100644
index 000000000000..a1a222fb438c
--- /dev/null
+++ b/include/asm-arm/arch-orion/uncompress.h
@@ -0,0 +1,44 @@
1/*
2 * include/asm-arm/arch-orion/uncompress.h
3 *
4 * Tzachi Perelstein <tzachi@marvell.com>
5 *
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
9 */
10
11#include <asm/arch/orion.h>
12
13#define MV_UART_LSR ((volatile unsigned char *)(UART0_BASE + 0x14))
14#define MV_UART_THR ((volatile unsigned char *)(UART0_BASE + 0x0))
15
16#define LSR_THRE 0x20
17
18static void putc(const char c)
19{
20 int j = 0x1000;
21 while (--j && !(*MV_UART_LSR & LSR_THRE))
22 barrier();
23 *MV_UART_THR = c;
24}
25
26static void flush(void)
27{
28}
29
30static void orion_early_putstr(const char *ptr)
31{
32 char c;
33 while ((c = *ptr++) != '\0') {
34 if (c == '\n')
35 putc('\r');
36 putc(c);
37 }
38}
39
40/*
41 * nothing to do
42 */
43#define arch_decomp_setup()
44#define arch_decomp_wdog()
diff --git a/include/asm-arm/arch-orion/vmalloc.h b/include/asm-arm/arch-orion/vmalloc.h
new file mode 100644
index 000000000000..23e2a102fe0c
--- /dev/null
+++ b/include/asm-arm/arch-orion/vmalloc.h
@@ -0,0 +1,5 @@
1/*
2 * include/asm-arm/arch-orion/vmalloc.h
3 */
4
5#define VMALLOC_END 0xf0000000
diff --git a/include/asm-arm/arch-pxa/audio.h b/include/asm-arm/arch-pxa/audio.h
index 17eccd720136..52bbe3bc25e1 100644
--- a/include/asm-arm/arch-pxa/audio.h
+++ b/include/asm-arm/arch-pxa/audio.h
@@ -1,7 +1,6 @@
1#ifndef __ASM_ARCH_AUDIO_H__ 1#ifndef __ASM_ARCH_AUDIO_H__
2#define __ASM_ARCH_AUDIO_H__ 2#define __ASM_ARCH_AUDIO_H__
3 3
4#include <sound/driver.h>
5#include <sound/core.h> 4#include <sound/core.h>
6#include <sound/pcm.h> 5#include <sound/pcm.h>
7 6
diff --git a/include/asm-arm/arch-pxa/colibri.h b/include/asm-arm/arch-pxa/colibri.h
new file mode 100644
index 000000000000..2ae373fb5675
--- /dev/null
+++ b/include/asm-arm/arch-pxa/colibri.h
@@ -0,0 +1,19 @@
1#ifndef _COLIBRI_H_
2#define _COLIBRI_H_
3
4/* physical memory regions */
5#define COLIBRI_FLASH_PHYS (PXA_CS0_PHYS) /* Flash region */
6#define COLIBRI_ETH_PHYS (PXA_CS2_PHYS) /* Ethernet DM9000 region */
7#define COLIBRI_SDRAM_BASE 0xa0000000 /* SDRAM region */
8
9/* virtual memory regions */
10#define COLIBRI_DISK_VIRT 0xF0000000 /* Disk On Chip region */
11
12/* size of flash */
13#define COLIBRI_FLASH_SIZE 0x02000000 /* Flash size 32 MB */
14
15/* Ethernet Controller Davicom DM9000 */
16#define GPIO_DM9000 114
17#define COLIBRI_ETH_IRQ IRQ_GPIO(GPIO_DM9000)
18
19#endif /* _COLIBRI_H_ */
diff --git a/include/asm-arm/arch-pxa/corgi.h b/include/asm-arm/arch-pxa/corgi.h
index e554caa0d18b..bf856503baf6 100644
--- a/include/asm-arm/arch-pxa/corgi.h
+++ b/include/asm-arm/arch-pxa/corgi.h
@@ -104,7 +104,6 @@
104 */ 104 */
105extern struct platform_device corgiscoop_device; 105extern struct platform_device corgiscoop_device;
106extern struct platform_device corgissp_device; 106extern struct platform_device corgissp_device;
107extern struct platform_device corgifb_device;
108 107
109#endif /* __ASM_ARCH_CORGI_H */ 108#endif /* __ASM_ARCH_CORGI_H */
110 109
diff --git a/include/asm-arm/arch-pxa/hardware.h b/include/asm-arm/arch-pxa/hardware.h
index ab2d963e742a..e25558faa5a4 100644
--- a/include/asm-arm/arch-pxa/hardware.h
+++ b/include/asm-arm/arch-pxa/hardware.h
@@ -121,38 +121,32 @@
121 121
122#define cpu_is_pxa21x() \ 122#define cpu_is_pxa21x() \
123 ({ \ 123 ({ \
124 unsigned int id = read_cpuid(CPUID_ID); \ 124 __cpu_is_pxa21x(read_cpuid_id()); \
125 __cpu_is_pxa21x(id); \
126 }) 125 })
127 126
128#define cpu_is_pxa25x() \ 127#define cpu_is_pxa25x() \
129 ({ \ 128 ({ \
130 unsigned int id = read_cpuid(CPUID_ID); \ 129 __cpu_is_pxa25x(read_cpuid_id()); \
131 __cpu_is_pxa25x(id); \
132 }) 130 })
133 131
134#define cpu_is_pxa27x() \ 132#define cpu_is_pxa27x() \
135 ({ \ 133 ({ \
136 unsigned int id = read_cpuid(CPUID_ID); \ 134 __cpu_is_pxa27x(read_cpuid_id()); \
137 __cpu_is_pxa27x(id); \
138 }) 135 })
139 136
140#define cpu_is_pxa300() \ 137#define cpu_is_pxa300() \
141 ({ \ 138 ({ \
142 unsigned int id = read_cpuid(CPUID_ID); \ 139 __cpu_is_pxa300(read_cpuid_id()); \
143 __cpu_is_pxa300(id); \
144 }) 140 })
145 141
146#define cpu_is_pxa310() \ 142#define cpu_is_pxa310() \
147 ({ \ 143 ({ \
148 unsigned int id = read_cpuid(CPUID_ID); \ 144 __cpu_is_pxa310(read_cpuid_id()); \
149 __cpu_is_pxa310(id); \
150 }) 145 })
151 146
152#define cpu_is_pxa320() \ 147#define cpu_is_pxa320() \
153 ({ \ 148 ({ \
154 unsigned int id = read_cpuid(CPUID_ID); \ 149 __cpu_is_pxa320(read_cpuid_id()); \
155 __cpu_is_pxa320(id); \
156 }) 150 })
157 151
158/* 152/*
@@ -174,14 +168,12 @@
174 168
175#define cpu_is_pxa2xx() \ 169#define cpu_is_pxa2xx() \
176 ({ \ 170 ({ \
177 unsigned int id = read_cpuid(CPUID_ID); \ 171 __cpu_is_pxa2xx(read_cpuid_id()); \
178 __cpu_is_pxa2xx(id); \
179 }) 172 })
180 173
181#define cpu_is_pxa3xx() \ 174#define cpu_is_pxa3xx() \
182 ({ \ 175 ({ \
183 unsigned int id = read_cpuid(CPUID_ID); \ 176 __cpu_is_pxa3xx(read_cpuid_id()); \
184 __cpu_is_pxa3xx(id); \
185 }) 177 })
186 178
187/* 179/*
diff --git a/include/asm-arm/arch-pxa/i2c.h b/include/asm-arm/arch-pxa/i2c.h
index e404b233d8a8..80596b013443 100644
--- a/include/asm-arm/arch-pxa/i2c.h
+++ b/include/asm-arm/arch-pxa/i2c.h
@@ -65,7 +65,13 @@ struct i2c_pxa_platform_data {
65 unsigned int slave_addr; 65 unsigned int slave_addr;
66 struct i2c_slave_client *slave; 66 struct i2c_slave_client *slave;
67 unsigned int class; 67 unsigned int class;
68 int use_pio;
68}; 69};
69 70
70extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info); 71extern void pxa_set_i2c_info(struct i2c_pxa_platform_data *info);
72
73#ifdef CONFIG_PXA27x
74extern void pxa_set_i2c_power_info(struct i2c_pxa_platform_data *info);
75#endif
76
71#endif 77#endif
diff --git a/include/asm-arm/arch-pxa/irqs.h b/include/asm-arm/arch-pxa/irqs.h
index 6238dbf7a236..c562b972a4a6 100644
--- a/include/asm-arm/arch-pxa/irqs.h
+++ b/include/asm-arm/arch-pxa/irqs.h
@@ -13,7 +13,7 @@
13 13
14#define PXA_IRQ(x) (x) 14#define PXA_IRQ(x) (x)
15 15
16#ifdef CONFIG_PXA27x 16#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
17#define IRQ_SSP3 PXA_IRQ(0) /* SSP3 service request */ 17#define IRQ_SSP3 PXA_IRQ(0) /* SSP3 service request */
18#define IRQ_MSL PXA_IRQ(1) /* MSL Interface interrupt */ 18#define IRQ_MSL PXA_IRQ(1) /* MSL Interface interrupt */
19#define IRQ_USBH2 PXA_IRQ(2) /* USB Host interrupt 1 (OHCI) */ 19#define IRQ_USBH2 PXA_IRQ(2) /* USB Host interrupt 1 (OHCI) */
@@ -52,11 +52,27 @@
52#define IRQ_RTC1Hz PXA_IRQ(30) /* RTC HZ Clock Tick */ 52#define IRQ_RTC1Hz PXA_IRQ(30) /* RTC HZ Clock Tick */
53#define IRQ_RTCAlrm PXA_IRQ(31) /* RTC Alarm */ 53#define IRQ_RTCAlrm PXA_IRQ(31) /* RTC Alarm */
54 54
55#ifdef CONFIG_PXA27x 55#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
56#define IRQ_TPM PXA_IRQ(32) /* TPM interrupt */ 56#define IRQ_TPM PXA_IRQ(32) /* TPM interrupt */
57#define IRQ_CAMERA PXA_IRQ(33) /* Camera Interface */ 57#define IRQ_CAMERA PXA_IRQ(33) /* Camera Interface */
58#endif 58#endif
59 59
60#ifdef CONFIG_PXA3xx
61#define IRQ_SSP4 PXA_IRQ(13) /* SSP4 service request */
62#define IRQ_CIR PXA_IRQ(34) /* Consumer IR */
63#define IRQ_TSI PXA_IRQ(36) /* Touch Screen Interface (PXA320) */
64#define IRQ_USIM2 PXA_IRQ(38) /* USIM2 Controller */
65#define IRQ_GRPHICS PXA_IRQ(39) /* Graphics Controller */
66#define IRQ_MMC2 PXA_IRQ(41) /* MMC2 Controller */
67#define IRQ_1WIRE PXA_IRQ(44) /* 1-Wire Controller */
68#define IRQ_NAND PXA_IRQ(45) /* NAND Controller */
69#define IRQ_USB2 PXA_IRQ(46) /* USB 2.0 Device Controller */
70#define IRQ_WAKEUP0 PXA_IRQ(49) /* EXT_WAKEUP0 */
71#define IRQ_WAKEUP1 PXA_IRQ(50) /* EXT_WAKEUP1 */
72#define IRQ_DMEMC PXA_IRQ(51) /* Dynamic Memory Controller */
73#define IRQ_MMC3 PXA_IRQ(55) /* MMC3 Controller (PXA310) */
74#endif
75
60#define PXA_GPIO_IRQ_BASE (64) 76#define PXA_GPIO_IRQ_BASE (64)
61#define PXA_GPIO_IRQ_NUM (128) 77#define PXA_GPIO_IRQ_NUM (128)
62 78
@@ -164,7 +180,8 @@
164#define NR_IRQS (IRQ_LOCOMO_SPI_TEND + 1) 180#define NR_IRQS (IRQ_LOCOMO_SPI_TEND + 1)
165#elif defined(CONFIG_ARCH_LUBBOCK) || \ 181#elif defined(CONFIG_ARCH_LUBBOCK) || \
166 defined(CONFIG_MACH_LOGICPD_PXA270) || \ 182 defined(CONFIG_MACH_LOGICPD_PXA270) || \
167 defined(CONFIG_MACH_MAINSTONE) 183 defined(CONFIG_MACH_MAINSTONE) || \
184 defined(CONFIG_MACH_PCM027)
168#define NR_IRQS (IRQ_BOARD_END) 185#define NR_IRQS (IRQ_BOARD_END)
169#else 186#else
170#define NR_IRQS (IRQ_BOARD_START) 187#define NR_IRQS (IRQ_BOARD_START)
@@ -211,6 +228,13 @@
211#define IRQ_LOCOMO_LT_BASE (IRQ_BOARD_START + 2) 228#define IRQ_LOCOMO_LT_BASE (IRQ_BOARD_START + 2)
212#define IRQ_LOCOMO_SPI_BASE (IRQ_BOARD_START + 3) 229#define IRQ_LOCOMO_SPI_BASE (IRQ_BOARD_START + 3)
213 230
231/* phyCORE-PXA270 (PCM027) Interrupts */
232#define PCM027_IRQ(x) (IRQ_BOARD_START + (x))
233#define PCM027_BTDET_IRQ PCM027_IRQ(0)
234#define PCM027_FF_RI_IRQ PCM027_IRQ(1)
235#define PCM027_MMCDET_IRQ PCM027_IRQ(2)
236#define PCM027_PM_5V_IRQ PCM027_IRQ(3)
237
214/* ITE8152 irqs */ 238/* ITE8152 irqs */
215/* add IT8152 IRQs beyond BOARD_END */ 239/* add IT8152 IRQs beyond BOARD_END */
216#ifdef CONFIG_PCI_HOST_ITE8152 240#ifdef CONFIG_PCI_HOST_ITE8152
diff --git a/include/asm-arm/arch-pxa/littleton.h b/include/asm-arm/arch-pxa/littleton.h
new file mode 100644
index 000000000000..79d209b826f4
--- /dev/null
+++ b/include/asm-arm/arch-pxa/littleton.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_ARCH_ZYLONITE_H
2#define __ASM_ARCH_ZYLONITE_H
3
4#define LITTLETON_ETH_PHYS 0x30000000
5
6#endif /* __ASM_ARCH_ZYLONITE_H */
diff --git a/include/asm-arm/arch-pxa/magician.h b/include/asm-arm/arch-pxa/magician.h
new file mode 100644
index 000000000000..337f51f06b3a
--- /dev/null
+++ b/include/asm-arm/arch-pxa/magician.h
@@ -0,0 +1,111 @@
1/*
2 * GPIO and IRQ definitions for HTC Magician PDA phones
3 *
4 * Copyright (c) 2007 Philipp Zabel
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#ifndef _MAGICIAN_H_
13#define _MAGICIAN_H_
14
15#include <asm/arch/pxa-regs.h>
16
17/*
18 * PXA GPIOs
19 */
20
21#define GPIO0_MAGICIAN_KEY_POWER 0
22#define GPIO9_MAGICIAN_UNKNOWN 9
23#define GPIO10_MAGICIAN_GSM_IRQ 10
24#define GPIO11_MAGICIAN_GSM_OUT1 11
25#define GPIO13_MAGICIAN_CPLD_IRQ 13
26#define GPIO18_MAGICIAN_UNKNOWN 18
27#define GPIO22_MAGICIAN_VIBRA_EN 22
28#define GPIO26_MAGICIAN_GSM_POWER 26
29#define GPIO27_MAGICIAN_USBC_PUEN 27
30#define GPIO30_MAGICIAN_nCHARGE_EN 30
31#define GPIO37_MAGICIAN_KEY_HANGUP 37
32#define GPIO38_MAGICIAN_KEY_CONTACTS 38
33#define GPIO40_MAGICIAN_GSM_OUT2 40
34#define GPIO48_MAGICIAN_UNKNOWN 48
35#define GPIO56_MAGICIAN_UNKNOWN 56
36#define GPIO57_MAGICIAN_CAM_RESET 57
37#define GPIO83_MAGICIAN_nIR_EN 83
38#define GPIO86_MAGICIAN_GSM_RESET 86
39#define GPIO87_MAGICIAN_GSM_SELECT 87
40#define GPIO90_MAGICIAN_KEY_CALENDAR 90
41#define GPIO91_MAGICIAN_KEY_CAMERA 91
42#define GPIO93_MAGICIAN_KEY_UP 93
43#define GPIO94_MAGICIAN_KEY_DOWN 94
44#define GPIO95_MAGICIAN_KEY_LEFT 95
45#define GPIO96_MAGICIAN_KEY_RIGHT 96
46#define GPIO97_MAGICIAN_KEY_ENTER 97
47#define GPIO98_MAGICIAN_KEY_RECORD 98
48#define GPIO99_MAGICIAN_HEADPHONE_IN 99
49#define GPIO100_MAGICIAN_KEY_VOL_UP 100
50#define GPIO101_MAGICIAN_KEY_VOL_DOWN 101
51#define GPIO102_MAGICIAN_KEY_PHONE 102
52#define GPIO103_MAGICIAN_LED_KP 103
53#define GPIO104_MAGICIAN_LCD_POWER_1 104
54#define GPIO105_MAGICIAN_LCD_POWER_2 105
55#define GPIO106_MAGICIAN_LCD_POWER_3 106
56#define GPIO107_MAGICIAN_DS1WM_IRQ 107
57#define GPIO108_MAGICIAN_GSM_READY 108
58#define GPIO114_MAGICIAN_UNKNOWN 114
59#define GPIO115_MAGICIAN_nPEN_IRQ 115
60#define GPIO116_MAGICIAN_nCAM_EN 116
61#define GPIO119_MAGICIAN_UNKNOWN 119
62#define GPIO120_MAGICIAN_UNKNOWN 120
63
64/*
65 * PXA GPIO alternate function mode & direction
66 */
67
68#define GPIO0_MAGICIAN_KEY_POWER_MD (0 | GPIO_IN)
69#define GPIO9_MAGICIAN_UNKNOWN_MD (9 | GPIO_IN)
70#define GPIO10_MAGICIAN_GSM_IRQ_MD (10 | GPIO_IN)
71#define GPIO11_MAGICIAN_GSM_OUT1_MD (11 | GPIO_OUT)
72#define GPIO13_MAGICIAN_CPLD_IRQ_MD (13 | GPIO_IN)
73#define GPIO18_MAGICIAN_UNKNOWN_MD (18 | GPIO_OUT)
74#define GPIO22_MAGICIAN_VIBRA_EN_MD (22 | GPIO_OUT)
75#define GPIO26_MAGICIAN_GSM_POWER_MD (26 | GPIO_OUT)
76#define GPIO27_MAGICIAN_USBC_PUEN_MD (27 | GPIO_OUT)
77#define GPIO30_MAGICIAN_nCHARGE_EN_MD (30 | GPIO_OUT)
78#define GPIO37_MAGICIAN_KEY_HANGUP_MD (37 | GPIO_OUT)
79#define GPIO38_MAGICIAN_KEY_CONTACTS_MD (38 | GPIO_OUT)
80#define GPIO40_MAGICIAN_GSM_OUT2_MD (40 | GPIO_OUT)
81#define GPIO48_MAGICIAN_UNKNOWN_MD (48 | GPIO_OUT)
82#define GPIO56_MAGICIAN_UNKNOWN_MD (56 | GPIO_OUT)
83#define GPIO57_MAGICIAN_CAM_RESET_MD (57 | GPIO_OUT)
84#define GPIO83_MAGICIAN_nIR_EN_MD (83 | GPIO_OUT)
85#define GPIO86_MAGICIAN_GSM_RESET_MD (86 | GPIO_OUT)
86#define GPIO87_MAGICIAN_GSM_SELECT_MD (87 | GPIO_OUT)
87#define GPIO90_MAGICIAN_KEY_CALENDAR_MD (90 | GPIO_OUT)
88#define GPIO91_MAGICIAN_KEY_CAMERA_MD (91 | GPIO_OUT)
89#define GPIO93_MAGICIAN_KEY_UP_MD (93 | GPIO_IN)
90#define GPIO94_MAGICIAN_KEY_DOWN_MD (94 | GPIO_IN)
91#define GPIO95_MAGICIAN_KEY_LEFT_MD (95 | GPIO_IN)
92#define GPIO96_MAGICIAN_KEY_RIGHT_MD (96 | GPIO_IN)
93#define GPIO97_MAGICIAN_KEY_ENTER_MD (97 | GPIO_IN)
94#define GPIO98_MAGICIAN_KEY_RECORD_MD (98 | GPIO_IN)
95#define GPIO99_MAGICIAN_HEADPHONE_IN_MD (99 | GPIO_IN)
96#define GPIO100_MAGICIAN_KEY_VOL_UP_MD (100 | GPIO_IN)
97#define GPIO101_MAGICIAN_KEY_VOL_DOWN_MD (101 | GPIO_IN)
98#define GPIO102_MAGICIAN_KEY_PHONE_MD (102 | GPIO_IN)
99#define GPIO103_MAGICIAN_LED_KP_MD (103 | GPIO_OUT)
100#define GPIO104_MAGICIAN_LCD_POWER_1_MD (104 | GPIO_OUT)
101#define GPIO105_MAGICIAN_LCD_POWER_2_MD (105 | GPIO_OUT)
102#define GPIO106_MAGICIAN_LCD_POWER_3_MD (106 | GPIO_OUT)
103#define GPIO107_MAGICIAN_DS1WM_IRQ_MD (107 | GPIO_IN)
104#define GPIO108_MAGICIAN_GSM_READY_MD (108 | GPIO_IN)
105#define GPIO114_MAGICIAN_UNKNOWN_MD (114 | GPIO_OUT)
106#define GPIO115_MAGICIAN_nPEN_IRQ_MD (115 | GPIO_IN)
107#define GPIO116_MAGICIAN_nCAM_EN_MD (116 | GPIO_OUT)
108#define GPIO119_MAGICIAN_UNKNOWN_MD (119 | GPIO_OUT)
109#define GPIO120_MAGICIAN_UNKNOWN_MD (120 | GPIO_OUT)
110
111#endif /* _MAGICIAN_H_ */
diff --git a/include/asm-arm/arch-pxa/mfp-pxa300.h b/include/asm-arm/arch-pxa/mfp-pxa300.h
index 7513c7a3402d..bb410313556f 100644
--- a/include/asm-arm/arch-pxa/mfp-pxa300.h
+++ b/include/asm-arm/arch-pxa/mfp-pxa300.h
@@ -4,7 +4,7 @@
4 * PXA300/PXA310 specific MFP configuration definitions 4 * PXA300/PXA310 specific MFP configuration definitions
5 * 5 *
6 * Copyright (C) 2007 Marvell International Ltd. 6 * Copyright (C) 2007 Marvell International Ltd.
7 * 2007-08-21: eric miao <eric.y.miao@gmail.com> 7 * 2007-08-21: eric miao <eric.miao@marvell.com>
8 * initial version 8 * initial version
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
@@ -16,6 +16,7 @@
16#define __ASM_ARCH_MFP_PXA300_H 16#define __ASM_ARCH_MFP_PXA300_H
17 17
18#include <asm/arch/mfp.h> 18#include <asm/arch/mfp.h>
19#include <asm/arch/mfp-pxa3xx.h>
19 20
20/* GPIO */ 21/* GPIO */
21#define GPIO46_GPIO MFP_CFG(GPIO46, AF1) 22#define GPIO46_GPIO MFP_CFG(GPIO46, AF1)
@@ -179,7 +180,7 @@
179#define GPIO62_LCD_CS_N MFP_CFG_DRV(GPIO62, AF2, DS01X) 180#define GPIO62_LCD_CS_N MFP_CFG_DRV(GPIO62, AF2, DS01X)
180#define GPIO72_LCD_FCLK MFP_CFG_DRV(GPIO72, AF1, DS01X) 181#define GPIO72_LCD_FCLK MFP_CFG_DRV(GPIO72, AF1, DS01X)
181#define GPIO73_LCD_LCLK MFP_CFG_DRV(GPIO73, AF1, DS01X) 182#define GPIO73_LCD_LCLK MFP_CFG_DRV(GPIO73, AF1, DS01X)
182#define GPIO74_LCD_PCLK MFP_CFG_DRV(GPIO74, AF1, DS01X) 183#define GPIO74_LCD_PCLK MFP_CFG_DRV(GPIO74, AF1, DS02X)
183#define GPIO75_LCD_BIAS MFP_CFG_DRV(GPIO75, AF1, DS01X) 184#define GPIO75_LCD_BIAS MFP_CFG_DRV(GPIO75, AF1, DS01X)
184#define GPIO76_LCD_VSYNC MFP_CFG_DRV(GPIO76, AF2, DS01X) 185#define GPIO76_LCD_VSYNC MFP_CFG_DRV(GPIO76, AF2, DS01X)
185 186
diff --git a/include/asm-arm/arch-pxa/mfp-pxa320.h b/include/asm-arm/arch-pxa/mfp-pxa320.h
index ae8ba34194cf..576aa46d90fc 100644
--- a/include/asm-arm/arch-pxa/mfp-pxa320.h
+++ b/include/asm-arm/arch-pxa/mfp-pxa320.h
@@ -4,7 +4,7 @@
4 * PXA320 specific MFP configuration definitions 4 * PXA320 specific MFP configuration definitions
5 * 5 *
6 * Copyright (C) 2007 Marvell International Ltd. 6 * Copyright (C) 2007 Marvell International Ltd.
7 * 2007-08-21: eric miao <eric.y.miao@gmail.com> 7 * 2007-08-21: eric miao <eric.miao@marvell.com>
8 * initial version 8 * initial version
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
@@ -16,9 +16,10 @@
16#define __ASM_ARCH_MFP_PXA320_H 16#define __ASM_ARCH_MFP_PXA320_H
17 17
18#include <asm/arch/mfp.h> 18#include <asm/arch/mfp.h>
19#include <asm/arch/mfp-pxa3xx.h>
19 20
20/* GPIO */ 21/* GPIO */
21#define GPIO46_GPIO MFP_CFG(GPIO6, AF0) 22#define GPIO46_GPIO MFP_CFG(GPIO46, AF0)
22#define GPIO49_GPIO MFP_CFG(GPIO49, AF0) 23#define GPIO49_GPIO MFP_CFG(GPIO49, AF0)
23#define GPIO50_GPIO MFP_CFG(GPIO50, AF0) 24#define GPIO50_GPIO MFP_CFG(GPIO50, AF0)
24#define GPIO51_GPIO MFP_CFG(GPIO51, AF0) 25#define GPIO51_GPIO MFP_CFG(GPIO51, AF0)
diff --git a/include/asm-arm/arch-pxa/mfp-pxa3xx.h b/include/asm-arm/arch-pxa/mfp-pxa3xx.h
new file mode 100644
index 000000000000..1f6b35c015d0
--- /dev/null
+++ b/include/asm-arm/arch-pxa/mfp-pxa3xx.h
@@ -0,0 +1,252 @@
1#ifndef __ASM_ARCH_MFP_PXA3XX_H
2#define __ASM_ARCH_MFP_PXA3XX_H
3
4#define MFPR_BASE (0x40e10000)
5#define MFPR_SIZE (PAGE_SIZE)
6
7/* MFPR register bit definitions */
8#define MFPR_PULL_SEL (0x1 << 15)
9#define MFPR_PULLUP_EN (0x1 << 14)
10#define MFPR_PULLDOWN_EN (0x1 << 13)
11#define MFPR_SLEEP_SEL (0x1 << 9)
12#define MFPR_SLEEP_OE_N (0x1 << 7)
13#define MFPR_EDGE_CLEAR (0x1 << 6)
14#define MFPR_EDGE_FALL_EN (0x1 << 5)
15#define MFPR_EDGE_RISE_EN (0x1 << 4)
16
17#define MFPR_SLEEP_DATA(x) ((x) << 8)
18#define MFPR_DRIVE(x) (((x) & 0x7) << 10)
19#define MFPR_AF_SEL(x) (((x) & 0x7) << 0)
20
21#define MFPR_EDGE_NONE (0)
22#define MFPR_EDGE_RISE (MFPR_EDGE_RISE_EN)
23#define MFPR_EDGE_FALL (MFPR_EDGE_FALL_EN)
24#define MFPR_EDGE_BOTH (MFPR_EDGE_RISE | MFPR_EDGE_FALL)
25
26/*
27 * Table that determines the low power modes outputs, with actual settings
28 * used in parentheses for don't-care values. Except for the float output,
29 * the configured driven and pulled levels match, so if there is a need for
30 * non-LPM pulled output, the same configuration could probably be used.
31 *
32 * Output value sleep_oe_n sleep_data pullup_en pulldown_en pull_sel
33 * (bit 7) (bit 8) (bit 14) (bit 13) (bit 15)
34 *
35 * Input 0 X(0) X(0) X(0) 0
36 * Drive 0 0 0 0 X(1) 0
37 * Drive 1 0 1 X(1) 0 0
38 * Pull hi (1) 1 X(1) 1 0 0
39 * Pull lo (0) 1 X(0) 0 1 0
40 * Z (float) 1 X(0) 0 0 0
41 */
42#define MFPR_LPM_INPUT (0)
43#define MFPR_LPM_DRIVE_LOW (MFPR_SLEEP_DATA(0) | MFPR_PULLDOWN_EN)
44#define MFPR_LPM_DRIVE_HIGH (MFPR_SLEEP_DATA(1) | MFPR_PULLUP_EN)
45#define MFPR_LPM_PULL_LOW (MFPR_LPM_DRIVE_LOW | MFPR_SLEEP_OE_N)
46#define MFPR_LPM_PULL_HIGH (MFPR_LPM_DRIVE_HIGH | MFPR_SLEEP_OE_N)
47#define MFPR_LPM_FLOAT (MFPR_SLEEP_OE_N)
48#define MFPR_LPM_MASK (0xe080)
49
50/*
51 * The pullup and pulldown state of the MFP pin at run mode is by default
52 * determined by the selected alternate function. In case that some buggy
53 * devices need to override this default behavior, the definitions below
54 * indicates the setting of corresponding MFPR bits
55 *
56 * Definition pull_sel pullup_en pulldown_en
57 * MFPR_PULL_NONE 0 0 0
58 * MFPR_PULL_LOW 1 0 1
59 * MFPR_PULL_HIGH 1 1 0
60 * MFPR_PULL_BOTH 1 1 1
61 */
62#define MFPR_PULL_NONE (0)
63#define MFPR_PULL_LOW (MFPR_PULL_SEL | MFPR_PULLDOWN_EN)
64#define MFPR_PULL_BOTH (MFPR_PULL_LOW | MFPR_PULLUP_EN)
65#define MFPR_PULL_HIGH (MFPR_PULL_SEL | MFPR_PULLUP_EN)
66
67/* PXA3xx common MFP configurations - processor specific ones defined
68 * in mfp-pxa300.h and mfp-pxa320.h
69 */
70#define GPIO0_GPIO MFP_CFG(GPIO0, AF0)
71#define GPIO1_GPIO MFP_CFG(GPIO1, AF0)
72#define GPIO2_GPIO MFP_CFG(GPIO2, AF0)
73#define GPIO3_GPIO MFP_CFG(GPIO3, AF0)
74#define GPIO4_GPIO MFP_CFG(GPIO4, AF0)
75#define GPIO5_GPIO MFP_CFG(GPIO5, AF0)
76#define GPIO6_GPIO MFP_CFG(GPIO6, AF0)
77#define GPIO7_GPIO MFP_CFG(GPIO7, AF0)
78#define GPIO8_GPIO MFP_CFG(GPIO8, AF0)
79#define GPIO9_GPIO MFP_CFG(GPIO9, AF0)
80#define GPIO10_GPIO MFP_CFG(GPIO10, AF0)
81#define GPIO11_GPIO MFP_CFG(GPIO11, AF0)
82#define GPIO12_GPIO MFP_CFG(GPIO12, AF0)
83#define GPIO13_GPIO MFP_CFG(GPIO13, AF0)
84#define GPIO14_GPIO MFP_CFG(GPIO14, AF0)
85#define GPIO15_GPIO MFP_CFG(GPIO15, AF0)
86#define GPIO16_GPIO MFP_CFG(GPIO16, AF0)
87#define GPIO17_GPIO MFP_CFG(GPIO17, AF0)
88#define GPIO18_GPIO MFP_CFG(GPIO18, AF0)
89#define GPIO19_GPIO MFP_CFG(GPIO19, AF0)
90#define GPIO20_GPIO MFP_CFG(GPIO20, AF0)
91#define GPIO21_GPIO MFP_CFG(GPIO21, AF0)
92#define GPIO22_GPIO MFP_CFG(GPIO22, AF0)
93#define GPIO23_GPIO MFP_CFG(GPIO23, AF0)
94#define GPIO24_GPIO MFP_CFG(GPIO24, AF0)
95#define GPIO25_GPIO MFP_CFG(GPIO25, AF0)
96#define GPIO26_GPIO MFP_CFG(GPIO26, AF0)
97#define GPIO27_GPIO MFP_CFG(GPIO27, AF0)
98#define GPIO28_GPIO MFP_CFG(GPIO28, AF0)
99#define GPIO29_GPIO MFP_CFG(GPIO29, AF0)
100#define GPIO30_GPIO MFP_CFG(GPIO30, AF0)
101#define GPIO31_GPIO MFP_CFG(GPIO31, AF0)
102#define GPIO32_GPIO MFP_CFG(GPIO32, AF0)
103#define GPIO33_GPIO MFP_CFG(GPIO33, AF0)
104#define GPIO34_GPIO MFP_CFG(GPIO34, AF0)
105#define GPIO35_GPIO MFP_CFG(GPIO35, AF0)
106#define GPIO36_GPIO MFP_CFG(GPIO36, AF0)
107#define GPIO37_GPIO MFP_CFG(GPIO37, AF0)
108#define GPIO38_GPIO MFP_CFG(GPIO38, AF0)
109#define GPIO39_GPIO MFP_CFG(GPIO39, AF0)
110#define GPIO40_GPIO MFP_CFG(GPIO40, AF0)
111#define GPIO41_GPIO MFP_CFG(GPIO41, AF0)
112#define GPIO42_GPIO MFP_CFG(GPIO42, AF0)
113#define GPIO43_GPIO MFP_CFG(GPIO43, AF0)
114#define GPIO44_GPIO MFP_CFG(GPIO44, AF0)
115#define GPIO45_GPIO MFP_CFG(GPIO45, AF0)
116
117#define GPIO47_GPIO MFP_CFG(GPIO47, AF0)
118#define GPIO48_GPIO MFP_CFG(GPIO48, AF0)
119
120#define GPIO53_GPIO MFP_CFG(GPIO53, AF0)
121#define GPIO54_GPIO MFP_CFG(GPIO54, AF0)
122#define GPIO55_GPIO MFP_CFG(GPIO55, AF0)
123
124#define GPIO57_GPIO MFP_CFG(GPIO57, AF0)
125
126#define GPIO63_GPIO MFP_CFG(GPIO63, AF0)
127#define GPIO64_GPIO MFP_CFG(GPIO64, AF0)
128#define GPIO65_GPIO MFP_CFG(GPIO65, AF0)
129#define GPIO66_GPIO MFP_CFG(GPIO66, AF0)
130#define GPIO67_GPIO MFP_CFG(GPIO67, AF0)
131#define GPIO68_GPIO MFP_CFG(GPIO68, AF0)
132#define GPIO69_GPIO MFP_CFG(GPIO69, AF0)
133#define GPIO70_GPIO MFP_CFG(GPIO70, AF0)
134#define GPIO71_GPIO MFP_CFG(GPIO71, AF0)
135#define GPIO72_GPIO MFP_CFG(GPIO72, AF0)
136#define GPIO73_GPIO MFP_CFG(GPIO73, AF0)
137#define GPIO74_GPIO MFP_CFG(GPIO74, AF0)
138#define GPIO75_GPIO MFP_CFG(GPIO75, AF0)
139#define GPIO76_GPIO MFP_CFG(GPIO76, AF0)
140#define GPIO77_GPIO MFP_CFG(GPIO77, AF0)
141#define GPIO78_GPIO MFP_CFG(GPIO78, AF0)
142#define GPIO79_GPIO MFP_CFG(GPIO79, AF0)
143#define GPIO80_GPIO MFP_CFG(GPIO80, AF0)
144#define GPIO81_GPIO MFP_CFG(GPIO81, AF0)
145#define GPIO82_GPIO MFP_CFG(GPIO82, AF0)
146#define GPIO83_GPIO MFP_CFG(GPIO83, AF0)
147#define GPIO84_GPIO MFP_CFG(GPIO84, AF0)
148#define GPIO85_GPIO MFP_CFG(GPIO85, AF0)
149#define GPIO86_GPIO MFP_CFG(GPIO86, AF0)
150#define GPIO87_GPIO MFP_CFG(GPIO87, AF0)
151#define GPIO88_GPIO MFP_CFG(GPIO88, AF0)
152#define GPIO89_GPIO MFP_CFG(GPIO89, AF0)
153#define GPIO90_GPIO MFP_CFG(GPIO90, AF0)
154#define GPIO91_GPIO MFP_CFG(GPIO91, AF0)
155#define GPIO92_GPIO MFP_CFG(GPIO92, AF0)
156#define GPIO93_GPIO MFP_CFG(GPIO93, AF0)
157#define GPIO94_GPIO MFP_CFG(GPIO94, AF0)
158#define GPIO95_GPIO MFP_CFG(GPIO95, AF0)
159#define GPIO96_GPIO MFP_CFG(GPIO96, AF0)
160#define GPIO97_GPIO MFP_CFG(GPIO97, AF0)
161#define GPIO98_GPIO MFP_CFG(GPIO98, AF0)
162#define GPIO99_GPIO MFP_CFG(GPIO99, AF0)
163#define GPIO100_GPIO MFP_CFG(GPIO100, AF0)
164#define GPIO101_GPIO MFP_CFG(GPIO101, AF0)
165#define GPIO102_GPIO MFP_CFG(GPIO102, AF0)
166#define GPIO103_GPIO MFP_CFG(GPIO103, AF0)
167#define GPIO104_GPIO MFP_CFG(GPIO104, AF0)
168#define GPIO105_GPIO MFP_CFG(GPIO105, AF0)
169#define GPIO106_GPIO MFP_CFG(GPIO106, AF0)
170#define GPIO107_GPIO MFP_CFG(GPIO107, AF0)
171#define GPIO108_GPIO MFP_CFG(GPIO108, AF0)
172#define GPIO109_GPIO MFP_CFG(GPIO109, AF0)
173#define GPIO110_GPIO MFP_CFG(GPIO110, AF0)
174#define GPIO111_GPIO MFP_CFG(GPIO111, AF0)
175#define GPIO112_GPIO MFP_CFG(GPIO112, AF0)
176#define GPIO113_GPIO MFP_CFG(GPIO113, AF0)
177#define GPIO114_GPIO MFP_CFG(GPIO114, AF0)
178#define GPIO115_GPIO MFP_CFG(GPIO115, AF0)
179#define GPIO116_GPIO MFP_CFG(GPIO116, AF0)
180#define GPIO117_GPIO MFP_CFG(GPIO117, AF0)
181#define GPIO118_GPIO MFP_CFG(GPIO118, AF0)
182#define GPIO119_GPIO MFP_CFG(GPIO119, AF0)
183#define GPIO120_GPIO MFP_CFG(GPIO120, AF0)
184#define GPIO121_GPIO MFP_CFG(GPIO121, AF0)
185#define GPIO122_GPIO MFP_CFG(GPIO122, AF0)
186#define GPIO123_GPIO MFP_CFG(GPIO123, AF0)
187#define GPIO124_GPIO MFP_CFG(GPIO124, AF0)
188#define GPIO125_GPIO MFP_CFG(GPIO125, AF0)
189#define GPIO126_GPIO MFP_CFG(GPIO126, AF0)
190#define GPIO127_GPIO MFP_CFG(GPIO127, AF0)
191
192#define GPIO0_2_GPIO MFP_CFG(GPIO0_2, AF0)
193#define GPIO1_2_GPIO MFP_CFG(GPIO1_2, AF0)
194#define GPIO2_2_GPIO MFP_CFG(GPIO2_2, AF0)
195#define GPIO3_2_GPIO MFP_CFG(GPIO3_2, AF0)
196#define GPIO4_2_GPIO MFP_CFG(GPIO4_2, AF0)
197#define GPIO5_2_GPIO MFP_CFG(GPIO5_2, AF0)
198#define GPIO6_2_GPIO MFP_CFG(GPIO6_2, AF0)
199
200/*
201 * each MFP pin will have a MFPR register, since the offset of the
202 * register varies between processors, the processor specific code
203 * should initialize the pin offsets by pxa3xx_mfp_init_addr()
204 *
205 * pxa3xx_mfp_init_addr - accepts a table of "pxa3xx_mfp_addr_map"
206 * structure, which represents a range of MFP pins from "start" to
207 * "end", with the offset begining at "offset", to define a single
208 * pin, let "end" = -1
209 *
210 * use
211 *
212 * MFP_ADDR_X() to define a range of pins
213 * MFP_ADDR() to define a single pin
214 * MFP_ADDR_END to signal the end of pin offset definitions
215 */
216struct pxa3xx_mfp_addr_map {
217 unsigned int start;
218 unsigned int end;
219 unsigned long offset;
220};
221
222#define MFP_ADDR_X(start, end, offset) \
223 { MFP_PIN_##start, MFP_PIN_##end, offset }
224
225#define MFP_ADDR(pin, offset) \
226 { MFP_PIN_##pin, -1, offset }
227
228#define MFP_ADDR_END { MFP_PIN_INVALID, 0 }
229
230/*
231 * pxa3xx_mfp_read()/pxa3xx_mfp_write() - for direct read/write access
232 * to the MFPR register
233 */
234unsigned long pxa3xx_mfp_read(int mfp);
235void pxa3xx_mfp_write(int mfp, unsigned long mfpr_val);
236
237/*
238 * pxa3xx_mfp_config - configure the MFPR registers
239 *
240 * used by board specific initialization code
241 */
242void pxa3xx_mfp_config(unsigned long *mfp_cfgs, int num);
243
244/*
245 * pxa3xx_mfp_init_addr() - initialize the mapping between mfp pin
246 * index and MFPR register offset
247 *
248 * used by processor specific code
249 */
250void __init pxa3xx_mfp_init_addr(struct pxa3xx_mfp_addr_map *);
251void __init pxa3xx_init_mfp(void);
252#endif /* __ASM_ARCH_MFP_PXA3XX_H */
diff --git a/include/asm-arm/arch-pxa/mfp.h b/include/asm-arm/arch-pxa/mfp.h
index 60291742ffdd..02f6157396d3 100644
--- a/include/asm-arm/arch-pxa/mfp.h
+++ b/include/asm-arm/arch-pxa/mfp.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2007 Marvell International Ltd. 6 * Copyright (C) 2007 Marvell International Ltd.
7 * 7 *
8 * 2007-8-21: eric miao <eric.y.miao@gmail.com> 8 * 2007-8-21: eric miao <eric.miao@marvell.com>
9 * initial version 9 * initial version
10 * 10 *
11 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
@@ -16,9 +16,6 @@
16#ifndef __ASM_ARCH_MFP_H 16#ifndef __ASM_ARCH_MFP_H
17#define __ASM_ARCH_MFP_H 17#define __ASM_ARCH_MFP_H
18 18
19#define MFPR_BASE (0x40e10000)
20#define MFPR_SIZE (PAGE_SIZE)
21
22#define mfp_to_gpio(m) ((m) % 128) 19#define mfp_to_gpio(m) ((m) % 128)
23 20
24/* list of all the configurable MFP pins */ 21/* list of all the configurable MFP pins */
@@ -217,114 +214,21 @@ enum {
217}; 214};
218 215
219/* 216/*
220 * Table that determines the low power modes outputs, with actual settings
221 * used in parentheses for don't-care values. Except for the float output,
222 * the configured driven and pulled levels match, so if there is a need for
223 * non-LPM pulled output, the same configuration could probably be used.
224 *
225 * Output value sleep_oe_n sleep_data pullup_en pulldown_en pull_sel
226 * (bit 7) (bit 8) (bit 14d) (bit 13d)
227 *
228 * Drive 0 0 0 0 X (1) 0
229 * Drive 1 0 1 X (1) 0 0
230 * Pull hi (1) 1 X(1) 1 0 0
231 * Pull lo (0) 1 X(0) 0 1 0
232 * Z (float) 1 X(0) 0 0 0
233 */
234#define MFP_LPM_DRIVE_LOW 0x8
235#define MFP_LPM_DRIVE_HIGH 0x6
236#define MFP_LPM_PULL_HIGH 0x7
237#define MFP_LPM_PULL_LOW 0x9
238#define MFP_LPM_FLOAT 0x1
239#define MFP_LPM_PULL_NEITHER 0x0
240
241/*
242 * The pullup and pulldown state of the MFP pin is by default determined by
243 * selected alternate function. In case some buggy devices need to override
244 * this default behavior, pxa3xx_mfp_set_pull() can be invoked with one of
245 * the following definition as the parameter.
246 *
247 * Definition pull_sel pullup_en pulldown_en
248 * MFP_PULL_HIGH 1 1 0
249 * MFP_PULL_LOW 1 0 1
250 * MFP_PULL_BOTH 1 1 1
251 * MFP_PULL_NONE 1 0 0
252 * MFP_PULL_DEFAULT 0 X X
253 *
254 * NOTE: pxa3xx_mfp_set_pull() will modify the PULLUP_EN and PULLDOWN_EN
255 * bits, which will cause potential conflicts with the low power mode
256 * setting, device drivers should take care of this
257 */
258#define MFP_PULL_BOTH (0x7u)
259#define MFP_PULL_HIGH (0x6u)
260#define MFP_PULL_LOW (0x5u)
261#define MFP_PULL_NONE (0x4u)
262#define MFP_PULL_DEFAULT (0x0u)
263
264#define MFP_AF0 (0)
265#define MFP_AF1 (1)
266#define MFP_AF2 (2)
267#define MFP_AF3 (3)
268#define MFP_AF4 (4)
269#define MFP_AF5 (5)
270#define MFP_AF6 (6)
271#define MFP_AF7 (7)
272
273#define MFP_DS01X (0)
274#define MFP_DS02X (1)
275#define MFP_DS03X (2)
276#define MFP_DS04X (3)
277#define MFP_DS06X (4)
278#define MFP_DS08X (5)
279#define MFP_DS10X (6)
280#define MFP_DS12X (7)
281
282#define MFP_EDGE_BOTH 0x3
283#define MFP_EDGE_RISE 0x2
284#define MFP_EDGE_FALL 0x1
285#define MFP_EDGE_NONE 0x0
286
287#define MFPR_AF_MASK 0x0007
288#define MFPR_DRV_MASK 0x1c00
289#define MFPR_RDH_MASK 0x0200
290#define MFPR_LPM_MASK 0xe180
291#define MFPR_PULL_MASK 0xe000
292#define MFPR_EDGE_MASK 0x0070
293
294#define MFPR_ALT_OFFSET 0
295#define MFPR_ERE_OFFSET 4
296#define MFPR_EFE_OFFSET 5
297#define MFPR_EC_OFFSET 6
298#define MFPR_SON_OFFSET 7
299#define MFPR_SD_OFFSET 8
300#define MFPR_SS_OFFSET 9
301#define MFPR_DRV_OFFSET 10
302#define MFPR_PD_OFFSET 13
303#define MFPR_PU_OFFSET 14
304#define MFPR_PS_OFFSET 15
305
306#define MFPR(af, drv, rdh, lpm, edge) \
307 (((af) & 0x7) | (((drv) & 0x7) << 10) |\
308 (((rdh) & 0x1) << 9) |\
309 (((lpm) & 0x3) << 7) |\
310 (((lpm) & 0x4) << 12)|\
311 (((lpm) & 0x8) << 10)|\
312 ((!(edge)) << 6) |\
313 (((edge) & 0x1) << 5) |\
314 (((edge) & 0x2) << 3))
315
316/*
317 * a possible MFP configuration is represented by a 32-bit integer 217 * a possible MFP configuration is represented by a 32-bit integer
318 * bit 0..15 - MFPR value (16-bit) 218 *
319 * bit 16..31 - mfp pin index (used to obtain the MFPR offset) 219 * bit 0.. 9 - MFP Pin Number (1024 Pins Maximum)
220 * bit 10..12 - Alternate Function Selection
221 * bit 13..15 - Drive Strength
222 * bit 16..18 - Low Power Mode State
223 * bit 19..20 - Low Power Mode Edge Detection
224 * bit 21..22 - Run Mode Pull State
320 * 225 *
321 * to facilitate the definition, the following macros are provided 226 * to facilitate the definition, the following macros are provided
322 * 227 *
323 * MFPR_DEFAULT - default MFPR value, with 228 * MFP_CFG_DEFAULT - default MFP configuration value, with
324 * alternate function = 0, 229 * alternate function = 0,
325 * drive strength = fast 1mA (MFP_DS01X) 230 * drive strength = fast 3mA (MFP_DS03X)
326 * low power mode = default 231 * low power mode = default
327 * release dalay hold = false (RDH bit)
328 * edge detection = none 232 * edge detection = none
329 * 233 *
330 * MFP_CFG - default MFPR value with alternate function 234 * MFP_CFG - default MFPR value with alternate function
@@ -334,243 +238,74 @@ enum {
334 * low power mode 238 * low power mode
335 * MFP_CFG_X - default MFPR value with alternate function, 239 * MFP_CFG_X - default MFPR value with alternate function,
336 * pin drive strength and low power mode 240 * pin drive strength and low power mode
337 *
338 * use
339 *
340 * MFP_CFG_PIN - to get the MFP pin index
341 * MFP_CFG_VAL - to get the corresponding MFPR value
342 */ 241 */
343 242
344typedef uint32_t mfp_cfg_t; 243typedef unsigned long mfp_cfg_t;
345 244
346#define MFP_CFG_PIN(mfp_cfg) (((mfp_cfg) >> 16) & 0xffff) 245#define MFP_PIN(x) ((x) & 0x3ff)
347#define MFP_CFG_VAL(mfp_cfg) ((mfp_cfg) & 0xffff) 246
348 247#define MFP_AF0 (0x0 << 10)
349#define MFPR_DEFAULT (0x0000) 248#define MFP_AF1 (0x1 << 10)
249#define MFP_AF2 (0x2 << 10)
250#define MFP_AF3 (0x3 << 10)
251#define MFP_AF4 (0x4 << 10)
252#define MFP_AF5 (0x5 << 10)
253#define MFP_AF6 (0x6 << 10)
254#define MFP_AF7 (0x7 << 10)
255#define MFP_AF_MASK (0x7 << 10)
256#define MFP_AF(x) (((x) >> 10) & 0x7)
257
258#define MFP_DS01X (0x0 << 13)
259#define MFP_DS02X (0x1 << 13)
260#define MFP_DS03X (0x2 << 13)
261#define MFP_DS04X (0x3 << 13)
262#define MFP_DS06X (0x4 << 13)
263#define MFP_DS08X (0x5 << 13)
264#define MFP_DS10X (0x6 << 13)
265#define MFP_DS13X (0x7 << 13)
266#define MFP_DS_MASK (0x7 << 13)
267#define MFP_DS(x) (((x) >> 13) & 0x7)
268
269#define MFP_LPM_INPUT (0x0 << 16)
270#define MFP_LPM_DRIVE_LOW (0x1 << 16)
271#define MFP_LPM_DRIVE_HIGH (0x2 << 16)
272#define MFP_LPM_PULL_LOW (0x3 << 16)
273#define MFP_LPM_PULL_HIGH (0x4 << 16)
274#define MFP_LPM_FLOAT (0x5 << 16)
275#define MFP_LPM_STATE_MASK (0x7 << 16)
276#define MFP_LPM_STATE(x) (((x) >> 16) & 0x7)
277
278#define MFP_LPM_EDGE_NONE (0x0 << 19)
279#define MFP_LPM_EDGE_RISE (0x1 << 19)
280#define MFP_LPM_EDGE_FALL (0x2 << 19)
281#define MFP_LPM_EDGE_BOTH (0x3 << 19)
282#define MFP_LPM_EDGE_MASK (0x3 << 19)
283#define MFP_LPM_EDGE(x) (((x) >> 19) & 0x3)
284
285#define MFP_PULL_NONE (0x0 << 21)
286#define MFP_PULL_LOW (0x1 << 21)
287#define MFP_PULL_HIGH (0x2 << 21)
288#define MFP_PULL_BOTH (0x3 << 21)
289#define MFP_PULL_MASK (0x3 << 21)
290#define MFP_PULL(x) (((x) >> 21) & 0x3)
291
292#define MFP_CFG_DEFAULT (MFP_AF0 | MFP_DS03X | MFP_LPM_INPUT |\
293 MFP_LPM_EDGE_NONE | MFP_PULL_NONE)
350 294
351#define MFP_CFG(pin, af) \ 295#define MFP_CFG(pin, af) \
352 ((MFP_PIN_##pin << 16) | MFPR_DEFAULT | (MFP_##af)) 296 ((MFP_CFG_DEFAULT & ~MFP_AF_MASK) |\
297 (MFP_PIN(MFP_PIN_##pin) | MFP_##af))
353 298
354#define MFP_CFG_DRV(pin, af, drv) \ 299#define MFP_CFG_DRV(pin, af, drv) \
355 ((MFP_PIN_##pin << 16) | MFPR_DEFAULT |\ 300 ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK)) |\
356 ((MFP_##drv) << 10) | (MFP_##af)) 301 (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv))
357 302
358#define MFP_CFG_LPM(pin, af, lpm) \ 303#define MFP_CFG_LPM(pin, af, lpm) \
359 ((MFP_PIN_##pin << 16) | MFPR_DEFAULT | (MFP_##af) |\ 304 ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_LPM_STATE_MASK)) |\
360 (((MFP_LPM_##lpm) & 0x3) << 7) |\ 305 (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_LPM_##lpm))
361 (((MFP_LPM_##lpm) & 0x4) << 12) |\
362 (((MFP_LPM_##lpm) & 0x8) << 10))
363 306
364#define MFP_CFG_X(pin, af, drv, lpm) \ 307#define MFP_CFG_X(pin, af, drv, lpm) \
365 ((MFP_PIN_##pin << 16) | MFPR_DEFAULT |\ 308 ((MFP_CFG_DEFAULT & ~(MFP_AF_MASK | MFP_DS_MASK | MFP_LPM_STATE_MASK)) |\
366 ((MFP_##drv) << 10) | (MFP_##af) |\ 309 (MFP_PIN(MFP_PIN_##pin) | MFP_##af | MFP_##drv | MFP_LPM_##lpm))
367 (((MFP_LPM_##lpm) & 0x3) << 7) |\
368 (((MFP_LPM_##lpm) & 0x4) << 12) |\
369 (((MFP_LPM_##lpm) & 0x8) << 10))
370
371/* common MFP configurations - processor specific ones defined
372 * in mfp-pxa3xx.h
373 */
374#define GPIO0_GPIO MFP_CFG(GPIO0, AF0)
375#define GPIO1_GPIO MFP_CFG(GPIO1, AF0)
376#define GPIO2_GPIO MFP_CFG(GPIO2, AF0)
377#define GPIO3_GPIO MFP_CFG(GPIO3, AF0)
378#define GPIO4_GPIO MFP_CFG(GPIO4, AF0)
379#define GPIO5_GPIO MFP_CFG(GPIO5, AF0)
380#define GPIO6_GPIO MFP_CFG(GPIO6, AF0)
381#define GPIO7_GPIO MFP_CFG(GPIO7, AF0)
382#define GPIO8_GPIO MFP_CFG(GPIO8, AF0)
383#define GPIO9_GPIO MFP_CFG(GPIO9, AF0)
384#define GPIO10_GPIO MFP_CFG(GPIO10, AF0)
385#define GPIO11_GPIO MFP_CFG(GPIO11, AF0)
386#define GPIO12_GPIO MFP_CFG(GPIO12, AF0)
387#define GPIO13_GPIO MFP_CFG(GPIO13, AF0)
388#define GPIO14_GPIO MFP_CFG(GPIO14, AF0)
389#define GPIO15_GPIO MFP_CFG(GPIO15, AF0)
390#define GPIO16_GPIO MFP_CFG(GPIO16, AF0)
391#define GPIO17_GPIO MFP_CFG(GPIO17, AF0)
392#define GPIO18_GPIO MFP_CFG(GPIO18, AF0)
393#define GPIO19_GPIO MFP_CFG(GPIO19, AF0)
394#define GPIO20_GPIO MFP_CFG(GPIO20, AF0)
395#define GPIO21_GPIO MFP_CFG(GPIO21, AF0)
396#define GPIO22_GPIO MFP_CFG(GPIO22, AF0)
397#define GPIO23_GPIO MFP_CFG(GPIO23, AF0)
398#define GPIO24_GPIO MFP_CFG(GPIO24, AF0)
399#define GPIO25_GPIO MFP_CFG(GPIO25, AF0)
400#define GPIO26_GPIO MFP_CFG(GPIO26, AF0)
401#define GPIO27_GPIO MFP_CFG(GPIO27, AF0)
402#define GPIO28_GPIO MFP_CFG(GPIO28, AF0)
403#define GPIO29_GPIO MFP_CFG(GPIO29, AF0)
404#define GPIO30_GPIO MFP_CFG(GPIO30, AF0)
405#define GPIO31_GPIO MFP_CFG(GPIO31, AF0)
406#define GPIO32_GPIO MFP_CFG(GPIO32, AF0)
407#define GPIO33_GPIO MFP_CFG(GPIO33, AF0)
408#define GPIO34_GPIO MFP_CFG(GPIO34, AF0)
409#define GPIO35_GPIO MFP_CFG(GPIO35, AF0)
410#define GPIO36_GPIO MFP_CFG(GPIO36, AF0)
411#define GPIO37_GPIO MFP_CFG(GPIO37, AF0)
412#define GPIO38_GPIO MFP_CFG(GPIO38, AF0)
413#define GPIO39_GPIO MFP_CFG(GPIO39, AF0)
414#define GPIO40_GPIO MFP_CFG(GPIO40, AF0)
415#define GPIO41_GPIO MFP_CFG(GPIO41, AF0)
416#define GPIO42_GPIO MFP_CFG(GPIO42, AF0)
417#define GPIO43_GPIO MFP_CFG(GPIO43, AF0)
418#define GPIO44_GPIO MFP_CFG(GPIO44, AF0)
419#define GPIO45_GPIO MFP_CFG(GPIO45, AF0)
420
421#define GPIO47_GPIO MFP_CFG(GPIO47, AF0)
422#define GPIO48_GPIO MFP_CFG(GPIO48, AF0)
423
424#define GPIO53_GPIO MFP_CFG(GPIO53, AF0)
425#define GPIO54_GPIO MFP_CFG(GPIO54, AF0)
426#define GPIO55_GPIO MFP_CFG(GPIO55, AF0)
427
428#define GPIO57_GPIO MFP_CFG(GPIO57, AF0)
429
430#define GPIO63_GPIO MFP_CFG(GPIO63, AF0)
431#define GPIO64_GPIO MFP_CFG(GPIO64, AF0)
432#define GPIO65_GPIO MFP_CFG(GPIO65, AF0)
433#define GPIO66_GPIO MFP_CFG(GPIO66, AF0)
434#define GPIO67_GPIO MFP_CFG(GPIO67, AF0)
435#define GPIO68_GPIO MFP_CFG(GPIO68, AF0)
436#define GPIO69_GPIO MFP_CFG(GPIO69, AF0)
437#define GPIO70_GPIO MFP_CFG(GPIO70, AF0)
438#define GPIO71_GPIO MFP_CFG(GPIO71, AF0)
439#define GPIO72_GPIO MFP_CFG(GPIO72, AF0)
440#define GPIO73_GPIO MFP_CFG(GPIO73, AF0)
441#define GPIO74_GPIO MFP_CFG(GPIO74, AF0)
442#define GPIO75_GPIO MFP_CFG(GPIO75, AF0)
443#define GPIO76_GPIO MFP_CFG(GPIO76, AF0)
444#define GPIO77_GPIO MFP_CFG(GPIO77, AF0)
445#define GPIO78_GPIO MFP_CFG(GPIO78, AF0)
446#define GPIO79_GPIO MFP_CFG(GPIO79, AF0)
447#define GPIO80_GPIO MFP_CFG(GPIO80, AF0)
448#define GPIO81_GPIO MFP_CFG(GPIO81, AF0)
449#define GPIO82_GPIO MFP_CFG(GPIO82, AF0)
450#define GPIO83_GPIO MFP_CFG(GPIO83, AF0)
451#define GPIO84_GPIO MFP_CFG(GPIO84, AF0)
452#define GPIO85_GPIO MFP_CFG(GPIO85, AF0)
453#define GPIO86_GPIO MFP_CFG(GPIO86, AF0)
454#define GPIO87_GPIO MFP_CFG(GPIO87, AF0)
455#define GPIO88_GPIO MFP_CFG(GPIO88, AF0)
456#define GPIO89_GPIO MFP_CFG(GPIO89, AF0)
457#define GPIO90_GPIO MFP_CFG(GPIO90, AF0)
458#define GPIO91_GPIO MFP_CFG(GPIO91, AF0)
459#define GPIO92_GPIO MFP_CFG(GPIO92, AF0)
460#define GPIO93_GPIO MFP_CFG(GPIO93, AF0)
461#define GPIO94_GPIO MFP_CFG(GPIO94, AF0)
462#define GPIO95_GPIO MFP_CFG(GPIO95, AF0)
463#define GPIO96_GPIO MFP_CFG(GPIO96, AF0)
464#define GPIO97_GPIO MFP_CFG(GPIO97, AF0)
465#define GPIO98_GPIO MFP_CFG(GPIO98, AF0)
466#define GPIO99_GPIO MFP_CFG(GPIO99, AF0)
467#define GPIO100_GPIO MFP_CFG(GPIO100, AF0)
468#define GPIO101_GPIO MFP_CFG(GPIO101, AF0)
469#define GPIO102_GPIO MFP_CFG(GPIO102, AF0)
470#define GPIO103_GPIO MFP_CFG(GPIO103, AF0)
471#define GPIO104_GPIO MFP_CFG(GPIO104, AF0)
472#define GPIO105_GPIO MFP_CFG(GPIO105, AF0)
473#define GPIO106_GPIO MFP_CFG(GPIO106, AF0)
474#define GPIO107_GPIO MFP_CFG(GPIO107, AF0)
475#define GPIO108_GPIO MFP_CFG(GPIO108, AF0)
476#define GPIO109_GPIO MFP_CFG(GPIO109, AF0)
477#define GPIO110_GPIO MFP_CFG(GPIO110, AF0)
478#define GPIO111_GPIO MFP_CFG(GPIO111, AF0)
479#define GPIO112_GPIO MFP_CFG(GPIO112, AF0)
480#define GPIO113_GPIO MFP_CFG(GPIO113, AF0)
481#define GPIO114_GPIO MFP_CFG(GPIO114, AF0)
482#define GPIO115_GPIO MFP_CFG(GPIO115, AF0)
483#define GPIO116_GPIO MFP_CFG(GPIO116, AF0)
484#define GPIO117_GPIO MFP_CFG(GPIO117, AF0)
485#define GPIO118_GPIO MFP_CFG(GPIO118, AF0)
486#define GPIO119_GPIO MFP_CFG(GPIO119, AF0)
487#define GPIO120_GPIO MFP_CFG(GPIO120, AF0)
488#define GPIO121_GPIO MFP_CFG(GPIO121, AF0)
489#define GPIO122_GPIO MFP_CFG(GPIO122, AF0)
490#define GPIO123_GPIO MFP_CFG(GPIO123, AF0)
491#define GPIO124_GPIO MFP_CFG(GPIO124, AF0)
492#define GPIO125_GPIO MFP_CFG(GPIO125, AF0)
493#define GPIO126_GPIO MFP_CFG(GPIO126, AF0)
494#define GPIO127_GPIO MFP_CFG(GPIO127, AF0)
495
496#define GPIO0_2_GPIO MFP_CFG(GPIO0_2, AF0)
497#define GPIO1_2_GPIO MFP_CFG(GPIO1_2, AF0)
498#define GPIO2_2_GPIO MFP_CFG(GPIO2_2, AF0)
499#define GPIO3_2_GPIO MFP_CFG(GPIO3_2, AF0)
500#define GPIO4_2_GPIO MFP_CFG(GPIO4_2, AF0)
501#define GPIO5_2_GPIO MFP_CFG(GPIO5_2, AF0)
502#define GPIO6_2_GPIO MFP_CFG(GPIO6_2, AF0)
503
504/*
505 * each MFP pin will have a MFPR register, since the offset of the
506 * register varies between processors, the processor specific code
507 * should initialize the pin offsets by pxa3xx_mfp_init_addr()
508 *
509 * pxa3xx_mfp_init_addr - accepts a table of "pxa3xx_mfp_addr_map"
510 * structure, which represents a range of MFP pins from "start" to
511 * "end", with the offset begining at "offset", to define a single
512 * pin, let "end" = -1
513 *
514 * use
515 *
516 * MFP_ADDR_X() to define a range of pins
517 * MFP_ADDR() to define a single pin
518 * MFP_ADDR_END to signal the end of pin offset definitions
519 */
520struct pxa3xx_mfp_addr_map {
521 unsigned int start;
522 unsigned int end;
523 unsigned long offset;
524};
525
526#define MFP_ADDR_X(start, end, offset) \
527 { MFP_PIN_##start, MFP_PIN_##end, offset }
528
529#define MFP_ADDR(pin, offset) \
530 { MFP_PIN_##pin, -1, offset }
531
532#define MFP_ADDR_END { MFP_PIN_INVALID, 0 }
533
534struct pxa3xx_mfp_pin {
535 unsigned long mfpr_off; /* MFPRxx register offset */
536 unsigned long mfpr_val; /* MFPRxx register value */
537};
538
539/*
540 * pxa3xx_mfp_read()/pxa3xx_mfp_write() - for direct read/write access
541 * to the MFPR register
542 */
543unsigned long pxa3xx_mfp_read(int mfp);
544void pxa3xx_mfp_write(int mfp, unsigned long mfpr_val);
545
546/*
547 * pxa3xx_mfp_set_afds - set MFP alternate function and drive strength
548 * pxa3xx_mfp_set_rdh - set MFP release delay hold on/off
549 * pxa3xx_mfp_set_lpm - set MFP low power mode state
550 * pxa3xx_mfp_set_edge - set MFP edge detection in low power mode
551 *
552 * use these functions to override/change the default configuration
553 * done by pxa3xx_mfp_set_config(s)
554 */
555void pxa3xx_mfp_set_afds(int mfp, int af, int ds);
556void pxa3xx_mfp_set_rdh(int mfp, int rdh);
557void pxa3xx_mfp_set_lpm(int mfp, int lpm);
558void pxa3xx_mfp_set_edge(int mfp, int edge);
559
560/*
561 * pxa3xx_mfp_config - configure the MFPR registers
562 *
563 * used by board specific initialization code
564 */
565void pxa3xx_mfp_config(mfp_cfg_t *mfp_cfgs, int num);
566
567/*
568 * pxa3xx_mfp_init_addr() - initialize the mapping between mfp pin
569 * index and MFPR register offset
570 *
571 * used by processor specific code
572 */
573void __init pxa3xx_mfp_init_addr(struct pxa3xx_mfp_addr_map *);
574void __init pxa3xx_init_mfp(void);
575 310
576#endif /* __ASM_ARCH_MFP_H */ 311#endif /* __ASM_ARCH_MFP_H */
diff --git a/include/asm-arm/arch-pxa/mmc.h b/include/asm-arm/arch-pxa/mmc.h
index ef4f570381d1..6d1304c9270f 100644
--- a/include/asm-arm/arch-pxa/mmc.h
+++ b/include/asm-arm/arch-pxa/mmc.h
@@ -17,5 +17,7 @@ struct pxamci_platform_data {
17}; 17};
18 18
19extern void pxa_set_mci_info(struct pxamci_platform_data *info); 19extern void pxa_set_mci_info(struct pxamci_platform_data *info);
20extern void pxa3xx_set_mci2_info(struct pxamci_platform_data *info);
21extern void pxa3xx_set_mci3_info(struct pxamci_platform_data *info);
20 22
21#endif 23#endif
diff --git a/include/asm-arm/arch-pxa/pcm027.h b/include/asm-arm/arch-pxa/pcm027.h
new file mode 100644
index 000000000000..7beae1472c3e
--- /dev/null
+++ b/include/asm-arm/arch-pxa/pcm027.h
@@ -0,0 +1,75 @@
1/*
2 * linux/include/asm-arm/arch-pxa/pcm027.h
3 *
4 * (c) 2003 Phytec Messtechnik GmbH <armlinux@phytec.de>
5 * (c) 2007 Juergen Beisert <j.beisert@pengutronix.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22/*
23 * Definitions of CPU card resources only
24 */
25
26/* I2C RTC */
27#define PCM027_RTC_IRQ_GPIO 0
28#define PCM027_RTC_IRQ IRQ_GPIO(PCM027_RTC_IRQ_GPIO)
29#define PCM027_RTC_IRQ_EDGE IRQ_TYPE_EDGE_FALLING
30#define ADR_PCM027_RTC 0x51 /* I2C address */
31
32/* I2C EEPROM */
33#define ADR_PCM027_EEPROM 0x54 /* I2C address */
34
35/* Ethernet chip (SMSC91C111) */
36#define PCM027_ETH_IRQ_GPIO 52
37#define PCM027_ETH_IRQ IRQ_GPIO(PCM027_ETH_IRQ_GPIO)
38#define PCM027_ETH_IRQ_EDGE IRQ_TYPE_EDGE_RISING
39#define PCM027_ETH_PHYS PXA_CS5_PHYS
40#define PCM027_ETH_SIZE (1*1024*1024)
41
42/* CAN controller SJA1000 (unsupported yet) */
43#define PCM027_CAN_IRQ_GPIO 114
44#define PCM027_CAN_IRQ IRQ_GPIO(PCM027_CAN_IRQ_GPIO)
45#define PCM027_CAN_IRQ_EDGE IRQ_TYPE_EDGE_FALLING
46#define PCM027_CAN_PHYS 0x22000000
47#define PCM027_CAN_SIZE 0x100
48
49/* SPI GPIO expander (unsupported yet) */
50#define PCM027_EGPIO_IRQ_GPIO 27
51#define PCM027_EGPIO_IRQ IRQ_GPIO(PCM027_EGPIO_IRQ_GPIO)
52#define PCM027_EGPIO_IRQ_EDGE IRQ_TYPE_EDGE_FALLING
53#define PCM027_EGPIO_CS 24
54/*
55 * TODO: Switch this pin from dedicated usage to GPIO if
56 * more than the MAX7301 device is connected to this SPI bus
57 */
58#define PCM027_EGPIO_CS_MODE GPIO24_SFRM_MD
59
60/* Flash memory */
61#define PCM027_FLASH_PHYS 0x00000000
62#define PCM027_FLASH_SIZE 0x02000000
63
64/* onboard LEDs connected to GPIO */
65#define PCM027_LED_CPU 90
66#define PCM027_LED_HEARD_BEAT 91
67
68/*
69 * This CPU module needs a baseboard to work. After basic initializing
70 * its own devices, it calls baseboard's init function.
71 * TODO: Add your own basebaord init function and call it from
72 * inside pcm027_init(). This example here is for the developmen board.
73 * Refer pcm990-baseboard.c
74 */
75extern void pcm990_baseboard_init(void);
diff --git a/include/asm-arm/arch-pxa/pcm990_baseboard.h b/include/asm-arm/arch-pxa/pcm990_baseboard.h
new file mode 100644
index 000000000000..b699d0d7bdb2
--- /dev/null
+++ b/include/asm-arm/arch-pxa/pcm990_baseboard.h
@@ -0,0 +1,275 @@
1/*
2 * include/asm-arm/arch-pxa/pcm990_baseboard.h
3 *
4 * (c) 2003 Phytec Messtechnik GmbH <armlinux@phytec.de>
5 * (c) 2007 Juergen Beisert <j.beisert@pengutronix.de>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include <asm/arch/pcm027.h>
23
24/*
25 * definitions relevant only when the PCM-990
26 * development base board is in use
27 */
28
29/* CPLD's interrupt controller is connected to PCM-027 GPIO 9 */
30#define PCM990_CTRL_INT_IRQ_GPIO 9
31#define PCM990_CTRL_INT_IRQ IRQ_GPIO(PCM990_CTRL_INT_IRQ_GPIO)
32#define PCM990_CTRL_INT_IRQ_EDGE IRQT_RISING
33#define PCM990_CTRL_PHYS PXA_CS1_PHYS /* 16-Bit */
34#define PCM990_CTRL_BASE 0xea000000
35#define PCM990_CTRL_SIZE (1*1024*1024)
36
37#define PCM990_CTRL_PWR_IRQ_GPIO 14
38#define PCM990_CTRL_PWR_IRQ IRQ_GPIO(PCM990_CTRL_PWR_IRQ_GPIO)
39#define PCM990_CTRL_PWR_IRQ_EDGE IRQT_RISING
40
41/* visible CPLD (U7) registers */
42#define PCM990_CTRL_REG0 0x0000 /* RESET REGISTER */
43#define PCM990_CTRL_SYSRES 0x0001 /* System RESET REGISTER */
44#define PCM990_CTRL_RESOUT 0x0002 /* RESETOUT Enable REGISTER */
45#define PCM990_CTRL_RESGPIO 0x0004 /* RESETGPIO Enable REGISTER */
46
47#define PCM990_CTRL_REG1 0x0002 /* Power REGISTER */
48#define PCM990_CTRL_5VOFF 0x0001 /* Disable 5V Regulators */
49#define PCM990_CTRL_CANPWR 0x0004 /* Enable CANPWR ADUM */
50#define PCM990_CTRL_PM_5V 0x0008 /* Read 5V OK */
51
52#define PCM990_CTRL_REG2 0x0004 /* LED REGISTER */
53#define PCM990_CTRL_LEDPWR 0x0001 /* POWER LED enable */
54#define PCM990_CTRL_LEDBAS 0x0002 /* BASIS LED enable */
55#define PCM990_CTRL_LEDUSR 0x0004 /* USER LED enable */
56
57#define PCM990_CTRL_REG3 0x0006 /* LCD CTRL REGISTER 3 */
58#define PCM990_CTRL_LCDPWR 0x0001 /* RW LCD Power on */
59#define PCM990_CTRL_LCDON 0x0002 /* RW LCD Latch on */
60#define PCM990_CTRL_LCDPOS1 0x0004 /* RW POS 1 */
61#define PCM990_CTRL_LCDPOS2 0x0008 /* RW POS 2 */
62
63#define PCM990_CTRL_REG4 0x0008 /* MMC1 CTRL REGISTER 4 */
64#define PCM990_CTRL_MMC1PWR 0x0001 /* RW MMC1 Power on */
65
66#define PCM990_CTRL_REG5 0x000A /* MMC2 CTRL REGISTER 5 */
67#define PCM990_CTRL_MMC2PWR 0x0001 /* RW MMC2 Power on */
68#define PCM990_CTRL_MMC2LED 0x0002 /* RW MMC2 LED */
69#define PCM990_CTRL_MMC2DE 0x0004 /* R MMC2 Card detect */
70#define PCM990_CTRL_MMC2WP 0x0008 /* R MMC2 Card write protect */
71
72#define PCM990_CTRL_REG6 0x000C /* Interrupt Clear REGISTER */
73#define PCM990_CTRL_INTC0 0x0001 /* Clear Reg BT Detect */
74#define PCM990_CTRL_INTC1 0x0002 /* Clear Reg FR RI */
75#define PCM990_CTRL_INTC2 0x0004 /* Clear Reg MMC1 Detect */
76#define PCM990_CTRL_INTC3 0x0008 /* Clear Reg PM_5V off */
77
78#define PCM990_CTRL_REG7 0x000E /* Interrupt Enable REGISTER */
79#define PCM990_CTRL_ENAINT0 0x0001 /* Enable Int BT Detect */
80#define PCM990_CTRL_ENAINT1 0x0002 /* Enable Int FR RI */
81#define PCM990_CTRL_ENAINT2 0x0004 /* Enable Int MMC1 Detect */
82#define PCM990_CTRL_ENAINT3 0x0008 /* Enable Int PM_5V off */
83
84#define PCM990_CTRL_REG8 0x0014 /* Uart REGISTER */
85#define PCM990_CTRL_FFSD 0x0001 /* BT Uart Enable */
86#define PCM990_CTRL_BTSD 0x0002 /* FF Uart Enable */
87#define PCM990_CTRL_FFRI 0x0004 /* FF Uart RI detect */
88#define PCM990_CTRL_BTRX 0x0008 /* BT Uart Rx detect */
89
90#define PCM990_CTRL_REG9 0x0010 /* AC97 Flash REGISTER */
91#define PCM990_CTRL_FLWP 0x0001 /* pC Flash Write Protect */
92#define PCM990_CTRL_FLDIS 0x0002 /* pC Flash Disable */
93#define PCM990_CTRL_AC97ENA 0x0004 /* Enable AC97 Expansion */
94
95#define PCM990_CTRL_REG10 0x0012 /* GPS-REGISTER */
96#define PCM990_CTRL_GPSPWR 0x0004 /* GPS-Modul Power on */
97#define PCM990_CTRL_GPSENA 0x0008 /* GPS-Modul Enable */
98
99#define PCM990_CTRL_REG11 0x0014 /* Accu REGISTER */
100#define PCM990_CTRL_ACENA 0x0001 /* Charge Enable */
101#define PCM990_CTRL_ACSEL 0x0002 /* Charge Akku -> DC Enable */
102#define PCM990_CTRL_ACPRES 0x0004 /* DC Present */
103#define PCM990_CTRL_ACALARM 0x0008 /* Error Akku */
104
105#define PCM990_CTRL_P2V(x) ((x) - PCM990_CTRL_PHYS + PCM990_CTRL_BASE)
106#define PCM990_CTRL_V2P(x) ((x) - PCM990_CTRL_BASE + PCM990_CTRL_PHYS)
107
108#ifndef __ASSEMBLY__
109# define __PCM990_CTRL_REG(x) \
110 (*((volatile unsigned char *)PCM990_CTRL_P2V(x)))
111#else
112# define __PCM990_CTRL_REG(x) PCM990_CTRL_P2V(x)
113#endif
114
115#define PCM990_INTMSKENA __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG7)
116#define PCM990_INTSETCLR __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG6)
117#define PCM990_CTRL0 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG0)
118#define PCM990_CTRL1 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG1)
119#define PCM990_CTRL2 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG2)
120#define PCM990_CTRL3 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG3)
121#define PCM990_CTRL4 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG4)
122#define PCM990_CTRL5 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG5)
123#define PCM990_CTRL6 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG6)
124#define PCM990_CTRL7 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG7)
125#define PCM990_CTRL8 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG8)
126#define PCM990_CTRL9 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG9)
127#define PCM990_CTRL10 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG10)
128#define PCM990_CTRL11 __PCM990_CTRL_REG(PCM990_CTRL_PHYS + PCM990_CTRL_REG11)
129
130
131/*
132 * IDE
133 */
134#define PCM990_IDE_IRQ_GPIO 13
135#define PCM990_IDE_IRQ IRQ_GPIO(PCM990_IDE_IRQ_GPIO)
136#define PCM990_IDE_IRQ_EDGE IRQT_RISING
137#define PCM990_IDE_PLD_PHYS 0x20000000 /* 16 bit wide */
138#define PCM990_IDE_PLD_BASE 0xee000000
139#define PCM990_IDE_PLD_SIZE (1*1024*1024)
140
141/* visible CPLD (U6) registers */
142#define PCM990_IDE_PLD_REG0 0x1000 /* OFFSET IDE REGISTER 0 */
143#define PCM990_IDE_PM5V 0x0004 /* R System VCC_5V */
144#define PCM990_IDE_STBY 0x0008 /* R System StandBy */
145
146#define PCM990_IDE_PLD_REG1 0x1002 /* OFFSET IDE REGISTER 1 */
147#define PCM990_IDE_IDEMODE 0x0001 /* R TrueIDE Mode */
148#define PCM990_IDE_DMAENA 0x0004 /* RW DMA Enable */
149#define PCM990_IDE_DMA1_0 0x0008 /* RW 1=DREQ1 0=DREQ0 */
150
151#define PCM990_IDE_PLD_REG2 0x1004 /* OFFSET IDE REGISTER 2 */
152#define PCM990_IDE_RESENA 0x0001 /* RW IDE Reset Bit enable */
153#define PCM990_IDE_RES 0x0002 /* RW IDE Reset Bit */
154#define PCM990_IDE_RDY 0x0008 /* RDY */
155
156#define PCM990_IDE_PLD_REG3 0x1006 /* OFFSET IDE REGISTER 3 */
157#define PCM990_IDE_IDEOE 0x0001 /* RW Latch on Databus */
158#define PCM990_IDE_IDEON 0x0002 /* RW Latch on Control Address */
159#define PCM990_IDE_IDEIN 0x0004 /* RW Latch on Interrupt usw. */
160
161#define PCM990_IDE_PLD_REG4 0x1008 /* OFFSET IDE REGISTER 4 */
162#define PCM990_IDE_PWRENA 0x0001 /* RW IDE Power enable */
163#define PCM990_IDE_5V 0x0002 /* R IDE Power 5V */
164#define PCM990_IDE_PWG 0x0008 /* R IDE Power is on */
165
166#define PCM990_IDE_PLD_P2V(x) ((x) - PCM990_IDE_PLD_PHYS + PCM990_IDE_PLD_BASE)
167#define PCM990_IDE_PLD_V2P(x) ((x) - PCM990_IDE_PLD_BASE + PCM990_IDE_PLD_PHYS)
168
169#ifndef __ASSEMBLY__
170# define __PCM990_IDE_PLD_REG(x) \
171 (*((volatile unsigned char *)PCM990_IDE_PLD_P2V(x)))
172#else
173# define __PCM990_IDE_PLD_REG(x) PCM990_IDE_PLD_P2V(x)
174#endif
175
176#define PCM990_IDE0 \
177 __PCM990_IDE_PLD_REG(PCM990_IDE_PLD_PHYS + PCM990_IDE_PLD_REG0)
178#define PCM990_IDE1 \
179 __PCM990_IDE_PLD_REG(PCM990_IDE_PLD_PHYS + PCM990_IDE_PLD_REG1)
180#define PCM990_IDE2 \
181 __PCM990_IDE_PLD_REG(PCM990_IDE_PLD_PHYS + PCM990_IDE_PLD_REG2)
182#define PCM990_IDE3 \
183 __PCM990_IDE_PLD_REG(PCM990_IDE_PLD_PHYS + PCM990_IDE_PLD_REG3)
184#define PCM990_IDE4 \
185 __PCM990_IDE_PLD_REG(PCM990_IDE_PLD_PHYS + PCM990_IDE_PLD_REG4)
186
187/*
188 * Compact Flash
189 */
190#define PCM990_CF_IRQ_GPIO 11
191#define PCM990_CF_IRQ IRQ_GPIO(PCM990_CF_IRQ_GPIO)
192#define PCM990_CF_IRQ_EDGE IRQT_RISING
193
194#define PCM990_CF_CD_GPIO 12
195#define PCM990_CF_CD IRQ_GPIO(PCM990_CF_CD_GPIO)
196#define PCM990_CF_CD_EDGE IRQT_RISING
197
198#define PCM990_CF_PLD_PHYS 0x30000000 /* 16 bit wide */
199#define PCM990_CF_PLD_BASE 0xef000000
200#define PCM990_CF_PLD_SIZE (1*1024*1024)
201#define PCM990_CF_PLD_P2V(x) ((x) - PCM990_CF_PLD_PHYS + PCM990_CF_PLD_BASE)
202#define PCM990_CF_PLD_V2P(x) ((x) - PCM990_CF_PLD_BASE + PCM990_CF_PLD_PHYS)
203
204/* visible CPLD (U6) registers */
205#define PCM990_CF_PLD_REG0 0x1000 /* OFFSET CF REGISTER 0 */
206#define PCM990_CF_REG0_LED 0x0001 /* RW LED on */
207#define PCM990_CF_REG0_BLK 0x0002 /* RW LED flash when access */
208#define PCM990_CF_REG0_PM5V 0x0004 /* R System VCC_5V enable */
209#define PCM990_CF_REG0_STBY 0x0008 /* R System StandBy */
210
211#define PCM990_CF_PLD_REG1 0x1002 /* OFFSET CF REGISTER 1 */
212#define PCM990_CF_REG1_IDEMODE 0x0001 /* RW CF card run as TrueIDE */
213#define PCM990_CF_REG1_CF0 0x0002 /* RW CF card at ADDR 0x28000000 */
214
215#define PCM990_CF_PLD_REG2 0x1004 /* OFFSET CF REGISTER 2 */
216#define PCM990_CF_REG2_RES 0x0002 /* RW CF RESET BIT */
217#define PCM990_CF_REG2_RDYENA 0x0004 /* RW Enable CF_RDY */
218#define PCM990_CF_REG2_RDY 0x0008 /* R CF_RDY auf PWAIT */
219
220#define PCM990_CF_PLD_REG3 0x1006 /* OFFSET CF REGISTER 3 */
221#define PCM990_CF_REG3_CFOE 0x0001 /* RW Latch on Databus */
222#define PCM990_CF_REG3_CFON 0x0002 /* RW Latch on Control Address */
223#define PCM990_CF_REG3_CFIN 0x0004 /* RW Latch on Interrupt usw. */
224#define PCM990_CF_REG3_CFCD 0x0008 /* RW Latch on CD1/2 VS1/2 usw */
225
226#define PCM990_CF_PLD_REG4 0x1008 /* OFFSET CF REGISTER 4 */
227#define PCM990_CF_REG4_PWRENA 0x0001 /* RW CF Power on (CD1/2 = "00") */
228#define PCM990_CF_REG4_5_3V 0x0002 /* RW 1 = 5V CF_VCC 0 = 3 V CF_VCC */
229#define PCM990_CF_REG4_3B 0x0004 /* RW 3.0V Backup from VCC (5_3V=0) */
230#define PCM990_CF_REG4_PWG 0x0008 /* R CF-Power is on */
231
232#define PCM990_CF_PLD_REG5 0x100A /* OFFSET CF REGISTER 5 */
233#define PCM990_CF_REG5_BVD1 0x0001 /* R CF /BVD1 */
234#define PCM990_CF_REG5_BVD2 0x0002 /* R CF /BVD2 */
235#define PCM990_CF_REG5_VS1 0x0004 /* R CF /VS1 */
236#define PCM990_CF_REG5_VS2 0x0008 /* R CF /VS2 */
237
238#define PCM990_CF_PLD_REG6 0x100C /* OFFSET CF REGISTER 6 */
239#define PCM990_CF_REG6_CD1 0x0001 /* R CF Card_Detect1 */
240#define PCM990_CF_REG6_CD2 0x0002 /* R CF Card_Detect2 */
241
242#ifndef __ASSEMBLY__
243# define __PCM990_CF_PLD_REG(x) \
244 (*((volatile unsigned char *)PCM990_CF_PLD_P2V(x)))
245#else
246# define __PCM990_CF_PLD_REG(x) PCM990_CF_PLD_P2V(x)
247#endif
248
249#define PCM990_CF0 __PCM990_CF_PLD_REG(PCM990_CF_PLD_PHYS + PCM990_CF_PLD_REG0)
250#define PCM990_CF1 __PCM990_CF_PLD_REG(PCM990_CF_PLD_PHYS + PCM990_CF_PLD_REG1)
251#define PCM990_CF2 __PCM990_CF_PLD_REG(PCM990_CF_PLD_PHYS + PCM990_CF_PLD_REG2)
252#define PCM990_CF3 __PCM990_CF_PLD_REG(PCM990_CF_PLD_PHYS + PCM990_CF_PLD_REG3)
253#define PCM990_CF4 __PCM990_CF_PLD_REG(PCM990_CF_PLD_PHYS + PCM990_CF_PLD_REG4)
254#define PCM990_CF5 __PCM990_CF_PLD_REG(PCM990_CF_PLD_PHYS + PCM990_CF_PLD_REG5)
255#define PCM990_CF6 __PCM990_CF_PLD_REG(PCM990_CF_PLD_PHYS + PCM990_CF_PLD_REG6)
256
257/*
258 * Wolfson AC97 Touch
259 */
260#define PCM990_AC97_IRQ_GPIO 10
261#define PCM990_AC97_IRQ IRQ_GPIO(PCM990_AC97_IRQ_GPIO)
262#define PCM990_AC97_IRQ_EDGE IRQT_RISING
263
264/*
265 * MMC phyCORE
266 */
267#define PCM990_MMC0_IRQ_GPIO 9
268#define PCM990_MMC0_IRQ IRQ_GPIO(PCM990_MMC0_IRQ_GPIO)
269#define PCM990_MMC0_IRQ_EDGE IRQT_FALLING
270
271/*
272 * USB phyCore
273 */
274#define PCM990_USB_OVERCURRENT (88 | GPIO_ALT_FN_1_IN)
275#define PCM990_USB_PWR_EN (89 | GPIO_ALT_FN_2_OUT)
diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h
index bb68b598c436..442494d71f12 100644
--- a/include/asm-arm/arch-pxa/pxa-regs.h
+++ b/include/asm-arm/arch-pxa/pxa-regs.h
@@ -110,7 +110,10 @@
110#define DALGN __REG(0x400000a0) /* DMA Alignment Register */ 110#define DALGN __REG(0x400000a0) /* DMA Alignment Register */
111#define DINT __REG(0x400000f0) /* DMA Interrupt Register */ 111#define DINT __REG(0x400000f0) /* DMA Interrupt Register */
112 112
113#define DRCMR(n) __REG2(0x40000100, (n)<<2) 113#define DRCMR(n) (*(((n) < 64) ? \
114 &__REG2(0x40000100, ((n) & 0x3f) << 2) : \
115 &__REG2(0x40001100, ((n) & 0x3f) << 2)))
116
114#define DRCMR0 __REG(0x40000100) /* Request to Channel Map Register for DREQ 0 */ 117#define DRCMR0 __REG(0x40000100) /* Request to Channel Map Register for DREQ 0 */
115#define DRCMR1 __REG(0x40000104) /* Request to Channel Map Register for DREQ 1 */ 118#define DRCMR1 __REG(0x40000104) /* Request to Channel Map Register for DREQ 1 */
116#define DRCMR2 __REG(0x40000108) /* Request to Channel Map Register for I2S receive Request */ 119#define DRCMR2 __REG(0x40000108) /* Request to Channel Map Register for I2S receive Request */
@@ -1594,176 +1597,10 @@
1594#define PWER_GPIO15 PWER_GPIO (15) /* GPIO [15] wake-up enable */ 1597#define PWER_GPIO15 PWER_GPIO (15) /* GPIO [15] wake-up enable */
1595#define PWER_RTC 0x80000000 /* RTC alarm wake-up enable */ 1598#define PWER_RTC 0x80000000 /* RTC alarm wake-up enable */
1596 1599
1597
1598/* 1600/*
1599 * SSP Serial Port Registers 1601 * SSP Serial Port Registers - see include/asm-arm/arch-pxa/regs-ssp.h
1600 * PXA250, PXA255, PXA26x and PXA27x SSP controllers are all slightly different.
1601 * PXA255, PXA26x and PXA27x have extra ports, registers and bits.
1602 */ 1602 */
1603 1603
1604 /* Common PXA2xx bits first */
1605#define SSCR0_DSS (0x0000000f) /* Data Size Select (mask) */
1606#define SSCR0_DataSize(x) ((x) - 1) /* Data Size Select [4..16] */
1607#define SSCR0_FRF (0x00000030) /* FRame Format (mask) */
1608#define SSCR0_Motorola (0x0 << 4) /* Motorola's Serial Peripheral Interface (SPI) */
1609#define SSCR0_TI (0x1 << 4) /* Texas Instruments' Synchronous Serial Protocol (SSP) */
1610#define SSCR0_National (0x2 << 4) /* National Microwire */
1611#define SSCR0_ECS (1 << 6) /* External clock select */
1612#define SSCR0_SSE (1 << 7) /* Synchronous Serial Port Enable */
1613#if defined(CONFIG_PXA25x)
1614#define SSCR0_SCR (0x0000ff00) /* Serial Clock Rate (mask) */
1615#define SSCR0_SerClkDiv(x) ((((x) - 2)/2) << 8) /* Divisor [2..512] */
1616#elif defined(CONFIG_PXA27x)
1617#define SSCR0_SCR (0x000fff00) /* Serial Clock Rate (mask) */
1618#define SSCR0_SerClkDiv(x) (((x) - 1) << 8) /* Divisor [1..4096] */
1619#define SSCR0_EDSS (1 << 20) /* Extended data size select */
1620#define SSCR0_NCS (1 << 21) /* Network clock select */
1621#define SSCR0_RIM (1 << 22) /* Receive FIFO overrrun interrupt mask */
1622#define SSCR0_TUM (1 << 23) /* Transmit FIFO underrun interrupt mask */
1623#define SSCR0_FRDC (0x07000000) /* Frame rate divider control (mask) */
1624#define SSCR0_SlotsPerFrm(x) (((x) - 1) << 24) /* Time slots per frame [1..8] */
1625#define SSCR0_ADC (1 << 30) /* Audio clock select */
1626#define SSCR0_MOD (1 << 31) /* Mode (normal or network) */
1627#endif
1628
1629#define SSCR1_RIE (1 << 0) /* Receive FIFO Interrupt Enable */
1630#define SSCR1_TIE (1 << 1) /* Transmit FIFO Interrupt Enable */
1631#define SSCR1_LBM (1 << 2) /* Loop-Back Mode */
1632#define SSCR1_SPO (1 << 3) /* Motorola SPI SSPSCLK polarity setting */
1633#define SSCR1_SPH (1 << 4) /* Motorola SPI SSPSCLK phase setting */
1634#define SSCR1_MWDS (1 << 5) /* Microwire Transmit Data Size */
1635#define SSCR1_TFT (0x000003c0) /* Transmit FIFO Threshold (mask) */
1636#define SSCR1_TxTresh(x) (((x) - 1) << 6) /* level [1..16] */
1637#define SSCR1_RFT (0x00003c00) /* Receive FIFO Threshold (mask) */
1638#define SSCR1_RxTresh(x) (((x) - 1) << 10) /* level [1..16] */
1639
1640#define SSSR_TNF (1 << 2) /* Transmit FIFO Not Full */
1641#define SSSR_RNE (1 << 3) /* Receive FIFO Not Empty */
1642#define SSSR_BSY (1 << 4) /* SSP Busy */
1643#define SSSR_TFS (1 << 5) /* Transmit FIFO Service Request */
1644#define SSSR_RFS (1 << 6) /* Receive FIFO Service Request */
1645#define SSSR_ROR (1 << 7) /* Receive FIFO Overrun */
1646
1647#define SSCR0_TIM (1 << 23) /* Transmit FIFO Under Run Interrupt Mask */
1648#define SSCR0_RIM (1 << 22) /* Receive FIFO Over Run interrupt Mask */
1649#define SSCR0_NCS (1 << 21) /* Network Clock Select */
1650#define SSCR0_EDSS (1 << 20) /* Extended Data Size Select */
1651
1652/* extra bits in PXA255, PXA26x and PXA27x SSP ports */
1653#define SSCR0_TISSP (1 << 4) /* TI Sync Serial Protocol */
1654#define SSCR0_PSP (3 << 4) /* PSP - Programmable Serial Protocol */
1655#define SSCR1_TTELP (1 << 31) /* TXD Tristate Enable Last Phase */
1656#define SSCR1_TTE (1 << 30) /* TXD Tristate Enable */
1657#define SSCR1_EBCEI (1 << 29) /* Enable Bit Count Error interrupt */
1658#define SSCR1_SCFR (1 << 28) /* Slave Clock free Running */
1659#define SSCR1_ECRA (1 << 27) /* Enable Clock Request A */
1660#define SSCR1_ECRB (1 << 26) /* Enable Clock request B */
1661#define SSCR1_SCLKDIR (1 << 25) /* Serial Bit Rate Clock Direction */
1662#define SSCR1_SFRMDIR (1 << 24) /* Frame Direction */
1663#define SSCR1_RWOT (1 << 23) /* Receive Without Transmit */
1664#define SSCR1_TRAIL (1 << 22) /* Trailing Byte */
1665#define SSCR1_TSRE (1 << 21) /* Transmit Service Request Enable */
1666#define SSCR1_RSRE (1 << 20) /* Receive Service Request Enable */
1667#define SSCR1_TINTE (1 << 19) /* Receiver Time-out Interrupt enable */
1668#define SSCR1_PINTE (1 << 18) /* Peripheral Trailing Byte Interupt Enable */
1669#define SSCR1_STRF (1 << 15) /* Select FIFO or EFWR */
1670#define SSCR1_EFWR (1 << 14) /* Enable FIFO Write/Read */
1671
1672#define SSSR_BCE (1 << 23) /* Bit Count Error */
1673#define SSSR_CSS (1 << 22) /* Clock Synchronisation Status */
1674#define SSSR_TUR (1 << 21) /* Transmit FIFO Under Run */
1675#define SSSR_EOC (1 << 20) /* End Of Chain */
1676#define SSSR_TINT (1 << 19) /* Receiver Time-out Interrupt */
1677#define SSSR_PINT (1 << 18) /* Peripheral Trailing Byte Interrupt */
1678
1679#define SSPSP_FSRT (1 << 25) /* Frame Sync Relative Timing */
1680#define SSPSP_DMYSTOP(x) ((x) << 23) /* Dummy Stop */
1681#define SSPSP_SFRMWDTH(x) ((x) << 16) /* Serial Frame Width */
1682#define SSPSP_SFRMDLY(x) ((x) << 9) /* Serial Frame Delay */
1683#define SSPSP_DMYSTRT(x) ((x) << 7) /* Dummy Start */
1684#define SSPSP_STRTDLY(x) ((x) << 4) /* Start Delay */
1685#define SSPSP_ETDS (1 << 3) /* End of Transfer data State */
1686#define SSPSP_SFRMP (1 << 2) /* Serial Frame Polarity */
1687#define SSPSP_SCMODE(x) ((x) << 0) /* Serial Bit Rate Clock Mode */
1688
1689#define SSACD_SCDB (1 << 3) /* SSPSYSCLK Divider Bypass */
1690#define SSACD_ACPS(x) ((x) << 4) /* Audio clock PLL select */
1691#define SSACD_ACDS(x) ((x) << 0) /* Audio clock divider select */
1692
1693#define SSCR0_P1 __REG(0x41000000) /* SSP Port 1 Control Register 0 */
1694#define SSCR1_P1 __REG(0x41000004) /* SSP Port 1 Control Register 1 */
1695#define SSSR_P1 __REG(0x41000008) /* SSP Port 1 Status Register */
1696#define SSITR_P1 __REG(0x4100000C) /* SSP Port 1 Interrupt Test Register */
1697#define SSDR_P1 __REG(0x41000010) /* (Write / Read) SSP Port 1 Data Write Register/SSP Data Read Register */
1698
1699/* Support existing PXA25x drivers */
1700#define SSCR0 SSCR0_P1 /* SSP Control Register 0 */
1701#define SSCR1 SSCR1_P1 /* SSP Control Register 1 */
1702#define SSSR SSSR_P1 /* SSP Status Register */
1703#define SSITR SSITR_P1 /* SSP Interrupt Test Register */
1704#define SSDR SSDR_P1 /* (Write / Read) SSP Data Write Register/SSP Data Read Register */
1705
1706/* PXA27x ports */
1707#if defined (CONFIG_PXA27x)
1708#define SSTO_P1 __REG(0x41000028) /* SSP Port 1 Time Out Register */
1709#define SSPSP_P1 __REG(0x4100002C) /* SSP Port 1 Programmable Serial Protocol */
1710#define SSTSA_P1 __REG(0x41000030) /* SSP Port 1 Tx Timeslot Active */
1711#define SSRSA_P1 __REG(0x41000034) /* SSP Port 1 Rx Timeslot Active */
1712#define SSTSS_P1 __REG(0x41000038) /* SSP Port 1 Timeslot Status */
1713#define SSACD_P1 __REG(0x4100003C) /* SSP Port 1 Audio Clock Divider */
1714#define SSCR0_P2 __REG(0x41700000) /* SSP Port 2 Control Register 0 */
1715#define SSCR1_P2 __REG(0x41700004) /* SSP Port 2 Control Register 1 */
1716#define SSSR_P2 __REG(0x41700008) /* SSP Port 2 Status Register */
1717#define SSITR_P2 __REG(0x4170000C) /* SSP Port 2 Interrupt Test Register */
1718#define SSDR_P2 __REG(0x41700010) /* (Write / Read) SSP Port 2 Data Write Register/SSP Data Read Register */
1719#define SSTO_P2 __REG(0x41700028) /* SSP Port 2 Time Out Register */
1720#define SSPSP_P2 __REG(0x4170002C) /* SSP Port 2 Programmable Serial Protocol */
1721#define SSTSA_P2 __REG(0x41700030) /* SSP Port 2 Tx Timeslot Active */
1722#define SSRSA_P2 __REG(0x41700034) /* SSP Port 2 Rx Timeslot Active */
1723#define SSTSS_P2 __REG(0x41700038) /* SSP Port 2 Timeslot Status */
1724#define SSACD_P2 __REG(0x4170003C) /* SSP Port 2 Audio Clock Divider */
1725#define SSCR0_P3 __REG(0x41900000) /* SSP Port 3 Control Register 0 */
1726#define SSCR1_P3 __REG(0x41900004) /* SSP Port 3 Control Register 1 */
1727#define SSSR_P3 __REG(0x41900008) /* SSP Port 3 Status Register */
1728#define SSITR_P3 __REG(0x4190000C) /* SSP Port 3 Interrupt Test Register */
1729#define SSDR_P3 __REG(0x41900010) /* (Write / Read) SSP Port 3 Data Write Register/SSP Data Read Register */
1730#define SSTO_P3 __REG(0x41900028) /* SSP Port 3 Time Out Register */
1731#define SSPSP_P3 __REG(0x4190002C) /* SSP Port 3 Programmable Serial Protocol */
1732#define SSTSA_P3 __REG(0x41900030) /* SSP Port 3 Tx Timeslot Active */
1733#define SSRSA_P3 __REG(0x41900034) /* SSP Port 3 Rx Timeslot Active */
1734#define SSTSS_P3 __REG(0x41900038) /* SSP Port 3 Timeslot Status */
1735#define SSACD_P3 __REG(0x4190003C) /* SSP Port 3 Audio Clock Divider */
1736#else /* PXA255 (only port 2) and PXA26x ports*/
1737#define SSTO_P1 __REG(0x41000028) /* SSP Port 1 Time Out Register */
1738#define SSPSP_P1 __REG(0x4100002C) /* SSP Port 1 Programmable Serial Protocol */
1739#define SSCR0_P2 __REG(0x41400000) /* SSP Port 2 Control Register 0 */
1740#define SSCR1_P2 __REG(0x41400004) /* SSP Port 2 Control Register 1 */
1741#define SSSR_P2 __REG(0x41400008) /* SSP Port 2 Status Register */
1742#define SSITR_P2 __REG(0x4140000C) /* SSP Port 2 Interrupt Test Register */
1743#define SSDR_P2 __REG(0x41400010) /* (Write / Read) SSP Port 2 Data Write Register/SSP Data Read Register */
1744#define SSTO_P2 __REG(0x41400028) /* SSP Port 2 Time Out Register */
1745#define SSPSP_P2 __REG(0x4140002C) /* SSP Port 2 Programmable Serial Protocol */
1746#define SSCR0_P3 __REG(0x41500000) /* SSP Port 3 Control Register 0 */
1747#define SSCR1_P3 __REG(0x41500004) /* SSP Port 3 Control Register 1 */
1748#define SSSR_P3 __REG(0x41500008) /* SSP Port 3 Status Register */
1749#define SSITR_P3 __REG(0x4150000C) /* SSP Port 3 Interrupt Test Register */
1750#define SSDR_P3 __REG(0x41500010) /* (Write / Read) SSP Port 3 Data Write Register/SSP Data Read Register */
1751#define SSTO_P3 __REG(0x41500028) /* SSP Port 3 Time Out Register */
1752#define SSPSP_P3 __REG(0x4150002C) /* SSP Port 3 Programmable Serial Protocol */
1753#endif
1754
1755#define SSCR0_P(x) (*(((x) == 1) ? &SSCR0_P1 : ((x) == 2) ? &SSCR0_P2 : ((x) == 3) ? &SSCR0_P3 : NULL))
1756#define SSCR1_P(x) (*(((x) == 1) ? &SSCR1_P1 : ((x) == 2) ? &SSCR1_P2 : ((x) == 3) ? &SSCR1_P3 : NULL))
1757#define SSSR_P(x) (*(((x) == 1) ? &SSSR_P1 : ((x) == 2) ? &SSSR_P2 : ((x) == 3) ? &SSSR_P3 : NULL))
1758#define SSITR_P(x) (*(((x) == 1) ? &SSITR_P1 : ((x) == 2) ? &SSITR_P2 : ((x) == 3) ? &SSITR_P3 : NULL))
1759#define SSDR_P(x) (*(((x) == 1) ? &SSDR_P1 : ((x) == 2) ? &SSDR_P2 : ((x) == 3) ? &SSDR_P3 : NULL))
1760#define SSTO_P(x) (*(((x) == 1) ? &SSTO_P1 : ((x) == 2) ? &SSTO_P2 : ((x) == 3) ? &SSTO_P3 : NULL))
1761#define SSPSP_P(x) (*(((x) == 1) ? &SSPSP_P1 : ((x) == 2) ? &SSPSP_P2 : ((x) == 3) ? &SSPSP_P3 : NULL))
1762#define SSTSA_P(x) (*(((x) == 1) ? &SSTSA_P1 : ((x) == 2) ? &SSTSA_P2 : ((x) == 3) ? &SSTSA_P3 : NULL))
1763#define SSRSA_P(x) (*(((x) == 1) ? &SSRSA_P1 : ((x) == 2) ? &SSRSA_P2 : ((x) == 3) ? &SSRSA_P3 : NULL))
1764#define SSTSS_P(x) (*(((x) == 1) ? &SSTSS_P1 : ((x) == 2) ? &SSTSS_P2 : ((x) == 3) ? &SSTSS_P3 : NULL))
1765#define SSACD_P(x) (*(((x) == 1) ? &SSACD_P1 : ((x) == 2) ? &SSACD_P2 : ((x) == 3) ? &SSACD_P3 : NULL))
1766
1767/* 1604/*
1768 * MultiMediaCard (MMC) controller - see drivers/mmc/host/pxamci.h 1605 * MultiMediaCard (MMC) controller - see drivers/mmc/host/pxamci.h
1769 */ 1606 */
@@ -1781,6 +1618,7 @@
1781#define CCCR_M_MASK 0x0060 /* Memory Frequency to Run Mode Frequency Multiplier */ 1618#define CCCR_M_MASK 0x0060 /* Memory Frequency to Run Mode Frequency Multiplier */
1782#define CCCR_L_MASK 0x001f /* Crystal Frequency to Memory Frequency Multiplier */ 1619#define CCCR_L_MASK 0x001f /* Crystal Frequency to Memory Frequency Multiplier */
1783 1620
1621#define CKEN_AC97CONF (31) /* AC97 Controller Configuration */
1784#define CKEN_CAMERA (24) /* Camera Interface Clock Enable */ 1622#define CKEN_CAMERA (24) /* Camera Interface Clock Enable */
1785#define CKEN_SSP1 (23) /* SSP1 Unit Clock Enable */ 1623#define CKEN_SSP1 (23) /* SSP1 Unit Clock Enable */
1786#define CKEN_MEMC (22) /* Memory Controller Clock Enable */ 1624#define CKEN_MEMC (22) /* Memory Controller Clock Enable */
@@ -2010,71 +1848,8 @@
2010 1848
2011#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */ 1849#define LDCMD_PAL (1 << 26) /* instructs DMA to load palette buffer */
2012 1850
2013/*
2014 * Memory controller
2015 */
2016
2017#define MDCNFG __REG(0x48000000) /* SDRAM Configuration Register 0 */
2018#define MDREFR __REG(0x48000004) /* SDRAM Refresh Control Register */
2019#define MSC0 __REG(0x48000008) /* Static Memory Control Register 0 */
2020#define MSC1 __REG(0x4800000C) /* Static Memory Control Register 1 */
2021#define MSC2 __REG(0x48000010) /* Static Memory Control Register 2 */
2022#define MECR __REG(0x48000014) /* Expansion Memory (PCMCIA/Compact Flash) Bus Configuration */
2023#define SXLCR __REG(0x48000018) /* LCR value to be written to SDRAM-Timing Synchronous Flash */
2024#define SXCNFG __REG(0x4800001C) /* Synchronous Static Memory Control Register */
2025#define SXMRS __REG(0x48000024) /* MRS value to be written to Synchronous Flash or SMROM */
2026#define MCMEM0 __REG(0x48000028) /* Card interface Common Memory Space Socket 0 Timing */
2027#define MCMEM1 __REG(0x4800002C) /* Card interface Common Memory Space Socket 1 Timing */
2028#define MCATT0 __REG(0x48000030) /* Card interface Attribute Space Socket 0 Timing Configuration */
2029#define MCATT1 __REG(0x48000034) /* Card interface Attribute Space Socket 1 Timing Configuration */
2030#define MCIO0 __REG(0x48000038) /* Card interface I/O Space Socket 0 Timing Configuration */
2031#define MCIO1 __REG(0x4800003C) /* Card interface I/O Space Socket 1 Timing Configuration */
2032#define MDMRS __REG(0x48000040) /* MRS value to be written to SDRAM */
2033#define BOOT_DEF __REG(0x48000044) /* Read-Only Boot-Time Register. Contains BOOT_SEL and PKG_SEL */
2034
2035/*
2036 * More handy macros for PCMCIA
2037 *
2038 * Arg is socket number
2039 */
2040#define MCMEM(s) __REG2(0x48000028, (s)<<2 ) /* Card interface Common Memory Space Socket s Timing */
2041#define MCATT(s) __REG2(0x48000030, (s)<<2 ) /* Card interface Attribute Space Socket s Timing Configuration */
2042#define MCIO(s) __REG2(0x48000038, (s)<<2 ) /* Card interface I/O Space Socket s Timing Configuration */
2043
2044/* MECR register defines */
2045#define MECR_NOS (1 << 0) /* Number Of Sockets: 0 -> 1 sock, 1 -> 2 sock */
2046#define MECR_CIT (1 << 1) /* Card Is There: 0 -> no card, 1 -> card inserted */
2047
2048#define MDREFR_K0DB4 (1 << 29) /* SDCLK0 Divide by 4 Control/Status */
2049#define MDREFR_K2FREE (1 << 25) /* SDRAM Free-Running Control */
2050#define MDREFR_K1FREE (1 << 24) /* SDRAM Free-Running Control */
2051#define MDREFR_K0FREE (1 << 23) /* SDRAM Free-Running Control */
2052#define MDREFR_SLFRSH (1 << 22) /* SDRAM Self-Refresh Control/Status */
2053#define MDREFR_APD (1 << 20) /* SDRAM/SSRAM Auto-Power-Down Enable */
2054#define MDREFR_K2DB2 (1 << 19) /* SDCLK2 Divide by 2 Control/Status */
2055#define MDREFR_K2RUN (1 << 18) /* SDCLK2 Run Control/Status */
2056#define MDREFR_K1DB2 (1 << 17) /* SDCLK1 Divide by 2 Control/Status */
2057#define MDREFR_K1RUN (1 << 16) /* SDCLK1 Run Control/Status */
2058#define MDREFR_E1PIN (1 << 15) /* SDCKE1 Level Control/Status */
2059#define MDREFR_K0DB2 (1 << 14) /* SDCLK0 Divide by 2 Control/Status */
2060#define MDREFR_K0RUN (1 << 13) /* SDCLK0 Run Control/Status */
2061#define MDREFR_E0PIN (1 << 12) /* SDCKE0 Level Control/Status */
2062
2063
2064#ifdef CONFIG_PXA27x 1851#ifdef CONFIG_PXA27x
2065 1852
2066#define ARB_CNTRL __REG(0x48000048) /* Arbiter Control Register */
2067
2068#define ARB_DMA_SLV_PARK (1<<31) /* Be parked with DMA slave when idle */
2069#define ARB_CI_PARK (1<<30) /* Be parked with Camera Interface when idle */
2070#define ARB_EX_MEM_PARK (1<<29) /* Be parked with external MEMC when idle */
2071#define ARB_INT_MEM_PARK (1<<28) /* Be parked with internal MEMC when idle */
2072#define ARB_USB_PARK (1<<27) /* Be parked with USB when idle */
2073#define ARB_LCD_PARK (1<<26) /* Be parked with LCD when idle */
2074#define ARB_DMA_PARK (1<<25) /* Be parked with DMA when idle */
2075#define ARB_CORE_PARK (1<<24) /* Be parked with core when idle */
2076#define ARB_LOCK_FLAG (1<<23) /* Only Locking masters gain access to the bus */
2077
2078/* 1853/*
2079 * Keypad 1854 * Keypad
2080 */ 1855 */
@@ -2131,74 +1906,6 @@
2131#define KPAS_SO (0x1 << 31) 1906#define KPAS_SO (0x1 << 31)
2132#define KPASMKPx_SO (0x1 << 31) 1907#define KPASMKPx_SO (0x1 << 31)
2133 1908
2134/*
2135 * UHC: USB Host Controller (OHCI-like) register definitions
2136 */
2137#define UHC_BASE_PHYS (0x4C000000)
2138#define UHCREV __REG(0x4C000000) /* UHC HCI Spec Revision */
2139#define UHCHCON __REG(0x4C000004) /* UHC Host Control Register */
2140#define UHCCOMS __REG(0x4C000008) /* UHC Command Status Register */
2141#define UHCINTS __REG(0x4C00000C) /* UHC Interrupt Status Register */
2142#define UHCINTE __REG(0x4C000010) /* UHC Interrupt Enable */
2143#define UHCINTD __REG(0x4C000014) /* UHC Interrupt Disable */
2144#define UHCHCCA __REG(0x4C000018) /* UHC Host Controller Comm. Area */
2145#define UHCPCED __REG(0x4C00001C) /* UHC Period Current Endpt Descr */
2146#define UHCCHED __REG(0x4C000020) /* UHC Control Head Endpt Descr */
2147#define UHCCCED __REG(0x4C000024) /* UHC Control Current Endpt Descr */
2148#define UHCBHED __REG(0x4C000028) /* UHC Bulk Head Endpt Descr */
2149#define UHCBCED __REG(0x4C00002C) /* UHC Bulk Current Endpt Descr */
2150#define UHCDHEAD __REG(0x4C000030) /* UHC Done Head */
2151#define UHCFMI __REG(0x4C000034) /* UHC Frame Interval */
2152#define UHCFMR __REG(0x4C000038) /* UHC Frame Remaining */
2153#define UHCFMN __REG(0x4C00003C) /* UHC Frame Number */
2154#define UHCPERS __REG(0x4C000040) /* UHC Periodic Start */
2155#define UHCLS __REG(0x4C000044) /* UHC Low Speed Threshold */
2156
2157#define UHCRHDA __REG(0x4C000048) /* UHC Root Hub Descriptor A */
2158#define UHCRHDA_NOCP (1 << 12) /* No over current protection */
2159
2160#define UHCRHDB __REG(0x4C00004C) /* UHC Root Hub Descriptor B */
2161#define UHCRHS __REG(0x4C000050) /* UHC Root Hub Status */
2162#define UHCRHPS1 __REG(0x4C000054) /* UHC Root Hub Port 1 Status */
2163#define UHCRHPS2 __REG(0x4C000058) /* UHC Root Hub Port 2 Status */
2164#define UHCRHPS3 __REG(0x4C00005C) /* UHC Root Hub Port 3 Status */
2165
2166#define UHCSTAT __REG(0x4C000060) /* UHC Status Register */
2167#define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
2168#define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
2169#define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
2170#define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
2171#define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
2172#define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
2173#define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
2174#define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
2175#define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
2176
2177#define UHCHR __REG(0x4C000064) /* UHC Reset Register */
2178#define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
2179#define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
2180#define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
2181#define UHCHR_PCPL (1 << 7) /* Power control polarity low */
2182#define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
2183#define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
2184#define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
2185#define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
2186#define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
2187#define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
2188#define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
2189
2190#define UHCHIE __REG(0x4C000068) /* UHC Interrupt Enable Register*/
2191#define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
2192#define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
2193#define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
2194#define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
2195#define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
2196 Interrupt Enable*/
2197#define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
2198#define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
2199
2200#define UHCHIT __REG(0x4C00006C) /* UHC Interrupt Test register */
2201
2202/* Camera Interface */ 1909/* Camera Interface */
2203#define CICR0 __REG(0x50000000) 1910#define CICR0 __REG(0x50000000)
2204#define CICR1 __REG(0x50000004) 1911#define CICR1 __REG(0x50000004)
@@ -2346,6 +2053,77 @@
2346 2053
2347#endif 2054#endif
2348 2055
2056#if defined(CONFIG_PXA27x) || defined(CONFIG_PXA3xx)
2057/*
2058 * UHC: USB Host Controller (OHCI-like) register definitions
2059 */
2060#define UHC_BASE_PHYS (0x4C000000)
2061#define UHCREV __REG(0x4C000000) /* UHC HCI Spec Revision */
2062#define UHCHCON __REG(0x4C000004) /* UHC Host Control Register */
2063#define UHCCOMS __REG(0x4C000008) /* UHC Command Status Register */
2064#define UHCINTS __REG(0x4C00000C) /* UHC Interrupt Status Register */
2065#define UHCINTE __REG(0x4C000010) /* UHC Interrupt Enable */
2066#define UHCINTD __REG(0x4C000014) /* UHC Interrupt Disable */
2067#define UHCHCCA __REG(0x4C000018) /* UHC Host Controller Comm. Area */
2068#define UHCPCED __REG(0x4C00001C) /* UHC Period Current Endpt Descr */
2069#define UHCCHED __REG(0x4C000020) /* UHC Control Head Endpt Descr */
2070#define UHCCCED __REG(0x4C000024) /* UHC Control Current Endpt Descr */
2071#define UHCBHED __REG(0x4C000028) /* UHC Bulk Head Endpt Descr */
2072#define UHCBCED __REG(0x4C00002C) /* UHC Bulk Current Endpt Descr */
2073#define UHCDHEAD __REG(0x4C000030) /* UHC Done Head */
2074#define UHCFMI __REG(0x4C000034) /* UHC Frame Interval */
2075#define UHCFMR __REG(0x4C000038) /* UHC Frame Remaining */
2076#define UHCFMN __REG(0x4C00003C) /* UHC Frame Number */
2077#define UHCPERS __REG(0x4C000040) /* UHC Periodic Start */
2078#define UHCLS __REG(0x4C000044) /* UHC Low Speed Threshold */
2079
2080#define UHCRHDA __REG(0x4C000048) /* UHC Root Hub Descriptor A */
2081#define UHCRHDA_NOCP (1 << 12) /* No over current protection */
2082
2083#define UHCRHDB __REG(0x4C00004C) /* UHC Root Hub Descriptor B */
2084#define UHCRHS __REG(0x4C000050) /* UHC Root Hub Status */
2085#define UHCRHPS1 __REG(0x4C000054) /* UHC Root Hub Port 1 Status */
2086#define UHCRHPS2 __REG(0x4C000058) /* UHC Root Hub Port 2 Status */
2087#define UHCRHPS3 __REG(0x4C00005C) /* UHC Root Hub Port 3 Status */
2088
2089#define UHCSTAT __REG(0x4C000060) /* UHC Status Register */
2090#define UHCSTAT_UPS3 (1 << 16) /* USB Power Sense Port3 */
2091#define UHCSTAT_SBMAI (1 << 15) /* System Bus Master Abort Interrupt*/
2092#define UHCSTAT_SBTAI (1 << 14) /* System Bus Target Abort Interrupt*/
2093#define UHCSTAT_UPRI (1 << 13) /* USB Port Resume Interrupt */
2094#define UHCSTAT_UPS2 (1 << 12) /* USB Power Sense Port 2 */
2095#define UHCSTAT_UPS1 (1 << 11) /* USB Power Sense Port 1 */
2096#define UHCSTAT_HTA (1 << 10) /* HCI Target Abort */
2097#define UHCSTAT_HBA (1 << 8) /* HCI Buffer Active */
2098#define UHCSTAT_RWUE (1 << 7) /* HCI Remote Wake Up Event */
2099
2100#define UHCHR __REG(0x4C000064) /* UHC Reset Register */
2101#define UHCHR_SSEP3 (1 << 11) /* Sleep Standby Enable for Port3 */
2102#define UHCHR_SSEP2 (1 << 10) /* Sleep Standby Enable for Port2 */
2103#define UHCHR_SSEP1 (1 << 9) /* Sleep Standby Enable for Port1 */
2104#define UHCHR_PCPL (1 << 7) /* Power control polarity low */
2105#define UHCHR_PSPL (1 << 6) /* Power sense polarity low */
2106#define UHCHR_SSE (1 << 5) /* Sleep Standby Enable */
2107#define UHCHR_UIT (1 << 4) /* USB Interrupt Test */
2108#define UHCHR_SSDC (1 << 3) /* Simulation Scale Down Clock */
2109#define UHCHR_CGR (1 << 2) /* Clock Generation Reset */
2110#define UHCHR_FHR (1 << 1) /* Force Host Controller Reset */
2111#define UHCHR_FSBIR (1 << 0) /* Force System Bus Iface Reset */
2112
2113#define UHCHIE __REG(0x4C000068) /* UHC Interrupt Enable Register*/
2114#define UHCHIE_UPS3IE (1 << 14) /* Power Sense Port3 IntEn */
2115#define UHCHIE_UPRIE (1 << 13) /* Port Resume IntEn */
2116#define UHCHIE_UPS2IE (1 << 12) /* Power Sense Port2 IntEn */
2117#define UHCHIE_UPS1IE (1 << 11) /* Power Sense Port1 IntEn */
2118#define UHCHIE_TAIE (1 << 10) /* HCI Interface Transfer Abort
2119 Interrupt Enable*/
2120#define UHCHIE_HBAIE (1 << 8) /* HCI Buffer Active IntEn */
2121#define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
2122
2123#define UHCHIT __REG(0x4C00006C) /* UHC Interrupt Test register */
2124
2125#endif /* CONFIG_PXA27x || CONFIG_PXA3xx */
2126
2349/* PWRMODE register M field values */ 2127/* PWRMODE register M field values */
2350 2128
2351#define PWRMODE_IDLE 0x1 2129#define PWRMODE_IDLE 0x1
diff --git a/include/asm-arm/arch-pxa/pxa2xx-regs.h b/include/asm-arm/arch-pxa/pxa2xx-regs.h
new file mode 100644
index 000000000000..9553b54fa5bc
--- /dev/null
+++ b/include/asm-arm/arch-pxa/pxa2xx-regs.h
@@ -0,0 +1,84 @@
1/*
2 * linux/include/asm-arm/arch-pxa/pxa2xx-regs.h
3 *
4 * Taken from pxa-regs.h by Russell King
5 *
6 * Author: Nicolas Pitre
7 * Copyright: MontaVista Software Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#ifndef __PXA2XX_REGS_H
15#define __PXA2XX_REGS_H
16
17/*
18 * Memory controller
19 */
20
21#define MDCNFG __REG(0x48000000) /* SDRAM Configuration Register 0 */
22#define MDREFR __REG(0x48000004) /* SDRAM Refresh Control Register */
23#define MSC0 __REG(0x48000008) /* Static Memory Control Register 0 */
24#define MSC1 __REG(0x4800000C) /* Static Memory Control Register 1 */
25#define MSC2 __REG(0x48000010) /* Static Memory Control Register 2 */
26#define MECR __REG(0x48000014) /* Expansion Memory (PCMCIA/Compact Flash) Bus Configuration */
27#define SXLCR __REG(0x48000018) /* LCR value to be written to SDRAM-Timing Synchronous Flash */
28#define SXCNFG __REG(0x4800001C) /* Synchronous Static Memory Control Register */
29#define SXMRS __REG(0x48000024) /* MRS value to be written to Synchronous Flash or SMROM */
30#define MCMEM0 __REG(0x48000028) /* Card interface Common Memory Space Socket 0 Timing */
31#define MCMEM1 __REG(0x4800002C) /* Card interface Common Memory Space Socket 1 Timing */
32#define MCATT0 __REG(0x48000030) /* Card interface Attribute Space Socket 0 Timing Configuration */
33#define MCATT1 __REG(0x48000034) /* Card interface Attribute Space Socket 1 Timing Configuration */
34#define MCIO0 __REG(0x48000038) /* Card interface I/O Space Socket 0 Timing Configuration */
35#define MCIO1 __REG(0x4800003C) /* Card interface I/O Space Socket 1 Timing Configuration */
36#define MDMRS __REG(0x48000040) /* MRS value to be written to SDRAM */
37#define BOOT_DEF __REG(0x48000044) /* Read-Only Boot-Time Register. Contains BOOT_SEL and PKG_SEL */
38
39/*
40 * More handy macros for PCMCIA
41 *
42 * Arg is socket number
43 */
44#define MCMEM(s) __REG2(0x48000028, (s)<<2 ) /* Card interface Common Memory Space Socket s Timing */
45#define MCATT(s) __REG2(0x48000030, (s)<<2 ) /* Card interface Attribute Space Socket s Timing Configuration */
46#define MCIO(s) __REG2(0x48000038, (s)<<2 ) /* Card interface I/O Space Socket s Timing Configuration */
47
48/* MECR register defines */
49#define MECR_NOS (1 << 0) /* Number Of Sockets: 0 -> 1 sock, 1 -> 2 sock */
50#define MECR_CIT (1 << 1) /* Card Is There: 0 -> no card, 1 -> card inserted */
51
52#define MDREFR_K0DB4 (1 << 29) /* SDCLK0 Divide by 4 Control/Status */
53#define MDREFR_K2FREE (1 << 25) /* SDRAM Free-Running Control */
54#define MDREFR_K1FREE (1 << 24) /* SDRAM Free-Running Control */
55#define MDREFR_K0FREE (1 << 23) /* SDRAM Free-Running Control */
56#define MDREFR_SLFRSH (1 << 22) /* SDRAM Self-Refresh Control/Status */
57#define MDREFR_APD (1 << 20) /* SDRAM/SSRAM Auto-Power-Down Enable */
58#define MDREFR_K2DB2 (1 << 19) /* SDCLK2 Divide by 2 Control/Status */
59#define MDREFR_K2RUN (1 << 18) /* SDCLK2 Run Control/Status */
60#define MDREFR_K1DB2 (1 << 17) /* SDCLK1 Divide by 2 Control/Status */
61#define MDREFR_K1RUN (1 << 16) /* SDCLK1 Run Control/Status */
62#define MDREFR_E1PIN (1 << 15) /* SDCKE1 Level Control/Status */
63#define MDREFR_K0DB2 (1 << 14) /* SDCLK0 Divide by 2 Control/Status */
64#define MDREFR_K0RUN (1 << 13) /* SDCLK0 Run Control/Status */
65#define MDREFR_E0PIN (1 << 12) /* SDCKE0 Level Control/Status */
66
67
68#ifdef CONFIG_PXA27x
69
70#define ARB_CNTRL __REG(0x48000048) /* Arbiter Control Register */
71
72#define ARB_DMA_SLV_PARK (1<<31) /* Be parked with DMA slave when idle */
73#define ARB_CI_PARK (1<<30) /* Be parked with Camera Interface when idle */
74#define ARB_EX_MEM_PARK (1<<29) /* Be parked with external MEMC when idle */
75#define ARB_INT_MEM_PARK (1<<28) /* Be parked with internal MEMC when idle */
76#define ARB_USB_PARK (1<<27) /* Be parked with USB when idle */
77#define ARB_LCD_PARK (1<<26) /* Be parked with LCD when idle */
78#define ARB_DMA_PARK (1<<25) /* Be parked with DMA when idle */
79#define ARB_CORE_PARK (1<<24) /* Be parked with core when idle */
80#define ARB_LOCK_FLAG (1<<23) /* Only Locking masters gain access to the bus */
81
82#endif
83
84#endif
diff --git a/include/asm-arm/arch-pxa/pxa2xx_spi.h b/include/asm-arm/arch-pxa/pxa2xx_spi.h
index acc7ec7a84a1..3459fb26ce97 100644
--- a/include/asm-arm/arch-pxa/pxa2xx_spi.h
+++ b/include/asm-arm/arch-pxa/pxa2xx_spi.h
@@ -22,32 +22,8 @@
22#define PXA2XX_CS_ASSERT (0x01) 22#define PXA2XX_CS_ASSERT (0x01)
23#define PXA2XX_CS_DEASSERT (0x02) 23#define PXA2XX_CS_DEASSERT (0x02)
24 24
25#if defined(CONFIG_PXA25x)
26#define CLOCK_SPEED_HZ 3686400
27#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/2/(x+1))<<8)&0x0000ff00)
28#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
29#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
30#elif defined(CONFIG_PXA27x)
31#define CLOCK_SPEED_HZ 13000000
32#define SSP1_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
33#define SSP2_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
34#define SSP3_SerClkDiv(x) (((CLOCK_SPEED_HZ/(x+1))<<8)&0x000fff00)
35#endif
36
37#define SSP1_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(1)))))
38#define SSP2_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(2)))))
39#define SSP3_VIRT ((void *)(io_p2v(__PREG(SSCR0_P(3)))))
40
41enum pxa_ssp_type {
42 SSP_UNDEFINED = 0,
43 PXA25x_SSP, /* pxa 210, 250, 255, 26x */
44 PXA25x_NSSP, /* pxa 255, 26x (including ASSP) */
45 PXA27x_SSP,
46};
47
48/* device.platform_data for SSP controller devices */ 25/* device.platform_data for SSP controller devices */
49struct pxa2xx_spi_master { 26struct pxa2xx_spi_master {
50 enum pxa_ssp_type ssp_type;
51 u32 clock_enable; 27 u32 clock_enable;
52 u16 num_chipselect; 28 u16 num_chipselect;
53 u8 enable_dma; 29 u8 enable_dma;
diff --git a/include/asm-arm/arch-pxa/pxa3xx-regs.h b/include/asm-arm/arch-pxa/pxa3xx-regs.h
index 3900a0ca0bc0..66d54119757c 100644
--- a/include/asm-arm/arch-pxa/pxa3xx-regs.h
+++ b/include/asm-arm/arch-pxa/pxa3xx-regs.h
@@ -14,6 +14,92 @@
14#define __ASM_ARCH_PXA3XX_REGS_H 14#define __ASM_ARCH_PXA3XX_REGS_H
15 15
16/* 16/*
17 * Slave Power Managment Unit
18 */
19#define ASCR __REG(0x40f40000) /* Application Subsystem Power Status/Configuration */
20#define ARSR __REG(0x40f40004) /* Application Subsystem Reset Status */
21#define AD3ER __REG(0x40f40008) /* Application Subsystem Wake-Up from D3 Enable */
22#define AD3SR __REG(0x40f4000c) /* Application Subsystem Wake-Up from D3 Status */
23#define AD2D0ER __REG(0x40f40010) /* Application Subsystem Wake-Up from D2 to D0 Enable */
24#define AD2D0SR __REG(0x40f40014) /* Application Subsystem Wake-Up from D2 to D0 Status */
25#define AD2D1ER __REG(0x40f40018) /* Application Subsystem Wake-Up from D2 to D1 Enable */
26#define AD2D1SR __REG(0x40f4001c) /* Application Subsystem Wake-Up from D2 to D1 Status */
27#define AD1D0ER __REG(0x40f40020) /* Application Subsystem Wake-Up from D1 to D0 Enable */
28#define AD1D0SR __REG(0x40f40024) /* Application Subsystem Wake-Up from D1 to D0 Status */
29#define AGENP __REG(0x40f4002c) /* Application Subsystem General Purpose */
30#define AD3R __REG(0x40f40030) /* Application Subsystem D3 Configuration */
31#define AD2R __REG(0x40f40034) /* Application Subsystem D2 Configuration */
32#define AD1R __REG(0x40f40038) /* Application Subsystem D1 Configuration */
33
34/*
35 * Application Subsystem Configuration bits.
36 */
37#define ASCR_RDH (1 << 31)
38#define ASCR_D1S (1 << 2)
39#define ASCR_D2S (1 << 1)
40#define ASCR_D3S (1 << 0)
41
42/*
43 * Application Reset Status bits.
44 */
45#define ARSR_GPR (1 << 3)
46#define ARSR_LPMR (1 << 2)
47#define ARSR_WDT (1 << 1)
48#define ARSR_HWR (1 << 0)
49
50/*
51 * Application Subsystem Wake-Up bits.
52 */
53#define ADXER_WRTC (1 << 31) /* RTC */
54#define ADXER_WOST (1 << 30) /* OS Timer */
55#define ADXER_WTSI (1 << 29) /* Touchscreen */
56#define ADXER_WUSBH (1 << 28) /* USB host */
57#define ADXER_WUSB2 (1 << 26) /* USB client 2.0 */
58#define ADXER_WMSL0 (1 << 24) /* MSL port 0*/
59#define ADXER_WDMUX3 (1 << 23) /* USB EDMUX3 */
60#define ADXER_WDMUX2 (1 << 22) /* USB EDMUX2 */
61#define ADXER_WKP (1 << 21) /* Keypad */
62#define ADXER_WUSIM1 (1 << 20) /* USIM Port 1 */
63#define ADXER_WUSIM0 (1 << 19) /* USIM Port 0 */
64#define ADXER_WOTG (1 << 16) /* USBOTG input */
65#define ADXER_MFP_WFLASH (1 << 15) /* MFP: Data flash busy */
66#define ADXER_MFP_GEN12 (1 << 14) /* MFP: MMC3/GPIO/OST inputs */
67#define ADXER_MFP_WMMC2 (1 << 13) /* MFP: MMC2 */
68#define ADXER_MFP_WMMC1 (1 << 12) /* MFP: MMC1 */
69#define ADXER_MFP_WI2C (1 << 11) /* MFP: I2C */
70#define ADXER_MFP_WSSP4 (1 << 10) /* MFP: SSP4 */
71#define ADXER_MFP_WSSP3 (1 << 9) /* MFP: SSP3 */
72#define ADXER_MFP_WMAXTRIX (1 << 8) /* MFP: matrix keypad */
73#define ADXER_MFP_WUART3 (1 << 7) /* MFP: UART3 */
74#define ADXER_MFP_WUART2 (1 << 6) /* MFP: UART2 */
75#define ADXER_MFP_WUART1 (1 << 5) /* MFP: UART1 */
76#define ADXER_MFP_WSSP2 (1 << 4) /* MFP: SSP2 */
77#define ADXER_MFP_WSSP1 (1 << 3) /* MFP: SSP1 */
78#define ADXER_MFP_WAC97 (1 << 2) /* MFP: AC97 */
79#define ADXER_WEXTWAKE1 (1 << 1) /* External Wake 1 */
80#define ADXER_WEXTWAKE0 (1 << 0) /* External Wake 0 */
81
82/*
83 * AD3R/AD2R/AD1R bits. R2-R5 are only defined for PXA320.
84 */
85#define ADXR_L2 (1 << 8)
86#define ADXR_R5 (1 << 5)
87#define ADXR_R4 (1 << 4)
88#define ADXR_R3 (1 << 3)
89#define ADXR_R2 (1 << 2)
90#define ADXR_R1 (1 << 1)
91#define ADXR_R0 (1 << 0)
92
93/*
94 * Values for PWRMODE CP15 register
95 */
96#define PXA3xx_PM_S3D4C4 0x07 /* aka deep sleep */
97#define PXA3xx_PM_S2D3C4 0x06 /* aka sleep */
98#define PXA3xx_PM_S0D2C2 0x03 /* aka standby */
99#define PXA3xx_PM_S0D1C2 0x02 /* aka LCD refresh */
100#define PXA3xx_PM_S0D0C1 0x01
101
102/*
17 * Application Subsystem Clock 103 * Application Subsystem Clock
18 */ 104 */
19#define ACCR __REG(0x41340000) /* Application Subsystem Clock Configuration Register */ 105#define ACCR __REG(0x41340000) /* Application Subsystem Clock Configuration Register */
diff --git a/include/asm-arm/arch-pxa/regs-ssp.h b/include/asm-arm/arch-pxa/regs-ssp.h
new file mode 100644
index 000000000000..991cb688db75
--- /dev/null
+++ b/include/asm-arm/arch-pxa/regs-ssp.h
@@ -0,0 +1,112 @@
1#ifndef __ASM_ARCH_REGS_SSP_H
2#define __ASM_ARCH_REGS_SSP_H
3
4/*
5 * SSP Serial Port Registers
6 * PXA250, PXA255, PXA26x and PXA27x SSP controllers are all slightly different.
7 * PXA255, PXA26x and PXA27x have extra ports, registers and bits.
8 */
9
10#define SSCR0 (0x00) /* SSP Control Register 0 */
11#define SSCR1 (0x04) /* SSP Control Register 1 */
12#define SSSR (0x08) /* SSP Status Register */
13#define SSITR (0x0C) /* SSP Interrupt Test Register */
14#define SSDR (0x10) /* SSP Data Write/Data Read Register */
15
16#define SSTO (0x28) /* SSP Time Out Register */
17#define SSPSP (0x2C) /* SSP Programmable Serial Protocol */
18#define SSTSA (0x30) /* SSP Tx Timeslot Active */
19#define SSRSA (0x34) /* SSP Rx Timeslot Active */
20#define SSTSS (0x38) /* SSP Timeslot Status */
21#define SSACD (0x3C) /* SSP Audio Clock Divider */
22
23/* Common PXA2xx bits first */
24#define SSCR0_DSS (0x0000000f) /* Data Size Select (mask) */
25#define SSCR0_DataSize(x) ((x) - 1) /* Data Size Select [4..16] */
26#define SSCR0_FRF (0x00000030) /* FRame Format (mask) */
27#define SSCR0_Motorola (0x0 << 4) /* Motorola's Serial Peripheral Interface (SPI) */
28#define SSCR0_TI (0x1 << 4) /* Texas Instruments' Synchronous Serial Protocol (SSP) */
29#define SSCR0_National (0x2 << 4) /* National Microwire */
30#define SSCR0_ECS (1 << 6) /* External clock select */
31#define SSCR0_SSE (1 << 7) /* Synchronous Serial Port Enable */
32#if defined(CONFIG_PXA25x)
33#define SSCR0_SCR (0x0000ff00) /* Serial Clock Rate (mask) */
34#define SSCR0_SerClkDiv(x) ((((x) - 2)/2) << 8) /* Divisor [2..512] */
35#elif defined(CONFIG_PXA27x)
36#define SSCR0_SCR (0x000fff00) /* Serial Clock Rate (mask) */
37#define SSCR0_SerClkDiv(x) (((x) - 1) << 8) /* Divisor [1..4096] */
38#define SSCR0_EDSS (1 << 20) /* Extended data size select */
39#define SSCR0_NCS (1 << 21) /* Network clock select */
40#define SSCR0_RIM (1 << 22) /* Receive FIFO overrrun interrupt mask */
41#define SSCR0_TUM (1 << 23) /* Transmit FIFO underrun interrupt mask */
42#define SSCR0_FRDC (0x07000000) /* Frame rate divider control (mask) */
43#define SSCR0_SlotsPerFrm(x) (((x) - 1) << 24) /* Time slots per frame [1..8] */
44#define SSCR0_ADC (1 << 30) /* Audio clock select */
45#define SSCR0_MOD (1 << 31) /* Mode (normal or network) */
46#endif
47
48#define SSCR1_RIE (1 << 0) /* Receive FIFO Interrupt Enable */
49#define SSCR1_TIE (1 << 1) /* Transmit FIFO Interrupt Enable */
50#define SSCR1_LBM (1 << 2) /* Loop-Back Mode */
51#define SSCR1_SPO (1 << 3) /* Motorola SPI SSPSCLK polarity setting */
52#define SSCR1_SPH (1 << 4) /* Motorola SPI SSPSCLK phase setting */
53#define SSCR1_MWDS (1 << 5) /* Microwire Transmit Data Size */
54#define SSCR1_TFT (0x000003c0) /* Transmit FIFO Threshold (mask) */
55#define SSCR1_TxTresh(x) (((x) - 1) << 6) /* level [1..16] */
56#define SSCR1_RFT (0x00003c00) /* Receive FIFO Threshold (mask) */
57#define SSCR1_RxTresh(x) (((x) - 1) << 10) /* level [1..16] */
58
59#define SSSR_TNF (1 << 2) /* Transmit FIFO Not Full */
60#define SSSR_RNE (1 << 3) /* Receive FIFO Not Empty */
61#define SSSR_BSY (1 << 4) /* SSP Busy */
62#define SSSR_TFS (1 << 5) /* Transmit FIFO Service Request */
63#define SSSR_RFS (1 << 6) /* Receive FIFO Service Request */
64#define SSSR_ROR (1 << 7) /* Receive FIFO Overrun */
65
66#define SSCR0_TIM (1 << 23) /* Transmit FIFO Under Run Interrupt Mask */
67#define SSCR0_RIM (1 << 22) /* Receive FIFO Over Run interrupt Mask */
68#define SSCR0_NCS (1 << 21) /* Network Clock Select */
69#define SSCR0_EDSS (1 << 20) /* Extended Data Size Select */
70
71/* extra bits in PXA255, PXA26x and PXA27x SSP ports */
72#define SSCR0_TISSP (1 << 4) /* TI Sync Serial Protocol */
73#define SSCR0_PSP (3 << 4) /* PSP - Programmable Serial Protocol */
74#define SSCR1_TTELP (1 << 31) /* TXD Tristate Enable Last Phase */
75#define SSCR1_TTE (1 << 30) /* TXD Tristate Enable */
76#define SSCR1_EBCEI (1 << 29) /* Enable Bit Count Error interrupt */
77#define SSCR1_SCFR (1 << 28) /* Slave Clock free Running */
78#define SSCR1_ECRA (1 << 27) /* Enable Clock Request A */
79#define SSCR1_ECRB (1 << 26) /* Enable Clock request B */
80#define SSCR1_SCLKDIR (1 << 25) /* Serial Bit Rate Clock Direction */
81#define SSCR1_SFRMDIR (1 << 24) /* Frame Direction */
82#define SSCR1_RWOT (1 << 23) /* Receive Without Transmit */
83#define SSCR1_TRAIL (1 << 22) /* Trailing Byte */
84#define SSCR1_TSRE (1 << 21) /* Transmit Service Request Enable */
85#define SSCR1_RSRE (1 << 20) /* Receive Service Request Enable */
86#define SSCR1_TINTE (1 << 19) /* Receiver Time-out Interrupt enable */
87#define SSCR1_PINTE (1 << 18) /* Peripheral Trailing Byte Interupt Enable */
88#define SSCR1_STRF (1 << 15) /* Select FIFO or EFWR */
89#define SSCR1_EFWR (1 << 14) /* Enable FIFO Write/Read */
90
91#define SSSR_BCE (1 << 23) /* Bit Count Error */
92#define SSSR_CSS (1 << 22) /* Clock Synchronisation Status */
93#define SSSR_TUR (1 << 21) /* Transmit FIFO Under Run */
94#define SSSR_EOC (1 << 20) /* End Of Chain */
95#define SSSR_TINT (1 << 19) /* Receiver Time-out Interrupt */
96#define SSSR_PINT (1 << 18) /* Peripheral Trailing Byte Interrupt */
97
98#define SSPSP_FSRT (1 << 25) /* Frame Sync Relative Timing */
99#define SSPSP_DMYSTOP(x) ((x) << 23) /* Dummy Stop */
100#define SSPSP_SFRMWDTH(x) ((x) << 16) /* Serial Frame Width */
101#define SSPSP_SFRMDLY(x) ((x) << 9) /* Serial Frame Delay */
102#define SSPSP_DMYSTRT(x) ((x) << 7) /* Dummy Start */
103#define SSPSP_STRTDLY(x) ((x) << 4) /* Start Delay */
104#define SSPSP_ETDS (1 << 3) /* End of Transfer data State */
105#define SSPSP_SFRMP (1 << 2) /* Serial Frame Polarity */
106#define SSPSP_SCMODE(x) ((x) << 0) /* Serial Bit Rate Clock Mode */
107
108#define SSACD_SCDB (1 << 3) /* SSPSYSCLK Divider Bypass */
109#define SSACD_ACPS(x) ((x) << 4) /* Audio clock PLL select */
110#define SSACD_ACDS(x) ((x) << 0) /* Audio clock divider select */
111
112#endif /* __ASM_ARCH_REGS_SSP_H */
diff --git a/include/asm-arm/arch-pxa/sharpsl.h b/include/asm-arm/arch-pxa/sharpsl.h
index 2b0fe773213a..3b1d4a72d4d1 100644
--- a/include/asm-arm/arch-pxa/sharpsl.h
+++ b/include/asm-arm/arch-pxa/sharpsl.h
@@ -16,7 +16,7 @@ int corgi_ssp_max1111_get(unsigned long data);
16 */ 16 */
17 17
18struct corgits_machinfo { 18struct corgits_machinfo {
19 unsigned long (*get_hsync_len)(void); 19 unsigned long (*get_hsync_invperiod)(void);
20 void (*put_hsync)(void); 20 void (*put_hsync)(void);
21 void (*wait_hsync)(void); 21 void (*wait_hsync)(void);
22}; 22};
diff --git a/include/asm-arm/arch-pxa/spitz.h b/include/asm-arm/arch-pxa/spitz.h
index 4953dd324d4d..bd14365f7ed5 100644
--- a/include/asm-arm/arch-pxa/spitz.h
+++ b/include/asm-arm/arch-pxa/spitz.h
@@ -156,5 +156,3 @@ extern struct platform_device spitzscoop_device;
156extern struct platform_device spitzscoop2_device; 156extern struct platform_device spitzscoop2_device;
157extern struct platform_device spitzssp_device; 157extern struct platform_device spitzssp_device;
158extern struct sharpsl_charger_machinfo spitz_pm_machinfo; 158extern struct sharpsl_charger_machinfo spitz_pm_machinfo;
159
160extern void spitz_lcd_power(int on, struct fb_var_screeninfo *var);
diff --git a/include/asm-arm/arch-pxa/ssp.h b/include/asm-arm/arch-pxa/ssp.h
index ea200551a75f..a012882c9ee6 100644
--- a/include/asm-arm/arch-pxa/ssp.h
+++ b/include/asm-arm/arch-pxa/ssp.h
@@ -13,10 +13,37 @@
13 * PXA255 SSP, NSSP 13 * PXA255 SSP, NSSP
14 * PXA26x SSP, NSSP, ASSP 14 * PXA26x SSP, NSSP, ASSP
15 * PXA27x SSP1, SSP2, SSP3 15 * PXA27x SSP1, SSP2, SSP3
16 * PXA3xx SSP1, SSP2, SSP3, SSP4
16 */ 17 */
17 18
18#ifndef SSP_H 19#ifndef __ASM_ARCH_SSP_H
19#define SSP_H 20#define __ASM_ARCH_SSP_H
21
22#include <linux/list.h>
23
24enum pxa_ssp_type {
25 SSP_UNDEFINED = 0,
26 PXA25x_SSP, /* pxa 210, 250, 255, 26x */
27 PXA25x_NSSP, /* pxa 255, 26x (including ASSP) */
28 PXA27x_SSP,
29};
30
31struct ssp_device {
32 struct platform_device *pdev;
33 struct list_head node;
34
35 struct clk *clk;
36 void __iomem *mmio_base;
37 unsigned long phys_base;
38
39 const char *label;
40 int port_id;
41 int type;
42 int use_count;
43 int irq;
44 int drcmr_rx;
45 int drcmr_tx;
46};
20 47
21/* 48/*
22 * SSP initialisation flags 49 * SSP initialisation flags
@@ -31,6 +58,7 @@ struct ssp_state {
31}; 58};
32 59
33struct ssp_dev { 60struct ssp_dev {
61 struct ssp_device *ssp;
34 u32 port; 62 u32 port;
35 u32 mode; 63 u32 mode;
36 u32 flags; 64 u32 flags;
@@ -50,4 +78,6 @@ int ssp_init(struct ssp_dev *dev, u32 port, u32 init_flags);
50int ssp_config(struct ssp_dev *dev, u32 mode, u32 flags, u32 psp_flags, u32 speed); 78int ssp_config(struct ssp_dev *dev, u32 mode, u32 flags, u32 psp_flags, u32 speed);
51void ssp_exit(struct ssp_dev *dev); 79void ssp_exit(struct ssp_dev *dev);
52 80
53#endif 81struct ssp_device *ssp_request(int port, const char *label);
82void ssp_free(struct ssp_device *);
83#endif /* __ASM_ARCH_SSP_H */
diff --git a/include/asm-arm/arch-pxa/uncompress.h b/include/asm-arm/arch-pxa/uncompress.h
index 178aa2e073ac..dadf4c20b622 100644
--- a/include/asm-arm/arch-pxa/uncompress.h
+++ b/include/asm-arm/arch-pxa/uncompress.h
@@ -9,19 +9,21 @@
9 * published by the Free Software Foundation. 9 * published by the Free Software Foundation.
10 */ 10 */
11 11
12#define FFUART ((volatile unsigned long *)0x40100000) 12#include <linux/serial_reg.h>
13#define BTUART ((volatile unsigned long *)0x40200000) 13#include <asm/arch/pxa-regs.h>
14#define STUART ((volatile unsigned long *)0x40700000) 14
15#define HWUART ((volatile unsigned long *)0x41600000) 15#define __REG(x) ((volatile unsigned long *)x)
16 16
17#define UART FFUART 17#define UART FFUART
18 18
19 19
20static inline void putc(char c) 20static inline void putc(char c)
21{ 21{
22 while (!(UART[5] & 0x20)) 22 if (!(UART[UART_IER] & IER_UUE))
23 return;
24 while (!(UART[UART_LSR] & LSR_TDRQ))
23 barrier(); 25 barrier();
24 UART[0] = c; 26 UART[UART_TX] = c;
25} 27}
26 28
27/* 29/*
diff --git a/include/asm-arm/arch-pxa/zylonite.h b/include/asm-arm/arch-pxa/zylonite.h
index f58b59162b82..5f717d64ea7d 100644
--- a/include/asm-arm/arch-pxa/zylonite.h
+++ b/include/asm-arm/arch-pxa/zylonite.h
@@ -3,9 +3,18 @@
3 3
4#define ZYLONITE_ETH_PHYS 0x14000000 4#define ZYLONITE_ETH_PHYS 0x14000000
5 5
6#define EXT_GPIO(x) (128 + (x))
7
6/* the following variables are processor specific and initialized 8/* the following variables are processor specific and initialized
7 * by the corresponding zylonite_pxa3xx_init() 9 * by the corresponding zylonite_pxa3xx_init()
8 */ 10 */
11struct platform_mmc_slot {
12 int gpio_cd;
13 int gpio_wp;
14};
15
16extern struct platform_mmc_slot zylonite_mmc_slot[];
17
9extern int gpio_backlight; 18extern int gpio_backlight;
10extern int gpio_eth_irq; 19extern int gpio_eth_irq;
11 20
diff --git a/include/asm-arm/arch-s3c2410/debug-macro.S b/include/asm-arm/arch-s3c2410/debug-macro.S
index 9c8cd9abb82b..89076c322726 100644
--- a/include/asm-arm/arch-s3c2410/debug-macro.S
+++ b/include/asm-arm/arch-s3c2410/debug-macro.S
@@ -92,11 +92,9 @@
92#if defined(CONFIG_CPU_LLSERIAL_S3C2410_ONLY) 92#if defined(CONFIG_CPU_LLSERIAL_S3C2410_ONLY)
93#define fifo_full fifo_full_s3c2410 93#define fifo_full fifo_full_s3c2410
94#define fifo_level fifo_level_s3c2410 94#define fifo_level fifo_level_s3c2410
95#warning 2410only
96#elif !defined(CONFIG_CPU_LLSERIAL_S3C2440_ONLY) 95#elif !defined(CONFIG_CPU_LLSERIAL_S3C2440_ONLY)
97#define fifo_full fifo_full_s3c24xx 96#define fifo_full fifo_full_s3c24xx
98#define fifo_level fifo_level_s3c24xx 97#define fifo_level fifo_level_s3c24xx
99#warning generic
100#endif 98#endif
101 99
102/* include the reset of the code which will do the work */ 100/* include the reset of the code which will do the work */
diff --git a/include/asm-arm/arch-s3c2410/dma.h b/include/asm-arm/arch-s3c2410/dma.h
index c6e8d8f64938..4f291d9b7d93 100644
--- a/include/asm-arm/arch-s3c2410/dma.h
+++ b/include/asm-arm/arch-s3c2410/dma.h
@@ -214,6 +214,7 @@ struct s3c2410_dma_chan {
214 unsigned long dev_addr; 214 unsigned long dev_addr;
215 unsigned long load_timeout; 215 unsigned long load_timeout;
216 unsigned int flags; /* channel flags */ 216 unsigned int flags; /* channel flags */
217 unsigned int hw_cfg; /* last hw config */
217 218
218 struct s3c24xx_dma_map *map; /* channel hw maps */ 219 struct s3c24xx_dma_map *map; /* channel hw maps */
219 220
diff --git a/include/asm-arm/arch-s3c2410/hardware.h b/include/asm-arm/arch-s3c2410/hardware.h
index 6dadf58ff984..29592c3ebf22 100644
--- a/include/asm-arm/arch-s3c2410/hardware.h
+++ b/include/asm-arm/arch-s3c2410/hardware.h
@@ -50,6 +50,17 @@ extern unsigned int s3c2410_gpio_getcfg(unsigned int pin);
50 50
51extern int s3c2410_gpio_getirq(unsigned int pin); 51extern int s3c2410_gpio_getirq(unsigned int pin);
52 52
53/* s3c2410_gpio_irq2pin
54 *
55 * turn the given irq number into the corresponding GPIO number
56 *
57 * returns:
58 * < 0 = no pin
59 * >=0 = gpio pin number
60*/
61
62extern int s3c2410_gpio_irq2pin(unsigned int irq);
63
53#ifdef CONFIG_CPU_S3C2400 64#ifdef CONFIG_CPU_S3C2400
54 65
55extern int s3c2400_gpio_getirq(unsigned int pin); 66extern int s3c2400_gpio_getirq(unsigned int pin);
@@ -87,6 +98,18 @@ extern int s3c2410_gpio_irqfilter(unsigned int pin, unsigned int on,
87 98
88extern void s3c2410_gpio_pullup(unsigned int pin, unsigned int to); 99extern void s3c2410_gpio_pullup(unsigned int pin, unsigned int to);
89 100
101/* s3c2410_gpio_getpull
102 *
103 * Read the state of the pull-up on a given pin
104 *
105 * return:
106 * < 0 => error code
107 * 0 => enabled
108 * 1 => disabled
109*/
110
111extern int s3c2410_gpio_getpull(unsigned int pin);
112
90extern void s3c2410_gpio_setpin(unsigned int pin, unsigned int to); 113extern void s3c2410_gpio_setpin(unsigned int pin, unsigned int to);
91 114
92extern unsigned int s3c2410_gpio_getpin(unsigned int pin); 115extern unsigned int s3c2410_gpio_getpin(unsigned int pin);
@@ -99,6 +122,11 @@ extern int s3c2440_set_dsc(unsigned int pin, unsigned int value);
99 122
100#endif /* CONFIG_CPU_S3C2440 */ 123#endif /* CONFIG_CPU_S3C2440 */
101 124
125#ifdef CONFIG_CPU_S3C2412
126
127extern int s3c2412_gpio_set_sleepcfg(unsigned int pin, unsigned int state);
128
129#endif /* CONFIG_CPU_S3C2412 */
102 130
103#endif /* __ASSEMBLY__ */ 131#endif /* __ASSEMBLY__ */
104 132
diff --git a/include/asm-arm/arch-s3c2410/irqs.h b/include/asm-arm/arch-s3c2410/irqs.h
index 996f65488d2d..d858b3eb5547 100644
--- a/include/asm-arm/arch-s3c2410/irqs.h
+++ b/include/asm-arm/arch-s3c2410/irqs.h
@@ -160,4 +160,7 @@
160#define NR_IRQS (IRQ_S3C2440_AC97+1) 160#define NR_IRQS (IRQ_S3C2440_AC97+1)
161#endif 161#endif
162 162
163/* Our FIQs are routable from IRQ_EINT0 to IRQ_ADCPARENT */
164#define FIQ_START IRQ_EINT0
165
163#endif /* __ASM_ARCH_IRQ_H */ 166#endif /* __ASM_ARCH_IRQ_H */
diff --git a/include/asm-arm/arch-s3c2410/regs-clock.h b/include/asm-arm/arch-s3c2410/regs-clock.h
index e39656b7a086..dba9df9d8713 100644
--- a/include/asm-arm/arch-s3c2410/regs-clock.h
+++ b/include/asm-arm/arch-s3c2410/regs-clock.h
@@ -138,6 +138,8 @@ s3c2410_get_pll(unsigned int pllval, unsigned int baseclk)
138#define S3C2412_CLKDIVN_PDIVN (1<<2) 138#define S3C2412_CLKDIVN_PDIVN (1<<2)
139#define S3C2412_CLKDIVN_HDIVN_MASK (3<<0) 139#define S3C2412_CLKDIVN_HDIVN_MASK (3<<0)
140#define S3C2421_CLKDIVN_ARMDIVN (1<<3) 140#define S3C2421_CLKDIVN_ARMDIVN (1<<3)
141#define S3C2412_CLKDIVN_DVSEN (1<<4)
142#define S3C2412_CLKDIVN_HALFHCLK (1<<5)
141#define S3C2412_CLKDIVN_USB48DIV (1<<6) 143#define S3C2412_CLKDIVN_USB48DIV (1<<6)
142#define S3C2412_CLKDIVN_UARTDIV_MASK (15<<8) 144#define S3C2412_CLKDIVN_UARTDIV_MASK (15<<8)
143#define S3C2412_CLKDIVN_UARTDIV_SHIFT (8) 145#define S3C2412_CLKDIVN_UARTDIV_SHIFT (8)
diff --git a/include/asm-arm/arch-s3c2410/regs-dsc.h b/include/asm-arm/arch-s3c2410/regs-dsc.h
index c0748511edbc..1235df70f34e 100644
--- a/include/asm-arm/arch-s3c2410/regs-dsc.h
+++ b/include/asm-arm/arch-s3c2410/regs-dsc.h
@@ -19,7 +19,7 @@
19#define S3C2412_DSC1 S3C2410_GPIOREG(0xe0) 19#define S3C2412_DSC1 S3C2410_GPIOREG(0xe0)
20#endif 20#endif
21 21
22#if defined(CONFIG_CPU_S3C2440) 22#if defined(CONFIG_CPU_S3C244X)
23 23
24#define S3C2440_DSC0 S3C2410_GPIOREG(0xc4) 24#define S3C2440_DSC0 S3C2410_GPIOREG(0xc4)
25#define S3C2440_DSC1 S3C2410_GPIOREG(0xc8) 25#define S3C2440_DSC1 S3C2410_GPIOREG(0xc8)
diff --git a/include/asm-arm/arch-s3c2410/regs-gpio.h b/include/asm-arm/arch-s3c2410/regs-gpio.h
index b693158b2d3c..0ad75d716ded 100644
--- a/include/asm-arm/arch-s3c2410/regs-gpio.h
+++ b/include/asm-arm/arch-s3c2410/regs-gpio.h
@@ -1133,12 +1133,16 @@
1133#define S3C2412_GPBSLPCON S3C2410_GPIOREG(0x1C) 1133#define S3C2412_GPBSLPCON S3C2410_GPIOREG(0x1C)
1134#define S3C2412_GPCSLPCON S3C2410_GPIOREG(0x2C) 1134#define S3C2412_GPCSLPCON S3C2410_GPIOREG(0x2C)
1135#define S3C2412_GPDSLPCON S3C2410_GPIOREG(0x3C) 1135#define S3C2412_GPDSLPCON S3C2410_GPIOREG(0x3C)
1136#define S3C2412_GPESLPCON S3C2410_GPIOREG(0x4C)
1137#define S3C2412_GPFSLPCON S3C2410_GPIOREG(0x5C) 1136#define S3C2412_GPFSLPCON S3C2410_GPIOREG(0x5C)
1138#define S3C2412_GPGSLPCON S3C2410_GPIOREG(0x6C) 1137#define S3C2412_GPGSLPCON S3C2410_GPIOREG(0x6C)
1139#define S3C2412_GPHSLPCON S3C2410_GPIOREG(0x7C) 1138#define S3C2412_GPHSLPCON S3C2410_GPIOREG(0x7C)
1140 1139
1141/* definitions for each pin bit */ 1140/* definitions for each pin bit */
1141#define S3C2412_GPIO_SLPCON_LOW ( 0x00 )
1142#define S3C2412_GPIO_SLPCON_HIGH ( 0x01 )
1143#define S3C2412_GPIO_SLPCON_IN ( 0x02 )
1144#define S3C2412_GPIO_SLPCON_PULL ( 0x03 )
1145
1142#define S3C2412_SLPCON_LOW(x) ( 0x00 << ((x) * 2)) 1146#define S3C2412_SLPCON_LOW(x) ( 0x00 << ((x) * 2))
1143#define S3C2412_SLPCON_HIGH(x) ( 0x01 << ((x) * 2)) 1147#define S3C2412_SLPCON_HIGH(x) ( 0x01 << ((x) * 2))
1144#define S3C2412_SLPCON_IN(x) ( 0x02 << ((x) * 2)) 1148#define S3C2412_SLPCON_IN(x) ( 0x02 << ((x) * 2))
diff --git a/include/asm-arm/arch-s3c2410/regs-mem.h b/include/asm-arm/arch-s3c2410/regs-mem.h
index e4d82341f7ba..312ff93b63c6 100644
--- a/include/asm-arm/arch-s3c2410/regs-mem.h
+++ b/include/asm-arm/arch-s3c2410/regs-mem.h
@@ -98,16 +98,19 @@
98#define S3C2410_BANKCON_Tacp3 (0x1 << 2) 98#define S3C2410_BANKCON_Tacp3 (0x1 << 2)
99#define S3C2410_BANKCON_Tacp4 (0x2 << 2) 99#define S3C2410_BANKCON_Tacp4 (0x2 << 2)
100#define S3C2410_BANKCON_Tacp6 (0x3 << 2) 100#define S3C2410_BANKCON_Tacp6 (0x3 << 2)
101#define S3C2410_BANKCON_Tacp_SHIFT (2)
101 102
102#define S3C2410_BANKCON_Tcah0 (0x0 << 4) 103#define S3C2410_BANKCON_Tcah0 (0x0 << 4)
103#define S3C2410_BANKCON_Tcah1 (0x1 << 4) 104#define S3C2410_BANKCON_Tcah1 (0x1 << 4)
104#define S3C2410_BANKCON_Tcah2 (0x2 << 4) 105#define S3C2410_BANKCON_Tcah2 (0x2 << 4)
105#define S3C2410_BANKCON_Tcah4 (0x3 << 4) 106#define S3C2410_BANKCON_Tcah4 (0x3 << 4)
107#define S3C2410_BANKCON_Tcah_SHIFT (4)
106 108
107#define S3C2410_BANKCON_Tcoh0 (0x0 << 6) 109#define S3C2410_BANKCON_Tcoh0 (0x0 << 6)
108#define S3C2410_BANKCON_Tcoh1 (0x1 << 6) 110#define S3C2410_BANKCON_Tcoh1 (0x1 << 6)
109#define S3C2410_BANKCON_Tcoh2 (0x2 << 6) 111#define S3C2410_BANKCON_Tcoh2 (0x2 << 6)
110#define S3C2410_BANKCON_Tcoh4 (0x3 << 6) 112#define S3C2410_BANKCON_Tcoh4 (0x3 << 6)
113#define S3C2410_BANKCON_Tcoh_SHIFT (6)
111 114
112#define S3C2410_BANKCON_Tacc1 (0x0 << 8) 115#define S3C2410_BANKCON_Tacc1 (0x0 << 8)
113#define S3C2410_BANKCON_Tacc2 (0x1 << 8) 116#define S3C2410_BANKCON_Tacc2 (0x1 << 8)
@@ -117,16 +120,19 @@
117#define S3C2410_BANKCON_Tacc8 (0x5 << 8) 120#define S3C2410_BANKCON_Tacc8 (0x5 << 8)
118#define S3C2410_BANKCON_Tacc10 (0x6 << 8) 121#define S3C2410_BANKCON_Tacc10 (0x6 << 8)
119#define S3C2410_BANKCON_Tacc14 (0x7 << 8) 122#define S3C2410_BANKCON_Tacc14 (0x7 << 8)
123#define S3C2410_BANKCON_Tacc_SHIFT (8)
120 124
121#define S3C2410_BANKCON_Tcos0 (0x0 << 11) 125#define S3C2410_BANKCON_Tcos0 (0x0 << 11)
122#define S3C2410_BANKCON_Tcos1 (0x1 << 11) 126#define S3C2410_BANKCON_Tcos1 (0x1 << 11)
123#define S3C2410_BANKCON_Tcos2 (0x2 << 11) 127#define S3C2410_BANKCON_Tcos2 (0x2 << 11)
124#define S3C2410_BANKCON_Tcos4 (0x3 << 11) 128#define S3C2410_BANKCON_Tcos4 (0x3 << 11)
129#define S3C2410_BANKCON_Tcos_SHIFT (11)
125 130
126#define S3C2410_BANKCON_Tacs0 (0x0 << 13) 131#define S3C2410_BANKCON_Tacs0 (0x0 << 13)
127#define S3C2410_BANKCON_Tacs1 (0x1 << 13) 132#define S3C2410_BANKCON_Tacs1 (0x1 << 13)
128#define S3C2410_BANKCON_Tacs2 (0x2 << 13) 133#define S3C2410_BANKCON_Tacs2 (0x2 << 13)
129#define S3C2410_BANKCON_Tacs4 (0x3 << 13) 134#define S3C2410_BANKCON_Tacs4 (0x3 << 13)
135#define S3C2410_BANKCON_Tacs_SHIFT (13)
130 136
131#define S3C2410_BANKCON_SRAM (0x0 << 15) 137#define S3C2410_BANKCON_SRAM (0x0 << 15)
132#define S3C2400_BANKCON_EDODRAM (0x2 << 15) 138#define S3C2400_BANKCON_EDODRAM (0x2 << 15)
diff --git a/include/asm-arm/arch-s3c2410/regs-power.h b/include/asm-arm/arch-s3c2410/regs-power.h
index f79987be55e8..13d13b7cfe98 100644
--- a/include/asm-arm/arch-s3c2410/regs-power.h
+++ b/include/asm-arm/arch-s3c2410/regs-power.h
@@ -23,7 +23,8 @@
23#define S3C2412_INFORM2 S3C24XX_PWRREG(0x78) 23#define S3C2412_INFORM2 S3C24XX_PWRREG(0x78)
24#define S3C2412_INFORM3 S3C24XX_PWRREG(0x7C) 24#define S3C2412_INFORM3 S3C24XX_PWRREG(0x7C)
25 25
26#define S3C2412_PWRCFG_BATF_IGNORE (0<<0) 26#define S3C2412_PWRCFG_BATF_IRQ (1<<0)
27#define S3C2412_PWRCFG_BATF_IGNORE (2<<0)
27#define S3C2412_PWRCFG_BATF_SLEEP (3<<0) 28#define S3C2412_PWRCFG_BATF_SLEEP (3<<0)
28#define S3C2412_PWRCFG_BATF_MASK (3<<0) 29#define S3C2412_PWRCFG_BATF_MASK (3<<0)
29 30
diff --git a/include/asm-arm/arch-s3c2410/spi-gpio.h b/include/asm-arm/arch-s3c2410/spi-gpio.h
index c1e4db7c9710..ba1dca88d480 100644
--- a/include/asm-arm/arch-s3c2410/spi-gpio.h
+++ b/include/asm-arm/arch-s3c2410/spi-gpio.h
@@ -21,6 +21,8 @@ struct s3c2410_spigpio_info {
21 unsigned long pin_mosi; 21 unsigned long pin_mosi;
22 unsigned long pin_miso; 22 unsigned long pin_miso;
23 23
24 int bus_num;
25
24 unsigned long board_size; 26 unsigned long board_size;
25 struct spi_board_info *board_info; 27 struct spi_board_info *board_info;
26 28
diff --git a/include/asm-arm/arch-s3c2410/system.h b/include/asm-arm/arch-s3c2410/system.h
index 63891786dfa0..14de4e596f87 100644
--- a/include/asm-arm/arch-s3c2410/system.h
+++ b/include/asm-arm/arch-s3c2410/system.h
@@ -20,6 +20,9 @@
20#include <asm/plat-s3c/regs-watchdog.h> 20#include <asm/plat-s3c/regs-watchdog.h>
21#include <asm/arch/regs-clock.h> 21#include <asm/arch/regs-clock.h>
22 22
23#include <linux/clk.h>
24#include <linux/err.h>
25
23void (*s3c24xx_idle)(void); 26void (*s3c24xx_idle)(void);
24void (*s3c24xx_reset_hook)(void); 27void (*s3c24xx_reset_hook)(void);
25 28
@@ -59,6 +62,8 @@ static void arch_idle(void)
59static void 62static void
60arch_reset(char mode) 63arch_reset(char mode)
61{ 64{
65 struct clk *wdtclk;
66
62 if (mode == 's') { 67 if (mode == 's') {
63 cpu_reset(0); 68 cpu_reset(0);
64 } 69 }
@@ -70,19 +75,28 @@ arch_reset(char mode)
70 75
71 __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */ 76 __raw_writel(0, S3C2410_WTCON); /* disable watchdog, to be safe */
72 77
78 wdtclk = clk_get(NULL, "watchdog");
79 if (!IS_ERR(wdtclk)) {
80 clk_enable(wdtclk);
81 } else
82 printk(KERN_WARNING "%s: warning: cannot get watchdog clock\n", __func__);
83
73 /* put initial values into count and data */ 84 /* put initial values into count and data */
74 __raw_writel(0x100, S3C2410_WTCNT); 85 __raw_writel(0x80, S3C2410_WTCNT);
75 __raw_writel(0x100, S3C2410_WTDAT); 86 __raw_writel(0x80, S3C2410_WTDAT);
76 87
77 /* set the watchdog to go and reset... */ 88 /* set the watchdog to go and reset... */
78 __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN | 89 __raw_writel(S3C2410_WTCON_ENABLE|S3C2410_WTCON_DIV16|S3C2410_WTCON_RSTEN |
79 S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON); 90 S3C2410_WTCON_PRESCALE(0x20), S3C2410_WTCON);
80 91
81 /* wait for reset to assert... */ 92 /* wait for reset to assert... */
82 mdelay(5000); 93 mdelay(500);
83 94
84 printk(KERN_ERR "Watchdog reset failed to assert reset\n"); 95 printk(KERN_ERR "Watchdog reset failed to assert reset\n");
85 96
97 /* delay to allow the serial port to show the message */
98 mdelay(50);
99
86 /* we'll take a jump through zero as a poor second */ 100 /* we'll take a jump through zero as a poor second */
87 cpu_reset(0); 101 cpu_reset(0);
88} 102}
diff --git a/include/asm-arm/bitops.h b/include/asm-arm/bitops.h
index 47a6b086eee2..5c60bfc1a84d 100644
--- a/include/asm-arm/bitops.h
+++ b/include/asm-arm/bitops.h
@@ -310,6 +310,8 @@ static inline int constant_fls(int x)
310 _find_first_zero_bit_le(p,sz) 310 _find_first_zero_bit_le(p,sz)
311#define ext2_find_next_zero_bit(p,sz,off) \ 311#define ext2_find_next_zero_bit(p,sz,off) \
312 _find_next_zero_bit_le(p,sz,off) 312 _find_next_zero_bit_le(p,sz,off)
313#define ext2_find_next_bit(p, sz, off) \
314 _find_next_bit_le(p, sz, off)
313 315
314/* 316/*
315 * Minix is defined to use little-endian byte ordering. 317 * Minix is defined to use little-endian byte ordering.
diff --git a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h
index 6c1c968b2987..759a97b56eed 100644
--- a/include/asm-arm/cacheflush.h
+++ b/include/asm-arm/cacheflush.h
@@ -94,6 +94,14 @@
94# endif 94# endif
95#endif 95#endif
96 96
97#if defined(CONFIG_CPU_FEROCEON)
98# ifdef _CACHE
99# define MULTI_CACHE 1
100# else
101# define _CACHE feroceon
102# endif
103#endif
104
97#if defined(CONFIG_CPU_V6) 105#if defined(CONFIG_CPU_V6)
98//# ifdef _CACHE 106//# ifdef _CACHE
99# define MULTI_CACHE 1 107# define MULTI_CACHE 1
diff --git a/include/asm-arm/flat.h b/include/asm-arm/flat.h
index 16f5375e57b8..9918aa46d9e5 100644
--- a/include/asm-arm/flat.h
+++ b/include/asm-arm/flat.h
@@ -11,8 +11,9 @@
11#define flat_argvp_envp_on_stack() 1 11#define flat_argvp_envp_on_stack() 1
12#define flat_old_ram_flag(flags) (flags) 12#define flat_old_ram_flag(flags) (flags)
13#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) 13#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
14#define flat_get_addr_from_rp(rp, relval, flags) get_unaligned(rp) 14#define flat_get_addr_from_rp(rp, relval, flags, persistent) get_unaligned(rp)
15#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp) 15#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp)
16#define flat_get_relocate_addr(rel) (rel) 16#define flat_get_relocate_addr(rel) (rel)
17#define flat_set_persistent(relval, p) 0
17 18
18#endif /* __ARM_FLAT_H__ */ 19#endif /* __ARM_FLAT_H__ */
diff --git a/include/asm-arm/fpstate.h b/include/asm-arm/fpstate.h
index f31cda5a55ee..392eb5332323 100644
--- a/include/asm-arm/fpstate.h
+++ b/include/asm-arm/fpstate.h
@@ -17,14 +17,18 @@
17/* 17/*
18 * VFP storage area has: 18 * VFP storage area has:
19 * - FPEXC, FPSCR, FPINST and FPINST2. 19 * - FPEXC, FPSCR, FPINST and FPINST2.
20 * - 16 double precision data registers 20 * - 16 or 32 double precision data registers
21 * - an implementation-dependant word of state for FLDMX/FSTMX 21 * - an implementation-dependant word of state for FLDMX/FSTMX (pre-ARMv6)
22 * 22 *
23 * FPEXC will always be non-zero once the VFP has been used in this process. 23 * FPEXC will always be non-zero once the VFP has been used in this process.
24 */ 24 */
25 25
26struct vfp_hard_struct { 26struct vfp_hard_struct {
27#ifdef CONFIG_VFPv3
28 __u64 fpregs[32];
29#else
27 __u64 fpregs[16]; 30 __u64 fpregs[16];
31#endif
28#if __LINUX_ARM_ARCH__ < 6 32#if __LINUX_ARM_ARCH__ < 6
29 __u32 fpmx_state; 33 __u32 fpmx_state;
30#endif 34#endif
@@ -35,6 +39,7 @@ struct vfp_hard_struct {
35 */ 39 */
36 __u32 fpinst; 40 __u32 fpinst;
37 __u32 fpinst2; 41 __u32 fpinst2;
42
38#ifdef CONFIG_SMP 43#ifdef CONFIG_SMP
39 __u32 cpu; 44 __u32 cpu;
40#endif 45#endif
diff --git a/include/asm-arm/hardware/iop3xx.h b/include/asm-arm/hardware/iop3xx.h
index fb90b421f31c..ede377ec9147 100644
--- a/include/asm-arm/hardware/iop3xx.h
+++ b/include/asm-arm/hardware/iop3xx.h
@@ -231,7 +231,7 @@ extern int init_atu;
231 IOP3XX_PCI_IO_WINDOW_SIZE - 1) 231 IOP3XX_PCI_IO_WINDOW_SIZE - 1)
232#define IOP3XX_PCI_UPPER_IO_VA (IOP3XX_PCI_LOWER_IO_VA +\ 232#define IOP3XX_PCI_UPPER_IO_VA (IOP3XX_PCI_LOWER_IO_VA +\
233 IOP3XX_PCI_IO_WINDOW_SIZE - 1) 233 IOP3XX_PCI_IO_WINDOW_SIZE - 1)
234#define IOP3XX_PCI_IO_PHYS_TO_VIRT(addr) (((u32) addr -\ 234#define IOP3XX_PCI_IO_PHYS_TO_VIRT(addr) (((u32) (addr) -\
235 IOP3XX_PCI_LOWER_IO_PA) +\ 235 IOP3XX_PCI_LOWER_IO_PA) +\
236 IOP3XX_PCI_LOWER_IO_VA) 236 IOP3XX_PCI_LOWER_IO_VA)
237 237
diff --git a/include/asm-arm/kprobes.h b/include/asm-arm/kprobes.h
new file mode 100644
index 000000000000..4e7bd32288ae
--- /dev/null
+++ b/include/asm-arm/kprobes.h
@@ -0,0 +1,79 @@
1/*
2 * include/asm-arm/kprobes.h
3 *
4 * Copyright (C) 2006, 2007 Motorola Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 */
15
16#ifndef _ARM_KPROBES_H
17#define _ARM_KPROBES_H
18
19#include <linux/types.h>
20#include <linux/ptrace.h>
21#include <linux/percpu.h>
22
23#define ARCH_SUPPORTS_KRETPROBES
24#define __ARCH_WANT_KPROBES_INSN_SLOT
25#define MAX_INSN_SIZE 2
26#define MAX_STACK_SIZE 64 /* 32 would probably be OK */
27
28/*
29 * This undefined instruction must be unique and
30 * reserved solely for kprobes' use.
31 */
32#define KPROBE_BREAKPOINT_INSTRUCTION 0xe7f001f8
33
34#define regs_return_value(regs) ((regs)->ARM_r0)
35#define flush_insn_slot(p) do { } while (0)
36#define kretprobe_blacklist_size 0
37
38typedef u32 kprobe_opcode_t;
39
40struct kprobe;
41typedef void (kprobe_insn_handler_t)(struct kprobe *, struct pt_regs *);
42
43/* Architecture specific copy of original instruction. */
44struct arch_specific_insn {
45 kprobe_opcode_t *insn;
46 kprobe_insn_handler_t *insn_handler;
47};
48
49struct prev_kprobe {
50 struct kprobe *kp;
51 unsigned int status;
52};
53
54/* per-cpu kprobe control block */
55struct kprobe_ctlblk {
56 unsigned int kprobe_status;
57 struct prev_kprobe prev_kprobe;
58 struct pt_regs jprobe_saved_regs;
59 char jprobes_stack[MAX_STACK_SIZE];
60};
61
62void arch_remove_kprobe(struct kprobe *);
63
64int kprobe_trap_handler(struct pt_regs *regs, unsigned int instr);
65int kprobe_fault_handler(struct pt_regs *regs, unsigned int fsr);
66int kprobe_exceptions_notify(struct notifier_block *self,
67 unsigned long val, void *data);
68
69enum kprobe_insn {
70 INSN_REJECTED,
71 INSN_GOOD,
72 INSN_GOOD_NO_SLOT
73};
74
75enum kprobe_insn arm_kprobe_decode_insn(kprobe_opcode_t,
76 struct arch_specific_insn *);
77void __init arm_kprobe_decode_init(void);
78
79#endif /* _ARM_KPROBES_H */
diff --git a/include/asm-arm/mach/udc_pxa2xx.h b/include/asm-arm/mach/udc_pxa2xx.h
index ff0a95715a07..f191e147ea90 100644
--- a/include/asm-arm/mach/udc_pxa2xx.h
+++ b/include/asm-arm/mach/udc_pxa2xx.h
@@ -19,7 +19,9 @@ struct pxa2xx_udc_mach_info {
19 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane 19 * with on-chip GPIOs not Lubbock's wierd hardware, can have a sane
20 * VBUS IRQ and omit the methods above. Store the GPIO number 20 * VBUS IRQ and omit the methods above. Store the GPIO number
21 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits. 21 * here; for GPIO 0, also mask in one of the pxa_gpio_mode() bits.
22 * Note that sometimes the signals go through inverters...
22 */ 23 */
24 bool gpio_vbus_inverted;
23 u16 gpio_vbus; /* high == vbus present */ 25 u16 gpio_vbus; /* high == vbus present */
24 u16 gpio_pullup; /* high == pullup activated */ 26 u16 gpio_pullup; /* high == pullup activated */
25}; 27};
diff --git a/include/asm-arm/pgtable.h b/include/asm-arm/pgtable.h
index d2e8171d1d4e..5e0182485d8c 100644
--- a/include/asm-arm/pgtable.h
+++ b/include/asm-arm/pgtable.h
@@ -249,7 +249,7 @@ extern struct page *empty_zero_page;
249#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext) 249#define set_pte_ext(ptep,pte,ext) cpu_set_pte_ext(ptep,pte,ext)
250 250
251#define set_pte_at(mm,addr,ptep,pteval) do { \ 251#define set_pte_at(mm,addr,ptep,pteval) do { \
252 set_pte_ext(ptep, pteval, (addr) >= PAGE_OFFSET ? 0 : PTE_EXT_NG); \ 252 set_pte_ext(ptep, pteval, (addr) >= TASK_SIZE ? 0 : PTE_EXT_NG); \
253 } while (0) 253 } while (0)
254 254
255/* 255/*
diff --git a/include/asm-arm/plat-s3c/regs-nand.h b/include/asm-arm/plat-s3c/regs-nand.h
index b824d371ae0b..d742205ac172 100644
--- a/include/asm-arm/plat-s3c/regs-nand.h
+++ b/include/asm-arm/plat-s3c/regs-nand.h
@@ -35,7 +35,7 @@
35#define S3C2440_NFESTAT1 S3C2410_NFREG(0x28) 35#define S3C2440_NFESTAT1 S3C2410_NFREG(0x28)
36#define S3C2440_NFMECC0 S3C2410_NFREG(0x2C) 36#define S3C2440_NFMECC0 S3C2410_NFREG(0x2C)
37#define S3C2440_NFMECC1 S3C2410_NFREG(0x30) 37#define S3C2440_NFMECC1 S3C2410_NFREG(0x30)
38#define S3C2440_NFSECC S3C24E10_NFREG(0x34) 38#define S3C2440_NFSECC S3C2410_NFREG(0x34)
39#define S3C2440_NFSBLK S3C2410_NFREG(0x38) 39#define S3C2440_NFSBLK S3C2410_NFREG(0x38)
40#define S3C2440_NFEBLK S3C2410_NFREG(0x3C) 40#define S3C2440_NFEBLK S3C2410_NFREG(0x3C)
41 41
diff --git a/include/asm-arm/plat-s3c24xx/dma.h b/include/asm-arm/plat-s3c24xx/dma.h
index 2c59406435e5..c78efe316fc8 100644
--- a/include/asm-arm/plat-s3c24xx/dma.h
+++ b/include/asm-arm/plat-s3c24xx/dma.h
@@ -32,6 +32,7 @@ struct s3c24xx_dma_map {
32 struct s3c24xx_dma_addr hw_addr; 32 struct s3c24xx_dma_addr hw_addr;
33 33
34 unsigned long channels[S3C2410_DMA_CHANNELS]; 34 unsigned long channels[S3C2410_DMA_CHANNELS];
35 unsigned long channels_rx[S3C2410_DMA_CHANNELS];
35}; 36};
36 37
37struct s3c24xx_dma_selection { 38struct s3c24xx_dma_selection {
@@ -41,6 +42,10 @@ struct s3c24xx_dma_selection {
41 42
42 void (*select)(struct s3c2410_dma_chan *chan, 43 void (*select)(struct s3c2410_dma_chan *chan,
43 struct s3c24xx_dma_map *map); 44 struct s3c24xx_dma_map *map);
45
46 void (*direction)(struct s3c2410_dma_chan *chan,
47 struct s3c24xx_dma_map *map,
48 enum s3c2410_dmasrc dir);
44}; 49};
45 50
46extern int s3c24xx_dma_init_map(struct s3c24xx_dma_selection *sel); 51extern int s3c24xx_dma_init_map(struct s3c24xx_dma_selection *sel);
diff --git a/include/asm-arm/plat-s3c24xx/irq.h b/include/asm-arm/plat-s3c24xx/irq.h
index 8af6d9579b31..45746a995343 100644
--- a/include/asm-arm/plat-s3c24xx/irq.h
+++ b/include/asm-arm/plat-s3c24xx/irq.h
@@ -15,7 +15,9 @@
15 15
16#define EXTINT_OFF (IRQ_EINT4 - 4) 16#define EXTINT_OFF (IRQ_EINT4 - 4)
17 17
18/* these are exported for arch/arm/mach-* usage */
18extern struct irq_chip s3c_irq_level_chip; 19extern struct irq_chip s3c_irq_level_chip;
20extern struct irq_chip s3c_irq_chip;
19 21
20static inline void 22static inline void
21s3c_irqsub_mask(unsigned int irqno, unsigned int parentbit, 23s3c_irqsub_mask(unsigned int irqno, unsigned int parentbit,
diff --git a/include/asm-arm/plat-s3c24xx/regs-s3c2412-iis.h b/include/asm-arm/plat-s3c24xx/regs-s3c2412-iis.h
new file mode 100644
index 000000000000..25d4058bcfed
--- /dev/null
+++ b/include/asm-arm/plat-s3c24xx/regs-s3c2412-iis.h
@@ -0,0 +1,72 @@
1/* linux/include/asm-arm/plat-s3c24xx/regs-s3c2412-iis.h
2 *
3 * Copyright 2007 Simtec Electronics <linux@simtec.co.uk>
4 * http://armlinux.simtec.co.uk/
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * S3C2412 IIS register definition
11*/
12
13#ifndef __ASM_ARCH_REGS_S3C2412_IIS_H
14#define __ASM_ARCH_REGS_S3C2412_IIS_H
15
16#define S3C2412_IISCON (0x00)
17#define S3C2412_IISMOD (0x04)
18#define S3C2412_IISFIC (0x08)
19#define S3C2412_IISPSR (0x0C)
20#define S3C2412_IISTXD (0x10)
21#define S3C2412_IISRXD (0x14)
22
23#define S3C2412_IISCON_LRINDEX (1 << 11)
24#define S3C2412_IISCON_TXFIFO_EMPTY (1 << 10)
25#define S3C2412_IISCON_RXFIFO_EMPTY (1 << 9)
26#define S3C2412_IISCON_TXFIFO_FULL (1 << 8)
27#define S3C2412_IISCON_RXFIFO_FULL (1 << 7)
28#define S3C2412_IISCON_TXDMA_PAUSE (1 << 6)
29#define S3C2412_IISCON_RXDMA_PAUSE (1 << 5)
30#define S3C2412_IISCON_TXCH_PAUSE (1 << 4)
31#define S3C2412_IISCON_RXCH_PAUSE (1 << 3)
32#define S3C2412_IISCON_TXDMA_ACTIVE (1 << 2)
33#define S3C2412_IISCON_RXDMA_ACTIVE (1 << 1)
34#define S3C2412_IISCON_IIS_ACTIVE (1 << 0)
35
36#define S3C2412_IISMOD_MASTER_INTERNAL (0 << 10)
37#define S3C2412_IISMOD_MASTER_EXTERNAL (1 << 10)
38#define S3C2412_IISMOD_SLAVE (2 << 10)
39#define S3C2412_IISMOD_MASTER_MASK (3 << 10)
40#define S3C2412_IISMOD_MODE_TXONLY (0 << 8)
41#define S3C2412_IISMOD_MODE_RXONLY (1 << 8)
42#define S3C2412_IISMOD_MODE_TXRX (2 << 8)
43#define S3C2412_IISMOD_MODE_MASK (3 << 8)
44#define S3C2412_IISMOD_LR_LLOW (0 << 7)
45#define S3C2412_IISMOD_LR_RLOW (1 << 7)
46#define S3C2412_IISMOD_SDF_IIS (0 << 5)
47#define S3C2412_IISMOD_SDF_MSB (0 << 5)
48#define S3C2412_IISMOD_SDF_LSB (0 << 5)
49#define S3C2412_IISMOD_SDF_MASK (3 << 5)
50#define S3C2412_IISMOD_RCLK_256FS (0 << 3)
51#define S3C2412_IISMOD_RCLK_512FS (1 << 3)
52#define S3C2412_IISMOD_RCLK_384FS (2 << 3)
53#define S3C2412_IISMOD_RCLK_768FS (3 << 3)
54#define S3C2412_IISMOD_RCLK_MASK (3 << 3)
55#define S3C2412_IISMOD_BCLK_32FS (0 << 1)
56#define S3C2412_IISMOD_BCLK_48FS (1 << 1)
57#define S3C2412_IISMOD_BCLK_16FS (2 << 1)
58#define S3C2412_IISMOD_BCLK_24FS (3 << 1)
59#define S3C2412_IISMOD_BCLK_MASK (3 << 1)
60#define S3C2412_IISMOD_8BIT (1 << 0)
61
62#define S3C2412_IISPSR_PSREN (1 << 15)
63
64#define S3C2412_IISFIC_TXFLUSH (1 << 15)
65#define S3C2412_IISFIC_RXFLUSH (1 << 7)
66#define S3C2412_IISFIC_TXCOUNT(x) (((x) >> 8) & 0xf)
67#define S3C2412_IISFIC_RXCOUNT(x) (((x) >> 0) & 0xf)
68
69
70
71#endif /* __ASM_ARCH_REGS_S3C2412_IIS_H */
72
diff --git a/include/asm-arm/plat-s3c24xx/regs-spi.h b/include/asm-arm/plat-s3c24xx/regs-spi.h
index 4a499a138256..ea565b007d04 100644
--- a/include/asm-arm/plat-s3c24xx/regs-spi.h
+++ b/include/asm-arm/plat-s3c24xx/regs-spi.h
@@ -17,6 +17,21 @@
17 17
18#define S3C2410_SPCON (0x00) 18#define S3C2410_SPCON (0x00)
19 19
20#define S3C2412_SPCON_RXFIFO_RB2 (0<<14)
21#define S3C2412_SPCON_RXFIFO_RB4 (1<<14)
22#define S3C2412_SPCON_RXFIFO_RB12 (2<<14)
23#define S3C2412_SPCON_RXFIFO_RB14 (3<<14)
24#define S3C2412_SPCON_TXFIFO_RB2 (0<<12)
25#define S3C2412_SPCON_TXFIFO_RB4 (1<<12)
26#define S3C2412_SPCON_TXFIFO_RB12 (2<<12)
27#define S3C2412_SPCON_TXFIFO_RB14 (3<<12)
28#define S3C2412_SPCON_RXFIFO_RESET (1<<11) /* RxFIFO reset */
29#define S3C2412_SPCON_TXFIFO_RESET (1<<10) /* TxFIFO reset */
30#define S3C2412_SPCON_RXFIFO_EN (1<<9) /* RxFIFO Enable */
31#define S3C2412_SPCON_TXFIFO_EN (1<<8) /* TxFIFO Enable */
32
33#define S3C2412_SPCON_DIRC_RX (1<<7)
34
20#define S3C2410_SPCON_SMOD_DMA (2<<5) /* DMA mode */ 35#define S3C2410_SPCON_SMOD_DMA (2<<5) /* DMA mode */
21#define S3C2410_SPCON_SMOD_INT (1<<5) /* interrupt mode */ 36#define S3C2410_SPCON_SMOD_INT (1<<5) /* interrupt mode */
22#define S3C2410_SPCON_SMOD_POLL (0<<5) /* polling mode */ 37#define S3C2410_SPCON_SMOD_POLL (0<<5) /* polling mode */
@@ -34,10 +49,19 @@
34 49
35#define S3C2410_SPSTA (0x04) 50#define S3C2410_SPSTA (0x04)
36 51
52#define S3C2412_SPSTA_RXFIFO_AE (1<<11)
53#define S3C2412_SPSTA_TXFIFO_AE (1<<10)
54#define S3C2412_SPSTA_RXFIFO_ERROR (1<<9)
55#define S3C2412_SPSTA_TXFIFO_ERROR (1<<8)
56#define S3C2412_SPSTA_RXFIFO_FIFO (1<<7)
57#define S3C2412_SPSTA_RXFIFO_EMPTY (1<<6)
58#define S3C2412_SPSTA_TXFIFO_NFULL (1<<5)
59#define S3C2412_SPSTA_TXFIFO_EMPTY (1<<4)
60
37#define S3C2410_SPSTA_DCOL (1<<2) /* Data Collision Error */ 61#define S3C2410_SPSTA_DCOL (1<<2) /* Data Collision Error */
38#define S3C2410_SPSTA_MULD (1<<1) /* Multi Master Error */ 62#define S3C2410_SPSTA_MULD (1<<1) /* Multi Master Error */
39#define S3C2410_SPSTA_READY (1<<0) /* Data Tx/Rx ready */ 63#define S3C2410_SPSTA_READY (1<<0) /* Data Tx/Rx ready */
40 64#define S3C2412_SPSTA_READY_ORG (1<<3)
41 65
42#define S3C2410_SPPIN (0x08) 66#define S3C2410_SPPIN (0x08)
43 67
@@ -46,9 +70,13 @@
46#define S3C2400_SPPIN_nCS (1<<1) /* SPI Card Select */ 70#define S3C2400_SPPIN_nCS (1<<1) /* SPI Card Select */
47#define S3C2410_SPPIN_KEEP (1<<0) /* Master Out keep */ 71#define S3C2410_SPPIN_KEEP (1<<0) /* Master Out keep */
48 72
49
50#define S3C2410_SPPRE (0x0C) 73#define S3C2410_SPPRE (0x0C)
51#define S3C2410_SPTDAT (0x10) 74#define S3C2410_SPTDAT (0x10)
52#define S3C2410_SPRDAT (0x14) 75#define S3C2410_SPRDAT (0x14)
53 76
77#define S3C2412_TXFIFO (0x18)
78#define S3C2412_RXFIFO (0x18)
79#define S3C2412_SPFIC (0x24)
80
81
54#endif /* __ASM_ARCH_REGS_SPI_H */ 82#endif /* __ASM_ARCH_REGS_SPI_H */
diff --git a/include/asm-arm/proc-fns.h b/include/asm-arm/proc-fns.h
index 5599d4e5e708..a4ce457199d3 100644
--- a/include/asm-arm/proc-fns.h
+++ b/include/asm-arm/proc-fns.h
@@ -185,6 +185,14 @@
185# define CPU_NAME cpu_xsc3 185# define CPU_NAME cpu_xsc3
186# endif 186# endif
187# endif 187# endif
188# ifdef CONFIG_CPU_FEROCEON
189# ifdef CPU_NAME
190# undef MULTI_CPU
191# define MULTI_CPU
192# else
193# define CPU_NAME cpu_feroceon
194# endif
195# endif
188# ifdef CONFIG_CPU_V6 196# ifdef CONFIG_CPU_V6
189# ifdef CPU_NAME 197# ifdef CPU_NAME
190# undef MULTI_CPU 198# undef MULTI_CPU
diff --git a/include/asm-arm/socket.h b/include/asm-arm/socket.h
index 65a1a64bf934..6817be9573a6 100644
--- a/include/asm-arm/socket.h
+++ b/include/asm-arm/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* _ASM_SOCKET_H */ 57#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-arm/system.h b/include/asm-arm/system.h
index 94ea8c6dc1a4..28425c473e71 100644
--- a/include/asm-arm/system.h
+++ b/include/asm-arm/system.h
@@ -75,8 +75,21 @@
75#ifndef __ASSEMBLY__ 75#ifndef __ASSEMBLY__
76 76
77#include <linux/linkage.h> 77#include <linux/linkage.h>
78#include <linux/stringify.h>
78#include <linux/irqflags.h> 79#include <linux/irqflags.h>
79 80
81/*
82 * The CPU ID never changes at run time, so we might as well tell the
83 * compiler that it's constant. Use this function to read the CPU ID
84 * rather than directly reading processor_id or read_cpuid() directly.
85 */
86static inline unsigned int read_cpuid_id(void) __attribute_const__;
87
88static inline unsigned int read_cpuid_id(void)
89{
90 return read_cpuid(CPUID_ID);
91}
92
80#define __exception __attribute__((section(".exception.text"))) 93#define __exception __attribute__((section(".exception.text")))
81 94
82struct thread_info; 95struct thread_info;
diff --git a/include/asm-arm/traps.h b/include/asm-arm/traps.h
index d4f34dc83eb0..f1541afcf85c 100644
--- a/include/asm-arm/traps.h
+++ b/include/asm-arm/traps.h
@@ -15,4 +15,13 @@ struct undef_hook {
15void register_undef_hook(struct undef_hook *hook); 15void register_undef_hook(struct undef_hook *hook);
16void unregister_undef_hook(struct undef_hook *hook); 16void unregister_undef_hook(struct undef_hook *hook);
17 17
18static inline int in_exception_text(unsigned long ptr)
19{
20 extern char __exception_text_start[];
21 extern char __exception_text_end[];
22
23 return ptr >= (unsigned long)&__exception_text_start &&
24 ptr < (unsigned long)&__exception_text_end;
25}
26
18#endif 27#endif
diff --git a/include/asm-arm/vfp.h b/include/asm-arm/vfp.h
index bd6be9d7f772..5f9a2cb3d452 100644
--- a/include/asm-arm/vfp.h
+++ b/include/asm-arm/vfp.h
@@ -7,7 +7,11 @@
7 7
8#define FPSID cr0 8#define FPSID cr0
9#define FPSCR cr1 9#define FPSCR cr1
10#define MVFR1 cr6
11#define MVFR0 cr7
10#define FPEXC cr8 12#define FPEXC cr8
13#define FPINST cr9
14#define FPINST2 cr10
11 15
12/* FPSID bits */ 16/* FPSID bits */
13#define FPSID_IMPLEMENTER_BIT (24) 17#define FPSID_IMPLEMENTER_BIT (24)
@@ -28,6 +32,19 @@
28/* FPEXC bits */ 32/* FPEXC bits */
29#define FPEXC_EX (1 << 31) 33#define FPEXC_EX (1 << 31)
30#define FPEXC_EN (1 << 30) 34#define FPEXC_EN (1 << 30)
35#define FPEXC_DEX (1 << 29)
36#define FPEXC_FP2V (1 << 28)
37#define FPEXC_VV (1 << 27)
38#define FPEXC_TFV (1 << 26)
39#define FPEXC_LENGTH_BIT (8)
40#define FPEXC_LENGTH_MASK (7 << FPEXC_LENGTH_BIT)
41#define FPEXC_IDF (1 << 7)
42#define FPEXC_IXF (1 << 4)
43#define FPEXC_UFF (1 << 3)
44#define FPEXC_OFF (1 << 2)
45#define FPEXC_DZF (1 << 1)
46#define FPEXC_IOF (1 << 0)
47#define FPEXC_TRAP_MASK (FPEXC_IDF|FPEXC_IXF|FPEXC_UFF|FPEXC_OFF|FPEXC_DZF|FPEXC_IOF)
31 48
32/* FPSCR bits */ 49/* FPSCR bits */
33#define FPSCR_DEFAULT_NAN (1<<25) 50#define FPSCR_DEFAULT_NAN (1<<25)
@@ -55,20 +72,9 @@
55#define FPSCR_IXC (1<<4) 72#define FPSCR_IXC (1<<4)
56#define FPSCR_IDC (1<<7) 73#define FPSCR_IDC (1<<7)
57 74
58/* 75/* MVFR0 bits */
59 * VFP9-S specific. 76#define MVFR0_A_SIMD_BIT (0)
60 */ 77#define MVFR0_A_SIMD_MASK (0xf << MVFR0_A_SIMD_BIT)
61#define FPINST cr9
62#define FPINST2 cr10
63
64/* FPEXC bits */
65#define FPEXC_FPV2 (1<<28)
66#define FPEXC_LENGTH_BIT (8)
67#define FPEXC_LENGTH_MASK (7 << FPEXC_LENGTH_BIT)
68#define FPEXC_INV (1 << 7)
69#define FPEXC_UFC (1 << 3)
70#define FPEXC_OFC (1 << 2)
71#define FPEXC_IOC (1 << 0)
72 78
73/* Bit patterns for decoding the packaged operation descriptors */ 79/* Bit patterns for decoding the packaged operation descriptors */
74#define VFPOPDESC_LENGTH_BIT (9) 80#define VFPOPDESC_LENGTH_BIT (9)
diff --git a/include/asm-arm/vfpmacros.h b/include/asm-arm/vfpmacros.h
index 27fe028b4e72..cccb3892e73c 100644
--- a/include/asm-arm/vfpmacros.h
+++ b/include/asm-arm/vfpmacros.h
@@ -15,19 +15,33 @@
15 .endm 15 .endm
16 16
17 @ read all the working registers back into the VFP 17 @ read all the working registers back into the VFP
18 .macro VFPFLDMIA, base 18 .macro VFPFLDMIA, base, tmp
19#if __LINUX_ARM_ARCH__ < 6 19#if __LINUX_ARM_ARCH__ < 6
20 LDC p11, cr0, [\base],#33*4 @ FLDMIAX \base!, {d0-d15} 20 LDC p11, cr0, [\base],#33*4 @ FLDMIAX \base!, {d0-d15}
21#else 21#else
22 LDC p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d0-d15} 22 LDC p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d0-d15}
23#endif 23#endif
24#ifdef CONFIG_VFPv3
25 VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0
26 and \tmp, \tmp, #MVFR0_A_SIMD_MASK @ A_SIMD field
27 cmp \tmp, #2 @ 32 x 64bit registers?
28 ldceql p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
29 addne \base, \base, #32*4 @ step over unused register space
30#endif
24 .endm 31 .endm
25 32
26 @ write all the working registers out of the VFP 33 @ write all the working registers out of the VFP
27 .macro VFPFSTMIA, base 34 .macro VFPFSTMIA, base, tmp
28#if __LINUX_ARM_ARCH__ < 6 35#if __LINUX_ARM_ARCH__ < 6
29 STC p11, cr0, [\base],#33*4 @ FSTMIAX \base!, {d0-d15} 36 STC p11, cr0, [\base],#33*4 @ FSTMIAX \base!, {d0-d15}
30#else 37#else
31 STC p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d0-d15} 38 STC p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d0-d15}
32#endif 39#endif
40#ifdef CONFIG_VFPv3
41 VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0
42 and \tmp, \tmp, #MVFR0_A_SIMD_MASK @ A_SIMD field
43 cmp \tmp, #2 @ 32 x 64bit registers?
44 stceql p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
45 addne \base, \base, #32*4 @ step over unused register space
46#endif
33 .endm 47 .endm
diff --git a/include/asm-arm26/irq_regs.h b/include/asm-arm26/irq_regs.h
deleted file mode 100644
index 3dd9c0b70270..000000000000
--- a/include/asm-arm26/irq_regs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/irq_regs.h>
diff --git a/include/asm-avr32/arch-at32ap/at32ap7000.h b/include/asm-avr32/arch-at32ap/at32ap700x.h
index 3914d7b94ff4..99684d6f3967 100644
--- a/include/asm-avr32/arch-at32ap/at32ap7000.h
+++ b/include/asm-avr32/arch-at32ap/at32ap700x.h
@@ -7,8 +7,8 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 */ 9 */
10#ifndef __ASM_ARCH_AT32AP7000_H__ 10#ifndef __ASM_ARCH_AT32AP700X_H__
11#define __ASM_ARCH_AT32AP7000_H__ 11#define __ASM_ARCH_AT32AP700X_H__
12 12
13#define GPIO_PERIPH_A 0 13#define GPIO_PERIPH_A 0
14#define GPIO_PERIPH_B 1 14#define GPIO_PERIPH_B 1
@@ -32,4 +32,4 @@
32#define GPIO_PIN_PD(N) (GPIO_PIOD_BASE + (N)) 32#define GPIO_PIN_PD(N) (GPIO_PIOD_BASE + (N))
33#define GPIO_PIN_PE(N) (GPIO_PIOE_BASE + (N)) 33#define GPIO_PIN_PE(N) (GPIO_PIOE_BASE + (N))
34 34
35#endif /* __ASM_ARCH_AT32AP7000_H__ */ 35#endif /* __ASM_ARCH_AT32AP700X_H__ */
diff --git a/include/asm-avr32/arch-at32ap/cpu.h b/include/asm-avr32/arch-at32ap/cpu.h
index a762f42cbb71..44d0bfa1f409 100644
--- a/include/asm-avr32/arch-at32ap/cpu.h
+++ b/include/asm-avr32/arch-at32ap/cpu.h
@@ -14,7 +14,7 @@
14 * Only AT32AP7000 is defined for now. We can identify the specific 14 * Only AT32AP7000 is defined for now. We can identify the specific
15 * chip at runtime, but I'm not sure if it's really worth it. 15 * chip at runtime, but I'm not sure if it's really worth it.
16 */ 16 */
17#ifdef CONFIG_CPU_AT32AP7000 17#ifdef CONFIG_CPU_AT32AP700X
18# define cpu_is_at32ap7000() (1) 18# define cpu_is_at32ap7000() (1)
19#else 19#else
20# define cpu_is_at32ap7000() (0) 20# define cpu_is_at32ap7000() (0)
@@ -30,5 +30,6 @@
30#define cpu_is_at91sam9261() (0) 30#define cpu_is_at91sam9261() (0)
31#define cpu_is_at91sam9263() (0) 31#define cpu_is_at91sam9263() (0)
32#define cpu_is_at91sam9rl() (0) 32#define cpu_is_at91sam9rl() (0)
33#define cpu_is_at91cap9() (0)
33 34
34#endif /* __ASM_ARCH_CPU_H */ 35#endif /* __ASM_ARCH_CPU_H */
diff --git a/include/asm-avr32/arch-at32ap/io.h b/include/asm-avr32/arch-at32ap/io.h
index ee59e401f041..4ec6abc68ea3 100644
--- a/include/asm-avr32/arch-at32ap/io.h
+++ b/include/asm-avr32/arch-at32ap/io.h
@@ -4,7 +4,7 @@
4/* For "bizarre" halfword swapping */ 4/* For "bizarre" halfword swapping */
5#include <linux/byteorder/swabb.h> 5#include <linux/byteorder/swabb.h>
6 6
7#if defined(CONFIG_AP7000_32_BIT_SMC) 7#if defined(CONFIG_AP700X_32_BIT_SMC)
8# define __swizzle_addr_b(addr) (addr ^ 3UL) 8# define __swizzle_addr_b(addr) (addr ^ 3UL)
9# define __swizzle_addr_w(addr) (addr ^ 2UL) 9# define __swizzle_addr_w(addr) (addr ^ 2UL)
10# define __swizzle_addr_l(addr) (addr) 10# define __swizzle_addr_l(addr) (addr)
@@ -14,7 +14,7 @@
14# define __mem_ioswabb(a, x) (x) 14# define __mem_ioswabb(a, x) (x)
15# define __mem_ioswabw(a, x) swab16(x) 15# define __mem_ioswabw(a, x) swab16(x)
16# define __mem_ioswabl(a, x) swab32(x) 16# define __mem_ioswabl(a, x) swab32(x)
17#elif defined(CONFIG_AP7000_16_BIT_SMC) 17#elif defined(CONFIG_AP700X_16_BIT_SMC)
18# define __swizzle_addr_b(addr) (addr ^ 1UL) 18# define __swizzle_addr_b(addr) (addr ^ 1UL)
19# define __swizzle_addr_w(addr) (addr) 19# define __swizzle_addr_w(addr) (addr)
20# define __swizzle_addr_l(addr) (addr) 20# define __swizzle_addr_l(addr) (addr)
diff --git a/include/asm-avr32/cacheflush.h b/include/asm-avr32/cacheflush.h
index dfaaa88cd412..670674749b20 100644
--- a/include/asm-avr32/cacheflush.h
+++ b/include/asm-avr32/cacheflush.h
@@ -116,15 +116,16 @@ extern void flush_icache_page(struct vm_area_struct *vma, struct page *page);
116 * flush with all configurations. 116 * flush with all configurations.
117 */ 117 */
118extern void flush_icache_range(unsigned long start, unsigned long end); 118extern void flush_icache_range(unsigned long start, unsigned long end);
119extern void flush_icache_user_range(struct vm_area_struct *vma,
120 struct page *page,
121 unsigned long addr, int len);
122 119
123#define copy_to_user_page(vma, page, vaddr, dst, src, len) do { \ 120extern void copy_to_user_page(struct vm_area_struct *vma, struct page *page,
124 memcpy(dst, src, len); \ 121 unsigned long vaddr, void *dst, const void *src,
125 flush_icache_user_range(vma, page, vaddr, len); \ 122 unsigned long len);
126} while(0) 123
127#define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 124static inline void copy_from_user_page(struct vm_area_struct *vma,
128 memcpy(dst, src, len) 125 struct page *page, unsigned long vaddr, void *dst,
126 const void *src, unsigned long len)
127{
128 memcpy(dst, src, len);
129}
129 130
130#endif /* __ASM_AVR32_CACHEFLUSH_H */ 131#endif /* __ASM_AVR32_CACHEFLUSH_H */
diff --git a/include/asm-avr32/irq.h b/include/asm-avr32/irq.h
index 83e6549d7783..9315724c0596 100644
--- a/include/asm-avr32/irq.h
+++ b/include/asm-avr32/irq.h
@@ -11,4 +11,9 @@
11 11
12#define irq_canonicalize(i) (i) 12#define irq_canonicalize(i) (i)
13 13
14#ifndef __ASSEMBLER__
15int nmi_enable(void);
16void nmi_disable(void);
17#endif
18
14#endif /* __ASM_AVR32_IOCTLS_H */ 19#endif /* __ASM_AVR32_IOCTLS_H */
diff --git a/include/asm-avr32/kdebug.h b/include/asm-avr32/kdebug.h
index fd7e99046b2f..ca4f9542365a 100644
--- a/include/asm-avr32/kdebug.h
+++ b/include/asm-avr32/kdebug.h
@@ -5,6 +5,7 @@
5enum die_val { 5enum die_val {
6 DIE_BREAKPOINT, 6 DIE_BREAKPOINT,
7 DIE_SSTEP, 7 DIE_SSTEP,
8 DIE_NMI,
8}; 9};
9 10
10#endif /* __ASM_AVR32_KDEBUG_H */ 11#endif /* __ASM_AVR32_KDEBUG_H */
diff --git a/include/asm-avr32/ocd.h b/include/asm-avr32/ocd.h
index 46f73180a127..6bef09490235 100644
--- a/include/asm-avr32/ocd.h
+++ b/include/asm-avr32/ocd.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * AVR32 OCD Registers 2 * AVR32 OCD Interface and register definitions
3 * 3 *
4 * Copyright (C) 2004-2006 Atmel Corporation 4 * Copyright (C) 2004-2007 Atmel Corporation
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
@@ -10,69 +10,534 @@
10#ifndef __ASM_AVR32_OCD_H 10#ifndef __ASM_AVR32_OCD_H
11#define __ASM_AVR32_OCD_H 11#define __ASM_AVR32_OCD_H
12 12
13/* Debug Registers */ 13/* OCD Register offsets. Abbreviations used below:
14#define DBGREG_DID 0 14 *
15#define DBGREG_DC 8 15 * BP Breakpoint
16#define DBGREG_DS 16 16 * Comm Communication
17#define DBGREG_RWCS 28 17 * DT Data Trace
18#define DBGREG_RWA 36 18 * PC Program Counter
19#define DBGREG_RWD 40 19 * PID Process ID
20#define DBGREG_WT 44 20 * R/W Read/Write
21#define DBGREG_DTC 52 21 * WP Watchpoint
22#define DBGREG_DTSA0 56 22 */
23#define DBGREG_DTSA1 60 23#define OCD_DID 0x0000 /* Device ID */
24#define DBGREG_DTEA0 72 24#define OCD_DC 0x0008 /* Development Control */
25#define DBGREG_DTEA1 76 25#define OCD_DS 0x0010 /* Development Status */
26#define DBGREG_BWC0A 88 26#define OCD_RWCS 0x001c /* R/W Access Control */
27#define DBGREG_BWC0B 92 27#define OCD_RWA 0x0024 /* R/W Access Address */
28#define DBGREG_BWC1A 96 28#define OCD_RWD 0x0028 /* R/W Access Data */
29#define DBGREG_BWC1B 100 29#define OCD_WT 0x002c /* Watchpoint Trigger */
30#define DBGREG_BWC2A 104 30#define OCD_DTC 0x0034 /* Data Trace Control */
31#define DBGREG_BWC2B 108 31#define OCD_DTSA0 0x0038 /* DT Start Addr Channel 0 */
32#define DBGREG_BWC3A 112 32#define OCD_DTSA1 0x003c /* DT Start Addr Channel 1 */
33#define DBGREG_BWC3B 116 33#define OCD_DTEA0 0x0048 /* DT End Addr Channel 0 */
34#define DBGREG_BWA0A 120 34#define OCD_DTEA1 0x004c /* DT End Addr Channel 1 */
35#define DBGREG_BWA0B 124 35#define OCD_BWC0A 0x0058 /* PC BP/WP Control 0A */
36#define DBGREG_BWA1A 128 36#define OCD_BWC0B 0x005c /* PC BP/WP Control 0B */
37#define DBGREG_BWA1B 132 37#define OCD_BWC1A 0x0060 /* PC BP/WP Control 1A */
38#define DBGREG_BWA2A 136 38#define OCD_BWC1B 0x0064 /* PC BP/WP Control 1B */
39#define DBGREG_BWA2B 140 39#define OCD_BWC2A 0x0068 /* PC BP/WP Control 2A */
40#define DBGREG_BWA3A 144 40#define OCD_BWC2B 0x006c /* PC BP/WP Control 2B */
41#define DBGREG_BWA3B 148 41#define OCD_BWC3A 0x0070 /* Data BP/WP Control 3A */
42#define DBGREG_BWD3A 153 42#define OCD_BWC3B 0x0074 /* Data BP/WP Control 3B */
43#define DBGREG_BWD3B 156 43#define OCD_BWA0A 0x0078 /* PC BP/WP Address 0A */
44 44#define OCD_BWA0B 0x007c /* PC BP/WP Address 0B */
45#define DBGREG_PID 284 45#define OCD_BWA1A 0x0080 /* PC BP/WP Address 1A */
46 46#define OCD_BWA1B 0x0084 /* PC BP/WP Address 1B */
47#define SABAH_OCD 0x01 47#define OCD_BWA2A 0x0088 /* PC BP/WP Address 2A */
48#define SABAH_ICACHE 0x02 48#define OCD_BWA2B 0x008c /* PC BP/WP Address 2B */
49#define SABAH_MEM_CACHED 0x04 49#define OCD_BWA3A 0x0090 /* Data BP/WP Address 3A */
50#define SABAH_MEM_UNCACHED 0x05 50#define OCD_BWA3B 0x0094 /* Data BP/WP Address 3B */
51 51#define OCD_NXCFG 0x0100 /* Nexus Configuration */
52/* Fields in the Development Control register */ 52#define OCD_DINST 0x0104 /* Debug Instruction */
53#define DC_SS_BIT 8 53#define OCD_DPC 0x0108 /* Debug Program Counter */
54 54#define OCD_CPUCM 0x010c /* CPU Control Mask */
55#define DC_SS (1 << DC_SS_BIT) 55#define OCD_DCCPU 0x0110 /* Debug Comm CPU */
56#define DC_DBE (1 << 13) 56#define OCD_DCEMU 0x0114 /* Debug Comm Emulator */
57#define DC_RID (1 << 27) 57#define OCD_DCSR 0x0118 /* Debug Comm Status */
58#define DC_ORP (1 << 28) 58#define OCD_PID 0x011c /* Ownership Trace PID */
59#define DC_MM (1 << 29) 59#define OCD_EPC0 0x0120 /* Event Pair Control 0 */
60#define DC_RES (1 << 30) 60#define OCD_EPC1 0x0124 /* Event Pair Control 1 */
61 61#define OCD_EPC2 0x0128 /* Event Pair Control 2 */
62/* Fields in the Development Status register */ 62#define OCD_EPC3 0x012c /* Event Pair Control 3 */
63#define DS_SSS (1 << 0) 63#define OCD_AXC 0x0130 /* AUX port Control */
64#define DS_SWB (1 << 1) 64
65#define DS_HWB (1 << 2) 65/* Bits in DID */
66#define DS_BP_SHIFT 8 66#define OCD_DID_MID_START 1
67#define DS_BP_MASK (0xff << DS_BP_SHIFT) 67#define OCD_DID_MID_SIZE 11
68 68#define OCD_DID_PN_START 12
69#define __mfdr(addr) \ 69#define OCD_DID_PN_SIZE 16
70({ \ 70#define OCD_DID_RN_START 28
71 register unsigned long value; \ 71#define OCD_DID_RN_SIZE 4
72 asm volatile("mfdr %0, %1" : "=r"(value) : "i"(addr)); \ 72
73 value; \ 73/* Bits in DC */
74}) 74#define OCD_DC_TM_START 0
75#define __mtdr(addr, value) \ 75#define OCD_DC_TM_SIZE 2
76 asm volatile("mtdr %0, %1" : : "i"(addr), "r"(value)) 76#define OCD_DC_EIC_START 3
77#define OCD_DC_EIC_SIZE 2
78#define OCD_DC_OVC_START 5
79#define OCD_DC_OVC_SIZE 3
80#define OCD_DC_SS_BIT 8
81#define OCD_DC_DBR_BIT 12
82#define OCD_DC_DBE_BIT 13
83#define OCD_DC_EOS_START 20
84#define OCD_DC_EOS_SIZE 2
85#define OCD_DC_SQA_BIT 22
86#define OCD_DC_IRP_BIT 23
87#define OCD_DC_IFM_BIT 24
88#define OCD_DC_TOZ_BIT 25
89#define OCD_DC_TSR_BIT 26
90#define OCD_DC_RID_BIT 27
91#define OCD_DC_ORP_BIT 28
92#define OCD_DC_MM_BIT 29
93#define OCD_DC_RES_BIT 30
94#define OCD_DC_ABORT_BIT 31
95
96/* Bits in DS */
97#define OCD_DS_SSS_BIT 0
98#define OCD_DS_SWB_BIT 1
99#define OCD_DS_HWB_BIT 2
100#define OCD_DS_HWE_BIT 3
101#define OCD_DS_STP_BIT 4
102#define OCD_DS_DBS_BIT 5
103#define OCD_DS_BP_START 8
104#define OCD_DS_BP_SIZE 8
105#define OCD_DS_INC_BIT 24
106#define OCD_DS_BOZ_BIT 25
107#define OCD_DS_DBA_BIT 26
108#define OCD_DS_EXB_BIT 27
109#define OCD_DS_NTBF_BIT 28
110
111/* Bits in RWCS */
112#define OCD_RWCS_DV_BIT 0
113#define OCD_RWCS_ERR_BIT 1
114#define OCD_RWCS_CNT_START 2
115#define OCD_RWCS_CNT_SIZE 14
116#define OCD_RWCS_CRC_BIT 19
117#define OCD_RWCS_NTBC_START 20
118#define OCD_RWCS_NTBC_SIZE 2
119#define OCD_RWCS_NTE_BIT 22
120#define OCD_RWCS_NTAP_BIT 23
121#define OCD_RWCS_WRAPPED_BIT 24
122#define OCD_RWCS_CCTRL_START 25
123#define OCD_RWCS_CCTRL_SIZE 2
124#define OCD_RWCS_SZ_START 27
125#define OCD_RWCS_SZ_SIZE 3
126#define OCD_RWCS_RW_BIT 30
127#define OCD_RWCS_AC_BIT 31
128
129/* Bits in RWA */
130#define OCD_RWA_RWA_START 0
131#define OCD_RWA_RWA_SIZE 32
132
133/* Bits in RWD */
134#define OCD_RWD_RWD_START 0
135#define OCD_RWD_RWD_SIZE 32
136
137/* Bits in WT */
138#define OCD_WT_DTE_START 20
139#define OCD_WT_DTE_SIZE 3
140#define OCD_WT_DTS_START 23
141#define OCD_WT_DTS_SIZE 3
142#define OCD_WT_PTE_START 26
143#define OCD_WT_PTE_SIZE 3
144#define OCD_WT_PTS_START 29
145#define OCD_WT_PTS_SIZE 3
146
147/* Bits in DTC */
148#define OCD_DTC_T0WP_BIT 0
149#define OCD_DTC_T1WP_BIT 1
150#define OCD_DTC_ASID0EN_BIT 2
151#define OCD_DTC_ASID0_START 3
152#define OCD_DTC_ASID0_SIZE 8
153#define OCD_DTC_ASID1EN_BIT 11
154#define OCD_DTC_ASID1_START 12
155#define OCD_DTC_ASID1_SIZE 8
156#define OCD_DTC_RWT1_START 28
157#define OCD_DTC_RWT1_SIZE 2
158#define OCD_DTC_RWT0_START 30
159#define OCD_DTC_RWT0_SIZE 2
160
161/* Bits in DTSA0 */
162#define OCD_DTSA0_DTSA_START 0
163#define OCD_DTSA0_DTSA_SIZE 32
164
165/* Bits in DTSA1 */
166#define OCD_DTSA1_DTSA_START 0
167#define OCD_DTSA1_DTSA_SIZE 32
168
169/* Bits in DTEA0 */
170#define OCD_DTEA0_DTEA_START 0
171#define OCD_DTEA0_DTEA_SIZE 32
172
173/* Bits in DTEA1 */
174#define OCD_DTEA1_DTEA_START 0
175#define OCD_DTEA1_DTEA_SIZE 32
176
177/* Bits in BWC0A */
178#define OCD_BWC0A_ASIDEN_BIT 0
179#define OCD_BWC0A_ASID_START 1
180#define OCD_BWC0A_ASID_SIZE 8
181#define OCD_BWC0A_EOC_BIT 14
182#define OCD_BWC0A_AME_BIT 25
183#define OCD_BWC0A_BWE_START 30
184#define OCD_BWC0A_BWE_SIZE 2
185
186/* Bits in BWC0B */
187#define OCD_BWC0B_ASIDEN_BIT 0
188#define OCD_BWC0B_ASID_START 1
189#define OCD_BWC0B_ASID_SIZE 8
190#define OCD_BWC0B_EOC_BIT 14
191#define OCD_BWC0B_AME_BIT 25
192#define OCD_BWC0B_BWE_START 30
193#define OCD_BWC0B_BWE_SIZE 2
194
195/* Bits in BWC1A */
196#define OCD_BWC1A_ASIDEN_BIT 0
197#define OCD_BWC1A_ASID_START 1
198#define OCD_BWC1A_ASID_SIZE 8
199#define OCD_BWC1A_EOC_BIT 14
200#define OCD_BWC1A_AME_BIT 25
201#define OCD_BWC1A_BWE_START 30
202#define OCD_BWC1A_BWE_SIZE 2
203
204/* Bits in BWC1B */
205#define OCD_BWC1B_ASIDEN_BIT 0
206#define OCD_BWC1B_ASID_START 1
207#define OCD_BWC1B_ASID_SIZE 8
208#define OCD_BWC1B_EOC_BIT 14
209#define OCD_BWC1B_AME_BIT 25
210#define OCD_BWC1B_BWE_START 30
211#define OCD_BWC1B_BWE_SIZE 2
212
213/* Bits in BWC2A */
214#define OCD_BWC2A_ASIDEN_BIT 0
215#define OCD_BWC2A_ASID_START 1
216#define OCD_BWC2A_ASID_SIZE 8
217#define OCD_BWC2A_EOC_BIT 14
218#define OCD_BWC2A_AMB_START 20
219#define OCD_BWC2A_AMB_SIZE 5
220#define OCD_BWC2A_AME_BIT 25
221#define OCD_BWC2A_BWE_START 30
222#define OCD_BWC2A_BWE_SIZE 2
223
224/* Bits in BWC2B */
225#define OCD_BWC2B_ASIDEN_BIT 0
226#define OCD_BWC2B_ASID_START 1
227#define OCD_BWC2B_ASID_SIZE 8
228#define OCD_BWC2B_EOC_BIT 14
229#define OCD_BWC2B_AME_BIT 25
230#define OCD_BWC2B_BWE_START 30
231#define OCD_BWC2B_BWE_SIZE 2
232
233/* Bits in BWC3A */
234#define OCD_BWC3A_ASIDEN_BIT 0
235#define OCD_BWC3A_ASID_START 1
236#define OCD_BWC3A_ASID_SIZE 8
237#define OCD_BWC3A_SIZE_START 9
238#define OCD_BWC3A_SIZE_SIZE 3
239#define OCD_BWC3A_EOC_BIT 14
240#define OCD_BWC3A_BWO_START 16
241#define OCD_BWC3A_BWO_SIZE 2
242#define OCD_BWC3A_BME_START 20
243#define OCD_BWC3A_BME_SIZE 4
244#define OCD_BWC3A_BRW_START 28
245#define OCD_BWC3A_BRW_SIZE 2
246#define OCD_BWC3A_BWE_START 30
247#define OCD_BWC3A_BWE_SIZE 2
248
249/* Bits in BWC3B */
250#define OCD_BWC3B_ASIDEN_BIT 0
251#define OCD_BWC3B_ASID_START 1
252#define OCD_BWC3B_ASID_SIZE 8
253#define OCD_BWC3B_SIZE_START 9
254#define OCD_BWC3B_SIZE_SIZE 3
255#define OCD_BWC3B_EOC_BIT 14
256#define OCD_BWC3B_BWO_START 16
257#define OCD_BWC3B_BWO_SIZE 2
258#define OCD_BWC3B_BME_START 20
259#define OCD_BWC3B_BME_SIZE 4
260#define OCD_BWC3B_BRW_START 28
261#define OCD_BWC3B_BRW_SIZE 2
262#define OCD_BWC3B_BWE_START 30
263#define OCD_BWC3B_BWE_SIZE 2
264
265/* Bits in BWA0A */
266#define OCD_BWA0A_BWA_START 0
267#define OCD_BWA0A_BWA_SIZE 32
268
269/* Bits in BWA0B */
270#define OCD_BWA0B_BWA_START 0
271#define OCD_BWA0B_BWA_SIZE 32
272
273/* Bits in BWA1A */
274#define OCD_BWA1A_BWA_START 0
275#define OCD_BWA1A_BWA_SIZE 32
276
277/* Bits in BWA1B */
278#define OCD_BWA1B_BWA_START 0
279#define OCD_BWA1B_BWA_SIZE 32
280
281/* Bits in BWA2A */
282#define OCD_BWA2A_BWA_START 0
283#define OCD_BWA2A_BWA_SIZE 32
284
285/* Bits in BWA2B */
286#define OCD_BWA2B_BWA_START 0
287#define OCD_BWA2B_BWA_SIZE 32
288
289/* Bits in BWA3A */
290#define OCD_BWA3A_BWA_START 0
291#define OCD_BWA3A_BWA_SIZE 32
292
293/* Bits in BWA3B */
294#define OCD_BWA3B_BWA_START 0
295#define OCD_BWA3B_BWA_SIZE 32
296
297/* Bits in NXCFG */
298#define OCD_NXCFG_NXARCH_START 0
299#define OCD_NXCFG_NXARCH_SIZE 4
300#define OCD_NXCFG_NXOCD_START 4
301#define OCD_NXCFG_NXOCD_SIZE 4
302#define OCD_NXCFG_NXPCB_START 8
303#define OCD_NXCFG_NXPCB_SIZE 4
304#define OCD_NXCFG_NXDB_START 12
305#define OCD_NXCFG_NXDB_SIZE 4
306#define OCD_NXCFG_MXMSEO_BIT 16
307#define OCD_NXCFG_NXMDO_START 17
308#define OCD_NXCFG_NXMDO_SIZE 4
309#define OCD_NXCFG_NXPT_BIT 21
310#define OCD_NXCFG_NXOT_BIT 22
311#define OCD_NXCFG_NXDWT_BIT 23
312#define OCD_NXCFG_NXDRT_BIT 24
313#define OCD_NXCFG_NXDTC_START 25
314#define OCD_NXCFG_NXDTC_SIZE 3
315#define OCD_NXCFG_NXDMA_BIT 28
316
317/* Bits in DINST */
318#define OCD_DINST_DINST_START 0
319#define OCD_DINST_DINST_SIZE 32
320
321/* Bits in CPUCM */
322#define OCD_CPUCM_BEM_BIT 1
323#define OCD_CPUCM_FEM_BIT 2
324#define OCD_CPUCM_REM_BIT 3
325#define OCD_CPUCM_IBEM_BIT 4
326#define OCD_CPUCM_IEEM_BIT 5
327
328/* Bits in DCCPU */
329#define OCD_DCCPU_DATA_START 0
330#define OCD_DCCPU_DATA_SIZE 32
331
332/* Bits in DCEMU */
333#define OCD_DCEMU_DATA_START 0
334#define OCD_DCEMU_DATA_SIZE 32
335
336/* Bits in DCSR */
337#define OCD_DCSR_CPUD_BIT 0
338#define OCD_DCSR_EMUD_BIT 1
339
340/* Bits in PID */
341#define OCD_PID_PROCESS_START 0
342#define OCD_PID_PROCESS_SIZE 32
343
344/* Bits in EPC0 */
345#define OCD_EPC0_RNG_START 0
346#define OCD_EPC0_RNG_SIZE 2
347#define OCD_EPC0_CE_BIT 4
348#define OCD_EPC0_ECNT_START 16
349#define OCD_EPC0_ECNT_SIZE 16
350
351/* Bits in EPC1 */
352#define OCD_EPC1_RNG_START 0
353#define OCD_EPC1_RNG_SIZE 2
354#define OCD_EPC1_ATB_BIT 5
355#define OCD_EPC1_AM_BIT 6
356
357/* Bits in EPC2 */
358#define OCD_EPC2_RNG_START 0
359#define OCD_EPC2_RNG_SIZE 2
360#define OCD_EPC2_DB_START 2
361#define OCD_EPC2_DB_SIZE 2
362
363/* Bits in EPC3 */
364#define OCD_EPC3_RNG_START 0
365#define OCD_EPC3_RNG_SIZE 2
366#define OCD_EPC3_DWE_BIT 2
367
368/* Bits in AXC */
369#define OCD_AXC_DIV_START 0
370#define OCD_AXC_DIV_SIZE 4
371#define OCD_AXC_AXE_BIT 8
372#define OCD_AXC_AXS_BIT 9
373#define OCD_AXC_DDR_BIT 10
374#define OCD_AXC_LS_BIT 11
375#define OCD_AXC_REX_BIT 12
376#define OCD_AXC_REXTEN_BIT 13
377
378/* Constants for DC:EIC */
379#define OCD_EIC_PROGRAM_AND_DATA_TRACE 0
380#define OCD_EIC_BREAKPOINT 1
381#define OCD_EIC_NOP 2
382
383/* Constants for DC:OVC */
384#define OCD_OVC_OVERRUN 0
385#define OCD_OVC_DELAY_CPU_BTM 1
386#define OCD_OVC_DELAY_CPU_DTM 2
387#define OCD_OVC_DELAY_CPU_BTM_DTM 3
388
389/* Constants for DC:EOS */
390#define OCD_EOS_NOP 0
391#define OCD_EOS_DEBUG_MODE 1
392#define OCD_EOS_BREAKPOINT_WATCHPOINT 2
393#define OCD_EOS_THQ 3
394
395/* Constants for RWCS:NTBC */
396#define OCD_NTBC_OVERWRITE 0
397#define OCD_NTBC_DISABLE 1
398#define OCD_NTBC_BREAKPOINT 2
399
400/* Constants for RWCS:CCTRL */
401#define OCD_CCTRL_AUTO 0
402#define OCD_CCTRL_CACHED 1
403#define OCD_CCTRL_UNCACHED 2
404
405/* Constants for RWCS:SZ */
406#define OCD_SZ_BYTE 0
407#define OCD_SZ_HALFWORD 1
408#define OCD_SZ_WORD 2
409
410/* Constants for WT:PTS */
411#define OCD_PTS_DISABLED 0
412#define OCD_PTS_PROGRAM_0B 1
413#define OCD_PTS_PROGRAM_1A 2
414#define OCD_PTS_PROGRAM_1B 3
415#define OCD_PTS_PROGRAM_2A 4
416#define OCD_PTS_PROGRAM_2B 5
417#define OCD_PTS_DATA_3A 6
418#define OCD_PTS_DATA_3B 7
419
420/* Constants for DTC:RWT1 */
421#define OCD_RWT1_NO_TRACE 0
422#define OCD_RWT1_DATA_READ 1
423#define OCD_RWT1_DATA_WRITE 2
424#define OCD_RWT1_DATA_READ_WRITE 3
425
426/* Constants for DTC:RWT0 */
427#define OCD_RWT0_NO_TRACE 0
428#define OCD_RWT0_DATA_READ 1
429#define OCD_RWT0_DATA_WRITE 2
430#define OCD_RWT0_DATA_READ_WRITE 3
431
432/* Constants for BWC0A:BWE */
433#define OCD_BWE_DISABLED 0
434#define OCD_BWE_BREAKPOINT_ENABLED 1
435#define OCD_BWE_WATCHPOINT_ENABLED 3
436
437/* Constants for BWC0B:BWE */
438#define OCD_BWE_DISABLED 0
439#define OCD_BWE_BREAKPOINT_ENABLED 1
440#define OCD_BWE_WATCHPOINT_ENABLED 3
441
442/* Constants for BWC1A:BWE */
443#define OCD_BWE_DISABLED 0
444#define OCD_BWE_BREAKPOINT_ENABLED 1
445#define OCD_BWE_WATCHPOINT_ENABLED 3
446
447/* Constants for BWC1B:BWE */
448#define OCD_BWE_DISABLED 0
449#define OCD_BWE_BREAKPOINT_ENABLED 1
450#define OCD_BWE_WATCHPOINT_ENABLED 3
451
452/* Constants for BWC2A:BWE */
453#define OCD_BWE_DISABLED 0
454#define OCD_BWE_BREAKPOINT_ENABLED 1
455#define OCD_BWE_WATCHPOINT_ENABLED 3
456
457/* Constants for BWC2B:BWE */
458#define OCD_BWE_DISABLED 0
459#define OCD_BWE_BREAKPOINT_ENABLED 1
460#define OCD_BWE_WATCHPOINT_ENABLED 3
461
462/* Constants for BWC3A:SIZE */
463#define OCD_SIZE_BYTE_ACCESS 4
464#define OCD_SIZE_HALFWORD_ACCESS 5
465#define OCD_SIZE_WORD_ACCESS 6
466#define OCD_SIZE_DOUBLE_WORD_ACCESS 7
467
468/* Constants for BWC3A:BRW */
469#define OCD_BRW_READ_BREAK 0
470#define OCD_BRW_WRITE_BREAK 1
471#define OCD_BRW_ANY_ACCES_BREAK 2
472
473/* Constants for BWC3A:BWE */
474#define OCD_BWE_DISABLED 0
475#define OCD_BWE_BREAKPOINT_ENABLED 1
476#define OCD_BWE_WATCHPOINT_ENABLED 3
477
478/* Constants for BWC3B:SIZE */
479#define OCD_SIZE_BYTE_ACCESS 4
480#define OCD_SIZE_HALFWORD_ACCESS 5
481#define OCD_SIZE_WORD_ACCESS 6
482#define OCD_SIZE_DOUBLE_WORD_ACCESS 7
483
484/* Constants for BWC3B:BRW */
485#define OCD_BRW_READ_BREAK 0
486#define OCD_BRW_WRITE_BREAK 1
487#define OCD_BRW_ANY_ACCES_BREAK 2
488
489/* Constants for BWC3B:BWE */
490#define OCD_BWE_DISABLED 0
491#define OCD_BWE_BREAKPOINT_ENABLED 1
492#define OCD_BWE_WATCHPOINT_ENABLED 3
493
494/* Constants for EPC0:RNG */
495#define OCD_RNG_DISABLED 0
496#define OCD_RNG_EXCLUSIVE 1
497#define OCD_RNG_INCLUSIVE 2
498
499/* Constants for EPC1:RNG */
500#define OCD_RNG_DISABLED 0
501#define OCD_RNG_EXCLUSIVE 1
502#define OCD_RNG_INCLUSIVE 2
503
504/* Constants for EPC2:RNG */
505#define OCD_RNG_DISABLED 0
506#define OCD_RNG_EXCLUSIVE 1
507#define OCD_RNG_INCLUSIVE 2
508
509/* Constants for EPC2:DB */
510#define OCD_DB_DISABLED 0
511#define OCD_DB_CHAINED_B 1
512#define OCD_DB_CHAINED_A 2
513#define OCD_DB_AHAINED_A_AND_B 3
514
515/* Constants for EPC3:RNG */
516#define OCD_RNG_DISABLED 0
517#define OCD_RNG_EXCLUSIVE 1
518#define OCD_RNG_INCLUSIVE 2
519
520#ifndef __ASSEMBLER__
521
522/* Register access macros */
523static inline unsigned long __ocd_read(unsigned int reg)
524{
525 return __builtin_mfdr(reg);
526}
527
528static inline void __ocd_write(unsigned int reg, unsigned long value)
529{
530 __builtin_mtdr(reg, value);
531}
532
533#define ocd_read(reg) __ocd_read(OCD_##reg)
534#define ocd_write(reg, value) __ocd_write(OCD_##reg, value)
535
536struct task_struct;
537
538void ocd_enable(struct task_struct *child);
539void ocd_disable(struct task_struct *child);
540
541#endif /* !__ASSEMBLER__ */
77 542
78#endif /* __ASM_AVR32_OCD_H */ 543#endif /* __ASM_AVR32_OCD_H */
diff --git a/include/asm-avr32/processor.h b/include/asm-avr32/processor.h
index 6a64833756a6..4212551c1cd9 100644
--- a/include/asm-avr32/processor.h
+++ b/include/asm-avr32/processor.h
@@ -57,11 +57,25 @@ struct avr32_cpuinfo {
57 unsigned short cpu_revision; 57 unsigned short cpu_revision;
58 enum tlb_config tlb_config; 58 enum tlb_config tlb_config;
59 unsigned long features; 59 unsigned long features;
60 u32 device_id;
60 61
61 struct cache_info icache; 62 struct cache_info icache;
62 struct cache_info dcache; 63 struct cache_info dcache;
63}; 64};
64 65
66static inline unsigned int avr32_get_manufacturer_id(struct avr32_cpuinfo *cpu)
67{
68 return (cpu->device_id >> 1) & 0x7f;
69}
70static inline unsigned int avr32_get_product_number(struct avr32_cpuinfo *cpu)
71{
72 return (cpu->device_id >> 12) & 0xffff;
73}
74static inline unsigned int avr32_get_chip_revision(struct avr32_cpuinfo *cpu)
75{
76 return (cpu->device_id >> 28) & 0x0f;
77}
78
65extern struct avr32_cpuinfo boot_cpu_data; 79extern struct avr32_cpuinfo boot_cpu_data;
66 80
67#ifdef CONFIG_SMP 81#ifdef CONFIG_SMP
@@ -139,6 +153,9 @@ extern void show_regs_log_lvl(struct pt_regs *regs, const char *log_lvl);
139extern void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp, 153extern void show_stack_log_lvl(struct task_struct *tsk, unsigned long sp,
140 struct pt_regs *regs, const char *log_lvl); 154 struct pt_regs *regs, const char *log_lvl);
141 155
156#define task_pt_regs(p) \
157 ((struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1)
158
142#define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc) 159#define KSTK_EIP(tsk) ((tsk)->thread.cpu_context.pc)
143#define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp) 160#define KSTK_ESP(tsk) ((tsk)->thread.cpu_context.ksp)
144 161
diff --git a/include/asm-avr32/ptrace.h b/include/asm-avr32/ptrace.h
index 60f0f19a81f1..9e2d44f4e0fe 100644
--- a/include/asm-avr32/ptrace.h
+++ b/include/asm-avr32/ptrace.h
@@ -14,8 +14,7 @@
14/* 14/*
15 * Status Register bits 15 * Status Register bits
16 */ 16 */
17#define SR_H 0x40000000 17#define SR_H 0x20000000
18#define SR_R 0x20000000
19#define SR_J 0x10000000 18#define SR_J 0x10000000
20#define SR_DM 0x08000000 19#define SR_DM 0x08000000
21#define SR_D 0x04000000 20#define SR_D 0x04000000
@@ -35,8 +34,7 @@
35#define SR_I0M 0x00020000 34#define SR_I0M 0x00020000
36#define SR_GM 0x00010000 35#define SR_GM 0x00010000
37 36
38#define SR_H_BIT 30 37#define SR_H_BIT 29
39#define SR_R_BIT 29
40#define SR_J_BIT 28 38#define SR_J_BIT 28
41#define SR_DM_BIT 27 39#define SR_DM_BIT 27
42#define SR_D_BIT 26 40#define SR_D_BIT 26
@@ -123,7 +121,15 @@ struct pt_regs {
123}; 121};
124 122
125#ifdef __KERNEL__ 123#ifdef __KERNEL__
126# define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER) 124
125#include <asm/ocd.h>
126
127#define arch_ptrace_attach(child) ocd_enable(child)
128
129#define user_mode(regs) (((regs)->sr & MODE_MASK) == MODE_USER)
130#define instruction_pointer(regs) ((regs)->pc)
131#define profile_pc(regs) instruction_pointer(regs)
132
127extern void show_regs (struct pt_regs *); 133extern void show_regs (struct pt_regs *);
128 134
129static __inline__ int valid_user_regs(struct pt_regs *regs) 135static __inline__ int valid_user_regs(struct pt_regs *regs)
@@ -143,9 +149,6 @@ static __inline__ int valid_user_regs(struct pt_regs *regs)
143 return 0; 149 return 0;
144} 150}
145 151
146#define instruction_pointer(regs) ((regs)->pc)
147
148#define profile_pc(regs) instruction_pointer(regs)
149 152
150#endif /* __KERNEL__ */ 153#endif /* __KERNEL__ */
151 154
diff --git a/include/asm-avr32/setup.h b/include/asm-avr32/setup.h
index b0828d43e110..ea3070ff13a5 100644
--- a/include/asm-avr32/setup.h
+++ b/include/asm-avr32/setup.h
@@ -110,7 +110,7 @@ struct tagtable {
110 int (*parse)(struct tag *); 110 int (*parse)(struct tag *);
111}; 111};
112 112
113#define __tag __attribute_used__ __attribute__((__section__(".taglist.init"))) 113#define __tag __used __attribute__((__section__(".taglist.init")))
114#define __tagtable(tag, fn) \ 114#define __tagtable(tag, fn) \
115 static struct tagtable __tagtable_##fn __tag = { tag, fn } 115 static struct tagtable __tagtable_##fn __tag = { tag, fn }
116 116
diff --git a/include/asm-avr32/socket.h b/include/asm-avr32/socket.h
index a0d0507a5034..35863f260929 100644
--- a/include/asm-avr32/socket.h
+++ b/include/asm-avr32/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* __ASM_AVR32_SOCKET_H */ 57#endif /* __ASM_AVR32_SOCKET_H */
diff --git a/include/asm-avr32/sysreg.h b/include/asm-avr32/sysreg.h
index c02bc8304b13..d4e0950170ca 100644
--- a/include/asm-avr32/sysreg.h
+++ b/include/asm-avr32/sysreg.h
@@ -93,6 +93,8 @@
93#define SYSREG_I3M_SIZE 1 93#define SYSREG_I3M_SIZE 1
94#define SYSREG_EM_OFFSET 21 94#define SYSREG_EM_OFFSET 21
95#define SYSREG_EM_SIZE 1 95#define SYSREG_EM_SIZE 1
96#define SYSREG_MODE_OFFSET 22
97#define SYSREG_MODE_SIZE 3
96#define SYSREG_M0_OFFSET 22 98#define SYSREG_M0_OFFSET 22
97#define SYSREG_M0_SIZE 1 99#define SYSREG_M0_SIZE 1
98#define SYSREG_M1_OFFSET 23 100#define SYSREG_M1_OFFSET 23
@@ -215,6 +217,8 @@
215#define SYSREG_IRP_SIZE 6 217#define SYSREG_IRP_SIZE 6
216 218
217/* Bitfields in PCCR */ 219/* Bitfields in PCCR */
220#define SYSREG_PCCR_E_OFFSET 0
221#define SYSREG_PCCR_E_SIZE 1
218#define SYSREG_PCCR_R_OFFSET 1 222#define SYSREG_PCCR_R_OFFSET 1
219#define SYSREG_PCCR_R_SIZE 1 223#define SYSREG_PCCR_R_SIZE 1
220#define SYSREG_PCCR_C_OFFSET 2 224#define SYSREG_PCCR_C_OFFSET 2
diff --git a/include/asm-avr32/system.h b/include/asm-avr32/system.h
index dc2d527cef41..c600cc15cbcb 100644
--- a/include/asm-avr32/system.h
+++ b/include/asm-avr32/system.h
@@ -35,8 +35,8 @@
35#include <asm/ocd.h> 35#include <asm/ocd.h>
36#define finish_arch_switch(prev) \ 36#define finish_arch_switch(prev) \
37 do { \ 37 do { \
38 __mtdr(DBGREG_PID, prev->pid); \ 38 ocd_write(PID, prev->pid); \
39 __mtdr(DBGREG_PID, current->pid); \ 39 ocd_write(PID, current->pid); \
40 } while(0) 40 } while(0)
41#endif 41#endif
42 42
diff --git a/include/asm-avr32/thread_info.h b/include/asm-avr32/thread_info.h
index 17dacf3f36d3..07049f6c0d41 100644
--- a/include/asm-avr32/thread_info.h
+++ b/include/asm-avr32/thread_info.h
@@ -25,6 +25,11 @@ struct thread_info {
25 unsigned long flags; /* low level flags */ 25 unsigned long flags; /* low level flags */
26 __u32 cpu; 26 __u32 cpu;
27 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */ 27 __s32 preempt_count; /* 0 => preemptable, <0 => BUG */
28 __u32 rar_saved; /* return address... */
29 __u32 rsr_saved; /* ...and status register
30 saved by debug handler
31 when setting up
32 trampoline */
28 struct restart_block restart_block; 33 struct restart_block restart_block;
29 __u8 supervisor_stack[0]; 34 __u8 supervisor_stack[0];
30}; 35};
@@ -78,29 +83,36 @@ static inline struct thread_info *current_thread_info(void)
78#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 83#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
79#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling 84#define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
80 TIF_NEED_RESCHED */ 85 TIF_NEED_RESCHED */
81#define TIF_BREAKPOINT 4 /* true if we should break after return */ 86#define TIF_BREAKPOINT 4 /* enter monitor mode on return */
82#define TIF_SINGLE_STEP 5 /* single step after next break */ 87#define TIF_SINGLE_STEP 5 /* single step in progress */
83#define TIF_MEMDIE 6 88#define TIF_MEMDIE 6
84#define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */ 89#define TIF_RESTORE_SIGMASK 7 /* restore signal mask in do_signal */
85#define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */ 90#define TIF_CPU_GOING_TO_SLEEP 8 /* CPU is entering sleep 0 mode */
91#define TIF_DEBUG 30 /* debugging enabled */
86#define TIF_USERSPACE 31 /* true if FS sets userspace */ 92#define TIF_USERSPACE 31 /* true if FS sets userspace */
87 93
88#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 94#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
89#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 95#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
90#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) 96#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
91#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 97#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
92#define _TIF_BREAKPOINT (1 << TIF_BREAKPOINT)
93#define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP) 98#define _TIF_SINGLE_STEP (1 << TIF_SINGLE_STEP)
94#define _TIF_MEMDIE (1 << TIF_MEMDIE) 99#define _TIF_MEMDIE (1 << TIF_MEMDIE)
95#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) 100#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
96#define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP) 101#define _TIF_CPU_GOING_TO_SLEEP (1 << TIF_CPU_GOING_TO_SLEEP)
97 102
98/* XXX: These two masks must never span more than 16 bits! */ 103/* Note: The masks below must never span more than 16 bits! */
104
99/* work to do on interrupt/exception return */ 105/* work to do on interrupt/exception return */
100#define _TIF_WORK_MASK 0x0000013e 106#define _TIF_WORK_MASK \
107 ((1 << TIF_SIGPENDING) \
108 | (1 << TIF_NEED_RESCHED) \
109 | (1 << TIF_POLLING_NRFLAG) \
110 | (1 << TIF_BREAKPOINT) \
111 | (1 << TIF_RESTORE_SIGMASK))
112
101/* work to do on any return to userspace */ 113/* work to do on any return to userspace */
102#define _TIF_ALLWORK_MASK 0x0000013f 114#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | (1 << TIF_SYSCALL_TRACE))
103/* work to do on return from debug mode */ 115/* work to do on return from debug mode */
104#define _TIF_DBGWORK_MASK 0x0000017e 116#define _TIF_DBGWORK_MASK (_TIF_WORK_MASK & ~(1 << TIF_BREAKPOINT))
105 117
106#endif /* __ASM_AVR32_THREAD_INFO_H */ 118#endif /* __ASM_AVR32_THREAD_INFO_H */
diff --git a/include/asm-blackfin/bfin-global.h b/include/asm-blackfin/bfin-global.h
index 14cb8d35924e..6ae0619d7696 100644
--- a/include/asm-blackfin/bfin-global.h
+++ b/include/asm-blackfin/bfin-global.h
@@ -50,8 +50,8 @@ extern unsigned long get_sclk(void);
50extern unsigned long sclk_to_usecs(unsigned long sclk); 50extern unsigned long sclk_to_usecs(unsigned long sclk);
51extern unsigned long usecs_to_sclk(unsigned long usecs); 51extern unsigned long usecs_to_sclk(unsigned long usecs);
52 52
53extern void dump_thread(struct pt_regs *regs, struct user *dump); 53extern void dump_bfin_process(struct pt_regs *regs);
54extern void dump_bfin_regs(struct pt_regs *fp, void *retaddr); 54extern void dump_bfin_mem(struct pt_regs *regs);
55extern void dump_bfin_trace_buffer(void); 55extern void dump_bfin_trace_buffer(void);
56 56
57extern int init_arch_irq(void); 57extern int init_arch_irq(void);
@@ -63,6 +63,7 @@ extern void bfin_dcache_init(void);
63extern int read_iloc(void); 63extern int read_iloc(void);
64extern int bfin_console_init(void); 64extern int bfin_console_init(void);
65extern asmlinkage void lower_to_irq14(void); 65extern asmlinkage void lower_to_irq14(void);
66extern asmlinkage void bfin_return_from_exception(void);
66extern void init_exception_vectors(void); 67extern void init_exception_vectors(void);
67extern void init_dma(void); 68extern void init_dma(void);
68extern void program_IAR(void); 69extern void program_IAR(void);
@@ -80,6 +81,7 @@ extern int atomic_sub32(void);
80extern int atomic_ior32(void); 81extern int atomic_ior32(void);
81extern int atomic_and32(void); 82extern int atomic_and32(void);
82extern int atomic_xor32(void); 83extern int atomic_xor32(void);
84extern void safe_user_instruction(void);
83extern void sigreturn_stub(void); 85extern void sigreturn_stub(void);
84 86
85extern void *l1_data_A_sram_alloc(size_t); 87extern void *l1_data_A_sram_alloc(size_t);
diff --git a/include/asm-blackfin/bfin5xx_spi.h b/include/asm-blackfin/bfin5xx_spi.h
index f617d8765451..1a0b57f6a3d4 100644
--- a/include/asm-blackfin/bfin5xx_spi.h
+++ b/include/asm-blackfin/bfin5xx_spi.h
@@ -152,6 +152,7 @@
152struct bfin5xx_spi_master { 152struct bfin5xx_spi_master {
153 u16 num_chipselect; 153 u16 num_chipselect;
154 u8 enable_dma; 154 u8 enable_dma;
155 u16 pin_req[4];
155}; 156};
156 157
157/* spi_board_info.controller_data for SPI slave devices, 158/* spi_board_info.controller_data for SPI slave devices,
@@ -162,7 +163,7 @@ struct bfin5xx_spi_chip {
162 u8 enable_dma; 163 u8 enable_dma;
163 u8 bits_per_word; 164 u8 bits_per_word;
164 u8 cs_change_per_word; 165 u8 cs_change_per_word;
165 u8 cs_chg_udelay; 166 u16 cs_chg_udelay; /* Some devices require 16-bit delays */
166}; 167};
167 168
168#endif /* _SPI_CHANNEL_H_ */ 169#endif /* _SPI_CHANNEL_H_ */
diff --git a/include/asm-blackfin/cplb-mpu.h b/include/asm-blackfin/cplb-mpu.h
new file mode 100644
index 000000000000..75c67b99d607
--- /dev/null
+++ b/include/asm-blackfin/cplb-mpu.h
@@ -0,0 +1,61 @@
1/*
2 * File: include/asm-blackfin/cplbinit.h
3 * Based on:
4 * Author:
5 *
6 * Created:
7 * Description:
8 *
9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc.
11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29#ifndef __ASM_BFIN_CPLB_MPU_H
30#define __ASM_BFIN_CPLB_MPU_H
31
32struct cplb_entry {
33 unsigned long data, addr;
34};
35
36struct mem_region {
37 unsigned long start, end;
38 unsigned long dcplb_data;
39 unsigned long icplb_data;
40};
41
42extern struct cplb_entry dcplb_tbl[MAX_CPLBS];
43extern struct cplb_entry icplb_tbl[MAX_CPLBS];
44extern int first_switched_icplb;
45extern int first_mask_dcplb;
46extern int first_switched_dcplb;
47
48extern int nr_dcplb_miss, nr_icplb_miss, nr_icplb_supv_miss, nr_dcplb_prot;
49extern int nr_cplb_flush;
50
51extern int page_mask_order;
52extern int page_mask_nelts;
53
54extern unsigned long *current_rwx_mask;
55
56extern void flush_switched_cplbs(void);
57extern void set_mask_dcplbs(unsigned long *);
58
59extern void __noreturn panic_cplb_error(int seqstat, struct pt_regs *);
60
61#endif /* __ASM_BFIN_CPLB_MPU_H */
diff --git a/include/asm-blackfin/cplb.h b/include/asm-blackfin/cplb.h
index 06828d77a58f..654375c2b746 100644
--- a/include/asm-blackfin/cplb.h
+++ b/include/asm-blackfin/cplb.h
@@ -65,7 +65,11 @@
65#define SIZE_1M 0x00100000 /* 1M */ 65#define SIZE_1M 0x00100000 /* 1M */
66#define SIZE_4M 0x00400000 /* 4M */ 66#define SIZE_4M 0x00400000 /* 4M */
67 67
68#ifdef CONFIG_MPU
69#define MAX_CPLBS 16
70#else
68#define MAX_CPLBS (16 * 2) 71#define MAX_CPLBS (16 * 2)
72#endif
69 73
70#define ASYNC_MEMORY_CPLB_COVERAGE ((ASYNC_BANK0_SIZE + ASYNC_BANK1_SIZE + \ 74#define ASYNC_MEMORY_CPLB_COVERAGE ((ASYNC_BANK0_SIZE + ASYNC_BANK1_SIZE + \
71 ASYNC_BANK2_SIZE + ASYNC_BANK3_SIZE) / SIZE_4M) 75 ASYNC_BANK2_SIZE + ASYNC_BANK3_SIZE) / SIZE_4M)
diff --git a/include/asm-blackfin/cplbinit.h b/include/asm-blackfin/cplbinit.h
index bec6ecdf1bdb..0eb1c1b685a7 100644
--- a/include/asm-blackfin/cplbinit.h
+++ b/include/asm-blackfin/cplbinit.h
@@ -27,9 +27,18 @@
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */ 28 */
29 29
30#ifndef __ASM_CPLBINIT_H__
31#define __ASM_CPLBINIT_H__
32
30#include <asm/blackfin.h> 33#include <asm/blackfin.h>
31#include <asm/cplb.h> 34#include <asm/cplb.h>
32 35
36#ifdef CONFIG_MPU
37
38#include <asm/cplb-mpu.h>
39
40#else
41
33#define INITIAL_T 0x1 42#define INITIAL_T 0x1
34#define SWITCH_T 0x2 43#define SWITCH_T 0x2
35#define I_CPLB 0x4 44#define I_CPLB 0x4
@@ -57,8 +66,8 @@ struct cplb_tab {
57 u16 size; 66 u16 size;
58}; 67};
59 68
60extern u_long icplb_table[MAX_CPLBS+1]; 69extern u_long icplb_table[];
61extern u_long dcplb_table[MAX_CPLBS+1]; 70extern u_long dcplb_table[];
62 71
63/* Till here we are discussing about the static memory management model. 72/* Till here we are discussing about the static memory management model.
64 * However, the operating envoronments commonly define more CPLB 73 * However, the operating envoronments commonly define more CPLB
@@ -69,28 +78,18 @@ extern u_long dcplb_table[MAX_CPLBS+1];
69 * This is how Page descriptor Table is implemented in uClinux/Blackfin. 78 * This is how Page descriptor Table is implemented in uClinux/Blackfin.
70 */ 79 */
71 80
72#ifdef CONFIG_CPLB_SWITCH_TAB_L1 81extern u_long ipdt_table[];
73extern u_long ipdt_table[MAX_SWITCH_I_CPLBS+1]__attribute__((l1_data)); 82extern u_long dpdt_table[];
74extern u_long dpdt_table[MAX_SWITCH_D_CPLBS+1]__attribute__((l1_data));
75
76#ifdef CONFIG_CPLB_INFO 83#ifdef CONFIG_CPLB_INFO
77extern u_long ipdt_swapcount_table[MAX_SWITCH_I_CPLBS]__attribute__((l1_data)); 84extern u_long ipdt_swapcount_table[];
78extern u_long dpdt_swapcount_table[MAX_SWITCH_D_CPLBS]__attribute__((l1_data)); 85extern u_long dpdt_swapcount_table[];
79#endif /* CONFIG_CPLB_INFO */ 86#endif
80 87
81#else 88#endif /* CONFIG_MPU */
82
83extern u_long ipdt_table[MAX_SWITCH_I_CPLBS+1];
84extern u_long dpdt_table[MAX_SWITCH_D_CPLBS+1];
85
86#ifdef CONFIG_CPLB_INFO
87extern u_long ipdt_swapcount_table[MAX_SWITCH_I_CPLBS];
88extern u_long dpdt_swapcount_table[MAX_SWITCH_D_CPLBS];
89#endif /* CONFIG_CPLB_INFO */
90
91#endif /*CONFIG_CPLB_SWITCH_TAB_L1*/
92 89
93extern unsigned long reserved_mem_dcache_on; 90extern unsigned long reserved_mem_dcache_on;
94extern unsigned long reserved_mem_icache_on; 91extern unsigned long reserved_mem_icache_on;
95 92
96extern void generate_cpl_tables(void); 93extern void generate_cpl_tables(void);
94
95#endif
diff --git a/include/asm-blackfin/delay.h b/include/asm-blackfin/delay.h
index 52e7a10d7ff8..473a8113277f 100644
--- a/include/asm-blackfin/delay.h
+++ b/include/asm-blackfin/delay.h
@@ -1,29 +1,47 @@
1#ifndef _BLACKFIN_DELAY_H
2#define _BLACKFIN_DELAY_H
3
4static inline void __delay(unsigned long loops)
5{
6
7/* FIXME: Currently the assembler doesn't recognize Loop Register Clobbers,
8 uncomment this as soon those are implemented */
9/* 1/*
10 __asm__ __volatile__ ( "\t LSETUP (1f,1f) LC0= %0\n\t" 2 * delay.h - delay functions
11 "1:\t NOP;\n\t" 3 *
12 : :"a" (loops) 4 * Copyright (c) 2004-2007 Analog Devices Inc.
13 : "LT0","LB0","LC0"); 5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __ASM_DELAY_H__
10#define __ASM_DELAY_H__
14 11
15*/ 12#include <asm/mach/anomaly.h>
16 13
17 __asm__ __volatile__("[--SP] = LC0;\n\t" 14static inline void __delay(unsigned long loops)
18 "[--SP] = LT0;\n\t" 15{
19 "[--SP] = LB0;\n\t" 16 if (ANOMALY_05000312) {
20 "LSETUP (1f,1f) LC0 = %0;\n\t" 17 /* Interrupted loads to loop registers -> bad */
21 "1:\t NOP;\n\t" 18 unsigned long tmp;
22 "LB0 = [SP++];\n\t" 19 __asm__ __volatile__(
23 "LT0 = [SP++];\n\t" 20 "[--SP] = LC0;"
24 "LC0 = [SP++];\n" 21 "[--SP] = LT0;"
25 : 22 "[--SP] = LB0;"
26 :"a" (loops)); 23 "LSETUP (1f,1f) LC0 = %1;"
24 "1: NOP;"
25 /* We take advantage of the fact that LC0 is 0 at
26 * the end of the loop. Otherwise we'd need some
27 * NOPs after the CLI here.
28 */
29 "CLI %0;"
30 "LB0 = [SP++];"
31 "LT0 = [SP++];"
32 "LC0 = [SP++];"
33 "STI %0;"
34 : "=d" (tmp)
35 : "a" (loops)
36 );
37 } else
38 __asm__ __volatile__ (
39 "LSETUP(1f, 1f) LC0 = %0;"
40 "1: NOP;"
41 :
42 : "a" (loops)
43 : "LT0", "LB0", "LC0"
44 );
27} 45}
28 46
29#include <linux/param.h> /* needed for HZ */ 47#include <linux/param.h> /* needed for HZ */
@@ -41,4 +59,4 @@ static inline void udelay(unsigned long usecs)
41 __delay(usecs * loops_per_jiffy / (1000000 / HZ)); 59 __delay(usecs * loops_per_jiffy / (1000000 / HZ));
42} 60}
43 61
44#endif /* defined(_BLACKFIN_DELAY_H) */ 62#endif
diff --git a/include/asm-blackfin/dma.h b/include/asm-blackfin/dma.h
index b469505af364..5abaa2cee8db 100644
--- a/include/asm-blackfin/dma.h
+++ b/include/asm-blackfin/dma.h
@@ -76,6 +76,9 @@ enum dma_chan_status {
76#define INTR_ON_BUF 2 76#define INTR_ON_BUF 2
77#define INTR_ON_ROW 3 77#define INTR_ON_ROW 3
78 78
79#define DMA_NOSYNC_KEEP_DMA_BUF 0
80#define DMA_SYNC_RESTART 1
81
79struct dmasg { 82struct dmasg {
80 unsigned long next_desc_addr; 83 unsigned long next_desc_addr;
81 unsigned long start_addr; 84 unsigned long start_addr;
@@ -157,7 +160,8 @@ void set_dma_y_count(unsigned int channel, unsigned short y_count);
157void set_dma_y_modify(unsigned int channel, short y_modify); 160void set_dma_y_modify(unsigned int channel, short y_modify);
158void set_dma_config(unsigned int channel, unsigned short config); 161void set_dma_config(unsigned int channel, unsigned short config);
159unsigned short set_bfin_dma_config(char direction, char flow_mode, 162unsigned short set_bfin_dma_config(char direction, char flow_mode,
160 char intr_mode, char dma_mode, char width); 163 char intr_mode, char dma_mode, char width,
164 char syncmode);
161void set_dma_curr_addr(unsigned int channel, unsigned long addr); 165void set_dma_curr_addr(unsigned int channel, unsigned long addr);
162 166
163/* get curr status for polling */ 167/* get curr status for polling */
diff --git a/include/asm-blackfin/fixed_code.h b/include/asm-blackfin/fixed_code.h
index e6df84ee1557..37db66c7030d 100644
--- a/include/asm-blackfin/fixed_code.h
+++ b/include/asm-blackfin/fixed_code.h
@@ -17,4 +17,6 @@
17 17
18#define ATOMIC_SEQS_END 0x480 18#define ATOMIC_SEQS_END 0x480
19 19
20#define FIXED_CODE_END 0x480 20#define SAFE_USER_INSTRUCTION 0x480
21
22#define FIXED_CODE_END 0x490
diff --git a/include/asm-blackfin/gpio.h b/include/asm-blackfin/gpio.h
index 33ce98ef7e0f..d0426c108262 100644
--- a/include/asm-blackfin/gpio.h
+++ b/include/asm-blackfin/gpio.h
@@ -7,7 +7,7 @@
7 * Description: 7 * Description:
8 * 8 *
9 * Modified: 9 * Modified:
10 * Copyright 2004-2006 Analog Devices Inc. 10 * Copyright 2004-2008 Analog Devices Inc.
11 * 11 *
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/ 12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
13 * 13 *
@@ -304,39 +304,39 @@
304**************************************************************/ 304**************************************************************/
305 305
306#ifndef BF548_FAMILY 306#ifndef BF548_FAMILY
307void set_gpio_dir(unsigned short, unsigned short); 307void set_gpio_dir(unsigned, unsigned short);
308void set_gpio_inen(unsigned short, unsigned short); 308void set_gpio_inen(unsigned, unsigned short);
309void set_gpio_polar(unsigned short, unsigned short); 309void set_gpio_polar(unsigned, unsigned short);
310void set_gpio_edge(unsigned short, unsigned short); 310void set_gpio_edge(unsigned, unsigned short);
311void set_gpio_both(unsigned short, unsigned short); 311void set_gpio_both(unsigned, unsigned short);
312void set_gpio_data(unsigned short, unsigned short); 312void set_gpio_data(unsigned, unsigned short);
313void set_gpio_maska(unsigned short, unsigned short); 313void set_gpio_maska(unsigned, unsigned short);
314void set_gpio_maskb(unsigned short, unsigned short); 314void set_gpio_maskb(unsigned, unsigned short);
315void set_gpio_toggle(unsigned short); 315void set_gpio_toggle(unsigned);
316void set_gpiop_dir(unsigned short, unsigned short); 316void set_gpiop_dir(unsigned, unsigned short);
317void set_gpiop_inen(unsigned short, unsigned short); 317void set_gpiop_inen(unsigned, unsigned short);
318void set_gpiop_polar(unsigned short, unsigned short); 318void set_gpiop_polar(unsigned, unsigned short);
319void set_gpiop_edge(unsigned short, unsigned short); 319void set_gpiop_edge(unsigned, unsigned short);
320void set_gpiop_both(unsigned short, unsigned short); 320void set_gpiop_both(unsigned, unsigned short);
321void set_gpiop_data(unsigned short, unsigned short); 321void set_gpiop_data(unsigned, unsigned short);
322void set_gpiop_maska(unsigned short, unsigned short); 322void set_gpiop_maska(unsigned, unsigned short);
323void set_gpiop_maskb(unsigned short, unsigned short); 323void set_gpiop_maskb(unsigned, unsigned short);
324unsigned short get_gpio_dir(unsigned short); 324unsigned short get_gpio_dir(unsigned);
325unsigned short get_gpio_inen(unsigned short); 325unsigned short get_gpio_inen(unsigned);
326unsigned short get_gpio_polar(unsigned short); 326unsigned short get_gpio_polar(unsigned);
327unsigned short get_gpio_edge(unsigned short); 327unsigned short get_gpio_edge(unsigned);
328unsigned short get_gpio_both(unsigned short); 328unsigned short get_gpio_both(unsigned);
329unsigned short get_gpio_maska(unsigned short); 329unsigned short get_gpio_maska(unsigned);
330unsigned short get_gpio_maskb(unsigned short); 330unsigned short get_gpio_maskb(unsigned);
331unsigned short get_gpio_data(unsigned short); 331unsigned short get_gpio_data(unsigned);
332unsigned short get_gpiop_dir(unsigned short); 332unsigned short get_gpiop_dir(unsigned);
333unsigned short get_gpiop_inen(unsigned short); 333unsigned short get_gpiop_inen(unsigned);
334unsigned short get_gpiop_polar(unsigned short); 334unsigned short get_gpiop_polar(unsigned);
335unsigned short get_gpiop_edge(unsigned short); 335unsigned short get_gpiop_edge(unsigned);
336unsigned short get_gpiop_both(unsigned short); 336unsigned short get_gpiop_both(unsigned);
337unsigned short get_gpiop_maska(unsigned short); 337unsigned short get_gpiop_maska(unsigned);
338unsigned short get_gpiop_maskb(unsigned short); 338unsigned short get_gpiop_maskb(unsigned);
339unsigned short get_gpiop_data(unsigned short); 339unsigned short get_gpiop_data(unsigned);
340 340
341struct gpio_port_t { 341struct gpio_port_t {
342 unsigned short data; 342 unsigned short data;
@@ -382,8 +382,8 @@ struct gpio_port_t {
382#define PM_WAKE_LOW 0x8 382#define PM_WAKE_LOW 0x8
383#define PM_WAKE_BOTH_EDGES (PM_WAKE_RISING | PM_WAKE_FALLING) 383#define PM_WAKE_BOTH_EDGES (PM_WAKE_RISING | PM_WAKE_FALLING)
384 384
385int gpio_pm_wakeup_request(unsigned short gpio, unsigned char type); 385int gpio_pm_wakeup_request(unsigned gpio, unsigned char type);
386void gpio_pm_wakeup_free(unsigned short gpio); 386void gpio_pm_wakeup_free(unsigned gpio);
387unsigned int gpio_pm_setup(void); 387unsigned int gpio_pm_setup(void);
388void gpio_pm_restore(void); 388void gpio_pm_restore(void);
389 389
@@ -426,19 +426,19 @@ struct gpio_port_s {
426* MODIFICATION HISTORY : 426* MODIFICATION HISTORY :
427**************************************************************/ 427**************************************************************/
428 428
429int gpio_request(unsigned short, const char *); 429int gpio_request(unsigned, const char *);
430void gpio_free(unsigned short); 430void gpio_free(unsigned);
431 431
432void gpio_set_value(unsigned short gpio, unsigned short arg); 432void gpio_set_value(unsigned gpio, int arg);
433unsigned short gpio_get_value(unsigned short gpio); 433int gpio_get_value(unsigned gpio);
434 434
435#ifndef BF548_FAMILY 435#ifndef BF548_FAMILY
436#define gpio_get_value(gpio) get_gpio_data(gpio) 436#define gpio_get_value(gpio) get_gpio_data(gpio)
437#define gpio_set_value(gpio, value) set_gpio_data(gpio, value) 437#define gpio_set_value(gpio, value) set_gpio_data(gpio, value)
438#endif 438#endif
439 439
440void gpio_direction_input(unsigned short gpio); 440int gpio_direction_input(unsigned gpio);
441void gpio_direction_output(unsigned short gpio); 441int gpio_direction_output(unsigned gpio, int value);
442 442
443#include <asm-generic/gpio.h> /* cansleep wrappers */ 443#include <asm-generic/gpio.h> /* cansleep wrappers */
444#include <asm/irq.h> 444#include <asm/irq.h>
diff --git a/include/asm-blackfin/gptimers.h b/include/asm-blackfin/gptimers.h
index c97ab03e43a6..8265ea473d5b 100644
--- a/include/asm-blackfin/gptimers.h
+++ b/include/asm-blackfin/gptimers.h
@@ -197,6 +197,8 @@ uint32_t get_gptimer_period (int timer_id);
197uint32_t get_gptimer_count (int timer_id); 197uint32_t get_gptimer_count (int timer_id);
198uint16_t get_gptimer_intr (int timer_id); 198uint16_t get_gptimer_intr (int timer_id);
199void clear_gptimer_intr (int timer_id); 199void clear_gptimer_intr (int timer_id);
200uint16_t get_gptimer_over (int timer_id);
201void clear_gptimer_over (int timer_id);
200void set_gptimer_config (int timer_id, uint16_t config); 202void set_gptimer_config (int timer_id, uint16_t config);
201uint16_t get_gptimer_config (int timer_id); 203uint16_t get_gptimer_config (int timer_id);
202void set_gptimer_pulse_hi (int timer_id); 204void set_gptimer_pulse_hi (int timer_id);
diff --git a/include/asm-blackfin/io.h b/include/asm-blackfin/io.h
index d1d2e6be3b59..1601d62f39a5 100644
--- a/include/asm-blackfin/io.h
+++ b/include/asm-blackfin/io.h
@@ -122,6 +122,7 @@ extern void outsl(unsigned long port, const void *addr, unsigned long count);
122extern void insb(unsigned long port, void *addr, unsigned long count); 122extern void insb(unsigned long port, void *addr, unsigned long count);
123extern void insw(unsigned long port, void *addr, unsigned long count); 123extern void insw(unsigned long port, void *addr, unsigned long count);
124extern void insl(unsigned long port, void *addr, unsigned long count); 124extern void insl(unsigned long port, void *addr, unsigned long count);
125extern void insl_16(unsigned long port, void *addr, unsigned long count);
125 126
126extern void dma_outsb(unsigned long port, const void *addr, unsigned short count); 127extern void dma_outsb(unsigned long port, const void *addr, unsigned short count);
127extern void dma_outsw(unsigned long port, const void *addr, unsigned short count); 128extern void dma_outsw(unsigned long port, const void *addr, unsigned short count);
diff --git a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
index 0b867e6a76c4..15dbc21eed8b 100644
--- a/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf527/bfin_serial_5xx.h
@@ -146,7 +146,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
146 146
147 if (uart->rts_pin >= 0) { 147 if (uart->rts_pin >= 0) {
148 gpio_request(uart->rts_pin, DRIVER_NAME); 148 gpio_request(uart->rts_pin, DRIVER_NAME);
149 gpio_direction_output(uart->rts_pin); 149 gpio_direction_output(uart->rts_pin, 0);
150 } 150 }
151#endif 151#endif
152} 152}
diff --git a/include/asm-blackfin/mach-bf527/defBF52x_base.h b/include/asm-blackfin/mach-bf527/defBF52x_base.h
index d6c24c54699d..fc69cf93f149 100644
--- a/include/asm-blackfin/mach-bf527/defBF52x_base.h
+++ b/include/asm-blackfin/mach-bf527/defBF52x_base.h
@@ -1718,55 +1718,55 @@
1718 1718
1719/* Bit masks for HOST_CONTROL */ 1719/* Bit masks for HOST_CONTROL */
1720 1720
1721#define HOST_EN 0x1 /* Host Enable */ 1721#define HOST_CNTR_HOST_EN 0x1 /* Host Enable */
1722#define nHOST_EN 0x0 1722#define HOST_CNTR_nHOST_EN 0x0
1723#define HOST_END 0x2 /* Host Endianess */ 1723#define HOST_CNTR_HOST_END 0x2 /* Host Endianess */
1724#define nHOST_END 0x0 1724#define HOST_CNTR_nHOST_END 0x0
1725#define DATA_SIZE 0x4 /* Data Size */ 1725#define HOST_CNTR_DATA_SIZE 0x4 /* Data Size */
1726#define nDATA_SIZE 0x0 1726#define HOST_CNTR_nDATA_SIZE 0x0
1727#define HOST_RST 0x8 /* Host Reset */ 1727#define HOST_CNTR_HOST_RST 0x8 /* Host Reset */
1728#define nHOST_RST 0x0 1728#define HOST_CNTR_nHOST_RST 0x0
1729#define HRDY_OVR 0x20 /* Host Ready Override */ 1729#define HOST_CNTR_HRDY_OVR 0x20 /* Host Ready Override */
1730#define nHRDY_OVR 0x0 1730#define HOST_CNTR_nHRDY_OVR 0x0
1731#define INT_MODE 0x40 /* Interrupt Mode */ 1731#define HOST_CNTR_INT_MODE 0x40 /* Interrupt Mode */
1732#define nINT_MODE 0x0 1732#define HOST_CNTR_nINT_MODE 0x0
1733#define BT_EN 0x80 /* Bus Timeout Enable */ 1733#define HOST_CNTR_BT_EN 0x80 /* Bus Timeout Enable */
1734#define nBT_EN 0x0 1734#define HOST_CNTR_ nBT_EN 0x0
1735#define EHW 0x100 /* Enable Host Write */ 1735#define HOST_CNTR_EHW 0x100 /* Enable Host Write */
1736#define nEHW 0x0 1736#define HOST_CNTR_nEHW 0x0
1737#define EHR 0x200 /* Enable Host Read */ 1737#define HOST_CNTR_EHR 0x200 /* Enable Host Read */
1738#define nEHR 0x0 1738#define HOST_CNTR_nEHR 0x0
1739#define BDR 0x400 /* Burst DMA Requests */ 1739#define HOST_CNTR_BDR 0x400 /* Burst DMA Requests */
1740#define nBDR 0x0 1740#define HOST_CNTR_nBDR 0x0
1741 1741
1742/* Bit masks for HOST_STATUS */ 1742/* Bit masks for HOST_STATUS */
1743 1743
1744#define READY 0x1 /* DMA Ready */ 1744#define HOST_STAT_READY 0x1 /* DMA Ready */
1745#define nREADY 0x0 1745#define HOST_STAT_nREADY 0x0
1746#define FIFOFULL 0x2 /* FIFO Full */ 1746#define HOST_STAT_FIFOFULL 0x2 /* FIFO Full */
1747#define nFIFOFULL 0x0 1747#define HOST_STAT_nFIFOFULL 0x0
1748#define FIFOEMPTY 0x4 /* FIFO Empty */ 1748#define HOST_STAT_FIFOEMPTY 0x4 /* FIFO Empty */
1749#define nFIFOEMPTY 0x0 1749#define HOST_STAT_nFIFOEMPTY 0x0
1750#define COMPLETE 0x8 /* DMA Complete */ 1750#define HOST_STAT_COMPLETE 0x8 /* DMA Complete */
1751#define nCOMPLETE 0x0 1751#define HOST_STAT_nCOMPLETE 0x0
1752#define HSHK 0x10 /* Host Handshake */ 1752#define HOST_STAT_HSHK 0x10 /* Host Handshake */
1753#define nHSHK 0x0 1753#define HOST_STAT_nHSHK 0x0
1754#define TIMEOUT 0x20 /* Host Timeout */ 1754#define HOST_STAT_TIMEOUT 0x20 /* Host Timeout */
1755#define nTIMEOUT 0x0 1755#define HOST_STAT_nTIMEOUT 0x0
1756#define HIRQ 0x40 /* Host Interrupt Request */ 1756#define HOST_STAT_HIRQ 0x40 /* Host Interrupt Request */
1757#define nHIRQ 0x0 1757#define HOST_STAT_nHIRQ 0x0
1758#define ALLOW_CNFG 0x80 /* Allow New Configuration */ 1758#define HOST_STAT_ALLOW_CNFG 0x80 /* Allow New Configuration */
1759#define nALLOW_CNFG 0x0 1759#define HOST_STAT_nALLOW_CNFG 0x0
1760#define DMA_DIR 0x100 /* DMA Direction */ 1760#define HOST_STAT_DMA_DIR 0x100 /* DMA Direction */
1761#define nDMA_DIR 0x0 1761#define HOST_STAT_nDMA_DIR 0x0
1762#define BTE 0x200 /* Bus Timeout Enabled */ 1762#define HOST_STAT_BTE 0x200 /* Bus Timeout Enabled */
1763#define nBTE 0x0 1763#define HOST_STAT_nBTE 0x0
1764#define HOSTRD_DONE 0x8000 /* Host Read Completion Interrupt */ 1764#define HOST_STAT_HOSTRD_DONE 0x8000 /* Host Read Completion Interrupt */
1765#define nHOSTRD_DONE 0x0 1765#define HOST_STAT_nHOSTRD_DONE 0x0
1766 1766
1767/* Bit masks for HOST_TIMEOUT */ 1767/* Bit masks for HOST_TIMEOUT */
1768 1768
1769#define COUNT_TIMEOUT 0x7ff /* Host Timeout count */ 1769#define HOST_COUNT_TIMEOUT 0x7ff /* Host Timeout count */
1770 1770
1771/* Bit masks for CNT_CONFIG */ 1771/* Bit masks for CNT_CONFIG */
1772 1772
diff --git a/include/asm-blackfin/mach-bf527/dma.h b/include/asm-blackfin/mach-bf527/dma.h
index a41627ae9134..2dfee12864f6 100644
--- a/include/asm-blackfin/mach-bf527/dma.h
+++ b/include/asm-blackfin/mach-bf527/dma.h
@@ -35,7 +35,6 @@
35#define MAX_BLACKFIN_DMA_CHANNEL 16 35#define MAX_BLACKFIN_DMA_CHANNEL 16
36 36
37#define CH_PPI 0 /* PPI receive/transmit or NFC */ 37#define CH_PPI 0 /* PPI receive/transmit or NFC */
38#define CH_NFC 0 /* PPI receive/transmit or NFC */
39#define CH_EMAC_RX 1 /* Ethernet MAC receive or HOSTDP */ 38#define CH_EMAC_RX 1 /* Ethernet MAC receive or HOSTDP */
40#define CH_EMAC_HOSTDP 1 /* Ethernet MAC receive or HOSTDP */ 39#define CH_EMAC_HOSTDP 1 /* Ethernet MAC receive or HOSTDP */
41#define CH_EMAC_TX 2 /* Ethernet MAC transmit or NFC */ 40#define CH_EMAC_TX 2 /* Ethernet MAC transmit or NFC */
@@ -54,6 +53,12 @@
54#define CH_MEM_STREAM1_DEST 14 /* TX */ 53#define CH_MEM_STREAM1_DEST 14 /* TX */
55#define CH_MEM_STREAM1_SRC 15 /* RX */ 54#define CH_MEM_STREAM1_SRC 15 /* RX */
56 55
56#if defined(CONFIG_BF527_NAND_D_PORTF)
57#define CH_NFC CH_PPI /* PPI receive/transmit or NFC */
58#elif defined(CONFIG_BF527_NAND_D_PORTH)
59#define CH_NFC CH_EMAC_TX /* PPI receive/transmit or NFC */
60#endif
61
57extern int channel2irq(unsigned int channel); 62extern int channel2irq(unsigned int channel);
58extern struct dma_register *base_addr[]; 63extern struct dma_register *base_addr[];
59 64
diff --git a/include/asm-blackfin/mach-bf527/irq.h b/include/asm-blackfin/mach-bf527/irq.h
index 304f5bcfebe4..4e2b3f2020e5 100644
--- a/include/asm-blackfin/mach-bf527/irq.h
+++ b/include/asm-blackfin/mach-bf527/irq.h
@@ -176,11 +176,7 @@
176 176
177#define GPIO_IRQ_BASE IRQ_PF0 177#define GPIO_IRQ_BASE IRQ_PF0
178 178
179#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
180#define NR_IRQS (IRQ_PH15+1) 179#define NR_IRQS (IRQ_PH15+1)
181#else
182#define NR_IRQS (SYS_IRQS+1)
183#endif
184 180
185#define IVG7 7 181#define IVG7 7
186#define IVG8 8 182#define IVG8 8
diff --git a/include/asm-blackfin/mach-bf527/mem_map.h b/include/asm-blackfin/mach-bf527/mem_map.h
index c5aa20102b24..193082deaa4e 100644
--- a/include/asm-blackfin/mach-bf527/mem_map.h
+++ b/include/asm-blackfin/mach-bf527/mem_map.h
@@ -47,6 +47,7 @@
47/* Boot ROM Memory */ 47/* Boot ROM Memory */
48 48
49#define BOOT_ROM_START 0xEF000000 49#define BOOT_ROM_START 0xEF000000
50#define BOOT_ROM_LENGTH 0x8000
50 51
51/* Level 1 Memory */ 52/* Level 1 Memory */
52 53
@@ -90,9 +91,7 @@
90 91
91/* Scratch Pad Memory */ 92/* Scratch Pad Memory */
92 93
93#if defined(CONFIG_BF527) || defined(CONFIG_BF536) || defined(CONFIG_BF534)
94#define L1_SCRATCH_START 0xFFB00000 94#define L1_SCRATCH_START 0xFFB00000
95#define L1_SCRATCH_LENGTH 0x1000 95#define L1_SCRATCH_LENGTH 0x1000
96#endif
97 96
98#endif /* _MEM_MAP_527_H_ */ 97#endif /* _MEM_MAP_527_H_ */
diff --git a/include/asm-blackfin/mach-bf527/portmux.h b/include/asm-blackfin/mach-bf527/portmux.h
index dcf001adc63c..ae4d205bfcf5 100644
--- a/include/asm-blackfin/mach-bf527/portmux.h
+++ b/include/asm-blackfin/mach-bf527/portmux.h
@@ -1,6 +1,8 @@
1#ifndef _MACH_PORTMUX_H_ 1#ifndef _MACH_PORTMUX_H_
2#define _MACH_PORTMUX_H_ 2#define _MACH_PORTMUX_H_
3 3
4#define MAX_RESOURCES MAX_BLACKFIN_GPIOS
5
4#define P_PPI0_D0 (P_DEFINED | P_IDENT(GPIO_PF0) | P_FUNCT(0)) 6#define P_PPI0_D0 (P_DEFINED | P_IDENT(GPIO_PF0) | P_FUNCT(0))
5#define P_PPI0_D1 (P_DEFINED | P_IDENT(GPIO_PF1) | P_FUNCT(0)) 7#define P_PPI0_D1 (P_DEFINED | P_IDENT(GPIO_PF1) | P_FUNCT(0))
6#define P_PPI0_D2 (P_DEFINED | P_IDENT(GPIO_PF2) | P_FUNCT(0)) 8#define P_PPI0_D2 (P_DEFINED | P_IDENT(GPIO_PF2) | P_FUNCT(0))
diff --git a/include/asm-blackfin/mach-bf533/anomaly.h b/include/asm-blackfin/mach-bf533/anomaly.h
index f36ff5af1b91..98209d40abba 100644
--- a/include/asm-blackfin/mach-bf533/anomaly.h
+++ b/include/asm-blackfin/mach-bf533/anomaly.h
@@ -7,9 +7,7 @@
7 */ 7 */
8 8
9/* This file shoule be up to date with: 9/* This file shoule be up to date with:
10 * - Revision X, March 23, 2007; ADSP-BF533 Blackfin Processor Anomaly List 10 * - Revision B, 12/10/2007; ADSP-BF531/BF532/BF533 Blackfin Processor Anomaly List
11 * - Revision AB, March 23, 2007; ADSP-BF532 Blackfin Processor Anomaly List
12 * - Revision W, March 23, 2007; ADSP-BF531 Blackfin Processor Anomaly List
13 */ 11 */
14 12
15#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -17,7 +15,7 @@
17 15
18/* We do not support 0.1 or 0.2 silicon - sorry */ 16/* We do not support 0.1 or 0.2 silicon - sorry */
19#if __SILICON_REVISION__ < 3 17#if __SILICON_REVISION__ < 3
20# error Kernel will not work on BF533 silicon version 0.0, 0.1, or 0.2 18# error will not work on BF533 silicon version 0.0, 0.1, or 0.2
21#endif 19#endif
22 20
23#if defined(__ADSPBF531__) 21#if defined(__ADSPBF531__)
@@ -251,6 +249,12 @@
251#define ANOMALY_05000192 (__SILICON_REVISION__ < 3) 249#define ANOMALY_05000192 (__SILICON_REVISION__ < 3)
252/* Internal Voltage Regulator may not start up */ 250/* Internal Voltage Regulator may not start up */
253#define ANOMALY_05000206 (__SILICON_REVISION__ < 3) 251#define ANOMALY_05000206 (__SILICON_REVISION__ < 3)
252/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */
253#define ANOMALY_05000357 (1)
254/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */
255#define ANOMALY_05000366 (1)
256/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */
257#define ANOMALY_05000371 (1)
254 258
255/* Anomalies that don't exist on this proc */ 259/* Anomalies that don't exist on this proc */
256#define ANOMALY_05000266 (0) 260#define ANOMALY_05000266 (0)
diff --git a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
index 69b9f8e120e9..7871d4313f49 100644
--- a/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf533/bfin_serial_5xx.h
@@ -111,7 +111,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
111 } 111 }
112 if (uart->rts_pin >= 0) { 112 if (uart->rts_pin >= 0) {
113 gpio_request(uart->rts_pin, DRIVER_NAME); 113 gpio_request(uart->rts_pin, DRIVER_NAME);
114 gpio_direction_input(uart->rts_pin); 114 gpio_direction_input(uart->rts_pin, 0);
115 } 115 }
116#endif 116#endif
117} 117}
diff --git a/include/asm-blackfin/mach-bf533/irq.h b/include/asm-blackfin/mach-bf533/irq.h
index 452fb825d891..832e6f6122da 100644
--- a/include/asm-blackfin/mach-bf533/irq.h
+++ b/include/asm-blackfin/mach-bf533/irq.h
@@ -130,11 +130,7 @@ Core Emulation **
130 130
131#define GPIO_IRQ_BASE IRQ_PF0 131#define GPIO_IRQ_BASE IRQ_PF0
132 132
133#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
134#define NR_IRQS (IRQ_PF15+1) 133#define NR_IRQS (IRQ_PF15+1)
135#else
136#define NR_IRQS SYS_IRQS
137#endif
138 134
139#define IVG7 7 135#define IVG7 7
140#define IVG8 8 136#define IVG8 8
diff --git a/include/asm-blackfin/mach-bf533/mem_map.h b/include/asm-blackfin/mach-bf533/mem_map.h
index 94d8c4062eb7..bd30b6f3be00 100644
--- a/include/asm-blackfin/mach-bf533/mem_map.h
+++ b/include/asm-blackfin/mach-bf533/mem_map.h
@@ -1,4 +1,3 @@
1
2/* 1/*
3 * File: include/asm-blackfin/mach-bf533/mem_map.h 2 * File: include/asm-blackfin/mach-bf533/mem_map.h
4 * Based on: 3 * Based on:
@@ -48,6 +47,7 @@
48/* Boot ROM Memory */ 47/* Boot ROM Memory */
49 48
50#define BOOT_ROM_START 0xEF000000 49#define BOOT_ROM_START 0xEF000000
50#define BOOT_ROM_LENGTH 0x400
51 51
52/* Level 1 Memory */ 52/* Level 1 Memory */
53 53
@@ -160,9 +160,7 @@
160 160
161/* Scratch Pad Memory */ 161/* Scratch Pad Memory */
162 162
163#if defined(CONFIG_BF533) || defined(CONFIG_BF532) || defined(CONFIG_BF531)
164#define L1_SCRATCH_START 0xFFB00000 163#define L1_SCRATCH_START 0xFFB00000
165#define L1_SCRATCH_LENGTH 0x1000 164#define L1_SCRATCH_LENGTH 0x1000
166#endif
167 165
168#endif /* _MEM_MAP_533_H_ */ 166#endif /* _MEM_MAP_533_H_ */
diff --git a/include/asm-blackfin/mach-bf533/portmux.h b/include/asm-blackfin/mach-bf533/portmux.h
index b88d7a03ee3e..685a2651dcda 100644
--- a/include/asm-blackfin/mach-bf533/portmux.h
+++ b/include/asm-blackfin/mach-bf533/portmux.h
@@ -1,6 +1,8 @@
1#ifndef _MACH_PORTMUX_H_ 1#ifndef _MACH_PORTMUX_H_
2#define _MACH_PORTMUX_H_ 2#define _MACH_PORTMUX_H_
3 3
4#define MAX_RESOURCES MAX_BLACKFIN_GPIOS
5
4#define P_PPI0_CLK (P_DONTCARE) 6#define P_PPI0_CLK (P_DONTCARE)
5#define P_PPI0_FS1 (P_DONTCARE) 7#define P_PPI0_FS1 (P_DONTCARE)
6#define P_PPI0_FS2 (P_DONTCARE) 8#define P_PPI0_FS2 (P_DONTCARE)
@@ -42,7 +44,7 @@
42#define P_SPORT0_DRPRI (P_DONTCARE) 44#define P_SPORT0_DRPRI (P_DONTCARE)
43 45
44#define P_SPI0_MOSI (P_DONTCARE) 46#define P_SPI0_MOSI (P_DONTCARE)
45#define P_SPI0_MIS0 (P_DONTCARE) 47#define P_SPI0_MISO (P_DONTCARE)
46#define P_SPI0_SCK (P_DONTCARE) 48#define P_SPI0_SCK (P_DONTCARE)
47#define P_SPI0_SSEL7 (P_DEFINED | P_IDENT(GPIO_PF7)) 49#define P_SPI0_SSEL7 (P_DEFINED | P_IDENT(GPIO_PF7))
48#define P_SPI0_SSEL6 (P_DEFINED | P_IDENT(GPIO_PF6)) 50#define P_SPI0_SSEL6 (P_DEFINED | P_IDENT(GPIO_PF6))
diff --git a/include/asm-blackfin/mach-bf537/anomaly.h b/include/asm-blackfin/mach-bf537/anomaly.h
index 2b66ecf489f7..746a794b3119 100644
--- a/include/asm-blackfin/mach-bf537/anomaly.h
+++ b/include/asm-blackfin/mach-bf537/anomaly.h
@@ -7,9 +7,7 @@
7 */ 7 */
8 8
9/* This file shoule be up to date with: 9/* This file shoule be up to date with:
10 * - Revision M, March 13, 2007; ADSP-BF537 Blackfin Processor Anomaly List 10 * - Revision A, 09/04/2007; ADSP-BF534/ADSP-BF536/ADSP-BF537 Blackfin Processor Anomaly List
11 * - Revision L, March 13, 2007; ADSP-BF536 Blackfin Processor Anomaly List
12 * - Revision M, March 13, 2007; ADSP-BF534 Blackfin Processor Anomaly List
13 */ 11 */
14 12
15#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -17,7 +15,7 @@
17 15
18/* We do not support 0.1 silicon - sorry */ 16/* We do not support 0.1 silicon - sorry */
19#if __SILICON_REVISION__ < 2 17#if __SILICON_REVISION__ < 2
20# error Kernel will not work on BF537 silicon version 0.0 or 0.1 18# error will not work on BF537 silicon version 0.0 or 0.1
21#endif 19#endif
22 20
23#if defined(__ADSPBF534__) 21#if defined(__ADSPBF534__)
@@ -44,6 +42,8 @@
44#define ANOMALY_05000122 (1) 42#define ANOMALY_05000122 (1)
45/* Killed 32-bit MMR write leads to next system MMR access thinking it should be 32-bit */ 43/* Killed 32-bit MMR write leads to next system MMR access thinking it should be 32-bit */
46#define ANOMALY_05000157 (__SILICON_REVISION__ < 2) 44#define ANOMALY_05000157 (__SILICON_REVISION__ < 2)
45/* Turning SPORTs on while External Frame Sync Is Active May Corrupt Data */
46#define ANOMALY_05000167 (1)
47/* PPI_DELAY not functional in PPI modes with 0 frame syncs */ 47/* PPI_DELAY not functional in PPI modes with 0 frame syncs */
48#define ANOMALY_05000180 (1) 48#define ANOMALY_05000180 (1)
49/* Instruction Cache Is Not Functional */ 49/* Instruction Cache Is Not Functional */
@@ -130,6 +130,12 @@
130#define ANOMALY_05000321 (__SILICON_REVISION__ < 3) 130#define ANOMALY_05000321 (__SILICON_REVISION__ < 3)
131/* EMAC RMII mode at 10-Base-T speed: RX frames not received properly */ 131/* EMAC RMII mode at 10-Base-T speed: RX frames not received properly */
132#define ANOMALY_05000322 (1) 132#define ANOMALY_05000322 (1)
133/* Ethernet MAC MDIO Reads Do Not Meet IEEE Specification */
134#define ANOMALY_05000341 (__SILICON_REVISION__ >= 3)
135/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */
136#define ANOMALY_05000357 (1)
137/* DMAs that Go Urgent during Tight Core Writes to External Memory Are Blocked */
138#define ANOMALY_05000359 (1)
133 139
134/* Anomalies that don't exist on this proc */ 140/* Anomalies that don't exist on this proc */
135#define ANOMALY_05000125 (0) 141#define ANOMALY_05000125 (0)
diff --git a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
index 6fb328f5186a..86e45c379838 100644
--- a/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf537/bfin_serial_5xx.h
@@ -146,7 +146,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
146 146
147 if (uart->rts_pin >= 0) { 147 if (uart->rts_pin >= 0) {
148 gpio_request(uart->rts_pin, DRIVER_NAME); 148 gpio_request(uart->rts_pin, DRIVER_NAME);
149 gpio_direction_output(uart->rts_pin); 149 gpio_direction_output(uart->rts_pin, 0);
150 } 150 }
151#endif 151#endif
152} 152}
diff --git a/include/asm-blackfin/mach-bf537/irq.h b/include/asm-blackfin/mach-bf537/irq.h
index 36c44bc1a917..be6f2ff77f31 100644
--- a/include/asm-blackfin/mach-bf537/irq.h
+++ b/include/asm-blackfin/mach-bf537/irq.h
@@ -162,11 +162,7 @@ Core Emulation **
162 162
163#define GPIO_IRQ_BASE IRQ_PF0 163#define GPIO_IRQ_BASE IRQ_PF0
164 164
165#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
166#define NR_IRQS (IRQ_PH15+1) 165#define NR_IRQS (IRQ_PH15+1)
167#else
168#define NR_IRQS (IRQ_UART1_ERROR+1)
169#endif
170 166
171#define IVG7 7 167#define IVG7 7
172#define IVG8 8 168#define IVG8 8
diff --git a/include/asm-blackfin/mach-bf537/mem_map.h b/include/asm-blackfin/mach-bf537/mem_map.h
index 18759e38eaae..5c6726d6f3b1 100644
--- a/include/asm-blackfin/mach-bf537/mem_map.h
+++ b/include/asm-blackfin/mach-bf537/mem_map.h
@@ -47,6 +47,7 @@
47/* Boot ROM Memory */ 47/* Boot ROM Memory */
48 48
49#define BOOT_ROM_START 0xEF000000 49#define BOOT_ROM_START 0xEF000000
50#define BOOT_ROM_LENGTH 0x800
50 51
51/* Level 1 Memory */ 52/* Level 1 Memory */
52 53
@@ -167,9 +168,7 @@
167 168
168/* Scratch Pad Memory */ 169/* Scratch Pad Memory */
169 170
170#if defined(CONFIG_BF537) || defined(CONFIG_BF536) || defined(CONFIG_BF534)
171#define L1_SCRATCH_START 0xFFB00000 171#define L1_SCRATCH_START 0xFFB00000
172#define L1_SCRATCH_LENGTH 0x1000 172#define L1_SCRATCH_LENGTH 0x1000
173#endif
174 173
175#endif /* _MEM_MAP_537_H_ */ 174#endif /* _MEM_MAP_537_H_ */
diff --git a/include/asm-blackfin/mach-bf537/portmux.h b/include/asm-blackfin/mach-bf537/portmux.h
index 5a3f7d3bf73d..78fee6e0f237 100644
--- a/include/asm-blackfin/mach-bf537/portmux.h
+++ b/include/asm-blackfin/mach-bf537/portmux.h
@@ -1,6 +1,8 @@
1#ifndef _MACH_PORTMUX_H_ 1#ifndef _MACH_PORTMUX_H_
2#define _MACH_PORTMUX_H_ 2#define _MACH_PORTMUX_H_
3 3
4#define MAX_RESOURCES (MAX_BLACKFIN_GPIOS + GPIO_BANKSIZE) /* We additionally handle PORTJ */
5
4#define P_UART0_TX (P_DEFINED | P_IDENT(GPIO_PF0) | P_FUNCT(0)) 6#define P_UART0_TX (P_DEFINED | P_IDENT(GPIO_PF0) | P_FUNCT(0))
5#define P_UART0_RX (P_DEFINED | P_IDENT(GPIO_PF1) | P_FUNCT(0)) 7#define P_UART0_RX (P_DEFINED | P_IDENT(GPIO_PF1) | P_FUNCT(0))
6#define P_UART1_TX (P_DEFINED | P_IDENT(GPIO_PF2) | P_FUNCT(0)) 8#define P_UART1_TX (P_DEFINED | P_IDENT(GPIO_PF2) | P_FUNCT(0))
diff --git a/include/asm-blackfin/mach-bf548/anomaly.h b/include/asm-blackfin/mach-bf548/anomaly.h
index c5b63759cdee..850dc12eb7f2 100644
--- a/include/asm-blackfin/mach-bf548/anomaly.h
+++ b/include/asm-blackfin/mach-bf548/anomaly.h
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9/* This file shoule be up to date with: 9/* This file shoule be up to date with:
10 * - Revision C, July 16, 2007; ADSP-BF549 Silicon Anomaly List 10 * - Revision E, 11/28/2007; ADSP-BF542/BF544/BF547/BF548/BF549 Blackfin Processor Anomaly List
11 */ 11 */
12 12
13#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -26,47 +26,59 @@
26/* Certain Data Cache Writethrough Modes Fail for Vddint <= 0.9V */ 26/* Certain Data Cache Writethrough Modes Fail for Vddint <= 0.9V */
27#define ANOMALY_05000272 (1) 27#define ANOMALY_05000272 (1)
28/* False Hardware Error Exception when ISR context is not restored */ 28/* False Hardware Error Exception when ISR context is not restored */
29#define ANOMALY_05000281 (1) 29#define ANOMALY_05000281 (__SILICON_REVISION__ < 1)
30/* SSYNCs After Writes To CAN/DMA MMR Registers Are Not Always Handled Correctly */ 30/* SSYNCs After Writes To CAN/DMA MMR Registers Are Not Always Handled Correctly */
31#define ANOMALY_05000304 (1) 31#define ANOMALY_05000304 (__SILICON_REVISION__ < 1)
32/* False Hardware Errors Caused by Fetches at the Boundary of Reserved Memory */ 32/* False Hardware Errors Caused by Fetches at the Boundary of Reserved Memory */
33#define ANOMALY_05000310 (1) 33#define ANOMALY_05000310 (1)
34/* Errors When SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */ 34/* Errors When SSYNC, CSYNC, or Loads to LT, LB and LC Registers Are Interrupted */
35#define ANOMALY_05000312 (1) 35#define ANOMALY_05000312 (__SILICON_REVISION__ < 1)
36/* TWI Slave Boot Mode Is Not Functional */ 36/* TWI Slave Boot Mode Is Not Functional */
37#define ANOMALY_05000324 (1) 37#define ANOMALY_05000324 (__SILICON_REVISION__ < 1)
38/* External FIFO Boot Mode Is Not Functional */ 38/* External FIFO Boot Mode Is Not Functional */
39#define ANOMALY_05000325 (1) 39#define ANOMALY_05000325 (__SILICON_REVISION__ < 1)
40/* Data Lost When Core and DMA Accesses Are Made to the USB FIFO Simultaneously */ 40/* Data Lost When Core and DMA Accesses Are Made to the USB FIFO Simultaneously */
41#define ANOMALY_05000327 (1) 41#define ANOMALY_05000327 (__SILICON_REVISION__ < 1)
42/* Incorrect Access of OTP_STATUS During otp_write() Function */ 42/* Incorrect Access of OTP_STATUS During otp_write() Function */
43#define ANOMALY_05000328 (1) 43#define ANOMALY_05000328 (__SILICON_REVISION__ < 1)
44/* Synchronous Burst Flash Boot Mode Is Not Functional */ 44/* Synchronous Burst Flash Boot Mode Is Not Functional */
45#define ANOMALY_05000329 (1) 45#define ANOMALY_05000329 (__SILICON_REVISION__ < 1)
46/* Host DMA Boot Mode Is Not Functional */ 46/* Host DMA Boot Mode Is Not Functional */
47#define ANOMALY_05000330 (1) 47#define ANOMALY_05000330 (__SILICON_REVISION__ < 1)
48/* Inadequate Timing Margins on DDR DQS to DQ and DQM Skew */ 48/* Inadequate Timing Margins on DDR DQS to DQ and DQM Skew */
49#define ANOMALY_05000334 (1) 49#define ANOMALY_05000334 (__SILICON_REVISION__ < 1)
50/* Inadequate Rotary Debounce Logic Duration */ 50/* Inadequate Rotary Debounce Logic Duration */
51#define ANOMALY_05000335 (1) 51#define ANOMALY_05000335 (__SILICON_REVISION__ < 1)
52/* Phantom Interrupt Occurs After First Configuration of Host DMA Port */ 52/* Phantom Interrupt Occurs After First Configuration of Host DMA Port */
53#define ANOMALY_05000336 (1) 53#define ANOMALY_05000336 (__SILICON_REVISION__ < 1)
54/* Disallowed Configuration Prevents Subsequent Allowed Configuration on Host DMA Port */ 54/* Disallowed Configuration Prevents Subsequent Allowed Configuration on Host DMA Port */
55#define ANOMALY_05000337 (1) 55#define ANOMALY_05000337 (__SILICON_REVISION__ < 1)
56/* Slave-Mode SPI0 MISO Failure With CPHA = 0 */ 56/* Slave-Mode SPI0 MISO Failure With CPHA = 0 */
57#define ANOMALY_05000338 (1) 57#define ANOMALY_05000338 (__SILICON_REVISION__ < 1)
58/* If Memory Reads Are Enabled on SDH or HOSTDP, Other DMAC1 Peripherals Cannot Read */ 58/* If Memory Reads Are Enabled on SDH or HOSTDP, Other DMAC1 Peripherals Cannot Read */
59#define ANOMALY_05000340 (1) 59#define ANOMALY_05000340 (__SILICON_REVISION__ < 1)
60/* Boot Host Wait (HWAIT) and Boot Host Wait Alternate (HWAITA) Signals Are Swapped */ 60/* Boot Host Wait (HWAIT) and Boot Host Wait Alternate (HWAITA) Signals Are Swapped */
61#define ANOMALY_05000344 (1) 61#define ANOMALY_05000344 (__SILICON_REVISION__ < 1)
62/* USB Calibration Value Is Not Intialized */ 62/* USB Calibration Value Is Not Intialized */
63#define ANOMALY_05000346 (1) 63#define ANOMALY_05000346 (__SILICON_REVISION__ < 1)
64/* Boot ROM Kernel Incorrectly Alters Reset Value of USB Register */ 64/* Boot ROM Kernel Incorrectly Alters Reset Value of USB Register */
65#define ANOMALY_05000347 (1) 65#define ANOMALY_05000347 (__SILICON_REVISION__ < 1)
66/* Data Lost when Core Reads SDH Data FIFO */ 66/* Data Lost when Core Reads SDH Data FIFO */
67#define ANOMALY_05000349 (1) 67#define ANOMALY_05000349 (__SILICON_REVISION__ < 1)
68/* PLL Status Register Is Inaccurate */ 68/* PLL Status Register Is Inaccurate */
69#define ANOMALY_05000351 (1) 69#define ANOMALY_05000351 (__SILICON_REVISION__ < 1)
70/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */
71#define ANOMALY_05000357 (1)
72/* External Memory Read Access Hangs Core With PLL Bypass */
73#define ANOMALY_05000360 (1)
74/* DMAs that Go Urgent during Tight Core Writes to External Memory Are Blocked */
75#define ANOMALY_05000365 (1)
76/* Addressing Conflict between Boot ROM and Asynchronous Memory */
77#define ANOMALY_05000369 (1)
78/* Mobile DDR Operation Not Functional */
79#define ANOMALY_05000377 (1)
80/* Security/Authentication Speedpath Causes Authentication To Fail To Initiate */
81#define ANOMALY_05000378 (1)
70 82
71/* Anomalies that don't exist on this proc */ 83/* Anomalies that don't exist on this proc */
72#define ANOMALY_05000125 (0) 84#define ANOMALY_05000125 (0)
diff --git a/include/asm-blackfin/mach-bf548/bf548.h b/include/asm-blackfin/mach-bf548/bf548.h
index 7e6d349beb08..e748588e8930 100644
--- a/include/asm-blackfin/mach-bf548/bf548.h
+++ b/include/asm-blackfin/mach-bf548/bf548.h
@@ -106,24 +106,22 @@
106 106
107#define AMGCTLVAL (V_AMBEN | V_AMCKEN) 107#define AMGCTLVAL (V_AMBEN | V_AMCKEN)
108 108
109#ifdef CONFIG_BF542 109#if defined(CONFIG_BF542)
110#define CPU "BF542" 110# define CPU "BF542"
111#define CPUID 0x027c8000 111# define CPUID 0x027c8000
112#endif 112#elif defined(CONFIG_BF544)
113#ifdef CONFIG_BF544 113# define CPU "BF544"
114#define CPU "BF544" 114# define CPUID 0x027c8000
115#define CPUID 0x027c8000 115#elif defined(CONFIG_BF547)
116#endif 116# define CPU "BF547"
117#ifdef CONFIG_BF548 117#elif defined(CONFIG_BF548)
118#define CPU "BF548" 118# define CPU "BF548"
119#define CPUID 0x027c6000 119# define CPUID 0x027c6000
120#endif 120#elif defined(CONFIG_BF549)
121#ifdef CONFIG_BF549 121# define CPU "BF549"
122#define CPU "BF549" 122#else
123#endif 123# define CPU "UNKNOWN"
124#ifndef CPU 124# define CPUID 0x0
125#define CPU "UNKNOWN"
126#define CPUID 0x0
127#endif 125#endif
128 126
129#endif /* __MACH_BF48_H__ */ 127#endif /* __MACH_BF48_H__ */
diff --git a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
index f21a1620e6bd..3770aa38ee9f 100644
--- a/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf548/bfin_serial_5xx.h
@@ -186,7 +186,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
186 186
187 if (uart->rts_pin >= 0) { 187 if (uart->rts_pin >= 0) {
188 gpio_request(uart->rts_pin, DRIVER_NAME); 188 gpio_request(uart->rts_pin, DRIVER_NAME);
189 gpio_direction_output(uart->rts_pin); 189 gpio_direction_output(uart->rts_pin, 0);
190 } 190 }
191#endif 191#endif
192} 192}
diff --git a/include/asm-blackfin/mach-bf548/cdefBF54x_base.h b/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
index aefab3f618c1..19ddcd83c71f 100644
--- a/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
+++ b/include/asm-blackfin/mach-bf548/cdefBF54x_base.h
@@ -244,39 +244,6 @@ static __inline__ void bfin_write_VR_CTL(unsigned int val)
244#define bfin_read_TWI0_RCV_DATA16() bfin_read16(TWI0_RCV_DATA16) 244#define bfin_read_TWI0_RCV_DATA16() bfin_read16(TWI0_RCV_DATA16)
245#define bfin_write_TWI0_RCV_DATA16(val) bfin_write16(TWI0_RCV_DATA16, val) 245#define bfin_write_TWI0_RCV_DATA16(val) bfin_write16(TWI0_RCV_DATA16, val)
246 246
247#define bfin_read_TWI_CLKDIV() bfin_read16(TWI0_CLKDIV)
248#define bfin_write_TWI_CLKDIV(val) bfin_write16(TWI0_CLKDIV, val)
249#define bfin_read_TWI_CONTROL() bfin_read16(TWI0_CONTROL)
250#define bfin_write_TWI_CONTROL(val) bfin_write16(TWI0_CONTROL, val)
251#define bfin_read_TWI_SLAVE_CTRL() bfin_read16(TWI0_SLAVE_CTRL)
252#define bfin_write_TWI_SLAVE_CTRL(val) bfin_write16(TWI0_SLAVE_CTRL, val)
253#define bfin_read_TWI_SLAVE_STAT() bfin_read16(TWI0_SLAVE_STAT)
254#define bfin_write_TWI_SLAVE_STAT(val) bfin_write16(TWI0_SLAVE_STAT, val)
255#define bfin_read_TWI_SLAVE_ADDR() bfin_read16(TWI0_SLAVE_ADDR)
256#define bfin_write_TWI_SLAVE_ADDR(val) bfin_write16(TWI0_SLAVE_ADDR, val)
257#define bfin_read_TWI_MASTER_CTL() bfin_read16(TWI0_MASTER_CTRL)
258#define bfin_write_TWI_MASTER_CTL(val) bfin_write16(TWI0_MASTER_CTRL, val)
259#define bfin_read_TWI_MASTER_STAT() bfin_read16(TWI0_MASTER_STAT)
260#define bfin_write_TWI_MASTER_STAT(val) bfin_write16(TWI0_MASTER_STAT, val)
261#define bfin_read_TWI_MASTER_ADDR() bfin_read16(TWI0_MASTER_ADDR)
262#define bfin_write_TWI_MASTER_ADDR(val) bfin_write16(TWI0_MASTER_ADDR, val)
263#define bfin_read_TWI_INT_STAT() bfin_read16(TWI0_INT_STAT)
264#define bfin_write_TWI_INT_STAT(val) bfin_write16(TWI0_INT_STAT, val)
265#define bfin_read_TWI_INT_MASK() bfin_read16(TWI0_INT_MASK)
266#define bfin_write_TWI_INT_MASK(val) bfin_write16(TWI0_INT_MASK, val)
267#define bfin_read_TWI_FIFO_CTL() bfin_read16(TWI0_FIFO_CTRL)
268#define bfin_write_TWI_FIFO_CTL(val) bfin_write16(TWI0_FIFO_CTRL, val)
269#define bfin_read_TWI_FIFO_STAT() bfin_read16(TWI0_FIFO_STAT)
270#define bfin_write_TWI_FIFO_STAT(val) bfin_write16(TWI0_FIFO_STAT, val)
271#define bfin_read_TWI_XMT_DATA8() bfin_read16(TWI0_XMT_DATA8)
272#define bfin_write_TWI_XMT_DATA8(val) bfin_write16(TWI0_XMT_DATA8, val)
273#define bfin_read_TWI_XMT_DATA16() bfin_read16(TWI0_XMT_DATA16)
274#define bfin_write_TWI_XMT_DATA16(val) bfin_write16(TWI0_XMT_DATA16, val)
275#define bfin_read_TWI_RCV_DATA8() bfin_read16(TWI0_RCV_DATA8)
276#define bfin_write_TWI_RCV_DATA8(val) bfin_write16(TWI0_RCV_DATA8, val)
277#define bfin_read_TWI_RCV_DATA16() bfin_read16(TWI0_RCV_DATA16)
278#define bfin_write_TWI_RCV_DATA16(val) bfin_write16(TWI0_RCV_DATA16, val)
279
280/* SPORT0 is not defined in the shared file because it is not available on the ADSP-BF542 and ADSP-BF544 bfin_read_()rocessors */ 247/* SPORT0 is not defined in the shared file because it is not available on the ADSP-BF542 and ADSP-BF544 bfin_read_()rocessors */
281 248
282/* SPORT1 Registers */ 249/* SPORT1 Registers */
diff --git a/include/asm-blackfin/mach-bf548/defBF542.h b/include/asm-blackfin/mach-bf548/defBF542.h
index 32d07130200c..a7c809f29ede 100644
--- a/include/asm-blackfin/mach-bf548/defBF542.h
+++ b/include/asm-blackfin/mach-bf548/defBF542.h
@@ -432,8 +432,8 @@
432 432
433#define CMD_CRC_FAIL 0x1 /* CMD CRC Fail */ 433#define CMD_CRC_FAIL 0x1 /* CMD CRC Fail */
434#define DAT_CRC_FAIL 0x2 /* Data CRC Fail */ 434#define DAT_CRC_FAIL 0x2 /* Data CRC Fail */
435#define CMD_TIMEOUT 0x4 /* CMD Time Out */ 435#define CMD_TIME_OUT 0x4 /* CMD Time Out */
436#define DAT_TIMEOUT 0x8 /* Data Time Out */ 436#define DAT_TIME_OUT 0x8 /* Data Time Out */
437#define TX_UNDERRUN 0x10 /* Transmit Underrun */ 437#define TX_UNDERRUN 0x10 /* Transmit Underrun */
438#define RX_OVERRUN 0x20 /* Receive Overrun */ 438#define RX_OVERRUN 0x20 /* Receive Overrun */
439#define CMD_RESP_END 0x40 /* CMD Response End */ 439#define CMD_RESP_END 0x40 /* CMD Response End */
diff --git a/include/asm-blackfin/mach-bf548/defBF544.h b/include/asm-blackfin/mach-bf548/defBF544.h
index 760307e34b9e..b8b9870e2697 100644
--- a/include/asm-blackfin/mach-bf548/defBF544.h
+++ b/include/asm-blackfin/mach-bf548/defBF544.h
@@ -645,7 +645,7 @@
645 645
646/* Bit masks for HOST_STATUS */ 646/* Bit masks for HOST_STATUS */
647 647
648#define READY 0x1 /* DMA Ready */ 648#define DMA_READY 0x1 /* DMA Ready */
649#define FIFOFULL 0x2 /* FIFO Full */ 649#define FIFOFULL 0x2 /* FIFO Full */
650#define FIFOEMPTY 0x4 /* FIFO Empty */ 650#define FIFOEMPTY 0x4 /* FIFO Empty */
651#define COMPLETE 0x8 /* DMA Complete */ 651#define COMPLETE 0x8 /* DMA Complete */
diff --git a/include/asm-blackfin/mach-bf548/defBF548.h b/include/asm-blackfin/mach-bf548/defBF548.h
index 70af33c963b0..e46f56891e6a 100644
--- a/include/asm-blackfin/mach-bf548/defBF548.h
+++ b/include/asm-blackfin/mach-bf548/defBF548.h
@@ -1007,7 +1007,7 @@
1007 1007
1008/* Bit masks for HOST_STATUS */ 1008/* Bit masks for HOST_STATUS */
1009 1009
1010#define READY 0x1 /* DMA Ready */ 1010#define DMA_READY 0x1 /* DMA Ready */
1011#define FIFOFULL 0x2 /* FIFO Full */ 1011#define FIFOFULL 0x2 /* FIFO Full */
1012#define FIFOEMPTY 0x4 /* FIFO Empty */ 1012#define FIFOEMPTY 0x4 /* FIFO Empty */
1013#define COMPLETE 0x8 /* DMA Complete */ 1013#define COMPLETE 0x8 /* DMA Complete */
@@ -1095,8 +1095,8 @@
1095 1095
1096#define CMD_CRC_FAIL 0x1 /* CMD CRC Fail */ 1096#define CMD_CRC_FAIL 0x1 /* CMD CRC Fail */
1097#define DAT_CRC_FAIL 0x2 /* Data CRC Fail */ 1097#define DAT_CRC_FAIL 0x2 /* Data CRC Fail */
1098#define CMD_TIMEOUT 0x4 /* CMD Time Out */ 1098#define CMD_TIME_OUT 0x4 /* CMD Time Out */
1099#define DAT_TIMEOUT 0x8 /* Data Time Out */ 1099#define DAT_TIME_OUT 0x8 /* Data Time Out */
1100#define TX_UNDERRUN 0x10 /* Transmit Underrun */ 1100#define TX_UNDERRUN 0x10 /* Transmit Underrun */
1101#define RX_OVERRUN 0x20 /* Receive Overrun */ 1101#define RX_OVERRUN 0x20 /* Receive Overrun */
1102#define CMD_RESP_END 0x40 /* CMD Response End */ 1102#define CMD_RESP_END 0x40 /* CMD Response End */
diff --git a/include/asm-blackfin/mach-bf548/defBF549.h b/include/asm-blackfin/mach-bf548/defBF549.h
index 4e46d657e50e..fcb72b41e007 100644
--- a/include/asm-blackfin/mach-bf548/defBF549.h
+++ b/include/asm-blackfin/mach-bf548/defBF549.h
@@ -1671,7 +1671,7 @@
1671/* Bit masks for MXVR_DMAx_CONFIG */ 1671/* Bit masks for MXVR_DMAx_CONFIG */
1672 1672
1673#define MDMAEN 0x1 /* DMA Channel Enable */ 1673#define MDMAEN 0x1 /* DMA Channel Enable */
1674#define DD 0x2 /* DMA Channel Direction */ 1674#define DMADD 0x2 /* DMA Channel Direction */
1675#define BY4SWAPEN 0x20 /* DMA Channel Four Byte Swap Enable */ 1675#define BY4SWAPEN 0x20 /* DMA Channel Four Byte Swap Enable */
1676#define LCHAN 0x3c0 /* DMA Channel Logical Channel */ 1676#define LCHAN 0x3c0 /* DMA Channel Logical Channel */
1677#define BITSWAPEN 0x400 /* DMA Channel Bit Swap Enable */ 1677#define BITSWAPEN 0x400 /* DMA Channel Bit Swap Enable */
diff --git a/include/asm-blackfin/mach-bf548/defBF54x_base.h b/include/asm-blackfin/mach-bf548/defBF54x_base.h
index 1d365c844ffe..08f90c21fe8a 100644
--- a/include/asm-blackfin/mach-bf548/defBF54x_base.h
+++ b/include/asm-blackfin/mach-bf548/defBF54x_base.h
@@ -1644,8 +1644,25 @@
1644#define RESTART 0x20 /* Work Unit Transitions */ 1644#define RESTART 0x20 /* Work Unit Transitions */
1645#define DI_SEL 0x40 /* Data Interrupt Timing Select */ 1645#define DI_SEL 0x40 /* Data Interrupt Timing Select */
1646#define DI_EN 0x80 /* Data Interrupt Enable */ 1646#define DI_EN 0x80 /* Data Interrupt Enable */
1647
1647#define NDSIZE 0xf00 /* Flex Descriptor Size */ 1648#define NDSIZE 0xf00 /* Flex Descriptor Size */
1649#define NDSIZE_0 0x0000 /* Next Descriptor Size = 0 (Stop/Autobuffer) */
1650#define NDSIZE_1 0x0100 /* Next Descriptor Size = 1 */
1651#define NDSIZE_2 0x0200 /* Next Descriptor Size = 2 */
1652#define NDSIZE_3 0x0300 /* Next Descriptor Size = 3 */
1653#define NDSIZE_4 0x0400 /* Next Descriptor Size = 4 */
1654#define NDSIZE_5 0x0500 /* Next Descriptor Size = 5 */
1655#define NDSIZE_6 0x0600 /* Next Descriptor Size = 6 */
1656#define NDSIZE_7 0x0700 /* Next Descriptor Size = 7 */
1657#define NDSIZE_8 0x0800 /* Next Descriptor Size = 8 */
1658#define NDSIZE_9 0x0900 /* Next Descriptor Size = 9 */
1659
1648#define DMAFLOW 0xf000 /* Next Operation */ 1660#define DMAFLOW 0xf000 /* Next Operation */
1661#define DMAFLOW_STOP 0x0000 /* Stop Mode */
1662#define DMAFLOW_AUTO 0x1000 /* Autobuffer Mode */
1663#define DMAFLOW_ARRAY 0x4000 /* Descriptor Array Mode */
1664#define DMAFLOW_SMALL 0x6000 /* Small Model Descriptor List Mode */
1665#define DMAFLOW_LARGE 0x7000 /* Large Model Descriptor List Mode */
1649 1666
1650/* Bit masks for DMAx_IRQ_STATUS, MDMA_Sx_IRQ_STATUS, MDMA_Dx_IRQ_STATUS */ 1667/* Bit masks for DMAx_IRQ_STATUS, MDMA_Sx_IRQ_STATUS, MDMA_Dx_IRQ_STATUS */
1651 1668
@@ -1755,17 +1772,36 @@
1755#define TRP 0x3c0000 /* Pre charge-to-active command period */ 1772#define TRP 0x3c0000 /* Pre charge-to-active command period */
1756#define TRAS 0x3c00000 /* Min Active-to-pre charge time */ 1773#define TRAS 0x3c00000 /* Min Active-to-pre charge time */
1757#define TRC 0x3c000000 /* Active-to-active time */ 1774#define TRC 0x3c000000 /* Active-to-active time */
1775#define DDR_TRAS(x) ((x<<22)&TRAS) /* DDR tRAS = (1~15) cycles */
1776#define DDR_TRP(x) ((x<<18)&TRP) /* DDR tRP = (1~15) cycles */
1777#define DDR_TRC(x) ((x<<26)&TRC) /* DDR tRC = (1~15) cycles */
1778#define DDR_TRFC(x) ((x<<14)&TRFC) /* DDR tRFC = (1~15) cycles */
1779#define DDR_TREFI(x) (x&TREFI) /* DDR tRFC = (1~15) cycles */
1758 1780
1759/* Bit masks for EBIU_DDRCTL1 */ 1781/* Bit masks for EBIU_DDRCTL1 */
1760 1782
1761#define TRCD 0xf /* Active-to-Read/write delay */ 1783#define TRCD 0xf /* Active-to-Read/write delay */
1762#define MRD 0xf0 /* Mode register set to active */ 1784#define TMRD 0xf0 /* Mode register set to active */
1763#define TWR 0x300 /* Write Recovery time */ 1785#define TWR 0x300 /* Write Recovery time */
1764#define DDRDATWIDTH 0x3000 /* DDR data width */ 1786#define DDRDATWIDTH 0x3000 /* DDR data width */
1765#define EXTBANKS 0xc000 /* External banks */ 1787#define EXTBANKS 0xc000 /* External banks */
1766#define DDRDEVWIDTH 0x30000 /* DDR device width */ 1788#define DDRDEVWIDTH 0x30000 /* DDR device width */
1767#define DDRDEVSIZE 0xc0000 /* DDR device size */ 1789#define DDRDEVSIZE 0xc0000 /* DDR device size */
1768#define TWWTR 0xf0000000 /* Write-to-read delay */ 1790#define TWTR 0xf0000000 /* Write-to-read delay */
1791#define DDR_TWTR(x) ((x<<28)&TWTR) /* DDR tWTR = (1~15) cycles */
1792#define DDR_TMRD(x) ((x<<4)&TMRD) /* DDR tMRD = (1~15) cycles */
1793#define DDR_TWR(x) ((x<<8)&TWR) /* DDR tWR = (1~15) cycles */
1794#define DDR_TRCD(x) (x&TRCD) /* DDR tRCD = (1~15) cycles */
1795#define DDR_DATWIDTH 0x2000 /* DDR data width */
1796#define EXTBANK_1 0 /* 1 external bank */
1797#define EXTBANK_2 0x4000 /* 2 external banks */
1798#define DEVSZ_64 0x40000 /* DDR External Bank Size = 64MB */
1799#define DEVSZ_128 0x80000 /* DDR External Bank Size = 128MB */
1800#define DEVSZ_256 0xc0000 /* DDR External Bank Size = 256MB */
1801#define DEVSZ_512 0 /* DDR External Bank Size = 512MB */
1802#define DEVWD_4 0 /* DDR Device Width = 4 Bits */
1803#define DEVWD_8 0x10000 /* DDR Device Width = 8 Bits */
1804#define DEVWD_16 0x20000 /* DDR Device Width = 16 Bits */
1769 1805
1770/* Bit masks for EBIU_DDRCTL2 */ 1806/* Bit masks for EBIU_DDRCTL2 */
1771 1807
@@ -1773,6 +1809,10 @@
1773#define CASLATENCY 0x70 /* CAS latency */ 1809#define CASLATENCY 0x70 /* CAS latency */
1774#define DLLRESET 0x100 /* DLL Reset */ 1810#define DLLRESET 0x100 /* DLL Reset */
1775#define REGE 0x1000 /* Register mode enable */ 1811#define REGE 0x1000 /* Register mode enable */
1812#define CL_1_5 0x50 /* DDR CAS Latency = 1.5 cycles */
1813#define CL_2 0x20 /* DDR CAS Latency = 2 cycles */
1814#define CL_2_5 0x60 /* DDR CAS Latency = 2.5 cycles */
1815#define CL_3 0x30 /* DDR CAS Latency = 3 cycles */
1776 1816
1777/* Bit masks for EBIU_DDRCTL3 */ 1817/* Bit masks for EBIU_DDRCTL3 */
1778 1818
@@ -2240,6 +2280,10 @@
2240 2280
2241#define CSEL 0x30 /* Core Select */ 2281#define CSEL 0x30 /* Core Select */
2242#define SSEL 0xf /* System Select */ 2282#define SSEL 0xf /* System Select */
2283#define CSEL_DIV1 0x0000 /* CCLK = VCO / 1 */
2284#define CSEL_DIV2 0x0010 /* CCLK = VCO / 2 */
2285#define CSEL_DIV4 0x0020 /* CCLK = VCO / 4 */
2286#define CSEL_DIV8 0x0030 /* CCLK = VCO / 8 */
2243 2287
2244/* Bit masks for PLL_CTL */ 2288/* Bit masks for PLL_CTL */
2245 2289
@@ -2252,6 +2296,13 @@
2252#define PLL_OFF 0x2 /* Disable PLL */ 2296#define PLL_OFF 0x2 /* Disable PLL */
2253#define DF 0x1 /* Divide Frequency */ 2297#define DF 0x1 /* Divide Frequency */
2254 2298
2299/* SWRST Masks */
2300#define SYSTEM_RESET 0x0007 /* Initiates A System Software Reset */
2301#define DOUBLE_FAULT 0x0008 /* Core Double Fault Causes Reset */
2302#define RESET_DOUBLE 0x2000 /* SW Reset Generated By Core Double-Fault */
2303#define RESET_WDOG 0x4000 /* SW Reset Generated By Watchdog Timer */
2304#define RESET_SOFTWARE 0x8000 /* SW Reset Occurred Since Last Read Of SWRST */
2305
2255/* Bit masks for PLL_STAT */ 2306/* Bit masks for PLL_STAT */
2256 2307
2257#define PLL_LOCKED 0x20 /* PLL Locked Status */ 2308#define PLL_LOCKED 0x20 /* PLL Locked Status */
diff --git a/include/asm-blackfin/mach-bf548/irq.h b/include/asm-blackfin/mach-bf548/irq.h
index 3b08cf9bd6f3..c34507a3f1df 100644
--- a/include/asm-blackfin/mach-bf548/irq.h
+++ b/include/asm-blackfin/mach-bf548/irq.h
@@ -88,7 +88,7 @@ Events (highest priority) EMU 0
88#define IRQ_PINT1 BFIN_IRQ(20) /* PINT1 Interrupt */ 88#define IRQ_PINT1 BFIN_IRQ(20) /* PINT1 Interrupt */
89#define IRQ_MDMAS0 BFIN_IRQ(21) /* MDMA Stream 0 Interrupt */ 89#define IRQ_MDMAS0 BFIN_IRQ(21) /* MDMA Stream 0 Interrupt */
90#define IRQ_MDMAS1 BFIN_IRQ(22) /* MDMA Stream 1 Interrupt */ 90#define IRQ_MDMAS1 BFIN_IRQ(22) /* MDMA Stream 1 Interrupt */
91#define IRQ_WATCHDOG BFIN_IRQ(23) /* Watchdog Interrupt */ 91#define IRQ_WATCH BFIN_IRQ(23) /* Watchdog Interrupt */
92#define IRQ_DMAC1_ERROR BFIN_IRQ(24) /* DMAC1 Status (Error) Interrupt */ 92#define IRQ_DMAC1_ERROR BFIN_IRQ(24) /* DMAC1 Status (Error) Interrupt */
93#define IRQ_SPORT2_ERROR BFIN_IRQ(25) /* SPORT2 Error Interrupt */ 93#define IRQ_SPORT2_ERROR BFIN_IRQ(25) /* SPORT2 Error Interrupt */
94#define IRQ_SPORT3_ERROR BFIN_IRQ(26) /* SPORT3 Error Interrupt */ 94#define IRQ_SPORT3_ERROR BFIN_IRQ(26) /* SPORT3 Error Interrupt */
@@ -338,11 +338,7 @@ Events (highest priority) EMU 0
338 338
339#define GPIO_IRQ_BASE IRQ_PA0 339#define GPIO_IRQ_BASE IRQ_PA0
340 340
341#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
342#define NR_IRQS (IRQ_PJ15+1) 341#define NR_IRQS (IRQ_PJ15+1)
343#else
344#define NR_IRQS (SYS_IRQS+1)
345#endif
346 342
347/* For compatibility reasons with existing code */ 343/* For compatibility reasons with existing code */
348 344
@@ -410,7 +406,7 @@ Events (highest priority) EMU 0
410#define IRQ_PINT1_POS 16 406#define IRQ_PINT1_POS 16
411#define IRQ_MDMAS0_POS 20 407#define IRQ_MDMAS0_POS 20
412#define IRQ_MDMAS1_POS 24 408#define IRQ_MDMAS1_POS 24
413#define IRQ_WATCHDOG_POS 28 409#define IRQ_WATCH_POS 28
414 410
415/* IAR3 BIT FIELDS */ 411/* IAR3 BIT FIELDS */
416#define IRQ_DMAC1_ERR_POS 0 412#define IRQ_DMAC1_ERR_POS 0
diff --git a/include/asm-blackfin/mach-bf548/mem_init.h b/include/asm-blackfin/mach-bf548/mem_init.h
index 0cb279e973d7..befc2903d5a5 100644
--- a/include/asm-blackfin/mach-bf548/mem_init.h
+++ b/include/asm-blackfin/mach-bf548/mem_init.h
@@ -28,8 +28,68 @@
28 * If not, write to the Free Software Foundation, 28 * If not, write to the Free Software Foundation,
29 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 29 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 */ 30 */
31#define MIN_DDR_SCLK(x) (x*(CONFIG_SCLK_HZ/1000/1000)/1000 + 1)
32
33#if (CONFIG_MEM_MT46V32M16_6T)
34#define DDR_SIZE DEVSZ_512
35#define DDR_WIDTH DEVWD_16
36
37#define DDR_tRC DDR_TRC(MIN_DDR_SCLK(60))
38#define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(42))
39#define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15))
40#define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(72))
41#define DDR_tREFI DDR_TREFI(MIN_DDR_SCLK(7800))
42
43#define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15))
44#define DDR_tWTR DDR_TWTR(1)
45#define DDR_tMRD DDR_TMRD(MIN_DDR_SCLK(12))
46#define DDR_tWR DDR_TWR(MIN_DDR_SCLK(15))
47#endif
48
49#if (CONFIG_MEM_MT46V32M16_5B)
50#define DDR_SIZE DEVSZ_512
51#define DDR_WIDTH DEVWD_16
52
53#define DDR_tRC DDR_TRC(MIN_DDR_SCLK(55))
54#define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(40))
55#define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15))
56#define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(70))
57#define DDR_tREFI DDR_TREFI(MIN_DDR_SCLK(7800))
58
59#define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15))
60#define DDR_tWTR DDR_TWTR(2)
61#define DDR_tMRD DDR_TMRD(MIN_DDR_SCLK(10))
62#define DDR_tWR DDR_TWR(MIN_DDR_SCLK(15))
63#endif
64
65#if (CONFIG_MEM_GENERIC_BOARD)
66#define DDR_SIZE DEVSZ_512
67#define DDR_WIDTH DEVWD_16
68
69#define DDR_tRCD DDR_TRCD(3)
70#define DDR_tWTR DDR_TWTR(2)
71#define DDR_tWR DDR_TWR(2)
72#define DDR_tMRD DDR_TMRD(2)
73#define DDR_tRP DDR_TRP(3)
74#define DDR_tRAS DDR_TRAS(7)
75#define DDR_tRC DDR_TRC(10)
76#define DDR_tRFC DDR_TRFC(12)
77#define DDR_tREFI DDR_TREFI(1288)
78#endif
79
80#if (CONFIG_SCLK_HZ <= 133333333)
81#define DDR_CL CL_2
82#elif (CONFIG_SCLK_HZ <= 166666666)
83#define DDR_CL CL_2_5
84#else
85#define DDR_CL CL_3
86#endif
87
88#define mem_DDRCTL0 (DDR_tRP | DDR_tRAS | DDR_tRC | DDR_tRFC | DDR_tREFI)
89#define mem_DDRCTL1 (DDR_DATWIDTH | EXTBANK_1 | DDR_SIZE | DDR_WIDTH | DDR_tWTR \
90 | DDR_tMRD | DDR_tWR | DDR_tRCD)
91#define mem_DDRCTL2 DDR_CL
31 92
32#if (CONFIG_MEM_MT46V32M16)
33 93
34#if defined CONFIG_CLKIN_HALF 94#if defined CONFIG_CLKIN_HALF
35#define CLKIN_HALF 1 95#define CLKIN_HALF 1
diff --git a/include/asm-blackfin/mach-bf548/mem_map.h b/include/asm-blackfin/mach-bf548/mem_map.h
index ec1597e31831..f99f47bc3a07 100644
--- a/include/asm-blackfin/mach-bf548/mem_map.h
+++ b/include/asm-blackfin/mach-bf548/mem_map.h
@@ -47,6 +47,12 @@
47/* Boot ROM Memory */ 47/* Boot ROM Memory */
48 48
49#define BOOT_ROM_START 0xEF000000 49#define BOOT_ROM_START 0xEF000000
50#define BOOT_ROM_LENGTH 0x1000
51
52/* L1 Instruction ROM */
53
54#define L1_ROM_START 0xFFA14000
55#define L1_ROM_LENGTH 0x10000
50 56
51/* Level 1 Memory */ 57/* Level 1 Memory */
52 58
@@ -87,11 +93,19 @@
87#define BFIN_DSUPBANKS 0 93#define BFIN_DSUPBANKS 0
88#endif /*CONFIG_BFIN_DCACHE*/ 94#endif /*CONFIG_BFIN_DCACHE*/
89 95
96/* Level 2 Memory */
97#if !defined(CONFIG_BF542)
98# define L2_START 0xFEB00000
99# if defined(CONFIG_BF544)
100# define L2_LENGTH 0x10000
101# else
102# define L2_LENGTH 0x20000
103# endif
104#endif
105
90/* Scratch Pad Memory */ 106/* Scratch Pad Memory */
91 107
92#if defined(CONFIG_BF54x)
93#define L1_SCRATCH_START 0xFFB00000 108#define L1_SCRATCH_START 0xFFB00000
94#define L1_SCRATCH_LENGTH 0x1000 109#define L1_SCRATCH_LENGTH 0x1000
95#endif
96 110
97#endif/* _MEM_MAP_548_H_ */ 111#endif/* _MEM_MAP_548_H_ */
diff --git a/include/asm-blackfin/mach-bf548/portmux.h b/include/asm-blackfin/mach-bf548/portmux.h
index b382deb501a7..8177a567dcdb 100644
--- a/include/asm-blackfin/mach-bf548/portmux.h
+++ b/include/asm-blackfin/mach-bf548/portmux.h
@@ -1,6 +1,8 @@
1#ifndef _MACH_PORTMUX_H_ 1#ifndef _MACH_PORTMUX_H_
2#define _MACH_PORTMUX_H_ 2#define _MACH_PORTMUX_H_
3 3
4#define MAX_RESOURCES MAX_BLACKFIN_GPIOS
5
4#define P_SPORT2_TFS (P_DEFINED | P_IDENT(GPIO_PA0) | P_FUNCT(0)) 6#define P_SPORT2_TFS (P_DEFINED | P_IDENT(GPIO_PA0) | P_FUNCT(0))
5#define P_SPORT2_DTSEC (P_DEFINED | P_IDENT(GPIO_PA1) | P_FUNCT(0)) 7#define P_SPORT2_DTSEC (P_DEFINED | P_IDENT(GPIO_PA1) | P_FUNCT(0))
6#define P_SPORT2_DTPRI (P_DEFINED | P_IDENT(GPIO_PA2) | P_FUNCT(0)) 8#define P_SPORT2_DTPRI (P_DEFINED | P_IDENT(GPIO_PA2) | P_FUNCT(0))
@@ -267,4 +269,18 @@
267#define P_AMC_BG (P_DEFINED | P_IDENT(GPIO_PJ12) | P_FUNCT(0)) 269#define P_AMC_BG (P_DEFINED | P_IDENT(GPIO_PJ12) | P_FUNCT(0))
268#define P_AMC_BGH (P_DEFINED | P_IDENT(GPIO_PJ13) | P_FUNCT(0)) 270#define P_AMC_BGH (P_DEFINED | P_IDENT(GPIO_PJ13) | P_FUNCT(0))
269 271
272
273#define P_NAND_D0 (P_DONTCARE)
274#define P_NAND_D1 (P_DONTCARE)
275#define P_NAND_D2 (P_DONTCARE)
276#define P_NAND_D3 (P_DONTCARE)
277#define P_NAND_D4 (P_DONTCARE)
278#define P_NAND_D5 (P_DONTCARE)
279#define P_NAND_D6 (P_DONTCARE)
280#define P_NAND_D7 (P_DONTCARE)
281#define P_NAND_WE (P_DONTCARE)
282#define P_NAND_RE (P_DONTCARE)
283#define P_NAND_CLE (P_DONTCARE)
284#define P_NAND_ALE (P_DONTCARE)
285
270#endif /* _MACH_PORTMUX_H_ */ 286#endif /* _MACH_PORTMUX_H_ */
diff --git a/include/asm-blackfin/mach-bf561/anomaly.h b/include/asm-blackfin/mach-bf561/anomaly.h
index bed956456884..0c1d46193939 100644
--- a/include/asm-blackfin/mach-bf561/anomaly.h
+++ b/include/asm-blackfin/mach-bf561/anomaly.h
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9/* This file shoule be up to date with: 9/* This file shoule be up to date with:
10 * - Revision N, March 28, 2007; ADSP-BF561 Silicon Anomaly List 10 * - Revision O, 11/15/2007; ADSP-BF561 Blackfin Processor Anomaly List
11 */ 11 */
12 12
13#ifndef _MACH_ANOMALY_H_ 13#ifndef _MACH_ANOMALY_H_
@@ -15,7 +15,7 @@
15 15
16/* We do not support 0.1, 0.2, or 0.4 silicon - sorry */ 16/* We do not support 0.1, 0.2, or 0.4 silicon - sorry */
17#if __SILICON_REVISION__ < 3 || __SILICON_REVISION__ == 4 17#if __SILICON_REVISION__ < 3 || __SILICON_REVISION__ == 4
18# error Kernel will not work on BF561 silicon version 0.0, 0.1, 0.2, or 0.4 18# error will not work on BF561 silicon version 0.0, 0.1, 0.2, or 0.4
19#endif 19#endif
20 20
21/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot 2 Not Supported */ 21/* Multi-Issue Instruction with dsp32shiftimm in slot1 and P-reg Store in slot 2 Not Supported */
@@ -208,6 +208,8 @@
208#define ANOMALY_05000275 (__SILICON_REVISION__ > 2) 208#define ANOMALY_05000275 (__SILICON_REVISION__ > 2)
209/* Timing Requirements Change for External Frame Sync PPI Modes with Non-Zero PPI_DELAY */ 209/* Timing Requirements Change for External Frame Sync PPI Modes with Non-Zero PPI_DELAY */
210#define ANOMALY_05000276 (__SILICON_REVISION__ < 5) 210#define ANOMALY_05000276 (__SILICON_REVISION__ < 5)
211/* Writes to an I/O data register one SCLK cycle after an edge is detected may clear interrupt */
212#define ANOMALY_05000277 (__SILICON_REVISION__ < 3)
211/* Disabling Peripherals with DMA Running May Cause DMA System Instability */ 213/* Disabling Peripherals with DMA Running May Cause DMA System Instability */
212#define ANOMALY_05000278 (__SILICON_REVISION__ < 5) 214#define ANOMALY_05000278 (__SILICON_REVISION__ < 5)
213/* False Hardware Error Exception When ISR Context Is Not Restored */ 215/* False Hardware Error Exception When ISR Context Is Not Restored */
@@ -246,6 +248,18 @@
246#define ANOMALY_05000332 (__SILICON_REVISION__ < 5) 248#define ANOMALY_05000332 (__SILICON_REVISION__ < 5)
247/* Flag Data Register Writes One SCLK Cycle After Edge Is Detected May Clear Interrupt Status */ 249/* Flag Data Register Writes One SCLK Cycle After Edge Is Detected May Clear Interrupt Status */
248#define ANOMALY_05000333 (__SILICON_REVISION__ < 5) 250#define ANOMALY_05000333 (__SILICON_REVISION__ < 5)
251/* New Feature: Additional PPI Frame Sync Sampling Options (Not Available on Older Silicon) */
252#define ANOMALY_05000339 (__SILICON_REVISION__ < 5)
253/* Memory DMA FIFO Causes Throughput Degradation on Writes to External Memory */
254#define ANOMALY_05000343 (__SILICON_REVISION__ < 5)
255/* Serial Port (SPORT) Multichannel Transmit Failure when Channel 0 Is Disabled */
256#define ANOMALY_05000357 (1)
257/* Conflicting Column Address Widths Causes SDRAM Errors */
258#define ANOMALY_05000362 (1)
259/* PPI Underflow Error Goes Undetected in ITU-R 656 Mode */
260#define ANOMALY_05000366 (1)
261/* Possible RETS Register Corruption when Subroutine Is under 5 Cycles in Duration */
262#define ANOMALY_05000371 (1)
249 263
250/* Anomalies that don't exist on this proc */ 264/* Anomalies that don't exist on this proc */
251#define ANOMALY_05000158 (0) 265#define ANOMALY_05000158 (0)
diff --git a/include/asm-blackfin/mach-bf561/bf561.h b/include/asm-blackfin/mach-bf561/bf561.h
index 17e1d5dcef02..3ef9e5f36136 100644
--- a/include/asm-blackfin/mach-bf561/bf561.h
+++ b/include/asm-blackfin/mach-bf561/bf561.h
@@ -33,25 +33,6 @@
33#define SUPPORTED_REVID 0x3 33#define SUPPORTED_REVID 0x3
34 34
35#define OFFSET_(x) ((x) & 0x0000FFFF) 35#define OFFSET_(x) ((x) & 0x0000FFFF)
36#define L1_ISRAM 0xFFA00000
37#define L1_ISRAM_END 0xFFA04000
38#define DATA_BANKA_SRAM 0xFF800000
39#define DATA_BANKA_SRAM_END 0xFF804000
40#define DATA_BANKB_SRAM 0xFF900000
41#define DATA_BANKB_SRAM_END 0xFF904000
42#define L1_DSRAMA 0xFF800000
43#define L1_DSRAMA_END 0xFF804000
44#define L1_DSRAMB 0xFF900000
45#define L1_DSRAMB_END 0xFF904000
46#define L2_SRAM 0xFEB00000
47#define L2_SRAM_END 0xFEB20000
48#define AMB_FLASH 0x20000000
49#define AMB_FLASH_END 0x21000000
50#define AMB_FLASH_LENGTH 0x01000000
51#define L1_ISRAM_LENGTH 0x4000
52#define L1_DSRAMA_LENGTH 0x4000
53#define L1_DSRAMB_LENGTH 0x4000
54#define L2_SRAM_LENGTH 0x20000
55 36
56/*some misc defines*/ 37/*some misc defines*/
57#define IMASK_IVG15 0x8000 38#define IMASK_IVG15 0x8000
diff --git a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
index 69b9f8e120e9..7871d4313f49 100644
--- a/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
+++ b/include/asm-blackfin/mach-bf561/bfin_serial_5xx.h
@@ -111,7 +111,7 @@ static void bfin_serial_hw_init(struct bfin_serial_port *uart)
111 } 111 }
112 if (uart->rts_pin >= 0) { 112 if (uart->rts_pin >= 0) {
113 gpio_request(uart->rts_pin, DRIVER_NAME); 113 gpio_request(uart->rts_pin, DRIVER_NAME);
114 gpio_direction_input(uart->rts_pin); 114 gpio_direction_input(uart->rts_pin, 0);
115 } 115 }
116#endif 116#endif
117} 117}
diff --git a/include/asm-blackfin/mach-bf561/defBF561.h b/include/asm-blackfin/mach-bf561/defBF561.h
index bf7dc4e00065..c3c0eb13c819 100644
--- a/include/asm-blackfin/mach-bf561/defBF561.h
+++ b/include/asm-blackfin/mach-bf561/defBF561.h
@@ -55,6 +55,10 @@
55/* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */ 55/* For MMR's that are reserved on Core B, set up defines to better integrate with other ports */
56#define SWRST SICA_SWRST 56#define SWRST SICA_SWRST
57#define SYSCR SICA_SYSCR 57#define SYSCR SICA_SYSCR
58#define DOUBLE_FAULT (DOUBLE_FAULT_B|DOUBLE_FAULT_A)
59#define RESET_DOUBLE (SWRST_DBL_FAULT_B|SWRST_DBL_FAULT_A)
60#define RESET_WDOG (SWRST_WDT_B|SWRST_WDT_A)
61#define RESET_SOFTWARE (SWRST_OCCURRED)
58 62
59/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */ 63/* System Reset and Interrupt Controller registers for core A (0xFFC0 0100-0xFFC0 01FF) */
60#define SICA_SWRST 0xFFC00100 /* Software Reset register */ 64#define SICA_SWRST 0xFFC00100 /* Software Reset register */
@@ -874,12 +878,14 @@
874#define PLL_LOCKED 0x0020 /* PLL_LOCKCNT Has Been Reached */ 878#define PLL_LOCKED 0x0020 /* PLL_LOCKCNT Has Been Reached */
875 879
876/* SWRST Mask */ 880/* SWRST Mask */
877#define SYSTEM_RESET 0x00000007 /* Initiates a system software reset */ 881#define SYSTEM_RESET 0x0007 /* Initiates a system software reset */
878#define SWRST_DBL_FAULT_B 0x00000800 /* SWRST Core B Double Fault */ 882#define DOUBLE_FAULT_A 0x0008 /* Core A Double Fault Causes Reset */
879#define SWRST_DBL_FAULT_A 0x00001000 /* SWRST Core A Double Fault */ 883#define DOUBLE_FAULT_B 0x0010 /* Core B Double Fault Causes Reset */
880#define SWRST_WDT_B 0x00002000 /* SWRST Watchdog B */ 884#define SWRST_DBL_FAULT_A 0x0800 /* SWRST Core A Double Fault */
881#define SWRST_WDT_A 0x00004000 /* SWRST Watchdog A */ 885#define SWRST_DBL_FAULT_B 0x1000 /* SWRST Core B Double Fault */
882#define SWRST_OCCURRED 0x00008000 /* SWRST Status */ 886#define SWRST_WDT_B 0x2000 /* SWRST Watchdog B */
887#define SWRST_WDT_A 0x4000 /* SWRST Watchdog A */
888#define SWRST_OCCURRED 0x8000 /* SWRST Status */
883 889
884/* ************* SYSTEM INTERRUPT CONTROLLER MASKS ***************** */ 890/* ************* SYSTEM INTERRUPT CONTROLLER MASKS ***************** */
885 891
diff --git a/include/asm-blackfin/mach-bf561/irq.h b/include/asm-blackfin/mach-bf561/irq.h
index 12789927db3d..83f0383957d2 100644
--- a/include/asm-blackfin/mach-bf561/irq.h
+++ b/include/asm-blackfin/mach-bf561/irq.h
@@ -291,11 +291,7 @@
291 291
292#define GPIO_IRQ_BASE IRQ_PF0 292#define GPIO_IRQ_BASE IRQ_PF0
293 293
294#ifdef CONFIG_IRQCHIP_DEMUX_GPIO
295#define NR_IRQS (IRQ_PF47 + 1) 294#define NR_IRQS (IRQ_PF47 + 1)
296#else
297#define NR_IRQS SYS_IRQS
298#endif
299 295
300#define IVG7 7 296#define IVG7 7
301#define IVG8 8 297#define IVG8 8
diff --git a/include/asm-blackfin/mach-bf561/mem_map.h b/include/asm-blackfin/mach-bf561/mem_map.h
index f7ac09cf2c3d..c26d8486cc4b 100644
--- a/include/asm-blackfin/mach-bf561/mem_map.h
+++ b/include/asm-blackfin/mach-bf561/mem_map.h
@@ -19,6 +19,11 @@
19#define ASYNC_BANK0_BASE 0x20000000 /* Async Bank 0 */ 19#define ASYNC_BANK0_BASE 0x20000000 /* Async Bank 0 */
20#define ASYNC_BANK0_SIZE 0x04000000 /* 64M */ 20#define ASYNC_BANK0_SIZE 0x04000000 /* 64M */
21 21
22/* Boot ROM Memory */
23
24#define BOOT_ROM_START 0xEF000000
25#define BOOT_ROM_LENGTH 0x800
26
22/* Level 1 Memory */ 27/* Level 1 Memory */
23 28
24#ifdef CONFIG_BFIN_ICACHE 29#ifdef CONFIG_BFIN_ICACHE
@@ -67,9 +72,7 @@
67 72
68/* Scratch Pad Memory */ 73/* Scratch Pad Memory */
69 74
70#if defined(CONFIG_BF561)
71#define L1_SCRATCH_START 0xFFB00000 75#define L1_SCRATCH_START 0xFFB00000
72#define L1_SCRATCH_LENGTH 0x1000 76#define L1_SCRATCH_LENGTH 0x1000
73#endif
74 77
75#endif /* _MEM_MAP_533_H_ */ 78#endif /* _MEM_MAP_533_H_ */
diff --git a/include/asm-blackfin/mach-bf561/portmux.h b/include/asm-blackfin/mach-bf561/portmux.h
index 132ad31665e3..a6ee8206efb6 100644
--- a/include/asm-blackfin/mach-bf561/portmux.h
+++ b/include/asm-blackfin/mach-bf561/portmux.h
@@ -1,6 +1,8 @@
1#ifndef _MACH_PORTMUX_H_ 1#ifndef _MACH_PORTMUX_H_
2#define _MACH_PORTMUX_H_ 2#define _MACH_PORTMUX_H_
3 3
4#define MAX_RESOURCES MAX_BLACKFIN_GPIOS
5
4#define P_PPI0_CLK (P_DONTCARE) 6#define P_PPI0_CLK (P_DONTCARE)
5#define P_PPI0_FS1 (P_DONTCARE) 7#define P_PPI0_FS1 (P_DONTCARE)
6#define P_PPI0_FS2 (P_DONTCARE) 8#define P_PPI0_FS2 (P_DONTCARE)
diff --git a/include/asm-blackfin/mach-common/def_LPBlackfin.h b/include/asm-blackfin/mach-common/def_LPBlackfin.h
index c1d8c4a78fcf..e8967f6124f7 100644
--- a/include/asm-blackfin/mach-common/def_LPBlackfin.h
+++ b/include/asm-blackfin/mach-common/def_LPBlackfin.h
@@ -46,7 +46,7 @@
46#endif 46#endif
47 47
48#define bfin_read8(addr) ({ \ 48#define bfin_read8(addr) ({ \
49 uint8_t __v; \ 49 uint32_t __v; \
50 __asm__ __volatile__( \ 50 __asm__ __volatile__( \
51 NOP_PAD_ANOMALY_05000198 \ 51 NOP_PAD_ANOMALY_05000198 \
52 "%0 = b[%1] (z);" \ 52 "%0 = b[%1] (z);" \
@@ -56,7 +56,7 @@
56 __v; }) 56 __v; })
57 57
58#define bfin_read16(addr) ({ \ 58#define bfin_read16(addr) ({ \
59 uint16_t __v; \ 59 uint32_t __v; \
60 __asm__ __volatile__( \ 60 __asm__ __volatile__( \
61 NOP_PAD_ANOMALY_05000198 \ 61 NOP_PAD_ANOMALY_05000198 \
62 "%0 = w[%1] (z);" \ 62 "%0 = w[%1] (z);" \
@@ -80,7 +80,7 @@
80 NOP_PAD_ANOMALY_05000198 \ 80 NOP_PAD_ANOMALY_05000198 \
81 "b[%0] = %1;" \ 81 "b[%0] = %1;" \
82 : \ 82 : \
83 : "a" (addr), "d" (val) \ 83 : "a" (addr), "d" ((uint8_t)(val)) \
84 : "memory" \ 84 : "memory" \
85 ) 85 )
86 86
@@ -89,7 +89,7 @@
89 NOP_PAD_ANOMALY_05000198 \ 89 NOP_PAD_ANOMALY_05000198 \
90 "w[%0] = %1;" \ 90 "w[%0] = %1;" \
91 : \ 91 : \
92 : "a" (addr), "d" (val) \ 92 : "a" (addr), "d" ((uint16_t)(val)) \
93 : "memory" \ 93 : "memory" \
94 ) 94 )
95 95
diff --git a/include/asm-blackfin/mmu.h b/include/asm-blackfin/mmu.h
index 11d52f1167d0..757e43906ed4 100644
--- a/include/asm-blackfin/mmu.h
+++ b/include/asm-blackfin/mmu.h
@@ -24,7 +24,9 @@ typedef struct {
24 unsigned long exec_fdpic_loadmap; 24 unsigned long exec_fdpic_loadmap;
25 unsigned long interp_fdpic_loadmap; 25 unsigned long interp_fdpic_loadmap;
26#endif 26#endif
27 27#ifdef CONFIG_MPU
28 unsigned long *page_rwx_mask;
29#endif
28} mm_context_t; 30} mm_context_t;
29 31
30#endif 32#endif
diff --git a/include/asm-blackfin/mmu_context.h b/include/asm-blackfin/mmu_context.h
index c5c71a6aaf19..b5eb67596ad5 100644
--- a/include/asm-blackfin/mmu_context.h
+++ b/include/asm-blackfin/mmu_context.h
@@ -30,9 +30,12 @@
30#ifndef __BLACKFIN_MMU_CONTEXT_H__ 30#ifndef __BLACKFIN_MMU_CONTEXT_H__
31#define __BLACKFIN_MMU_CONTEXT_H__ 31#define __BLACKFIN_MMU_CONTEXT_H__
32 32
33#include <linux/gfp.h>
34#include <linux/sched.h>
33#include <asm/setup.h> 35#include <asm/setup.h>
34#include <asm/page.h> 36#include <asm/page.h>
35#include <asm/pgalloc.h> 37#include <asm/pgalloc.h>
38#include <asm/cplbinit.h>
36 39
37extern void *current_l1_stack_save; 40extern void *current_l1_stack_save;
38extern int nr_l1stack_tasks; 41extern int nr_l1stack_tasks;
@@ -50,6 +53,12 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
50static inline int 53static inline int
51init_new_context(struct task_struct *tsk, struct mm_struct *mm) 54init_new_context(struct task_struct *tsk, struct mm_struct *mm)
52{ 55{
56#ifdef CONFIG_MPU
57 unsigned long p = __get_free_pages(GFP_KERNEL, page_mask_order);
58 mm->context.page_rwx_mask = (unsigned long *)p;
59 memset(mm->context.page_rwx_mask, 0,
60 page_mask_nelts * 3 * sizeof(long));
61#endif
53 return 0; 62 return 0;
54} 63}
55 64
@@ -73,6 +82,11 @@ static inline void destroy_context(struct mm_struct *mm)
73 sram_free(tmp->addr); 82 sram_free(tmp->addr);
74 kfree(tmp); 83 kfree(tmp);
75 } 84 }
85#ifdef CONFIG_MPU
86 if (current_rwx_mask == mm->context.page_rwx_mask)
87 current_rwx_mask = NULL;
88 free_pages((unsigned long)mm->context.page_rwx_mask, page_mask_order);
89#endif
76} 90}
77 91
78static inline unsigned long 92static inline unsigned long
@@ -106,9 +120,21 @@ activate_l1stack(struct mm_struct *mm, unsigned long sp_base)
106 120
107#define deactivate_mm(tsk,mm) do { } while (0) 121#define deactivate_mm(tsk,mm) do { } while (0)
108 122
109static inline void activate_mm(struct mm_struct *prev_mm, 123#define activate_mm(prev, next) switch_mm(prev, next, NULL)
110 struct mm_struct *next_mm) 124
125static inline void switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm,
126 struct task_struct *tsk)
111{ 127{
128 if (prev_mm == next_mm)
129 return;
130#ifdef CONFIG_MPU
131 if (prev_mm->context.page_rwx_mask == current_rwx_mask) {
132 flush_switched_cplbs();
133 set_mask_dcplbs(next_mm->context.page_rwx_mask);
134 }
135#endif
136
137 /* L1 stack switching. */
112 if (!next_mm->context.l1_stack_save) 138 if (!next_mm->context.l1_stack_save)
113 return; 139 return;
114 if (next_mm->context.l1_stack_save == current_l1_stack_save) 140 if (next_mm->context.l1_stack_save == current_l1_stack_save)
@@ -120,10 +146,36 @@ static inline void activate_mm(struct mm_struct *prev_mm,
120 memcpy(l1_stack_base, current_l1_stack_save, l1_stack_len); 146 memcpy(l1_stack_base, current_l1_stack_save, l1_stack_len);
121} 147}
122 148
123static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 149#ifdef CONFIG_MPU
124 struct task_struct *tsk) 150static inline void protect_page(struct mm_struct *mm, unsigned long addr,
151 unsigned long flags)
152{
153 unsigned long *mask = mm->context.page_rwx_mask;
154 unsigned long page = addr >> 12;
155 unsigned long idx = page >> 5;
156 unsigned long bit = 1 << (page & 31);
157
158 if (flags & VM_MAYREAD)
159 mask[idx] |= bit;
160 else
161 mask[idx] &= ~bit;
162 mask += page_mask_nelts;
163 if (flags & VM_MAYWRITE)
164 mask[idx] |= bit;
165 else
166 mask[idx] &= ~bit;
167 mask += page_mask_nelts;
168 if (flags & VM_MAYEXEC)
169 mask[idx] |= bit;
170 else
171 mask[idx] &= ~bit;
172}
173
174static inline void update_protections(struct mm_struct *mm)
125{ 175{
126 activate_mm(prev, next); 176 flush_switched_cplbs();
177 set_mask_dcplbs(mm->context.page_rwx_mask);
127} 178}
179#endif
128 180
129#endif 181#endif
diff --git a/include/asm-blackfin/page_offset.h b/include/asm-blackfin/page_offset.h
index 3b671d5fd70d..cbaff24b4b25 100644
--- a/include/asm-blackfin/page_offset.h
+++ b/include/asm-blackfin/page_offset.h
@@ -1,6 +1,6 @@
1 1
2/* This handles the memory map.. */ 2/* This handles the memory map.. */
3 3
4#ifdef CONFIG_BFIN 4#ifdef CONFIG_BLACKFIN
5#define PAGE_OFFSET_RAW 0x00000000 5#define PAGE_OFFSET_RAW 0x00000000
6#endif 6#endif
diff --git a/include/asm-blackfin/socket.h b/include/asm-blackfin/socket.h
index 5213c9652186..2ca702e44d47 100644
--- a/include/asm-blackfin/socket.h
+++ b/include/asm-blackfin/socket.h
@@ -50,4 +50,7 @@
50#define SO_PASSSEC 34 50#define SO_PASSSEC 34
51#define SO_TIMESTAMPNS 35 51#define SO_TIMESTAMPNS 35
52#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 52#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
53
54#define SO_MARK 36
55
53#endif /* _ASM_SOCKET_H */ 56#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-blackfin/string.h b/include/asm-blackfin/string.h
index e8ada91ab002..321f4d96e4ae 100644
--- a/include/asm-blackfin/string.h
+++ b/include/asm-blackfin/string.h
@@ -1,6 +1,8 @@
1#ifndef _BLACKFIN_STRING_H_ 1#ifndef _BLACKFIN_STRING_H_
2#define _BLACKFIN_STRING_H_ 2#define _BLACKFIN_STRING_H_
3 3
4#include <linux/types.h>
5
4#ifdef __KERNEL__ /* only set these up for kernel code */ 6#ifdef __KERNEL__ /* only set these up for kernel code */
5 7
6#define __HAVE_ARCH_STRCPY 8#define __HAVE_ARCH_STRCPY
diff --git a/include/asm-blackfin/traps.h b/include/asm-blackfin/traps.h
index fe365b1b7ca8..f0e5f940d9ca 100644
--- a/include/asm-blackfin/traps.h
+++ b/include/asm-blackfin/traps.h
@@ -45,31 +45,87 @@
45#define VEC_CPLB_I_M (44) 45#define VEC_CPLB_I_M (44)
46#define VEC_CPLB_I_MHIT (45) 46#define VEC_CPLB_I_MHIT (45)
47#define VEC_ILL_RES (46) /* including unvalid supervisor mode insn */ 47#define VEC_ILL_RES (46) /* including unvalid supervisor mode insn */
48/* The hardware reserves (63) for future use - we use it to tell our
49 * normal exception handling code we have a hardware error
50 */
51#define VEC_HWERR (63)
48 52
49#ifndef __ASSEMBLY__ 53#ifndef __ASSEMBLY__
50 54
51#define HWC_x2 "System MMR Error\nAn error occurred due to an invalid access to an System MMR location\nPossible reason: a 32-bit register is accessed with a 16-bit instruction,\nor a 16-bit register is accessed with a 32-bit instruction.\n" 55#define HWC_x2(level) \
52#define HWC_x3 "External Memory Addressing Error\n" 56 "System MMR Error\n" \
53#define HWC_x12 "Performance Monitor Overflow\n" 57 level " - An error occurred due to an invalid access to an System MMR location\n" \
54#define HWC_x18 "RAISE 5 instruction\n Software issued a RAISE 5 instruction to invoke the Hardware\n" 58 level " Possible reason: a 32-bit register is accessed with a 16-bit instruction\n" \
55#define HWC_default "Reserved\n" 59 level " or a 16-bit register is accessed with a 32-bit instruction.\n"
56 60#define HWC_x3(level) \
57#define EXC_0x03 "Application stack overflow\n - Please increase the stack size of the application using elf2flt -s option,\n and/or reduce the stack use of the application.\n" 61 "External Memory Addressing Error\n"
58#define EXC_0x10 "Single step\n - When the processor is in single step mode, every instruction\n generates an exception. Primarily used for debugging.\n" 62#define HWC_x12(level) \
59#define EXC_0x11 "Exception caused by a trace buffer full condition\n - The processor takes this exception when the trace\n buffer overflows (only when enabled by the Trace Unit Control register).\n" 63 "Performance Monitor Overflow\n"
60#define EXC_0x21 "Undefined instruction\n - May be used to emulate instructions that are not defined for\n a particular processor implementation.\n" 64#define HWC_x18(level) \
61#define EXC_0x22 "Illegal instruction combination\n - See section for multi-issue rules in the ADSP-BF53x Blackfin\n Processor Instruction Set Reference.\n" 65 "RAISE 5 instruction\n" \
62#define EXC_0x23 "Data access CPLB protection violation\n - Attempted read or write to Supervisor resource,\n or illegal data memory access. \n" 66 level " Software issued a RAISE 5 instruction to invoke the Hardware\n"
63#define EXC_0x24 "Data access misaligned address violation\n - Attempted misaligned data memory or data cache access.\n" 67#define HWC_default(level) \
64#define EXC_0x25 "Unrecoverable event\n - For example, an exception generated while processing a previous exception.\n" 68 "Reserved\n"
65#define EXC_0x26 "Data access CPLB miss\n - Used by the MMU to signal a CPLB miss on a data access.\n" 69#define EXC_0x03(level) \
66#define EXC_0x27 "Data access multiple CPLB hits\n - More than one CPLB entry matches data fetch address.\n" 70 "Application stack overflow\n" \
67#define EXC_0x28 "Program Sequencer Exception caused by an emulation watchpoint match\n - There is a watchpoint match, and one of the EMUSW\n bits in the Watchpoint Instruction Address Control register (WPIACTL) is set.\n" 71 level " - Please increase the stack size of the application using elf2flt -s option,\n" \
68#define EXC_0x2A "Instruction fetch misaligned address violation\n - Attempted misaligned instruction cache fetch. On a misaligned instruction fetch exception,\n the return address provided in RETX is the destination address which is misaligned, rather than the address of the offending instruction.\n" 72 level " and/or reduce the stack use of the application.\n"
69#define EXC_0x2B "CPLB protection violation\n - Illegal instruction fetch access (memory protection violation).\n" 73#define EXC_0x10(level) \
70#define EXC_0x2C "Instruction fetch CPLB miss\n - CPLB miss on an instruction fetch.\n" 74 "Single step\n" \
71#define EXC_0x2D "Instruction fetch multiple CPLB hits\n - More than one CPLB entry matches instruction fetch address.\n" 75 level " - When the processor is in single step mode, every instruction\n" \
72#define EXC_0x2E "Illegal use of supervisor resource\n - Attempted to use a Supervisor register or instruction from User mode.\n Supervisor resources are registers and instructions that are reserved\n for Supervisor use: Supervisor only registers, all MMRs, and Supervisor\n only instructions.\n" 76 level " generates an exception. Primarily used for debugging.\n"
77#define EXC_0x11(level) \
78 "Exception caused by a trace buffer full condition\n" \
79 level " - The processor takes this exception when the trace\n" \
80 level " buffer overflows (only when enabled by the Trace Unit Control register).\n"
81#define EXC_0x21(level) \
82 "Undefined instruction\n" \
83 level " - May be used to emulate instructions that are not defined for\n" \
84 level " a particular processor implementation.\n"
85#define EXC_0x22(level) \
86 "Illegal instruction combination\n" \
87 level " - See section for multi-issue rules in the ADSP-BF53x Blackfin\n" \
88 level " Processor Instruction Set Reference.\n"
89#define EXC_0x23(level) \
90 "Data access CPLB protection violation\n" \
91 level " - Attempted read or write to Supervisor resource,\n" \
92 level " or illegal data memory access. \n"
93#define EXC_0x24(level) \
94 "Data access misaligned address violation\n" \
95 level " - Attempted misaligned data memory or data cache access.\n"
96#define EXC_0x25(level) \
97 "Unrecoverable event\n" \
98 level " - For example, an exception generated while processing a previous exception.\n"
99#define EXC_0x26(level) \
100 "Data access CPLB miss\n" \
101 level " - Used by the MMU to signal a CPLB miss on a data access.\n"
102#define EXC_0x27(level) \
103 "Data access multiple CPLB hits\n" \
104 level " - More than one CPLB entry matches data fetch address.\n"
105#define EXC_0x28(level) \
106 "Program Sequencer Exception caused by an emulation watchpoint match\n" \
107 level " - There is a watchpoint match, and one of the EMUSW\n" \
108 level " bits in the Watchpoint Instruction Address Control register (WPIACTL) is set.\n"
109#define EXC_0x2A(level) \
110 "Instruction fetch misaligned address violation\n" \
111 level " - Attempted misaligned instruction cache fetch. On a misaligned instruction fetch\n" \
112 level " exception, the return address provided in RETX is the destination address which is\n" \
113 level " misaligned, rather than the address of the offending instruction.\n"
114#define EXC_0x2B(level) \
115 "CPLB protection violation\n" \
116 level " - Illegal instruction fetch access (memory protection violation).\n"
117#define EXC_0x2C(level) \
118 "Instruction fetch CPLB miss\n" \
119 level " - CPLB miss on an instruction fetch.\n"
120#define EXC_0x2D(level) \
121 "Instruction fetch multiple CPLB hits\n" \
122 level " - More than one CPLB entry matches instruction fetch address.\n"
123#define EXC_0x2E(level) \
124 "Illegal use of supervisor resource\n" \
125 level " - Attempted to use a Supervisor register or instruction from User mode.\n" \
126 level " Supervisor resources are registers and instructions that are reserved\n" \
127 level " for Supervisor use: Supervisor only registers, all MMRs, and Supervisor\n" \
128 level " only instructions.\n"
73 129
74#endif /* __ASSEMBLY__ */ 130#endif /* __ASSEMBLY__ */
75#endif /* _BFIN_TRAPS_H */ 131#endif /* _BFIN_TRAPS_H */
diff --git a/include/asm-blackfin/uaccess.h b/include/asm-blackfin/uaccess.h
index 2233f8f9314d..22a410b8003b 100644
--- a/include/asm-blackfin/uaccess.h
+++ b/include/asm-blackfin/uaccess.h
@@ -31,7 +31,7 @@ static inline void set_fs(mm_segment_t fs)
31#define VERIFY_READ 0 31#define VERIFY_READ 0
32#define VERIFY_WRITE 1 32#define VERIFY_WRITE 1
33 33
34#define access_ok(type,addr,size) _access_ok((unsigned long)(addr),(size)) 34#define access_ok(type, addr, size) _access_ok((unsigned long)(addr), (size))
35 35
36static inline int is_in_rom(unsigned long addr) 36static inline int is_in_rom(unsigned long addr)
37{ 37{
diff --git a/include/asm-blackfin/unistd.h b/include/asm-blackfin/unistd.h
index 07ffe8b718c5..e98167358d26 100644
--- a/include/asm-blackfin/unistd.h
+++ b/include/asm-blackfin/unistd.h
@@ -369,8 +369,9 @@
369#define __NR_set_robust_list 354 369#define __NR_set_robust_list 354
370#define __NR_get_robust_list 355 370#define __NR_get_robust_list 355
371#define __NR_fallocate 356 371#define __NR_fallocate 356
372#define __NR_semtimedop 357
372 373
373#define __NR_syscall 357 374#define __NR_syscall 358
374#define NR_syscalls __NR_syscall 375#define NR_syscalls __NR_syscall
375 376
376/* Old optional stuff no one actually uses */ 377/* Old optional stuff no one actually uses */
diff --git a/include/asm-cris/arch-v10/ide.h b/include/asm-cris/arch-v10/ide.h
index 78b301ed7b12..ea34e0d0a388 100644
--- a/include/asm-cris/arch-v10/ide.h
+++ b/include/asm-cris/arch-v10/ide.h
@@ -89,11 +89,6 @@ static inline void ide_init_default_hwifs(void)
89 } 89 }
90} 90}
91 91
92/* some configuration options we don't need */
93
94#undef SUPPORT_VLB_SYNC
95#define SUPPORT_VLB_SYNC 0
96
97#endif /* __KERNEL__ */ 92#endif /* __KERNEL__ */
98 93
99#endif /* __ASMCRIS_IDE_H */ 94#endif /* __ASMCRIS_IDE_H */
diff --git a/include/asm-cris/arch-v32/ide.h b/include/asm-cris/arch-v32/ide.h
index 11296170d057..fb9c3627a5b4 100644
--- a/include/asm-cris/arch-v32/ide.h
+++ b/include/asm-cris/arch-v32/ide.h
@@ -48,11 +48,6 @@ static inline unsigned long ide_default_io_base(int index)
48 return REG_TYPE_CONV(unsigned long, reg_ata_rw_ctrl2, ctrl2); 48 return REG_TYPE_CONV(unsigned long, reg_ata_rw_ctrl2, ctrl2);
49} 49}
50 50
51/* some configuration options we don't need */
52
53#undef SUPPORT_VLB_SYNC
54#define SUPPORT_VLB_SYNC 0
55
56#define IDE_ARCH_ACK_INTR 51#define IDE_ARCH_ACK_INTR
57#define ide_ack_intr(hwif) ((hwif)->ack_intr(hwif)) 52#define ide_ack_intr(hwif) ((hwif)->ack_intr(hwif))
58 53
diff --git a/include/asm-cris/atomic.h b/include/asm-cris/atomic.h
index 0b51a87e5532..2949a945876a 100644
--- a/include/asm-cris/atomic.h
+++ b/include/asm-cris/atomic.h
@@ -3,6 +3,8 @@
3#ifndef __ASM_CRIS_ATOMIC__ 3#ifndef __ASM_CRIS_ATOMIC__
4#define __ASM_CRIS_ATOMIC__ 4#define __ASM_CRIS_ATOMIC__
5 5
6#include <linux/compiler.h>
7
6#include <asm/system.h> 8#include <asm/system.h>
7#include <asm/arch/atomic.h> 9#include <asm/arch/atomic.h>
8 10
diff --git a/include/asm-cris/checksum.h b/include/asm-cris/checksum.h
index 180dbf2757b0..c6c5be62c698 100644
--- a/include/asm-cris/checksum.h
+++ b/include/asm-cris/checksum.h
@@ -62,7 +62,7 @@ static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
62 * returns a 16-bit checksum, already complemented 62 * returns a 16-bit checksum, already complemented
63 */ 63 */
64 64
65static inline __sum16 int csum_tcpudp_magic(__be32 saddr, __be32 daddr, 65static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
66 unsigned short len, 66 unsigned short len,
67 unsigned short proto, 67 unsigned short proto,
68 __wsum sum) 68 __wsum sum)
diff --git a/include/asm-cris/ethernet.h b/include/asm-cris/ethernet.h
index 30da58a7d00d..4d58652c3a49 100644
--- a/include/asm-cris/ethernet.h
+++ b/include/asm-cris/ethernet.h
@@ -15,4 +15,7 @@
15#define SET_ETH_DUPLEX_AUTO SIOCDEVPRIVATE+3 /* Auto neg duplex */ 15#define SET_ETH_DUPLEX_AUTO SIOCDEVPRIVATE+3 /* Auto neg duplex */
16#define SET_ETH_DUPLEX_HALF SIOCDEVPRIVATE+4 /* Full duplex */ 16#define SET_ETH_DUPLEX_HALF SIOCDEVPRIVATE+4 /* Full duplex */
17#define SET_ETH_DUPLEX_FULL SIOCDEVPRIVATE+5 /* Half duplex */ 17#define SET_ETH_DUPLEX_FULL SIOCDEVPRIVATE+5 /* Half duplex */
18#define SET_ETH_ENABLE_LEDS SIOCDEVPRIVATE+6 /* Enable net LEDs */
19#define SET_ETH_DISABLE_LEDS SIOCDEVPRIVATE+7 /* Disable net LEDs */
20#define SET_ETH_AUTONEG SIOCDEVPRIVATE+8
18#endif /* _CRIS_ETHERNET_H */ 21#endif /* _CRIS_ETHERNET_H */
diff --git a/include/asm-cris/fasttimer.h b/include/asm-cris/fasttimer.h
index a3a77132ce32..8f8a8d6c9653 100644
--- a/include/asm-cris/fasttimer.h
+++ b/include/asm-cris/fasttimer.h
@@ -1,9 +1,8 @@
1/* $Id: fasttimer.h,v 1.3 2004/05/14 10:19:19 starvik Exp $ 1/*
2 * linux/include/asm-cris/fasttimer.h 2 * linux/include/asm-cris/fasttimer.h
3 * 3 *
4 * Fast timers for ETRAX100LX 4 * Fast timers for ETRAX100LX
5 * This may be useful in other OS than Linux so use 2 space indentation... 5 * Copyright (C) 2000-2007 Axis Communications AB
6 * Copyright (C) 2000, 2002 Axis Communications AB
7 */ 6 */
8#include <linux/time.h> /* struct timeval */ 7#include <linux/time.h> /* struct timeval */
9#include <linux/timex.h> 8#include <linux/timex.h>
@@ -12,11 +11,16 @@
12 11
13typedef void fast_timer_function_type(unsigned long); 12typedef void fast_timer_function_type(unsigned long);
14 13
14struct fasttime_t {
15 unsigned long tv_jiff; /* jiffies */
16 unsigned long tv_usec; /* microseconds */
17};
18
15struct fast_timer{ /* Close to timer_list */ 19struct fast_timer{ /* Close to timer_list */
16 struct fast_timer *next; 20 struct fast_timer *next;
17 struct fast_timer *prev; 21 struct fast_timer *prev;
18 struct timeval tv_set; 22 struct fasttime_t tv_set;
19 struct timeval tv_expires; 23 struct fasttime_t tv_expires;
20 unsigned long delay_us; 24 unsigned long delay_us;
21 fast_timer_function_type *function; 25 fast_timer_function_type *function;
22 unsigned long data; 26 unsigned long data;
@@ -38,6 +42,6 @@ int del_fast_timer(struct fast_timer * t);
38void schedule_usleep(unsigned long us); 42void schedule_usleep(unsigned long us);
39 43
40 44
41void fast_timer_init(void); 45int fast_timer_init(void);
42 46
43#endif 47#endif
diff --git a/include/asm-cris/hardirq.h b/include/asm-cris/hardirq.h
index 1c13dd3faac3..74178adeb1cd 100644
--- a/include/asm-cris/hardirq.h
+++ b/include/asm-cris/hardirq.h
@@ -1,6 +1,7 @@
1#ifndef __ASM_HARDIRQ_H 1#ifndef __ASM_HARDIRQ_H
2#define __ASM_HARDIRQ_H 2#define __ASM_HARDIRQ_H
3 3
4#include <asm/irq.h>
4#include <linux/threads.h> 5#include <linux/threads.h>
5#include <linux/cache.h> 6#include <linux/cache.h>
6 7
diff --git a/include/asm-cris/page.h b/include/asm-cris/page.h
index 0648e3153f81..b84353ef6998 100644
--- a/include/asm-cris/page.h
+++ b/include/asm-cris/page.h
@@ -4,14 +4,11 @@
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5 5
6#include <asm/arch/page.h> 6#include <asm/arch/page.h>
7#include <linux/const.h>
7 8
8/* PAGE_SHIFT determines the page size */ 9/* PAGE_SHIFT determines the page size */
9#define PAGE_SHIFT 13 10#define PAGE_SHIFT 13
10#ifndef __ASSEMBLY__ 11#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11#define PAGE_SIZE (1UL << PAGE_SHIFT)
12#else
13#define PAGE_SIZE (1 << PAGE_SHIFT)
14#endif
15#define PAGE_MASK (~(PAGE_SIZE-1)) 12#define PAGE_MASK (~(PAGE_SIZE-1))
16 13
17#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) 14#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE)
diff --git a/include/asm-cris/posix_types.h b/include/asm-cris/posix_types.h
index 92000d0c3f97..3a5e4c43eae7 100644
--- a/include/asm-cris/posix_types.h
+++ b/include/asm-cris/posix_types.h
@@ -52,7 +52,6 @@ typedef struct {
52} __kernel_fsid_t; 52} __kernel_fsid_t;
53 53
54#ifdef __KERNEL__ 54#ifdef __KERNEL__
55#include <linux/bitops.h>
56 55
57#undef __FD_SET 56#undef __FD_SET
58#define __FD_SET(fd,fdsetp) set_bit(fd, (void *)(fdsetp)) 57#define __FD_SET(fd,fdsetp) set_bit(fd, (void *)(fdsetp))
diff --git a/include/asm-cris/socket.h b/include/asm-cris/socket.h
index 5b18dfdf1748..9df0ca82f5de 100644
--- a/include/asm-cris/socket.h
+++ b/include/asm-cris/socket.h
@@ -54,6 +54,8 @@
54#define SO_TIMESTAMPNS 35 54#define SO_TIMESTAMPNS 35
55#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 55#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
56 56
57#define SO_MARK 36
58
57#endif /* _ASM_SOCKET_H */ 59#endif /* _ASM_SOCKET_H */
58 60
59 61
diff --git a/include/asm-cris/termbits.h b/include/asm-cris/termbits.h
index 71c1b36269b8..66e1a7492a0c 100644
--- a/include/asm-cris/termbits.h
+++ b/include/asm-cris/termbits.h
@@ -171,6 +171,19 @@ struct ktermios {
171#define B115200 0010002 171#define B115200 0010002
172#define B230400 0010003 172#define B230400 0010003
173#define B460800 0010004 173#define B460800 0010004
174
175/* Unsupported rates, but needed to avoid compile error. */
176#define B500000 0010005
177#define B576000 0010006
178#define B1000000 0010010
179#define B1152000 0010011
180#define B1500000 0010012
181#define B2000000 0010013
182#define B2500000 0010014
183#define B3000000 0010015
184#define B3500000 0010016
185#define B4000000 0010017
186
174/* etrax supports these additional three baud rates */ 187/* etrax supports these additional three baud rates */
175#define B921600 0010005 188#define B921600 0010005
176#define B1843200 0010006 189#define B1843200 0010006
diff --git a/include/asm-cris/thread_info.h b/include/asm-cris/thread_info.h
index fde39f6c49c7..784668ab0fa2 100644
--- a/include/asm-cris/thread_info.h
+++ b/include/asm-cris/thread_info.h
@@ -32,6 +32,7 @@ struct thread_info {
32 unsigned long flags; /* low level flags */ 32 unsigned long flags; /* low level flags */
33 __u32 cpu; /* current CPU */ 33 __u32 cpu; /* current CPU */
34 int preempt_count; /* 0 => preemptable, <0 => BUG */ 34 int preempt_count; /* 0 => preemptable, <0 => BUG */
35 __u32 tls; /* TLS for this thread */
35 36
36 mm_segment_t addr_limit; /* thread address space: 37 mm_segment_t addr_limit; /* thread address space:
37 0-0xBFFFFFFF for user-thead 38 0-0xBFFFFFFF for user-thead
@@ -79,14 +80,18 @@ struct thread_info {
79 * - other flags in MSW 80 * - other flags in MSW
80 */ 81 */
81#define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 82#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
82#define TIF_SIGPENDING 1 /* signal pending */ 83#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
83#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 84#define TIF_SIGPENDING 2 /* signal pending */
85#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
86#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */
84#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 87#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */
85#define TIF_MEMDIE 17 88#define TIF_MEMDIE 17
86 89
87#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 90#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
91#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
88#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 92#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
89#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 93#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
94#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
90#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 95#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
91 96
92#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ 97#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
diff --git a/include/asm-cris/tlb.h b/include/asm-cris/tlb.h
index 6cc26debe40f..7724246a2601 100644
--- a/include/asm-cris/tlb.h
+++ b/include/asm-cris/tlb.h
@@ -1,6 +1,8 @@
1#ifndef _CRIS_TLB_H 1#ifndef _CRIS_TLB_H
2#define _CRIS_TLB_H 2#define _CRIS_TLB_H
3 3
4#include <linux/pagemap.h>
5
4#include <asm/arch/tlb.h> 6#include <asm/arch/tlb.h>
5 7
6/* 8/*
diff --git a/include/asm-cris/unistd.h b/include/asm-cris/unistd.h
index 7c90fa970c38..bd57a7949170 100644
--- a/include/asm-cris/unistd.h
+++ b/include/asm-cris/unistd.h
@@ -255,6 +255,7 @@
255#define __NR_io_submit 248 255#define __NR_io_submit 248
256#define __NR_io_cancel 249 256#define __NR_io_cancel 249
257#define __NR_fadvise64 250 257#define __NR_fadvise64 250
258/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
258#define __NR_exit_group 252 259#define __NR_exit_group 252
259#define __NR_lookup_dcookie 253 260#define __NR_lookup_dcookie 253
260#define __NR_epoll_create 254 261#define __NR_epoll_create 254
@@ -292,10 +293,46 @@
292#define __NR_add_key 286 293#define __NR_add_key 286
293#define __NR_request_key 287 294#define __NR_request_key 287
294#define __NR_keyctl 288 295#define __NR_keyctl 288
296#define __NR_ioprio_set 289
297#define __NR_ioprio_get 290
298#define __NR_inotify_init 291
299#define __NR_inotify_add_watch 292
300#define __NR_inotify_rm_watch 293
301#define __NR_migrate_pages 294
302#define __NR_openat 295
303#define __NR_mkdirat 296
304#define __NR_mknodat 297
305#define __NR_fchownat 298
306#define __NR_futimesat 299
307#define __NR_fstatat64 300
308#define __NR_unlinkat 301
309#define __NR_renameat 302
310#define __NR_linkat 303
311#define __NR_symlinkat 304
312#define __NR_readlinkat 305
313#define __NR_fchmodat 306
314#define __NR_faccessat 307
315#define __NR_pselect6 308
316#define __NR_ppoll 309
317#define __NR_unshare 310
318#define __NR_set_robust_list 311
319#define __NR_get_robust_list 312
320#define __NR_splice 313
321#define __NR_sync_file_range 314
322#define __NR_tee 315
323#define __NR_vmsplice 316
324#define __NR_move_pages 317
325#define __NR_getcpu 318
326#define __NR_epoll_pwait 319
327#define __NR_utimensat 320
328#define __NR_signalfd 321
329#define __NR_timerfd 322
330#define __NR_eventfd 323
331#define __NR_fallocate 324
295 332
296#ifdef __KERNEL__ 333#ifdef __KERNEL__
297 334
298#define NR_syscalls 289 335#define NR_syscalls 325
299 336
300#include <asm/arch/unistd.h> 337#include <asm/arch/unistd.h>
301 338
@@ -321,6 +358,7 @@
321#define __ARCH_WANT_SYS_SIGPENDING 358#define __ARCH_WANT_SYS_SIGPENDING
322#define __ARCH_WANT_SYS_SIGPROCMASK 359#define __ARCH_WANT_SYS_SIGPROCMASK
323#define __ARCH_WANT_SYS_RT_SIGACTION 360#define __ARCH_WANT_SYS_RT_SIGACTION
361#define __ARCH_WANT_SYS_RT_SIGSUSPEND
324 362
325/* 363/*
326 * "Conditional" syscalls 364 * "Conditional" syscalls
diff --git a/include/asm-frv/ide.h b/include/asm-frv/ide.h
index f0bd2cb250c1..8c9a540d4344 100644
--- a/include/asm-frv/ide.h
+++ b/include/asm-frv/ide.h
@@ -18,12 +18,6 @@
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/irq.h> 19#include <asm/irq.h>
20 20
21#undef SUPPORT_SLOW_DATA_PORTS
22#define SUPPORT_SLOW_DATA_PORTS 0
23
24#undef SUPPORT_VLB_SYNC
25#define SUPPORT_VLB_SYNC 0
26
27#ifndef MAX_HWIFS 21#ifndef MAX_HWIFS
28#define MAX_HWIFS 8 22#define MAX_HWIFS 8
29#endif 23#endif
diff --git a/include/asm-frv/irq.h b/include/asm-frv/irq.h
index 8fefd6b827aa..3a66ebd754bd 100644
--- a/include/asm-frv/irq.h
+++ b/include/asm-frv/irq.h
@@ -12,9 +12,6 @@
12#ifndef _ASM_IRQ_H_ 12#ifndef _ASM_IRQ_H_
13#define _ASM_IRQ_H_ 13#define _ASM_IRQ_H_
14 14
15/* this number is used when no interrupt has been assigned */
16#define NO_IRQ (-1)
17
18#define NR_IRQS 48 15#define NR_IRQS 48
19#define IRQ_BASE_CPU (0 * 16) 16#define IRQ_BASE_CPU (0 * 16)
20#define IRQ_BASE_FPGA (1 * 16) 17#define IRQ_BASE_FPGA (1 * 16)
diff --git a/include/asm-frv/socket.h b/include/asm-frv/socket.h
index a823befd11dd..e51ca67b9356 100644
--- a/include/asm-frv/socket.h
+++ b/include/asm-frv/socket.h
@@ -52,5 +52,7 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* _ASM_SOCKET_H */ 57#endif /* _ASM_SOCKET_H */
56 58
diff --git a/include/asm-generic/bitops/ext2-non-atomic.h b/include/asm-generic/bitops/ext2-non-atomic.h
index 1697404afa05..63cf822431a2 100644
--- a/include/asm-generic/bitops/ext2-non-atomic.h
+++ b/include/asm-generic/bitops/ext2-non-atomic.h
@@ -14,5 +14,7 @@
14 generic_find_first_zero_le_bit((unsigned long *)(addr), (size)) 14 generic_find_first_zero_le_bit((unsigned long *)(addr), (size))
15#define ext2_find_next_zero_bit(addr, size, off) \ 15#define ext2_find_next_zero_bit(addr, size, off) \
16 generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off)) 16 generic_find_next_zero_le_bit((unsigned long *)(addr), (size), (off))
17#define ext2_find_next_bit(addr, size, off) \
18 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
17 19
18#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */ 20#endif /* _ASM_GENERIC_BITOPS_EXT2_NON_ATOMIC_H_ */
diff --git a/include/asm-generic/bitops/le.h b/include/asm-generic/bitops/le.h
index b9c7e5d2d2ad..80e3bf13b2b9 100644
--- a/include/asm-generic/bitops/le.h
+++ b/include/asm-generic/bitops/le.h
@@ -20,6 +20,8 @@
20#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr) 20#define generic___test_and_clear_le_bit(nr, addr) __test_and_clear_bit(nr, addr)
21 21
22#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset) 22#define generic_find_next_zero_le_bit(addr, size, offset) find_next_zero_bit(addr, size, offset)
23#define generic_find_next_le_bit(addr, size, offset) \
24 find_next_bit(addr, size, offset)
23 25
24#elif defined(__BIG_ENDIAN) 26#elif defined(__BIG_ENDIAN)
25 27
@@ -42,6 +44,8 @@
42 44
43extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, 45extern unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
44 unsigned long size, unsigned long offset); 46 unsigned long size, unsigned long offset);
47extern unsigned long generic_find_next_le_bit(const unsigned long *addr,
48 unsigned long size, unsigned long offset);
45 49
46#else 50#else
47#error "Please fix <asm/byteorder.h>" 51#error "Please fix <asm/byteorder.h>"
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index d56fedbb457a..2632328d8646 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -31,14 +31,19 @@ struct bug_entry {
31#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0) 31#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
32#endif 32#endif
33 33
34#ifndef HAVE_ARCH_WARN_ON 34#ifndef __WARN
35#ifndef __ASSEMBLY__
36extern void warn_on_slowpath(const char *file, const int line);
37#define WANT_WARN_ON_SLOWPATH
38#endif
39#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
40#endif
41
42#ifndef WARN_ON
35#define WARN_ON(condition) ({ \ 43#define WARN_ON(condition) ({ \
36 int __ret_warn_on = !!(condition); \ 44 int __ret_warn_on = !!(condition); \
37 if (unlikely(__ret_warn_on)) { \ 45 if (unlikely(__ret_warn_on)) \
38 printk("WARNING: at %s:%d %s()\n", __FILE__, \ 46 __WARN(); \
39 __LINE__, __FUNCTION__); \
40 dump_stack(); \
41 } \
42 unlikely(__ret_warn_on); \ 47 unlikely(__ret_warn_on); \
43}) 48})
44#endif 49#endif
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index d85172e9ed45..4b8d31cda1a0 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -3,54 +3,79 @@
3#include <linux/compiler.h> 3#include <linux/compiler.h>
4#include <linux/threads.h> 4#include <linux/threads.h>
5 5
6#define __GENERIC_PER_CPU 6/*
7 * Determine the real variable name from the name visible in the
8 * kernel sources.
9 */
10#define per_cpu_var(var) per_cpu__##var
11
7#ifdef CONFIG_SMP 12#ifdef CONFIG_SMP
8 13
14/*
15 * per_cpu_offset() is the offset that has to be added to a
16 * percpu variable to get to the instance for a certain processor.
17 *
18 * Most arches use the __per_cpu_offset array for those offsets but
19 * some arches have their own ways of determining the offset (x86_64, s390).
20 */
21#ifndef __per_cpu_offset
9extern unsigned long __per_cpu_offset[NR_CPUS]; 22extern unsigned long __per_cpu_offset[NR_CPUS];
10 23
11#define per_cpu_offset(x) (__per_cpu_offset[x]) 24#define per_cpu_offset(x) (__per_cpu_offset[x])
25#endif
12 26
13/* Separate out the type, so (int[3], foo) works. */ 27/*
14#define DEFINE_PER_CPU(type, name) \ 28 * Determine the offset for the currently active processor.
15 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name 29 * An arch may define __my_cpu_offset to provide a more effective
16 30 * means of obtaining the offset to the per cpu variables of the
17#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \ 31 * current processor.
18 __attribute__((__section__(".data.percpu.shared_aligned"))) \ 32 */
19 __typeof__(type) per_cpu__##name \ 33#ifndef __my_cpu_offset
20 ____cacheline_aligned_in_smp 34#define __my_cpu_offset per_cpu_offset(raw_smp_processor_id())
21 35#define my_cpu_offset per_cpu_offset(smp_processor_id())
22/* var is in discarded region: offset to particular copy we want */ 36#else
23#define per_cpu(var, cpu) (*({ \ 37#define my_cpu_offset __my_cpu_offset
24 extern int simple_identifier_##var(void); \ 38#endif
25 RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]); })) 39
26#define __get_cpu_var(var) per_cpu(var, smp_processor_id()) 40/*
27#define __raw_get_cpu_var(var) per_cpu(var, raw_smp_processor_id()) 41 * Add a offset to a pointer but keep the pointer as is.
28 42 *
29/* A macro to avoid #include hell... */ 43 * Only S390 provides its own means of moving the pointer.
30#define percpu_modcopy(pcpudst, src, size) \ 44 */
31do { \ 45#ifndef SHIFT_PERCPU_PTR
32 unsigned int __i; \ 46#define SHIFT_PERCPU_PTR(__p, __offset) RELOC_HIDE((__p), (__offset))
33 for_each_possible_cpu(__i) \ 47#endif
34 memcpy((pcpudst)+__per_cpu_offset[__i], \
35 (src), (size)); \
36} while (0)
37#else /* ! SMP */
38 48
39#define DEFINE_PER_CPU(type, name) \ 49/*
40 __typeof__(type) per_cpu__##name 50 * A percpu variable may point to a discarded regions. The following are
51 * established ways to produce a usable pointer from the percpu variable
52 * offset.
53 */
54#define per_cpu(var, cpu) \
55 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), per_cpu_offset(cpu)))
56#define __get_cpu_var(var) \
57 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), my_cpu_offset))
58#define __raw_get_cpu_var(var) \
59 (*SHIFT_PERCPU_PTR(&per_cpu_var(var), __my_cpu_offset))
41 60
42#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
43 DEFINE_PER_CPU(type, name)
44 61
45#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var)) 62#ifdef CONFIG_HAVE_SETUP_PER_CPU_AREA
46#define __get_cpu_var(var) per_cpu__##var 63extern void setup_per_cpu_areas(void);
47#define __raw_get_cpu_var(var) per_cpu__##var 64#endif
65
66#else /* ! SMP */
67
68#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu_var(var)))
69#define __get_cpu_var(var) per_cpu_var(var)
70#define __raw_get_cpu_var(var) per_cpu_var(var)
48 71
49#endif /* SMP */ 72#endif /* SMP */
50 73
51#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name 74#ifndef PER_CPU_ATTRIBUTES
75#define PER_CPU_ATTRIBUTES
76#endif
52 77
53#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) 78#define DECLARE_PER_CPU(type, name) extern PER_CPU_ATTRIBUTES \
54#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var) 79 __typeof__(type) per_cpu_var(name)
55 80
56#endif /* _ASM_GENERIC_PERCPU_H_ */ 81#endif /* _ASM_GENERIC_PERCPU_H_ */
diff --git a/include/asm-generic/resource.h b/include/asm-generic/resource.h
index cfe3692b23e5..587566f95f6c 100644
--- a/include/asm-generic/resource.h
+++ b/include/asm-generic/resource.h
@@ -12,7 +12,7 @@
12 * then it defines them prior including asm-generic/resource.h. ) 12 * then it defines them prior including asm-generic/resource.h. )
13 */ 13 */
14 14
15#define RLIMIT_CPU 0 /* CPU time in ms */ 15#define RLIMIT_CPU 0 /* CPU time in sec */
16#define RLIMIT_FSIZE 1 /* Maximum filesize */ 16#define RLIMIT_FSIZE 1 /* Maximum filesize */
17#define RLIMIT_DATA 2 /* max data size */ 17#define RLIMIT_DATA 2 /* max data size */
18#define RLIMIT_STACK 3 /* max stack size */ 18#define RLIMIT_STACK 3 /* max stack size */
@@ -44,8 +44,8 @@
44#define RLIMIT_NICE 13 /* max nice prio allowed to raise to 44#define RLIMIT_NICE 13 /* max nice prio allowed to raise to
45 0-39 for nice level 19 .. -20 */ 45 0-39 for nice level 19 .. -20 */
46#define RLIMIT_RTPRIO 14 /* maximum realtime priority */ 46#define RLIMIT_RTPRIO 14 /* maximum realtime priority */
47 47#define RLIMIT_RTTIME 15 /* timeout for RT tasks in us */
48#define RLIM_NLIMITS 15 48#define RLIM_NLIMITS 16
49 49
50/* 50/*
51 * SuS says limits have to be unsigned. 51 * SuS says limits have to be unsigned.
@@ -86,6 +86,7 @@
86 [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \ 86 [RLIMIT_MSGQUEUE] = { MQ_BYTES_MAX, MQ_BYTES_MAX }, \
87 [RLIMIT_NICE] = { 0, 0 }, \ 87 [RLIMIT_NICE] = { 0, 0 }, \
88 [RLIMIT_RTPRIO] = { 0, 0 }, \ 88 [RLIMIT_RTPRIO] = { 0, 0 }, \
89 [RLIMIT_RTTIME] = { RLIM_INFINITY, RLIM_INFINITY }, \
89} 90}
90 91
91#endif /* __KERNEL__ */ 92#endif /* __KERNEL__ */
diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
index f490e43a90b9..75f2bfab614f 100644
--- a/include/asm-generic/tlb.h
+++ b/include/asm-generic/tlb.h
@@ -14,6 +14,7 @@
14#define _ASM_GENERIC__TLB_H 14#define _ASM_GENERIC__TLB_H
15 15
16#include <linux/swap.h> 16#include <linux/swap.h>
17#include <linux/quicklist.h>
17#include <asm/pgalloc.h> 18#include <asm/pgalloc.h>
18#include <asm/tlbflush.h> 19#include <asm/tlbflush.h>
19 20
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 9f584cc5c5fb..f784d2f34149 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -9,10 +9,46 @@
9/* Align . to a 8 byte boundary equals to maximum function alignment. */ 9/* Align . to a 8 byte boundary equals to maximum function alignment. */
10#define ALIGN_FUNCTION() . = ALIGN(8) 10#define ALIGN_FUNCTION() . = ALIGN(8)
11 11
12/* The actual configuration determine if the init/exit sections
13 * are handled as text/data or they can be discarded (which
14 * often happens at runtime)
15 */
16#ifdef CONFIG_HOTPLUG
17#define DEV_KEEP(sec) *(.dev##sec)
18#define DEV_DISCARD(sec)
19#else
20#define DEV_KEEP(sec)
21#define DEV_DISCARD(sec) *(.dev##sec)
22#endif
23
24#ifdef CONFIG_HOTPLUG_CPU
25#define CPU_KEEP(sec) *(.cpu##sec)
26#define CPU_DISCARD(sec)
27#else
28#define CPU_KEEP(sec)
29#define CPU_DISCARD(sec) *(.cpu##sec)
30#endif
31
32#if defined(CONFIG_MEMORY_HOTPLUG)
33#define MEM_KEEP(sec) *(.mem##sec)
34#define MEM_DISCARD(sec)
35#else
36#define MEM_KEEP(sec)
37#define MEM_DISCARD(sec) *(.mem##sec)
38#endif
39
40
12/* .data section */ 41/* .data section */
13#define DATA_DATA \ 42#define DATA_DATA \
14 *(.data) \ 43 *(.data) \
15 *(.data.init.refok) \ 44 *(.data.init.refok) \
45 *(.ref.data) \
46 DEV_KEEP(init.data) \
47 DEV_KEEP(exit.data) \
48 CPU_KEEP(init.data) \
49 CPU_KEEP(exit.data) \
50 MEM_KEEP(init.data) \
51 MEM_KEEP(exit.data) \
16 . = ALIGN(8); \ 52 . = ALIGN(8); \
17 VMLINUX_SYMBOL(__start___markers) = .; \ 53 VMLINUX_SYMBOL(__start___markers) = .; \
18 *(__markers) \ 54 *(__markers) \
@@ -132,14 +168,25 @@
132 *(__ksymtab_strings) \ 168 *(__ksymtab_strings) \
133 } \ 169 } \
134 \ 170 \
171 /* __*init sections */ \
172 __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
173 *(.ref.rodata) \
174 DEV_KEEP(init.rodata) \
175 DEV_KEEP(exit.rodata) \
176 CPU_KEEP(init.rodata) \
177 CPU_KEEP(exit.rodata) \
178 MEM_KEEP(init.rodata) \
179 MEM_KEEP(exit.rodata) \
180 } \
181 \
135 /* Built-in module parameters. */ \ 182 /* Built-in module parameters. */ \
136 __param : AT(ADDR(__param) - LOAD_OFFSET) { \ 183 __param : AT(ADDR(__param) - LOAD_OFFSET) { \
137 VMLINUX_SYMBOL(__start___param) = .; \ 184 VMLINUX_SYMBOL(__start___param) = .; \
138 *(__param) \ 185 *(__param) \
139 VMLINUX_SYMBOL(__stop___param) = .; \ 186 VMLINUX_SYMBOL(__stop___param) = .; \
187 . = ALIGN((align)); \
140 VMLINUX_SYMBOL(__end_rodata) = .; \ 188 VMLINUX_SYMBOL(__end_rodata) = .; \
141 } \ 189 } \
142 \
143 . = ALIGN((align)); 190 . = ALIGN((align));
144 191
145/* RODATA provided for backward compatibility. 192/* RODATA provided for backward compatibility.
@@ -158,8 +205,16 @@
158#define TEXT_TEXT \ 205#define TEXT_TEXT \
159 ALIGN_FUNCTION(); \ 206 ALIGN_FUNCTION(); \
160 *(.text) \ 207 *(.text) \
208 *(.ref.text) \
161 *(.text.init.refok) \ 209 *(.text.init.refok) \
162 *(.exit.text.refok) 210 *(.exit.text.refok) \
211 DEV_KEEP(init.text) \
212 DEV_KEEP(exit.text) \
213 CPU_KEEP(init.text) \
214 CPU_KEEP(exit.text) \
215 MEM_KEEP(init.text) \
216 MEM_KEEP(exit.text)
217
163 218
164/* sched.text is aling to function alignment to secure we have same 219/* sched.text is aling to function alignment to secure we have same
165 * address even at second ld pass when generating System.map */ 220 * address even at second ld pass when generating System.map */
@@ -183,6 +238,37 @@
183 *(.kprobes.text) \ 238 *(.kprobes.text) \
184 VMLINUX_SYMBOL(__kprobes_text_end) = .; 239 VMLINUX_SYMBOL(__kprobes_text_end) = .;
185 240
241/* init and exit section handling */
242#define INIT_DATA \
243 *(.init.data) \
244 DEV_DISCARD(init.data) \
245 DEV_DISCARD(init.rodata) \
246 CPU_DISCARD(init.data) \
247 CPU_DISCARD(init.rodata) \
248 MEM_DISCARD(init.data) \
249 MEM_DISCARD(init.rodata)
250
251#define INIT_TEXT \
252 *(.init.text) \
253 DEV_DISCARD(init.text) \
254 CPU_DISCARD(init.text) \
255 MEM_DISCARD(init.text)
256
257#define EXIT_DATA \
258 *(.exit.data) \
259 DEV_DISCARD(exit.data) \
260 DEV_DISCARD(exit.rodata) \
261 CPU_DISCARD(exit.data) \
262 CPU_DISCARD(exit.rodata) \
263 MEM_DISCARD(exit.data) \
264 MEM_DISCARD(exit.rodata)
265
266#define EXIT_TEXT \
267 *(.exit.text) \
268 DEV_DISCARD(exit.text) \
269 CPU_DISCARD(exit.text) \
270 MEM_DISCARD(exit.text)
271
186 /* DWARF debug sections. 272 /* DWARF debug sections.
187 Symbols in the DWARF debugging sections are relative to 273 Symbols in the DWARF debugging sections are relative to
188 the beginning of the section so we begin them at 0. */ 274 the beginning of the section so we begin them at 0. */
diff --git a/include/asm-h8300/socket.h b/include/asm-h8300/socket.h
index 39911d8c9684..da2520dbf254 100644
--- a/include/asm-h8300/socket.h
+++ b/include/asm-h8300/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* _ASM_SOCKET_H */ 57#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-h8300/timex.h b/include/asm-h8300/timex.h
index 20413145fabb..23e67013439f 100644
--- a/include/asm-h8300/timex.h
+++ b/include/asm-h8300/timex.h
@@ -6,7 +6,7 @@
6#ifndef _ASM_H8300_TIMEX_H 6#ifndef _ASM_H8300_TIMEX_H
7#define _ASM_H8300_TIMEX_H 7#define _ASM_H8300_TIMEX_H
8 8
9#define CLOCK_TICK_RATE CONFIG_CPU_CLOCK*1000/8192 /* Timer input freq. */ 9#define CLOCK_TICK_RATE (CONFIG_CPU_CLOCK*1000/8192) /* Timer input freq. */
10 10
11typedef unsigned long cycles_t; 11typedef unsigned long cycles_t;
12extern short h8300_timer_count; 12extern short h8300_timer_count;
diff --git a/include/asm-ia64/acpi.h b/include/asm-ia64/acpi.h
index 49730ffbbae4..cd1cc39b5599 100644
--- a/include/asm-ia64/acpi.h
+++ b/include/asm-ia64/acpi.h
@@ -94,6 +94,7 @@ ia64_acpi_release_global_lock (unsigned int *lock)
94#define acpi_noirq 0 /* ACPI always enabled on IA64 */ 94#define acpi_noirq 0 /* ACPI always enabled on IA64 */
95#define acpi_pci_disabled 0 /* ACPI PCI always enabled on IA64 */ 95#define acpi_pci_disabled 0 /* ACPI PCI always enabled on IA64 */
96#define acpi_strict 1 /* no ACPI spec workarounds on IA64 */ 96#define acpi_strict 1 /* no ACPI spec workarounds on IA64 */
97#define acpi_processor_cstate_check(x) (x) /* no idle limits on IA64 :) */
97static inline void disable_acpi(void) { } 98static inline void disable_acpi(void) { }
98 99
99const char *acpi_get_sysname (void); 100const char *acpi_get_sysname (void);
@@ -126,6 +127,8 @@ extern int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS];
126extern int __initdata nid_to_pxm_map[MAX_NUMNODES]; 127extern int __initdata nid_to_pxm_map[MAX_NUMNODES];
127#endif 128#endif
128 129
130#define acpi_unlazy_tlb(x)
131
129#endif /*__KERNEL__*/ 132#endif /*__KERNEL__*/
130 133
131#endif /*_ASM_ACPI_H*/ 134#endif /*_ASM_ACPI_H*/
diff --git a/include/asm-ia64/agp.h b/include/asm-ia64/agp.h
index 4e517f0e6afa..c11fdd8ab4d7 100644
--- a/include/asm-ia64/agp.h
+++ b/include/asm-ia64/agp.h
@@ -15,7 +15,6 @@
15 */ 15 */
16#define map_page_into_agp(page) /* nothing */ 16#define map_page_into_agp(page) /* nothing */
17#define unmap_page_from_agp(page) /* nothing */ 17#define unmap_page_from_agp(page) /* nothing */
18#define flush_agp_mappings() /* nothing */
19#define flush_agp_cache() mb() 18#define flush_agp_cache() mb()
20 19
21/* Convert a physical address to an address suitable for the GART. */ 20/* Convert a physical address to an address suitable for the GART. */
diff --git a/include/asm-ia64/bitops.h b/include/asm-ia64/bitops.h
index a977affaebec..a1b9719f5fbb 100644
--- a/include/asm-ia64/bitops.h
+++ b/include/asm-ia64/bitops.h
@@ -124,10 +124,21 @@ clear_bit_unlock (int nr, volatile void *addr)
124/** 124/**
125 * __clear_bit_unlock - Non-atomically clear a bit with release 125 * __clear_bit_unlock - Non-atomically clear a bit with release
126 * 126 *
127 * This is like clear_bit_unlock, but the implementation may use a non-atomic 127 * This is like clear_bit_unlock, but the implementation uses a store
128 * store (this one uses an atomic, however). 128 * with release semantics. See also __raw_spin_unlock().
129 */ 129 */
130#define __clear_bit_unlock clear_bit_unlock 130static __inline__ void
131__clear_bit_unlock(int nr, volatile void *addr)
132{
133 __u32 mask, new;
134 volatile __u32 *m;
135
136 m = (volatile __u32 *)addr + (nr >> 5);
137 mask = ~(1 << (nr & 31));
138 new = *m & mask;
139 barrier();
140 ia64_st4_rel_nta(m, new);
141}
131 142
132/** 143/**
133 * __clear_bit - Clears a bit in memory (non-atomic version) 144 * __clear_bit - Clears a bit in memory (non-atomic version)
diff --git a/include/asm-ia64/gcc_intrin.h b/include/asm-ia64/gcc_intrin.h
index 4fb4e439b05c..5b6665c754c9 100644
--- a/include/asm-ia64/gcc_intrin.h
+++ b/include/asm-ia64/gcc_intrin.h
@@ -24,7 +24,7 @@
24extern void ia64_bad_param_for_setreg (void); 24extern void ia64_bad_param_for_setreg (void);
25extern void ia64_bad_param_for_getreg (void); 25extern void ia64_bad_param_for_getreg (void);
26 26
27register unsigned long ia64_r13 asm ("r13") __attribute_used__; 27register unsigned long ia64_r13 asm ("r13") __used;
28 28
29#define ia64_setreg(regnum, val) \ 29#define ia64_setreg(regnum, val) \
30({ \ 30({ \
@@ -191,6 +191,11 @@ register unsigned long ia64_r13 asm ("r13") __attribute_used__;
191 asm volatile ("ldf.fill %0=[%1]" :"=f"(__f__): "r"(x)); \ 191 asm volatile ("ldf.fill %0=[%1]" :"=f"(__f__): "r"(x)); \
192}) 192})
193 193
194#define ia64_st4_rel_nta(m, val) \
195({ \
196 asm volatile ("st4.rel.nta [%0] = %1\n\t" :: "r"(m), "r"(val)); \
197})
198
194#define ia64_stfs(x, regnum) \ 199#define ia64_stfs(x, regnum) \
195({ \ 200({ \
196 register double __f__ asm ("f"#regnum); \ 201 register double __f__ asm ("f"#regnum); \
diff --git a/include/asm-ia64/hw_irq.h b/include/asm-ia64/hw_irq.h
index bba5baa3c7fc..7e6e3779670a 100644
--- a/include/asm-ia64/hw_irq.h
+++ b/include/asm-ia64/hw_irq.h
@@ -63,7 +63,7 @@ extern int ia64_last_device_vector;
63#define IA64_NUM_DEVICE_VECTORS (IA64_LAST_DEVICE_VECTOR - IA64_FIRST_DEVICE_VECTOR + 1) 63#define IA64_NUM_DEVICE_VECTORS (IA64_LAST_DEVICE_VECTOR - IA64_FIRST_DEVICE_VECTOR + 1)
64 64
65#define IA64_MCA_RENDEZ_VECTOR 0xe8 /* MCA rendez interrupt */ 65#define IA64_MCA_RENDEZ_VECTOR 0xe8 /* MCA rendez interrupt */
66#define IA64_PERFMON_VECTOR 0xee /* performanc monitor interrupt vector */ 66#define IA64_PERFMON_VECTOR 0xee /* performance monitor interrupt vector */
67#define IA64_TIMER_VECTOR 0xef /* use highest-prio group 15 interrupt for timer */ 67#define IA64_TIMER_VECTOR 0xef /* use highest-prio group 15 interrupt for timer */
68#define IA64_MCA_WAKEUP_VECTOR 0xf0 /* MCA wakeup (must be >MCA_RENDEZ_VECTOR) */ 68#define IA64_MCA_WAKEUP_VECTOR 0xf0 /* MCA wakeup (must be >MCA_RENDEZ_VECTOR) */
69#define IA64_IPI_LOCAL_TLB_FLUSH 0xfc /* SMP flush local TLB */ 69#define IA64_IPI_LOCAL_TLB_FLUSH 0xfc /* SMP flush local TLB */
diff --git a/include/asm-ia64/intel_intrin.h b/include/asm-ia64/intel_intrin.h
index d069b6acddce..a520d103d808 100644
--- a/include/asm-ia64/intel_intrin.h
+++ b/include/asm-ia64/intel_intrin.h
@@ -110,6 +110,9 @@
110#define ia64_st4_rel __st4_rel 110#define ia64_st4_rel __st4_rel
111#define ia64_st8_rel __st8_rel 111#define ia64_st8_rel __st8_rel
112 112
113/* FIXME: need st4.rel.nta intrinsic */
114#define ia64_st4_rel_nta __st4_rel
115
113#define ia64_ld1_acq __ld1_acq 116#define ia64_ld1_acq __ld1_acq
114#define ia64_ld2_acq __ld2_acq 117#define ia64_ld2_acq __ld2_acq
115#define ia64_ld4_acq __ld4_acq 118#define ia64_ld4_acq __ld4_acq
diff --git a/include/asm-ia64/iosapic.h b/include/asm-ia64/iosapic.h
index b8f712859140..a3a4288daae8 100644
--- a/include/asm-ia64/iosapic.h
+++ b/include/asm-ia64/iosapic.h
@@ -80,7 +80,6 @@ extern int iosapic_remove (unsigned int gsi_base);
80#else 80#else
81#define iosapic_remove(gsi_base) (-EINVAL) 81#define iosapic_remove(gsi_base) (-EINVAL)
82#endif /* CONFIG_HOTPLUG */ 82#endif /* CONFIG_HOTPLUG */
83extern int gsi_to_vector (unsigned int gsi);
84extern int gsi_to_irq (unsigned int gsi); 83extern int gsi_to_irq (unsigned int gsi);
85extern int iosapic_register_intr (unsigned int gsi, unsigned long polarity, 84extern int iosapic_register_intr (unsigned int gsi, unsigned long polarity,
86 unsigned long trigger); 85 unsigned long trigger);
@@ -94,7 +93,6 @@ extern int __init iosapic_register_platform_intr (u32 int_type,
94 u16 eid, u16 id, 93 u16 eid, u16 id,
95 unsigned long polarity, 94 unsigned long polarity,
96 unsigned long trigger); 95 unsigned long trigger);
97extern unsigned int iosapic_version (char __iomem *addr);
98 96
99#ifdef CONFIG_NUMA 97#ifdef CONFIG_NUMA
100extern void __devinit map_iosapic_to_node (unsigned int, int); 98extern void __devinit map_iosapic_to_node (unsigned int, int);
diff --git a/include/asm-ia64/pal.h b/include/asm-ia64/pal.h
index abfcb3a2588f..8a695d3407d2 100644
--- a/include/asm-ia64/pal.h
+++ b/include/asm-ia64/pal.h
@@ -1379,10 +1379,11 @@ struct pal_features_s;
1379static inline s64 1379static inline s64
1380ia64_pal_proc_get_features (u64 *features_avail, 1380ia64_pal_proc_get_features (u64 *features_avail,
1381 u64 *features_status, 1381 u64 *features_status,
1382 u64 *features_control) 1382 u64 *features_control,
1383 u64 features_set)
1383{ 1384{
1384 struct ia64_pal_retval iprv; 1385 struct ia64_pal_retval iprv;
1385 PAL_CALL_PHYS(iprv, PAL_PROC_GET_FEATURES, 0, 0, 0); 1386 PAL_CALL_PHYS(iprv, PAL_PROC_GET_FEATURES, 0, features_set, 0);
1386 if (iprv.status == 0) { 1387 if (iprv.status == 0) {
1387 *features_avail = iprv.v0; 1388 *features_avail = iprv.v0;
1388 *features_status = iprv.v1; 1389 *features_status = iprv.v1;
diff --git a/include/asm-ia64/percpu.h b/include/asm-ia64/percpu.h
index 43a7aac414e0..77f30b664b4e 100644
--- a/include/asm-ia64/percpu.h
+++ b/include/asm-ia64/percpu.h
@@ -15,69 +15,36 @@
15 15
16#include <linux/threads.h> 16#include <linux/threads.h>
17 17
18#ifdef HAVE_MODEL_SMALL_ATTRIBUTE
19# define __SMALL_ADDR_AREA __attribute__((__model__ (__small__)))
20#else
21# define __SMALL_ADDR_AREA
22#endif
23
24#define DECLARE_PER_CPU(type, name) \
25 extern __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
26
27/* Separate out the type, so (int[3], foo) works. */
28#define DEFINE_PER_CPU(type, name) \
29 __attribute__((__section__(".data.percpu"))) \
30 __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
31
32#ifdef CONFIG_SMP 18#ifdef CONFIG_SMP
33#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
34 __attribute__((__section__(".data.percpu.shared_aligned"))) \
35 __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name \
36 ____cacheline_aligned_in_smp
37#else
38#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
39 DEFINE_PER_CPU(type, name)
40#endif
41
42/*
43 * Pretty much a literal copy of asm-generic/percpu.h, except that percpu_modcopy() is an
44 * external routine, to avoid include-hell.
45 */
46#ifdef CONFIG_SMP
47
48extern unsigned long __per_cpu_offset[NR_CPUS];
49#define per_cpu_offset(x) (__per_cpu_offset(x))
50 19
51/* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */ 20#ifdef HAVE_MODEL_SMALL_ATTRIBUTE
52DECLARE_PER_CPU(unsigned long, local_per_cpu_offset); 21# define PER_CPU_ATTRIBUTES __attribute__((__model__ (__small__)))
22#endif
53 23
54#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu])) 24#define __my_cpu_offset __ia64_per_cpu_var(local_per_cpu_offset)
55#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
56#define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
57 25
58extern void percpu_modcopy(void *pcpudst, const void *src, unsigned long size);
59extern void setup_per_cpu_areas (void);
60extern void *per_cpu_init(void); 26extern void *per_cpu_init(void);
61 27
62#else /* ! SMP */ 28#else /* ! SMP */
63 29
64#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var)) 30#define PER_CPU_ATTRIBUTES __attribute__((__section__(".data.percpu")))
65#define __get_cpu_var(var) per_cpu__##var 31
66#define __raw_get_cpu_var(var) per_cpu__##var
67#define per_cpu_init() (__phys_per_cpu_start) 32#define per_cpu_init() (__phys_per_cpu_start)
68 33
69#endif /* SMP */ 34#endif /* SMP */
70 35
71#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
72#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
73
74/* 36/*
75 * Be extremely careful when taking the address of this variable! Due to virtual 37 * Be extremely careful when taking the address of this variable! Due to virtual
76 * remapping, it is different from the canonical address returned by __get_cpu_var(var)! 38 * remapping, it is different from the canonical address returned by __get_cpu_var(var)!
77 * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly 39 * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
78 * more efficient. 40 * more efficient.
79 */ 41 */
80#define __ia64_per_cpu_var(var) (per_cpu__##var) 42#define __ia64_per_cpu_var(var) per_cpu__##var
43
44#include <asm-generic/percpu.h>
45
46/* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */
47DECLARE_PER_CPU(unsigned long, local_per_cpu_offset);
81 48
82#endif /* !__ASSEMBLY__ */ 49#endif /* !__ASSEMBLY__ */
83 50
diff --git a/include/asm-ia64/smp.h b/include/asm-ia64/smp.h
index 471cc2ee9ac4..4fa733dd417a 100644
--- a/include/asm-ia64/smp.h
+++ b/include/asm-ia64/smp.h
@@ -60,7 +60,6 @@ extern cpumask_t cpu_online_map;
60extern cpumask_t cpu_core_map[NR_CPUS]; 60extern cpumask_t cpu_core_map[NR_CPUS];
61DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 61DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
62extern int smp_num_siblings; 62extern int smp_num_siblings;
63extern int smp_num_cpucores;
64extern void __iomem *ipi_base_addr; 63extern void __iomem *ipi_base_addr;
65extern unsigned char smp_int_redirect; 64extern unsigned char smp_int_redirect;
66 65
diff --git a/include/asm-ia64/sn/bte.h b/include/asm-ia64/sn/bte.h
index 5335d87ca5f8..a0d214f43115 100644
--- a/include/asm-ia64/sn/bte.h
+++ b/include/asm-ia64/sn/bte.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2000-2007 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9 9
@@ -150,6 +150,35 @@ typedef enum {
150 BTEFAIL_NOTAVAIL, /* BTE not available */ 150 BTEFAIL_NOTAVAIL, /* BTE not available */
151} bte_result_t; 151} bte_result_t;
152 152
153#define BTEFAIL_SH2_RESP_SHORT 0x1 /* bit 000001 */
154#define BTEFAIL_SH2_RESP_LONG 0x2 /* bit 000010 */
155#define BTEFAIL_SH2_RESP_DSP 0x4 /* bit 000100 */
156#define BTEFAIL_SH2_RESP_ACCESS 0x8 /* bit 001000 */
157#define BTEFAIL_SH2_CRB_TO 0x10 /* bit 010000 */
158#define BTEFAIL_SH2_NACK_LIMIT 0x20 /* bit 100000 */
159#define BTEFAIL_SH2_ALL 0x3F /* bit 111111 */
160
161#define BTE_ERR_BITS 0x3FUL
162#define BTE_ERR_SHIFT 36
163#define BTE_ERR_MASK (BTE_ERR_BITS << BTE_ERR_SHIFT)
164
165#define BTE_ERROR_RETRY(value) \
166 (is_shub2() ? (value != BTEFAIL_SH2_CRB_TO) \
167 : (value != BTEFAIL_TOUT))
168
169/*
170 * On shub1 BTE_ERR_MASK will always be false, so no need for is_shub2()
171 */
172#define BTE_SHUB2_ERROR(_status) \
173 ((_status & BTE_ERR_MASK) \
174 ? (((_status >> BTE_ERR_SHIFT) & BTE_ERR_BITS) | IBLS_ERROR) \
175 : _status)
176
177#define BTE_GET_ERROR_STATUS(_status) \
178 (BTE_SHUB2_ERROR(_status) & ~IBLS_ERROR)
179
180#define BTE_VALID_SH2_ERROR(value) \
181 ((value >= BTEFAIL_SH2_RESP_SHORT) && (value <= BTEFAIL_SH2_ALL))
153 182
154/* 183/*
155 * Structure defining a bte. An instance of this 184 * Structure defining a bte. An instance of this
diff --git a/include/asm-ia64/sn/xp.h b/include/asm-ia64/sn/xp.h
index 6f807e0193b7..f7711b308e48 100644
--- a/include/asm-ia64/sn/xp.h
+++ b/include/asm-ia64/sn/xp.h
@@ -86,7 +86,7 @@ xp_bte_copy(u64 src, u64 vdst, u64 len, u64 mode, void *notification)
86 BUG_ON(REGION_NUMBER(vdst) != RGN_KERNEL); 86 BUG_ON(REGION_NUMBER(vdst) != RGN_KERNEL);
87 87
88 ret = bte_copy(src, pdst, len, mode, notification); 88 ret = bte_copy(src, pdst, len, mode, notification);
89 if (ret != BTE_SUCCESS) { 89 if ((ret != BTE_SUCCESS) && BTE_ERROR_RETRY(ret)) {
90 if (!in_interrupt()) { 90 if (!in_interrupt()) {
91 cond_resched(); 91 cond_resched();
92 } 92 }
@@ -244,7 +244,30 @@ enum xpc_retval {
244 244
245 xpcDisconnected, /* 51: channel disconnected (closed) */ 245 xpcDisconnected, /* 51: channel disconnected (closed) */
246 246
247 xpcUnknownReason /* 52: unknown reason -- must be last in list */ 247 xpcBteSh2Start, /* 52: BTE CRB timeout */
248
249 /* 53: 0x1 BTE Error Response Short */
250 xpcBteSh2RspShort = xpcBteSh2Start + BTEFAIL_SH2_RESP_SHORT,
251
252 /* 54: 0x2 BTE Error Response Long */
253 xpcBteSh2RspLong = xpcBteSh2Start + BTEFAIL_SH2_RESP_LONG,
254
255 /* 56: 0x4 BTE Error Response DSB */
256 xpcBteSh2RspDSB = xpcBteSh2Start + BTEFAIL_SH2_RESP_DSP,
257
258 /* 60: 0x8 BTE Error Response Access */
259 xpcBteSh2RspAccess = xpcBteSh2Start + BTEFAIL_SH2_RESP_ACCESS,
260
261 /* 68: 0x10 BTE Error CRB timeout */
262 xpcBteSh2CRBTO = xpcBteSh2Start + BTEFAIL_SH2_CRB_TO,
263
264 /* 84: 0x20 BTE Error NACK limit */
265 xpcBteSh2NACKLimit = xpcBteSh2Start + BTEFAIL_SH2_NACK_LIMIT,
266
267 /* 115: BTE end */
268 xpcBteSh2End = xpcBteSh2Start + BTEFAIL_SH2_ALL,
269
270 xpcUnknownReason /* 116: unknown reason -- must be last in list */
248}; 271};
249 272
250 273
diff --git a/include/asm-ia64/sn/xpc.h b/include/asm-ia64/sn/xpc.h
index e52b8508083b..3c0900ab8003 100644
--- a/include/asm-ia64/sn/xpc.h
+++ b/include/asm-ia64/sn/xpc.h
@@ -3,7 +3,7 @@
3 * License. See the file "COPYING" in the main directory of this archive 3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (c) 2004-2006 Silicon Graphics, Inc. All Rights Reserved. 6 * Copyright (c) 2004-2007 Silicon Graphics, Inc. All Rights Reserved.
7 */ 7 */
8 8
9 9
@@ -1211,6 +1211,14 @@ xpc_IPI_init(int index)
1211static inline enum xpc_retval 1211static inline enum xpc_retval
1212xpc_map_bte_errors(bte_result_t error) 1212xpc_map_bte_errors(bte_result_t error)
1213{ 1213{
1214 if (error == BTE_SUCCESS)
1215 return xpcSuccess;
1216
1217 if (is_shub2()) {
1218 if (BTE_VALID_SH2_ERROR(error))
1219 return xpcBteSh2Start + error;
1220 return xpcBteUnmappedError;
1221 }
1214 switch (error) { 1222 switch (error) {
1215 case BTE_SUCCESS: return xpcSuccess; 1223 case BTE_SUCCESS: return xpcSuccess;
1216 case BTEFAIL_DIR: return xpcBteDirectoryError; 1224 case BTEFAIL_DIR: return xpcBteDirectoryError;
diff --git a/include/asm-ia64/socket.h b/include/asm-ia64/socket.h
index 9e42ce43cfbe..d5ef0aa3e312 100644
--- a/include/asm-ia64/socket.h
+++ b/include/asm-ia64/socket.h
@@ -61,4 +61,6 @@
61#define SO_TIMESTAMPNS 35 61#define SO_TIMESTAMPNS 35
62#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 62#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
63 63
64#define SO_MARK 36
65
64#endif /* _ASM_IA64_SOCKET_H */ 66#endif /* _ASM_IA64_SOCKET_H */
diff --git a/include/asm-ia64/tlbflush.h b/include/asm-ia64/tlbflush.h
index 80bcb0a38e8a..7774a1cac0cc 100644
--- a/include/asm-ia64/tlbflush.h
+++ b/include/asm-ia64/tlbflush.h
@@ -92,6 +92,10 @@ void smp_local_flush_tlb(void);
92#define smp_local_flush_tlb() 92#define smp_local_flush_tlb()
93#endif 93#endif
94 94
95#define flush_tlb_kernel_range(start, end) flush_tlb_all() /* XXX fix me */ 95static inline void flush_tlb_kernel_range(unsigned long start,
96 unsigned long end)
97{
98 flush_tlb_all(); /* XXX fix me */
99}
96 100
97#endif /* _ASM_IA64_TLBFLUSH_H */ 101#endif /* _ASM_IA64_TLBFLUSH_H */
diff --git a/include/asm-m32r/signal.h b/include/asm-m32r/signal.h
index 937258686ba5..1a607066bc64 100644
--- a/include/asm-m32r/signal.h
+++ b/include/asm-m32r/signal.h
@@ -157,7 +157,7 @@ typedef struct sigaltstack {
157#undef __HAVE_ARCH_SIG_BITOPS 157#undef __HAVE_ARCH_SIG_BITOPS
158 158
159struct pt_regs; 159struct pt_regs;
160extern int FASTCALL(do_signal(struct pt_regs *regs, sigset_t *oldset)); 160extern int do_signal(struct pt_regs *regs, sigset_t *oldset);
161 161
162#define ptrace_signal_deliver(regs, cookie) do { } while (0) 162#define ptrace_signal_deliver(regs, cookie) do { } while (0)
163 163
diff --git a/include/asm-m32r/socket.h b/include/asm-m32r/socket.h
index 793d5d30c850..9a0e20012224 100644
--- a/include/asm-m32r/socket.h
+++ b/include/asm-m32r/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* _ASM_M32R_SOCKET_H */ 57#endif /* _ASM_M32R_SOCKET_H */
diff --git a/include/asm-m32r/thread_info.h b/include/asm-m32r/thread_info.h
index c039820dba7c..1effcd0f5e63 100644
--- a/include/asm-m32r/thread_info.h
+++ b/include/asm-m32r/thread_info.h
@@ -149,16 +149,21 @@ static inline unsigned int get_thread_fault_code(void)
149#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 149#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
150#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */ 150#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
151#define TIF_IRET 4 /* return with iret */ 151#define TIF_IRET 4 /* return with iret */
152#define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 152#define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
153 /* 31..28 fault code */ 153#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
154#define TIF_MEMDIE 17 154#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
155#define TIF_MEMDIE 18 /* OOM killer killed process */
156#define TIF_FREEZE 19 /* is freezing for suspend */
155 157
156#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 158#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
157#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 159#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
158#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 160#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
159#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 161#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
160#define _TIF_IRET (1<<TIF_IRET) 162#define _TIF_IRET (1<<TIF_IRET)
163#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
164#define _TIF_USEDFPU (1<<TIF_USEDFPU)
161#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 165#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
166#define _TIF_FREEZE (1<<TIF_FREEZE)
162 167
163#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ 168#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
164#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */ 169#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
diff --git a/include/asm-m32r/unistd.h b/include/asm-m32r/unistd.h
index cbbd53762ea6..f467eac9ba70 100644
--- a/include/asm-m32r/unistd.h
+++ b/include/asm-m32r/unistd.h
@@ -290,10 +290,50 @@
290#define __NR_mq_getsetattr (__NR_mq_open+5) 290#define __NR_mq_getsetattr (__NR_mq_open+5)
291#define __NR_kexec_load 283 291#define __NR_kexec_load 283
292#define __NR_waitid 284 292#define __NR_waitid 284
293/* 285 is unused */
294#define __NR_add_key 286
295#define __NR_request_key 287
296#define __NR_keyctl 288
297#define __NR_ioprio_set 289
298#define __NR_ioprio_get 290
299#define __NR_inotify_init 291
300#define __NR_inotify_add_watch 292
301#define __NR_inotify_rm_watch 293
302#define __NR_migrate_pages 294
303#define __NR_openat 295
304#define __NR_mkdirat 296
305#define __NR_mknodat 297
306#define __NR_fchownat 298
307#define __NR_futimesat 299
308#define __NR_fstatat64 300
309#define __NR_unlinkat 301
310#define __NR_renameat 302
311#define __NR_linkat 303
312#define __NR_symlinkat 304
313#define __NR_readlinkat 305
314#define __NR_fchmodat 306
315#define __NR_faccessat 307
316#define __NR_pselect6 308
317#define __NR_ppoll 309
318#define __NR_unshare 310
319#define __NR_set_robust_list 311
320#define __NR_get_robust_list 312
321#define __NR_splice 313
322#define __NR_sync_file_range 314
323#define __NR_tee 315
324#define __NR_vmsplice 316
325#define __NR_move_pages 317
326#define __NR_getcpu 318
327#define __NR_epoll_pwait 319
328#define __NR_utimensat 320
329#define __NR_signalfd 321
330#define __NR_timerfd 322
331#define __NR_eventfd 323
332#define __NR_fallocate 324
293 333
294#ifdef __KERNEL__ 334#ifdef __KERNEL__
295 335
296#define NR_syscalls 285 336#define NR_syscalls 325
297 337
298#define __ARCH_WANT_IPC_PARSE_VERSION 338#define __ARCH_WANT_IPC_PARSE_VERSION
299#define __ARCH_WANT_STAT64 339#define __ARCH_WANT_STAT64
@@ -311,6 +351,30 @@
311#define __ARCH_WANT_SYS_OLDUMOUNT 351#define __ARCH_WANT_SYS_OLDUMOUNT
312#define __ARCH_WANT_SYS_RT_SIGACTION 352#define __ARCH_WANT_SYS_RT_SIGACTION
313 353
354#define __IGNORE_lchown
355#define __IGNORE_setuid
356#define __IGNORE_getuid
357#define __IGNORE_setgid
358#define __IGNORE_getgid
359#define __IGNORE_geteuid
360#define __IGNORE_getegid
361#define __IGNORE_fcntl
362#define __IGNORE_setreuid
363#define __IGNORE_setregid
364#define __IGNORE_getrlimit
365#define __IGNORE_getgroups
366#define __IGNORE_setgroups
367#define __IGNORE_select
368#define __IGNORE_mmap
369#define __IGNORE_fchown
370#define __IGNORE_setfsuid
371#define __IGNORE_setfsgid
372#define __IGNORE_setresuid
373#define __IGNORE_getresuid
374#define __IGNORE_setresgid
375#define __IGNORE_getresgid
376#define __IGNORE_chown
377
314/* 378/*
315 * "Conditional" syscalls 379 * "Conditional" syscalls
316 * 380 *
diff --git a/include/asm-m68k/bitops.h b/include/asm-m68k/bitops.h
index 2976b5d68e96..83d1f286230b 100644
--- a/include/asm-m68k/bitops.h
+++ b/include/asm-m68k/bitops.h
@@ -410,6 +410,8 @@ static inline int ext2_find_next_zero_bit(const void *vaddr, unsigned size,
410 res = ext2_find_first_zero_bit (p, size - 32 * (p - addr)); 410 res = ext2_find_first_zero_bit (p, size - 32 * (p - addr));
411 return (p - addr) * 32 + res; 411 return (p - addr) * 32 + res;
412} 412}
413#define ext2_find_next_bit(addr, size, off) \
414 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
413 415
414#endif /* __KERNEL__ */ 416#endif /* __KERNEL__ */
415 417
diff --git a/include/asm-m68k/socket.h b/include/asm-m68k/socket.h
index 6d21b90863ad..dbc64e92c41a 100644
--- a/include/asm-m68k/socket.h
+++ b/include/asm-m68k/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* _ASM_SOCKET_H */ 57#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-m68knommu/bitops.h b/include/asm-m68knommu/bitops.h
index f8dfb7ba2e25..f43afe1fc3b3 100644
--- a/include/asm-m68knommu/bitops.h
+++ b/include/asm-m68knommu/bitops.h
@@ -294,6 +294,8 @@ found_middle:
294 return result + ffz(__swab32(tmp)); 294 return result + ffz(__swab32(tmp));
295} 295}
296 296
297#define ext2_find_next_bit(addr, size, off) \
298 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
297#include <asm-generic/bitops/minix.h> 299#include <asm-generic/bitops/minix.h>
298 300
299#endif /* __KERNEL__ */ 301#endif /* __KERNEL__ */
diff --git a/include/asm-m68knommu/cacheflush.h b/include/asm-m68knommu/cacheflush.h
index 163dcb1a9689..29bc0aad2ebc 100644
--- a/include/asm-m68knommu/cacheflush.h
+++ b/include/asm-m68knommu/cacheflush.h
@@ -53,7 +53,7 @@ static inline void __flush_cache_all(void)
53#endif /* CONFIG_M5407 */ 53#endif /* CONFIG_M5407 */
54#if defined(CONFIG_M527x) || defined(CONFIG_M528x) 54#if defined(CONFIG_M527x) || defined(CONFIG_M528x)
55 __asm__ __volatile__ ( 55 __asm__ __volatile__ (
56 "movel #0x81400100, %%d0\n\t" 56 "movel #0x81000200, %%d0\n\t"
57 "movec %%d0, %%CACR\n\t" 57 "movec %%d0, %%CACR\n\t"
58 "nop\n\t" 58 "nop\n\t"
59 : : : "d0" ); 59 : : : "d0" );
diff --git a/include/asm-m68knommu/mcfcache.h b/include/asm-m68knommu/mcfcache.h
index 7b61a8a529f5..c042634fadaa 100644
--- a/include/asm-m68knommu/mcfcache.h
+++ b/include/asm-m68knommu/mcfcache.h
@@ -60,7 +60,7 @@
60 nop 60 nop
61 movel #0x0000c020, %d0 /* Set SDRAM cached only */ 61 movel #0x0000c020, %d0 /* Set SDRAM cached only */
62 movec %d0, %ACR0 62 movec %d0, %ACR0
63 movel #0xff00c000, %d0 /* Cache Flash also */ 63 movel #0x00000000, %d0 /* No other regions cached */
64 movec %d0, %ACR1 64 movec %d0, %ACR1
65 movel #0x80000200, %d0 /* Setup cache mask */ 65 movel #0x80000200, %d0 /* Setup cache mask */
66 movec %d0, %CACR /* Enable cache */ 66 movec %d0, %CACR /* Enable cache */
diff --git a/include/asm-m68knommu/mcfuart.h b/include/asm-m68knommu/mcfuart.h
index 873d0805219c..1319a81814b1 100644
--- a/include/asm-m68knommu/mcfuart.h
+++ b/include/asm-m68knommu/mcfuart.h
@@ -12,7 +12,6 @@
12#define mcfuart_h 12#define mcfuart_h
13/****************************************************************************/ 13/****************************************************************************/
14 14
15
16/* 15/*
17 * Define the base address of the UARTS within the MBAR address 16 * Define the base address of the UARTS within the MBAR address
18 * space. 17 * space.
@@ -33,7 +32,7 @@
33#define MCFUART_BASE2 0x240 /* Base address of UART2 */ 32#define MCFUART_BASE2 0x240 /* Base address of UART2 */
34#define MCFUART_BASE3 0x280 /* Base address of UART3 */ 33#define MCFUART_BASE3 0x280 /* Base address of UART3 */
35#elif defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) 34#elif defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407)
36#if defined(CONFIG_NETtel) || defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) 35#if defined(CONFIG_NETtel) || defined(CONFIG_SECUREEDGEMP3)
37#define MCFUART_BASE1 0x200 /* Base address of UART1 */ 36#define MCFUART_BASE1 0x200 /* Base address of UART1 */
38#define MCFUART_BASE2 0x1c0 /* Base address of UART2 */ 37#define MCFUART_BASE2 0x1c0 /* Base address of UART2 */
39#else 38#else
diff --git a/include/asm-m68knommu/unistd.h b/include/asm-m68knommu/unistd.h
index eb1b566793fe..27c2f9bb4dbd 100644
--- a/include/asm-m68knommu/unistd.h
+++ b/include/asm-m68knommu/unistd.h
@@ -185,8 +185,8 @@
185#define __NR_rt_sigtimedwait 177 185#define __NR_rt_sigtimedwait 177
186#define __NR_rt_sigqueueinfo 178 186#define __NR_rt_sigqueueinfo 178
187#define __NR_rt_sigsuspend 179 187#define __NR_rt_sigsuspend 179
188#define __NR_pread 180 188#define __NR_pread64 180
189#define __NR_pwrite 181 189#define __NR_pwrite64 181
190#define __NR_lchown 182 190#define __NR_lchown 182
191#define __NR_getcwd 183 191#define __NR_getcwd 183
192#define __NR_capget 184 192#define __NR_capget 184
diff --git a/include/asm-mips/8253pit.h b/include/asm-mips/8253pit.h
deleted file mode 100644
index 285f78488ccb..000000000000
--- a/include/asm-mips/8253pit.h
+++ /dev/null
@@ -1,10 +0,0 @@
1/*
2 * 8253/8254 Programmable Interval Timer
3 */
4
5#ifndef _8253PIT_H
6#define _8253PIT_H
7
8#define PIT_TICK_RATE 1193182UL
9
10#endif
diff --git a/include/asm-mips/addrspace.h b/include/asm-mips/addrspace.h
index 0bb7a93b7a5e..569f80aacbd2 100644
--- a/include/asm-mips/addrspace.h
+++ b/include/asm-mips/addrspace.h
@@ -127,7 +127,7 @@
127#define PHYS_TO_XKSEG_CACHED(p) PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE, (p)) 127#define PHYS_TO_XKSEG_CACHED(p) PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE, (p))
128#define XKPHYS_TO_PHYS(p) ((p) & TO_PHYS_MASK) 128#define XKPHYS_TO_PHYS(p) ((p) & TO_PHYS_MASK)
129#define PHYS_TO_XKPHYS(cm, a) (_CONST64_(0x8000000000000000) | \ 129#define PHYS_TO_XKPHYS(cm, a) (_CONST64_(0x8000000000000000) | \
130 ((cm)<<59) | (a)) 130 (_CONST64_(cm) << 59) | (a))
131 131
132/* 132/*
133 * The ultimate limited of the 64-bit MIPS architecture: 2 bits for selecting 133 * The ultimate limited of the 64-bit MIPS architecture: 2 bits for selecting
diff --git a/include/asm-mips/asm.h b/include/asm-mips/asm.h
index 12e17581b823..608cfcfbb3ea 100644
--- a/include/asm-mips/asm.h
+++ b/include/asm-mips/asm.h
@@ -398,4 +398,12 @@ symbol = value
398 398
399#define SSNOP sll zero, zero, 1 399#define SSNOP sll zero, zero, 1
400 400
401#ifdef CONFIG_SGI_IP28
402/* Inhibit speculative stores to volatile (e.g.DMA) or invalid addresses. */
403#include <asm/cacheops.h>
404#define R10KCBARRIER(addr) cache Cache_Barrier, addr;
405#else
406#define R10KCBARRIER(addr)
407#endif
408
401#endif /* __ASM_ASM_H */ 409#endif /* __ASM_ASM_H */
diff --git a/include/asm-mips/bootinfo.h b/include/asm-mips/bootinfo.h
index b2dd9b33de8f..e031bdff9920 100644
--- a/include/asm-mips/bootinfo.h
+++ b/include/asm-mips/bootinfo.h
@@ -48,22 +48,11 @@
48#define MACH_DS5900 10 /* DECsystem 5900 */ 48#define MACH_DS5900 10 /* DECsystem 5900 */
49 49
50/* 50/*
51 * Valid machtype for group ARC
52 */
53#define MACH_DESKSTATION_RPC44 0 /* Deskstation rPC44 */
54#define MACH_DESKSTATION_TYNE 1 /* Deskstation Tyne */
55
56/*
57 * Valid machtype for group SNI_RM 51 * Valid machtype for group SNI_RM
58 */ 52 */
59#define MACH_SNI_RM200_PCI 0 /* RM200/RM300/RM400 PCI series */ 53#define MACH_SNI_RM200_PCI 0 /* RM200/RM300/RM400 PCI series */
60 54
61/* 55/*
62 * Valid machtype for group ACN
63 */
64#define MACH_ACN_MIPS_BOARD 0 /* ACN MIPS single board */
65
66/*
67 * Valid machtype for group SGI 56 * Valid machtype for group SGI
68 */ 57 */
69#define MACH_SGI_IP22 0 /* Indy, Indigo2, Challenge S */ 58#define MACH_SGI_IP22 0 /* Indy, Indigo2, Challenge S */
@@ -73,44 +62,6 @@
73#define MACH_SGI_IP30 4 /* Octane, Octane2 */ 62#define MACH_SGI_IP30 4 /* Octane, Octane2 */
74 63
75/* 64/*
76 * Valid machtype for group COBALT
77 */
78#define MACH_COBALT_27 0 /* Proto "27" hardware */
79
80/*
81 * Valid machtype for group BAGET
82 */
83#define MACH_BAGET201 0 /* BT23-201 */
84#define MACH_BAGET202 1 /* BT23-202 */
85
86/*
87 * Cosine boards.
88 */
89#define MACH_COSINE_ORION 0
90
91/*
92 * Valid machtype for group MOMENCO
93 */
94#define MACH_MOMENCO_OCELOT 0
95#define MACH_MOMENCO_OCELOT_G 1 /* no more supported (may 2007) */
96#define MACH_MOMENCO_OCELOT_C 2 /* no more supported (jun 2007) */
97#define MACH_MOMENCO_JAGUAR_ATX 3 /* no more supported (may 2007) */
98#define MACH_MOMENCO_OCELOT_3 4
99
100/*
101 * Valid machtype for group PHILIPS
102 */
103#define MACH_PHILIPS_NINO 0 /* Nino */
104#define MACH_PHILIPS_VELO 1 /* Velo */
105#define MACH_PHILIPS_JBS 2 /* JBS */
106#define MACH_PHILIPS_STB810 3 /* STB810 */
107
108/*
109 * Valid machtype for group SIBYTE
110 */
111#define MACH_SWARM 0
112
113/*
114 * Valid machtypes for group Toshiba 65 * Valid machtypes for group Toshiba
115 */ 66 */
116#define MACH_PALLAS 0 67#define MACH_PALLAS 0
@@ -122,64 +73,17 @@
122#define MACH_TOSHIBA_RBTX4938 6 73#define MACH_TOSHIBA_RBTX4938 6
123 74
124/* 75/*
125 * Valid machtype for group Alchemy
126 */
127#define MACH_PB1000 0 /* Au1000-based eval board */
128#define MACH_PB1100 1 /* Au1100-based eval board */
129#define MACH_PB1500 2 /* Au1500-based eval board */
130#define MACH_DB1000 3 /* Au1000-based eval board */
131#define MACH_DB1100 4 /* Au1100-based eval board */
132#define MACH_DB1500 5 /* Au1500-based eval board */
133#define MACH_XXS1500 6 /* Au1500-based eval board */
134#define MACH_MTX1 7 /* 4G MTX-1 Au1500-based board */
135#define MACH_PB1550 8 /* Au1550-based eval board */
136#define MACH_DB1550 9 /* Au1550-based eval board */
137#define MACH_PB1200 10 /* Au1200-based eval board */
138#define MACH_DB1200 11 /* Au1200-based eval board */
139
140/*
141 * Valid machtype for group NEC_VR41XX
142 *
143 * Various NEC-based devices.
144 *
145 * FIXME: MACH_GROUPs should be by _MANUFACTURER_ of * the device, not by
146 * technical properties, so no new additions to this group.
147 */
148#define MACH_NEC_OSPREY 0 /* Osprey eval board */
149#define MACH_NEC_EAGLE 1 /* NEC Eagle/Hawk board */
150#define MACH_ZAO_CAPCELLA 2 /* ZAO Networks Capcella */
151#define MACH_VICTOR_MPC30X 3 /* Victor MP-C303/304 */
152#define MACH_IBM_WORKPAD 4 /* IBM WorkPad z50 */
153#define MACH_CASIO_E55 5 /* CASIO CASSIOPEIA E-10/15/55/65 */
154#define MACH_TANBAC_TB0226 6 /* TANBAC TB0226 (Mbase) */
155#define MACH_TANBAC_TB0229 7 /* TANBAC TB0229 (VR4131DIMM) */
156#define MACH_NEC_CMBVR4133 8 /* CMB VR4133 Board */
157
158#define MACH_HP_LASERJET 1
159
160/*
161 * Valid machtype for group LASAT 76 * Valid machtype for group LASAT
162 */ 77 */
163#define MACH_LASAT_100 0 /* Masquerade II/SP100/SP50/SP25 */ 78#define MACH_LASAT_100 0 /* Masquerade II/SP100/SP50/SP25 */
164#define MACH_LASAT_200 1 /* Masquerade PRO/SP200 */ 79#define MACH_LASAT_200 1 /* Masquerade PRO/SP200 */
165 80
166/* 81/*
167 * Valid machtype for group TITAN
168 */
169#define MACH_TITAN_YOSEMITE 1 /* PMC-Sierra Yosemite */
170#define MACH_TITAN_EXCITE 2 /* Basler eXcite */
171
172/*
173 * Valid machtype for group NEC EMMA2RH 82 * Valid machtype for group NEC EMMA2RH
174 */ 83 */
175#define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */ 84#define MACH_NEC_MARKEINS 0 /* NEC EMMA2RH Mark-eins */
176 85
177/* 86/*
178 * Valid machtype for group LEMOTE
179 */
180#define MACH_LEMOTE_FULONG 0
181
182/*
183 * Valid machtype for group PMC-MSP 87 * Valid machtype for group PMC-MSP
184 */ 88 */
185#define MACH_MSP4200_EVAL 0 /* PMC-Sierra MSP4200 Evaluation */ 89#define MACH_MSP4200_EVAL 0 /* PMC-Sierra MSP4200 Evaluation */
@@ -190,16 +94,9 @@
190#define MACH_MSP7120_FPGA 5 /* PMC-Sierra MSP7120 Emulation */ 94#define MACH_MSP7120_FPGA 5 /* PMC-Sierra MSP7120 Emulation */
191#define MACH_MSP_OTHER 255 /* PMC-Sierra unknown board type */ 95#define MACH_MSP_OTHER 255 /* PMC-Sierra unknown board type */
192 96
193#define MACH_WRPPMC 1
194
195/*
196 * Valid machtype for group Broadcom
197 */
198#define MACH_GROUP_BRCM 23 /* Broadcom */
199#define MACH_BCM47XX 1 /* Broadcom BCM47XX */
200
201#define CL_SIZE COMMAND_LINE_SIZE 97#define CL_SIZE COMMAND_LINE_SIZE
202 98
99extern char *system_type;
203const char *get_system_type(void); 100const char *get_system_type(void);
204 101
205extern unsigned long mips_machtype; 102extern unsigned long mips_machtype;
diff --git a/include/asm-mips/bugs.h b/include/asm-mips/bugs.h
index 0d7f9c1f5546..9dc10df32078 100644
--- a/include/asm-mips/bugs.h
+++ b/include/asm-mips/bugs.h
@@ -1,19 +1,34 @@
1/* 1/*
2 * This is included by init/main.c to check for architecture-dependent bugs. 2 * This is included by init/main.c to check for architecture-dependent bugs.
3 * 3 *
4 * Copyright (C) 2007 Maciej W. Rozycki
5 *
4 * Needs: 6 * Needs:
5 * void check_bugs(void); 7 * void check_bugs(void);
6 */ 8 */
7#ifndef _ASM_BUGS_H 9#ifndef _ASM_BUGS_H
8#define _ASM_BUGS_H 10#define _ASM_BUGS_H
9 11
12#include <linux/bug.h>
10#include <linux/delay.h> 13#include <linux/delay.h>
14
11#include <asm/cpu.h> 15#include <asm/cpu.h>
12#include <asm/cpu-info.h> 16#include <asm/cpu-info.h>
13 17
18extern int daddiu_bug;
19
20extern void check_bugs64_early(void);
21
14extern void check_bugs32(void); 22extern void check_bugs32(void);
15extern void check_bugs64(void); 23extern void check_bugs64(void);
16 24
25static inline void check_bugs_early(void)
26{
27#ifdef CONFIG_64BIT
28 check_bugs64_early();
29#endif
30}
31
17static inline void check_bugs(void) 32static inline void check_bugs(void)
18{ 33{
19 unsigned int cpu = smp_processor_id(); 34 unsigned int cpu = smp_processor_id();
@@ -25,4 +40,14 @@ static inline void check_bugs(void)
25#endif 40#endif
26} 41}
27 42
43static inline int r4k_daddiu_bug(void)
44{
45#ifdef CONFIG_64BIT
46 WARN_ON(daddiu_bug < 0);
47 return daddiu_bug != 0;
48#else
49 return 0;
50#endif
51}
52
28#endif /* _ASM_BUGS_H */ 53#endif /* _ASM_BUGS_H */
diff --git a/include/asm-mips/cacheops.h b/include/asm-mips/cacheops.h
index df7f2deb3b56..256ad2cc6eb8 100644
--- a/include/asm-mips/cacheops.h
+++ b/include/asm-mips/cacheops.h
@@ -64,7 +64,7 @@
64#define Page_Invalidate_T 0x16 64#define Page_Invalidate_T 0x16
65 65
66/* 66/*
67 * R1000-specific cacheops 67 * R10000-specific cacheops
68 * 68 *
69 * Cacheops 0x02, 0x06, 0x0a, 0x0c-0x0e, 0x16, 0x1a and 0x1e are unused. 69 * Cacheops 0x02, 0x06, 0x0a, 0x0c-0x0e, 0x16, 0x1a and 0x1e are unused.
70 * Most of the _S cacheops are identical to the R4000SC _SD cacheops. 70 * Most of the _S cacheops are identical to the R4000SC _SD cacheops.
diff --git a/include/asm-mips/cpu-features.h b/include/asm-mips/cpu-features.h
index f6bd308f047f..5ea701fc3425 100644
--- a/include/asm-mips/cpu-features.h
+++ b/include/asm-mips/cpu-features.h
@@ -207,13 +207,13 @@
207#endif 207#endif
208 208
209#ifndef cpu_dcache_line_size 209#ifndef cpu_dcache_line_size
210#define cpu_dcache_line_size() current_cpu_data.dcache.linesz 210#define cpu_dcache_line_size() cpu_data[0].dcache.linesz
211#endif 211#endif
212#ifndef cpu_icache_line_size 212#ifndef cpu_icache_line_size
213#define cpu_icache_line_size() current_cpu_data.icache.linesz 213#define cpu_icache_line_size() cpu_data[0].icache.linesz
214#endif 214#endif
215#ifndef cpu_scache_line_size 215#ifndef cpu_scache_line_size
216#define cpu_scache_line_size() current_cpu_data.scache.linesz 216#define cpu_scache_line_size() cpu_data[0].scache.linesz
217#endif 217#endif
218 218
219#endif /* __ASM_CPU_FEATURES_H */ 219#endif /* __ASM_CPU_FEATURES_H */
diff --git a/include/asm-mips/cpu-info.h b/include/asm-mips/cpu-info.h
index 94f1c8172360..0c5a358863f3 100644
--- a/include/asm-mips/cpu-info.h
+++ b/include/asm-mips/cpu-info.h
@@ -54,6 +54,8 @@ struct cpuinfo_mips {
54 struct cache_desc dcache; /* Primary D or combined I/D cache */ 54 struct cache_desc dcache; /* Primary D or combined I/D cache */
55 struct cache_desc scache; /* Secondary cache */ 55 struct cache_desc scache; /* Secondary cache */
56 struct cache_desc tcache; /* Tertiary/split secondary cache */ 56 struct cache_desc tcache; /* Tertiary/split secondary cache */
57 int srsets; /* Shadow register sets */
58 int core; /* physical core number */
57#if defined(CONFIG_MIPS_MT_SMTC) 59#if defined(CONFIG_MIPS_MT_SMTC)
58 /* 60 /*
59 * In the MIPS MT "SMTC" model, each TC is considered 61 * In the MIPS MT "SMTC" model, each TC is considered
@@ -62,8 +64,10 @@ struct cpuinfo_mips {
62 * to all TCs within the same VPE. 64 * to all TCs within the same VPE.
63 */ 65 */
64 int vpe_id; /* Virtual Processor number */ 66 int vpe_id; /* Virtual Processor number */
65 int tc_id; /* Thread Context number */
66#endif /* CONFIG_MIPS_MT */ 67#endif /* CONFIG_MIPS_MT */
68#ifdef CONFIG_MIPS_MT_SMTC
69 int tc_id; /* Thread Context number */
70#endif
67 void *data; /* Additional data */ 71 void *data; /* Additional data */
68} __attribute__((aligned(SMP_CACHE_BYTES))); 72} __attribute__((aligned(SMP_CACHE_BYTES)));
69 73
diff --git a/include/asm-mips/cpu.h b/include/asm-mips/cpu.h
index 54fc18a4e5a8..bf5bbc78a9f7 100644
--- a/include/asm-mips/cpu.h
+++ b/include/asm-mips/cpu.h
@@ -195,8 +195,8 @@ enum cpu_type_enum {
195 * MIPS32 class processors 195 * MIPS32 class processors
196 */ 196 */
197 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_74K, CPU_AU1000, 197 CPU_4KC, CPU_4KEC, CPU_4KSC, CPU_24K, CPU_34K, CPU_74K, CPU_AU1000,
198 CPU_AU1100, CPU_AU1200, CPU_AU1500, CPU_AU1550, CPU_PR4450, 198 CPU_AU1100, CPU_AU1200, CPU_AU1210, CPU_AU1250, CPU_AU1500, CPU_AU1550,
199 CPU_BCM3302, CPU_BCM4710, 199 CPU_PR4450, CPU_BCM3302, CPU_BCM4710,
200 200
201 /* 201 /*
202 * MIPS64 class processors 202 * MIPS64 class processors
diff --git a/include/asm-mips/delay.h b/include/asm-mips/delay.h
index fab32131e9b4..b0bccd2c4ed5 100644
--- a/include/asm-mips/delay.h
+++ b/include/asm-mips/delay.h
@@ -6,13 +6,16 @@
6 * Copyright (C) 1994 by Waldorf Electronics 6 * Copyright (C) 1994 by Waldorf Electronics
7 * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle 7 * Copyright (C) 1995 - 2000, 01, 03 by Ralf Baechle
8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 8 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
9 * Copyright (C) 2007 Maciej W. Rozycki
9 */ 10 */
10#ifndef _ASM_DELAY_H 11#ifndef _ASM_DELAY_H
11#define _ASM_DELAY_H 12#define _ASM_DELAY_H
12 13
13#include <linux/param.h> 14#include <linux/param.h>
14#include <linux/smp.h> 15#include <linux/smp.h>
16
15#include <asm/compiler.h> 17#include <asm/compiler.h>
18#include <asm/war.h>
16 19
17static inline void __delay(unsigned long loops) 20static inline void __delay(unsigned long loops)
18{ 21{
@@ -25,7 +28,7 @@ static inline void __delay(unsigned long loops)
25 " .set reorder \n" 28 " .set reorder \n"
26 : "=r" (loops) 29 : "=r" (loops)
27 : "0" (loops)); 30 : "0" (loops));
28 else if (sizeof(long) == 8) 31 else if (sizeof(long) == 8 && !DADDI_WAR)
29 __asm__ __volatile__ ( 32 __asm__ __volatile__ (
30 " .set noreorder \n" 33 " .set noreorder \n"
31 " .align 3 \n" 34 " .align 3 \n"
@@ -34,6 +37,15 @@ static inline void __delay(unsigned long loops)
34 " .set reorder \n" 37 " .set reorder \n"
35 : "=r" (loops) 38 : "=r" (loops)
36 : "0" (loops)); 39 : "0" (loops));
40 else if (sizeof(long) == 8 && DADDI_WAR)
41 __asm__ __volatile__ (
42 " .set noreorder \n"
43 " .align 3 \n"
44 "1: bnez %0, 1b \n"
45 " dsubu %0, %2 \n"
46 " .set reorder \n"
47 : "=r" (loops)
48 : "0" (loops), "r" (1));
37} 49}
38 50
39 51
@@ -50,7 +62,7 @@ static inline void __delay(unsigned long loops)
50 62
51static inline void __udelay(unsigned long usecs, unsigned long lpj) 63static inline void __udelay(unsigned long usecs, unsigned long lpj)
52{ 64{
53 unsigned long lo; 65 unsigned long hi, lo;
54 66
55 /* 67 /*
56 * The rates of 128 is rounded wrongly by the catchall case 68 * The rates of 128 is rounded wrongly by the catchall case
@@ -70,11 +82,16 @@ static inline void __udelay(unsigned long usecs, unsigned long lpj)
70 : "=h" (usecs), "=l" (lo) 82 : "=h" (usecs), "=l" (lo)
71 : "r" (usecs), "r" (lpj) 83 : "r" (usecs), "r" (lpj)
72 : GCC_REG_ACCUM); 84 : GCC_REG_ACCUM);
73 else if (sizeof(long) == 8) 85 else if (sizeof(long) == 8 && !R4000_WAR)
74 __asm__("dmultu\t%2, %3" 86 __asm__("dmultu\t%2, %3"
75 : "=h" (usecs), "=l" (lo) 87 : "=h" (usecs), "=l" (lo)
76 : "r" (usecs), "r" (lpj) 88 : "r" (usecs), "r" (lpj)
77 : GCC_REG_ACCUM); 89 : GCC_REG_ACCUM);
90 else if (sizeof(long) == 8 && R4000_WAR)
91 __asm__("dmultu\t%3, %4\n\tmfhi\t%0"
92 : "=r" (usecs), "=h" (hi), "=l" (lo)
93 : "r" (usecs), "r" (lpj)
94 : GCC_REG_ACCUM);
78 95
79 __delay(usecs); 96 __delay(usecs);
80} 97}
diff --git a/include/asm-mips/dma.h b/include/asm-mips/dma.h
index 833437d31ef1..1353c81065d1 100644
--- a/include/asm-mips/dma.h
+++ b/include/asm-mips/dma.h
@@ -84,14 +84,14 @@
84 * Deskstations or Acer PICA but not the much more versatile DMA logic used 84 * Deskstations or Acer PICA but not the much more versatile DMA logic used
85 * for the local devices on Acer PICA or Magnums. 85 * for the local devices on Acer PICA or Magnums.
86 */ 86 */
87#ifdef CONFIG_SGI_IP22 87#if defined(CONFIG_SGI_IP22) || defined(CONFIG_SGI_IP28)
88/* Horrible hack to have a correct DMA window on IP22 */ 88/* don't care; ISA bus master won't work, ISA slave DMA supports 32bit addr */
89#include <asm/sgi/mc.h> 89#define MAX_DMA_ADDRESS PAGE_OFFSET
90#define MAX_DMA_ADDRESS (PAGE_OFFSET + SGIMC_SEG0_BADDR + 0x01000000)
91#else 90#else
92#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000) 91#define MAX_DMA_ADDRESS (PAGE_OFFSET + 0x01000000)
93#endif 92#endif
94#define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS)) 93#define MAX_DMA_PFN PFN_DOWN(virt_to_phys((void *)MAX_DMA_ADDRESS))
94#define MAX_DMA32_PFN (1UL << (32 - PAGE_SHIFT))
95 95
96/* 8237 DMA controllers */ 96/* 8237 DMA controllers */
97#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */ 97#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
diff --git a/include/asm-mips/fixmap.h b/include/asm-mips/fixmap.h
index f27b96cfac2e..9cc8522a394f 100644
--- a/include/asm-mips/fixmap.h
+++ b/include/asm-mips/fixmap.h
@@ -60,16 +60,6 @@ enum fixed_addresses {
60 __end_of_fixed_addresses 60 __end_of_fixed_addresses
61}; 61};
62 62
63extern void __set_fixmap(enum fixed_addresses idx,
64 unsigned long phys, pgprot_t flags);
65
66#define set_fixmap(idx, phys) \
67 __set_fixmap(idx, phys, PAGE_KERNEL)
68/*
69 * Some hardware wants to get fixmapped without caching.
70 */
71#define set_fixmap_nocache(idx, phys) \
72 __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
73/* 63/*
74 * used by vmalloc.c. 64 * used by vmalloc.c.
75 * 65 *
diff --git a/include/asm-mips/futex.h b/include/asm-mips/futex.h
index 3e7e30d4f418..17f082cfea85 100644
--- a/include/asm-mips/futex.h
+++ b/include/asm-mips/futex.h
@@ -35,7 +35,7 @@
35 " .set mips0 \n" \ 35 " .set mips0 \n" \
36 " .section .fixup,\"ax\" \n" \ 36 " .section .fixup,\"ax\" \n" \
37 "4: li %0, %6 \n" \ 37 "4: li %0, %6 \n" \
38 " j 2b \n" \ 38 " j 3b \n" \
39 " .previous \n" \ 39 " .previous \n" \
40 " .section __ex_table,\"a\" \n" \ 40 " .section __ex_table,\"a\" \n" \
41 " "__UA_ADDR "\t1b, 4b \n" \ 41 " "__UA_ADDR "\t1b, 4b \n" \
@@ -61,7 +61,7 @@
61 " .set mips0 \n" \ 61 " .set mips0 \n" \
62 " .section .fixup,\"ax\" \n" \ 62 " .section .fixup,\"ax\" \n" \
63 "4: li %0, %6 \n" \ 63 "4: li %0, %6 \n" \
64 " j 2b \n" \ 64 " j 3b \n" \
65 " .previous \n" \ 65 " .previous \n" \
66 " .section __ex_table,\"a\" \n" \ 66 " .section __ex_table,\"a\" \n" \
67 " "__UA_ADDR "\t1b, 4b \n" \ 67 " "__UA_ADDR "\t1b, 4b \n" \
@@ -200,4 +200,4 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
200} 200}
201 201
202#endif 202#endif
203#endif 203#endif /* _ASM_FUTEX_H */
diff --git a/include/asm-mips/fw/cfe/cfe_api.h b/include/asm-mips/fw/cfe/cfe_api.h
index 1003e7156bfc..0995575db320 100644
--- a/include/asm-mips/fw/cfe/cfe_api.h
+++ b/include/asm-mips/fw/cfe/cfe_api.h
@@ -15,49 +15,27 @@
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18 18/*
19/* ********************************************************************* 19 * Broadcom Common Firmware Environment (CFE)
20 * 20 *
21 * Broadcom Common Firmware Environment (CFE) 21 * This file contains declarations for doing callbacks to
22 * 22 * cfe from an application. It should be the only header
23 * Device function prototypes File: cfe_api.h 23 * needed by the application to use this library
24 * 24 *
25 * This file contains declarations for doing callbacks to 25 * Authors: Mitch Lichtenberg, Chris Demetriou
26 * cfe from an application. It should be the only header 26 */
27 * needed by the application to use this library
28 *
29 * Authors: Mitch Lichtenberg, Chris Demetriou
30 *
31 ********************************************************************* */
32
33#ifndef CFE_API_H 27#ifndef CFE_API_H
34#define CFE_API_H 28#define CFE_API_H
35 29
36/*
37 * Apply customizations here for different OSes. These need to:
38 * * typedef uint64_t, int64_t, intptr_t, uintptr_t.
39 * * define cfe_strlen() if use of an existing function is desired.
40 * * define CFE_API_IMPL_NAMESPACE if API functions are to use
41 * names in the implementation namespace.
42 * Also, optionally, if the build environment does not do so automatically,
43 * CFE_API_* can be defined here as desired.
44 */
45/* Begin customization. */
46#include <linux/types.h> 30#include <linux/types.h>
47#include <linux/string.h> 31#include <linux/string.h>
48 32
49typedef long intptr_t; 33typedef long intptr_t;
50 34
51#define cfe_strlen strlen
52 35
53#define CFE_API_ALL 36/*
54#define CFE_API_STRLEN_CUSTOM 37 * Constants
55/* End customization. */ 38 */
56
57
58/* *********************************************************************
59 * Constants
60 ********************************************************************* */
61 39
62/* Seal indicating CFE's presence, passed to user program. */ 40/* Seal indicating CFE's presence, passed to user program. */
63#define CFE_EPTSEAL 0x43464531 41#define CFE_EPTSEAL 0x43464531
@@ -109,54 +87,13 @@ typedef struct {
109 87
110 88
111/* 89/*
112 * cfe_strlen is handled specially: If already defined, it has been
113 * overridden in this environment with a standard strlen-like function.
114 */
115#ifdef cfe_strlen
116# define CFE_API_STRLEN_CUSTOM
117#else
118# ifdef CFE_API_IMPL_NAMESPACE
119# define cfe_strlen(a) __cfe_strlen(a)
120# endif
121int cfe_strlen(char *name);
122#endif
123
124/*
125 * Defines and prototypes for functions which take no arguments. 90 * Defines and prototypes for functions which take no arguments.
126 */ 91 */
127#ifdef CFE_API_IMPL_NAMESPACE
128int64_t __cfe_getticks(void);
129#define cfe_getticks() __cfe_getticks()
130#else
131int64_t cfe_getticks(void); 92int64_t cfe_getticks(void);
132#endif
133 93
134/* 94/*
135 * Defines and prototypes for the rest of the functions. 95 * Defines and prototypes for the rest of the functions.
136 */ 96 */
137#ifdef CFE_API_IMPL_NAMESPACE
138#define cfe_close(a) __cfe_close(a)
139#define cfe_cpu_start(a, b, c, d, e) __cfe_cpu_start(a, b, c, d, e)
140#define cfe_cpu_stop(a) __cfe_cpu_stop(a)
141#define cfe_enumenv(a, b, d, e, f) __cfe_enumenv(a, b, d, e, f)
142#define cfe_enummem(a, b, c, d, e) __cfe_enummem(a, b, c, d, e)
143#define cfe_exit(a, b) __cfe_exit(a, b)
144#define cfe_flushcache(a) __cfe_cacheflush(a)
145#define cfe_getdevinfo(a) __cfe_getdevinfo(a)
146#define cfe_getenv(a, b, c) __cfe_getenv(a, b, c)
147#define cfe_getfwinfo(a) __cfe_getfwinfo(a)
148#define cfe_getstdhandle(a) __cfe_getstdhandle(a)
149#define cfe_init(a, b) __cfe_init(a, b)
150#define cfe_inpstat(a) __cfe_inpstat(a)
151#define cfe_ioctl(a, b, c, d, e, f) __cfe_ioctl(a, b, c, d, e, f)
152#define cfe_open(a) __cfe_open(a)
153#define cfe_read(a, b, c) __cfe_read(a, b, c)
154#define cfe_readblk(a, b, c, d) __cfe_readblk(a, b, c, d)
155#define cfe_setenv(a, b) __cfe_setenv(a, b)
156#define cfe_write(a, b, c) __cfe_write(a, b, c)
157#define cfe_writeblk(a, b, c, d) __cfe_writeblk(a, b, c, d)
158#endif /* CFE_API_IMPL_NAMESPACE */
159
160int cfe_close(int handle); 97int cfe_close(int handle);
161int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1); 98int cfe_cpu_start(int cpu, void (*fn) (void), long sp, long gp, long a1);
162int cfe_cpu_stop(int cpu); 99int cfe_cpu_stop(int cpu);
diff --git a/include/asm-mips/fw/cfe/cfe_error.h b/include/asm-mips/fw/cfe/cfe_error.h
index 975f00002cbe..b80374636279 100644
--- a/include/asm-mips/fw/cfe/cfe_error.h
+++ b/include/asm-mips/fw/cfe/cfe_error.h
@@ -16,18 +16,13 @@
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */ 17 */
18 18
19/* ********************************************************************* 19/*
20 * 20 * Broadcom Common Firmware Environment (CFE)
21 * Broadcom Common Firmware Environment (CFE) 21 *
22 * 22 * CFE's global error code list is here.
23 * Error codes File: cfe_error.h 23 *
24 * 24 * Author: Mitch Lichtenberg
25 * CFE's global error code list is here. 25 */
26 *
27 * Author: Mitch Lichtenberg
28 *
29 ********************************************************************* */
30
31 26
32#define CFE_OK 0 27#define CFE_OK 0
33#define CFE_ERR -1 /* generic error */ 28#define CFE_ERR -1 /* generic error */
diff --git a/include/asm-mips/i8253.h b/include/asm-mips/i8253.h
index affb32ce4af9..5dabc870b322 100644
--- a/include/asm-mips/i8253.h
+++ b/include/asm-mips/i8253.h
@@ -5,25 +5,16 @@
5#ifndef __ASM_I8253_H 5#ifndef __ASM_I8253_H
6#define __ASM_I8253_H 6#define __ASM_I8253_H
7 7
8#include <linux/spinlock.h>
9
8/* i8253A PIT registers */ 10/* i8253A PIT registers */
9#define PIT_MODE 0x43 11#define PIT_MODE 0x43
10#define PIT_CH0 0x40 12#define PIT_CH0 0x40
11#define PIT_CH2 0x42 13#define PIT_CH2 0x42
12 14
13/* i8259A PIC registers */ 15#define PIT_TICK_RATE 1193182UL
14#define PIC_MASTER_CMD 0x20
15#define PIC_MASTER_IMR 0x21
16#define PIC_MASTER_ISR PIC_MASTER_CMD
17#define PIC_MASTER_POLL PIC_MASTER_ISR
18#define PIC_MASTER_OCW3 PIC_MASTER_ISR
19#define PIC_SLAVE_CMD 0xa0
20#define PIC_SLAVE_IMR 0xa1
21 16
22/* i8259A PIC related value */ 17extern spinlock_t i8253_lock;
23#define PIC_CASCADE_IR 2
24#define MASTER_ICW4_DEFAULT 0x01
25#define SLAVE_ICW4_DEFAULT 0x01
26#define PIC_ICW4_AEOI 2
27 18
28extern void setup_pit_timer(void); 19extern void setup_pit_timer(void);
29 20
diff --git a/include/asm-mips/ip32/ip32_ints.h b/include/asm-mips/ip32/ip32_ints.h
index 042f821899a8..85bc5302bce0 100644
--- a/include/asm-mips/ip32/ip32_ints.h
+++ b/include/asm-mips/ip32/ip32_ints.h
@@ -22,10 +22,12 @@ enum ip32_irq_no {
22 * CPU interrupts are 0 ... 7 22 * CPU interrupts are 0 ... 7
23 */ 23 */
24 24
25 CRIME_IRQ_BASE = MIPS_CPU_IRQ_BASE + 8,
26
25 /* 27 /*
26 * MACE 28 * MACE
27 */ 29 */
28 MACE_VID_IN1_IRQ = MIPS_CPU_IRQ_BASE + 8, 30 MACE_VID_IN1_IRQ = CRIME_IRQ_BASE,
29 MACE_VID_IN2_IRQ, 31 MACE_VID_IN2_IRQ,
30 MACE_VID_OUT_IRQ, 32 MACE_VID_OUT_IRQ,
31 MACE_ETHERNET_IRQ, 33 MACE_ETHERNET_IRQ,
diff --git a/include/asm-mips/jmr3927/jmr3927.h b/include/asm-mips/jmr3927/jmr3927.h
index b2dc35f56181..81602c8047eb 100644
--- a/include/asm-mips/jmr3927/jmr3927.h
+++ b/include/asm-mips/jmr3927/jmr3927.h
@@ -132,9 +132,7 @@
132#define JMR3927_IRQ_IRC_DMA (JMR3927_IRQ_IRC + TX3927_IR_DMA) 132#define JMR3927_IRQ_IRC_DMA (JMR3927_IRQ_IRC + TX3927_IR_DMA)
133#define JMR3927_IRQ_IRC_PIO (JMR3927_IRQ_IRC + TX3927_IR_PIO) 133#define JMR3927_IRQ_IRC_PIO (JMR3927_IRQ_IRC + TX3927_IR_PIO)
134#define JMR3927_IRQ_IRC_PCI (JMR3927_IRQ_IRC + TX3927_IR_PCI) 134#define JMR3927_IRQ_IRC_PCI (JMR3927_IRQ_IRC + TX3927_IR_PCI)
135#define JMR3927_IRQ_IRC_TMR0 (JMR3927_IRQ_IRC + TX3927_IR_TMR0) 135#define JMR3927_IRQ_IRC_TMR(ch) (JMR3927_IRQ_IRC + TX3927_IR_TMR(ch))
136#define JMR3927_IRQ_IRC_TMR1 (JMR3927_IRQ_IRC + TX3927_IR_TMR1)
137#define JMR3927_IRQ_IRC_TMR2 (JMR3927_IRQ_IRC + TX3927_IR_TMR2)
138#define JMR3927_IRQ_IOC_PCIA (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIA) 136#define JMR3927_IRQ_IOC_PCIA (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIA)
139#define JMR3927_IRQ_IOC_PCIB (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIB) 137#define JMR3927_IRQ_IOC_PCIB (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIB)
140#define JMR3927_IRQ_IOC_PCIC (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIC) 138#define JMR3927_IRQ_IOC_PCIC (JMR3927_IRQ_IOC + JMR3927_IOC_INTB_PCIC)
@@ -148,17 +146,12 @@
148#define JMR3927_IRQ_IOCINT JMR3927_IRQ_IRC_INT1 146#define JMR3927_IRQ_IOCINT JMR3927_IRQ_IRC_INT1
149/* TC35815 100M Ether (JMR-TX3912:JPW4:2-3 Short) */ 147/* TC35815 100M Ether (JMR-TX3912:JPW4:2-3 Short) */
150#define JMR3927_IRQ_ETHER0 JMR3927_IRQ_IRC_INT3 148#define JMR3927_IRQ_ETHER0 JMR3927_IRQ_IRC_INT3
151/* Clock Tick (10ms) */
152#define JMR3927_IRQ_TICK JMR3927_IRQ_IRC_TMR0
153 149
154/* Clocks */ 150/* Clocks */
155#define JMR3927_CORECLK 132710400 /* 132.7MHz */ 151#define JMR3927_CORECLK 132710400 /* 132.7MHz */
156#define JMR3927_GBUSCLK (JMR3927_CORECLK / 2) /* 66.35MHz */ 152#define JMR3927_GBUSCLK (JMR3927_CORECLK / 2) /* 66.35MHz */
157#define JMR3927_IMCLK (JMR3927_CORECLK / 4) /* 33.17MHz */ 153#define JMR3927_IMCLK (JMR3927_CORECLK / 4) /* 33.17MHz */
158 154
159#define jmr3927_tmrptr tx3927_tmrptr(0) /* TMR0 */
160
161
162/* 155/*
163 * TX3927 Pin Configuration: 156 * TX3927 Pin Configuration:
164 * 157 *
diff --git a/include/asm-mips/jmr3927/tx3927.h b/include/asm-mips/jmr3927/tx3927.h
index 211bcf47fffb..338f99882a39 100644
--- a/include/asm-mips/jmr3927/tx3927.h
+++ b/include/asm-mips/jmr3927/tx3927.h
@@ -222,9 +222,7 @@ struct tx3927_ccfg_reg {
222#define TX3927_IR_DMA 8 222#define TX3927_IR_DMA 8
223#define TX3927_IR_PIO 9 223#define TX3927_IR_PIO 9
224#define TX3927_IR_PCI 10 224#define TX3927_IR_PCI 10
225#define TX3927_IR_TMR0 13 225#define TX3927_IR_TMR(ch) (13 + (ch))
226#define TX3927_IR_TMR1 14
227#define TX3927_IR_TMR2 15
228#define TX3927_NUM_IR 16 226#define TX3927_NUM_IR 16
229 227
230/* 228/*
diff --git a/include/asm-mips/jmr3927/txx927.h b/include/asm-mips/jmr3927/txx927.h
index 58a8ff6be815..0474fe8dac3f 100644
--- a/include/asm-mips/jmr3927/txx927.h
+++ b/include/asm-mips/jmr3927/txx927.h
@@ -10,22 +10,6 @@
10#ifndef __ASM_TXX927_H 10#ifndef __ASM_TXX927_H
11#define __ASM_TXX927_H 11#define __ASM_TXX927_H
12 12
13struct txx927_tmr_reg {
14 volatile unsigned long tcr;
15 volatile unsigned long tisr;
16 volatile unsigned long cpra;
17 volatile unsigned long cprb;
18 volatile unsigned long itmr;
19 volatile unsigned long unused0[3];
20 volatile unsigned long ccdr;
21 volatile unsigned long unused1[3];
22 volatile unsigned long pgmr;
23 volatile unsigned long unused2[3];
24 volatile unsigned long wtmr;
25 volatile unsigned long unused3[43];
26 volatile unsigned long trr;
27};
28
29struct txx927_sio_reg { 13struct txx927_sio_reg {
30 volatile unsigned long lcr; 14 volatile unsigned long lcr;
31 volatile unsigned long dicr; 15 volatile unsigned long dicr;
@@ -51,27 +35,6 @@ struct txx927_pio_reg {
51}; 35};
52 36
53/* 37/*
54 * TMR
55 */
56/* TMTCR : Timer Control */
57#define TXx927_TMTCR_TCE 0x00000080
58#define TXx927_TMTCR_CCDE 0x00000040
59#define TXx927_TMTCR_CRE 0x00000020
60#define TXx927_TMTCR_ECES 0x00000008
61#define TXx927_TMTCR_CCS 0x00000004
62#define TXx927_TMTCR_TMODE_MASK 0x00000003
63#define TXx927_TMTCR_TMODE_ITVL 0x00000000
64
65/* TMTISR : Timer Int. Status */
66#define TXx927_TMTISR_TPIBS 0x00000004
67#define TXx927_TMTISR_TPIAS 0x00000002
68#define TXx927_TMTISR_TIIS 0x00000001
69
70/* TMTITMR : Interval Timer Mode */
71#define TXx927_TMTITMR_TIIE 0x00008000
72#define TXx927_TMTITMR_TZCE 0x00000001
73
74/*
75 * SIO 38 * SIO
76 */ 39 */
77/* SILCR : Line Control */ 40/* SILCR : Line Control */
diff --git a/include/asm-mips/lasat/lasatint.h b/include/asm-mips/lasat/lasatint.h
index 581dc45685a2..e0d2458b43d0 100644
--- a/include/asm-mips/lasat/lasatint.h
+++ b/include/asm-mips/lasat/lasatint.h
@@ -1,11 +1,6 @@
1#ifndef __ASM_LASAT_LASATINT_H 1#ifndef __ASM_LASAT_LASATINT_H
2#define __ASM_LASAT_LASATINT_H 2#define __ASM_LASAT_LASATINT_H
3 3
4#include <linux/irq.h>
5
6#define LASATINT_BASE MIPS_CPU_IRQ_BASE
7#define LASATINT_END (LASATINT_BASE + 16)
8
9/* lasat 100 */ 4/* lasat 100 */
10#define LASAT_INT_STATUS_REG_100 (KSEG1ADDR(0x1c880000)) 5#define LASAT_INT_STATUS_REG_100 (KSEG1ADDR(0x1c880000))
11#define LASAT_INT_MASK_REG_100 (KSEG1ADDR(0x1c890000)) 6#define LASAT_INT_MASK_REG_100 (KSEG1ADDR(0x1c890000))
diff --git a/include/asm-mips/mach-au1x00/au1000.h b/include/asm-mips/mach-au1x00/au1000.h
index 3bdce9126f16..cb18af989645 100644
--- a/include/asm-mips/mach-au1x00/au1000.h
+++ b/include/asm-mips/mach-au1x00/au1000.h
@@ -526,7 +526,7 @@ extern struct au1xxx_irqmap au1xxx_irq_map[];
526/* Au1000 */ 526/* Au1000 */
527#ifdef CONFIG_SOC_AU1000 527#ifdef CONFIG_SOC_AU1000
528enum soc_au1000_ints { 528enum soc_au1000_ints {
529 AU1000_FIRST_INT = MIPS_CPU_IRQ_BASE, 529 AU1000_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
530 AU1000_UART0_INT = AU1000_FIRST_INT, 530 AU1000_UART0_INT = AU1000_FIRST_INT,
531 AU1000_UART1_INT, /* au1000 */ 531 AU1000_UART1_INT, /* au1000 */
532 AU1000_UART2_INT, /* au1000 */ 532 AU1000_UART2_INT, /* au1000 */
@@ -605,7 +605,7 @@ enum soc_au1000_ints {
605/* Au1500 */ 605/* Au1500 */
606#ifdef CONFIG_SOC_AU1500 606#ifdef CONFIG_SOC_AU1500
607enum soc_au1500_ints { 607enum soc_au1500_ints {
608 AU1500_FIRST_INT = MIPS_CPU_IRQ_BASE, 608 AU1500_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
609 AU1500_UART0_INT = AU1500_FIRST_INT, 609 AU1500_UART0_INT = AU1500_FIRST_INT,
610 AU1000_PCI_INTA, /* au1500 */ 610 AU1000_PCI_INTA, /* au1500 */
611 AU1000_PCI_INTB, /* au1500 */ 611 AU1000_PCI_INTB, /* au1500 */
@@ -686,7 +686,7 @@ enum soc_au1500_ints {
686/* Au1100 */ 686/* Au1100 */
687#ifdef CONFIG_SOC_AU1100 687#ifdef CONFIG_SOC_AU1100
688enum soc_au1100_ints { 688enum soc_au1100_ints {
689 AU1100_FIRST_INT = MIPS_CPU_IRQ_BASE, 689 AU1100_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
690 AU1100_UART0_INT, 690 AU1100_UART0_INT,
691 AU1100_UART1_INT, 691 AU1100_UART1_INT,
692 AU1100_SD_INT, 692 AU1100_SD_INT,
@@ -761,7 +761,7 @@ enum soc_au1100_ints {
761 761
762#ifdef CONFIG_SOC_AU1550 762#ifdef CONFIG_SOC_AU1550
763enum soc_au1550_ints { 763enum soc_au1550_ints {
764 AU1550_FIRST_INT = MIPS_CPU_IRQ_BASE, 764 AU1550_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
765 AU1550_UART0_INT = AU1550_FIRST_INT, 765 AU1550_UART0_INT = AU1550_FIRST_INT,
766 AU1550_PCI_INTA, 766 AU1550_PCI_INTA,
767 AU1550_PCI_INTB, 767 AU1550_PCI_INTB,
@@ -851,7 +851,7 @@ enum soc_au1550_ints {
851 851
852#ifdef CONFIG_SOC_AU1200 852#ifdef CONFIG_SOC_AU1200
853enum soc_au1200_ints { 853enum soc_au1200_ints {
854 AU1200_FIRST_INT = MIPS_CPU_IRQ_BASE, 854 AU1200_FIRST_INT = MIPS_CPU_IRQ_BASE + 8,
855 AU1200_UART0_INT = AU1200_FIRST_INT, 855 AU1200_UART0_INT = AU1200_FIRST_INT,
856 AU1200_SWT_INT, 856 AU1200_SWT_INT,
857 AU1200_SD_INT, 857 AU1200_SD_INT,
@@ -948,11 +948,12 @@ enum soc_au1200_ints {
948 948
949#endif /* CONFIG_SOC_AU1200 */ 949#endif /* CONFIG_SOC_AU1200 */
950 950
951#define AU1000_INTC0_INT_BASE (MIPS_CPU_IRQ_BASE + 0) 951#define AU1000_INTC0_INT_BASE (MIPS_CPU_IRQ_BASE + 8)
952#define AU1000_INTC0_INT_LAST (MIPS_CPU_IRQ_BASE + 31) 952#define AU1000_INTC0_INT_LAST (AU1000_INTC0_INT_BASE + 31)
953#define AU1000_INTC1_INT_BASE (MIPS_CPU_IRQ_BASE + 32) 953#define AU1000_INTC1_INT_BASE (AU1000_INTC0_INT_BASE + 32)
954#define AU1000_INTC1_INT_LAST (MIPS_CPU_IRQ_BASE + 63) 954#define AU1000_INTC1_INT_LAST (AU1000_INTC1_INT_BASE + 31)
955#define AU1000_MAX_INTR (MIPS_CPU_IRQ_BASE + 63) 955
956#define AU1000_MAX_INTR AU1000_INTC1_INT_LAST
956#define INTX 0xFF /* not valid */ 957#define INTX 0xFF /* not valid */
957 958
958/* Programmable Counters 0 and 1 */ 959/* Programmable Counters 0 and 1 */
@@ -1679,10 +1680,11 @@ enum soc_au1200_ints {
1679#define Au1500_PCI_MEM_START 0x440000000ULL 1680#define Au1500_PCI_MEM_START 0x440000000ULL
1680#define Au1500_PCI_MEM_END 0x44FFFFFFFULL 1681#define Au1500_PCI_MEM_END 0x44FFFFFFFULL
1681 1682
1682#define PCI_IO_START (Au1500_PCI_IO_START + 0x1000) 1683#define PCI_IO_START 0x00001000
1683#define PCI_IO_END (Au1500_PCI_IO_END) 1684#define PCI_IO_END 0x000FFFFF
1684#define PCI_MEM_START (Au1500_PCI_MEM_START) 1685#define PCI_MEM_START 0x40000000
1685#define PCI_MEM_END (Au1500_PCI_MEM_END) 1686#define PCI_MEM_END 0x4FFFFFFF
1687
1686#define PCI_FIRST_DEVFN (0<<3) 1688#define PCI_FIRST_DEVFN (0<<3)
1687#define PCI_LAST_DEVFN (19<<3) 1689#define PCI_LAST_DEVFN (19<<3)
1688 1690
diff --git a/include/asm-mips/mach-au1x00/au1100_mmc.h b/include/asm-mips/mach-au1x00/au1100_mmc.h
index 9e7d1ba21b55..9e0028f60a43 100644
--- a/include/asm-mips/mach-au1x00/au1100_mmc.h
+++ b/include/asm-mips/mach-au1x00/au1100_mmc.h
@@ -41,8 +41,11 @@
41 41
42#define NUM_AU1100_MMC_CONTROLLERS 2 42#define NUM_AU1100_MMC_CONTROLLERS 2
43 43
44 44#if defined(CONFIG_SOC_AU1100)
45#define AU1100_SD_IRQ 2 45#define AU1100_SD_IRQ AU1100_SD_INT
46#elif defined(CONFIG_SOC_AU1200)
47#define AU1100_SD_IRQ AU1200_SD_INT
48#endif
46 49
47 50
48#define SD0_BASE 0xB0600000 51#define SD0_BASE 0xB0600000
diff --git a/include/asm-mips/mach-au1x00/au1xxx_ide.h b/include/asm-mips/mach-au1x00/au1xxx_ide.h
index aef0edbfe4c6..e4fe26c160ba 100644
--- a/include/asm-mips/mach-au1x00/au1xxx_ide.h
+++ b/include/asm-mips/mach-au1x00/au1xxx_ide.h
@@ -74,7 +74,6 @@ typedef struct
74 struct dbdma_cmd *dma_table_cpu; 74 struct dbdma_cmd *dma_table_cpu;
75 dma_addr_t dma_table_dma; 75 dma_addr_t dma_table_dma;
76#endif 76#endif
77 struct device *dev;
78 int irq; 77 int irq;
79 u32 regbase; 78 u32 regbase;
80#ifdef CONFIG_PM 79#ifdef CONFIG_PM
diff --git a/include/asm-mips/mach-au1x00/timex.h b/include/asm-mips/mach-au1x00/timex.h
deleted file mode 100644
index e3ada66cb636..000000000000
--- a/include/asm-mips/mach-au1x00/timex.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_AU1X00_TIMEX_H
9#define __ASM_MACH_AU1X00_TIMEX_H
10
11#define CLOCK_TICK_RATE ((HZ * 100000UL) / 2)
12
13#endif /* __ASM_MACH_AU1X00_TIMEX_H */
diff --git a/include/asm-mips/mach-cobalt/cobalt.h b/include/asm-mips/mach-cobalt/cobalt.h
index a79e7caf3a86..5b9fce73f11d 100644
--- a/include/asm-mips/mach-cobalt/cobalt.h
+++ b/include/asm-mips/mach-cobalt/cobalt.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Lowlevel hardware stuff for the MIPS based Cobalt microservers. 2 * The Cobalt board ID information.
3 * 3 *
4 * This file is subject to the terms and conditions of the GNU General Public 4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
@@ -12,9 +12,6 @@
12#ifndef __ASM_COBALT_H 12#ifndef __ASM_COBALT_H
13#define __ASM_COBALT_H 13#define __ASM_COBALT_H
14 14
15/*
16 * The Cobalt board ID information.
17 */
18extern int cobalt_board_id; 15extern int cobalt_board_id;
19 16
20#define COBALT_BRD_ID_QUBE1 0x3 17#define COBALT_BRD_ID_QUBE1 0x3
@@ -22,14 +19,4 @@ extern int cobalt_board_id;
22#define COBALT_BRD_ID_QUBE2 0x5 19#define COBALT_BRD_ID_QUBE2 0x5
23#define COBALT_BRD_ID_RAQ2 0x6 20#define COBALT_BRD_ID_RAQ2 0x6
24 21
25#define COBALT_KEY_PORT ((~*(volatile unsigned int *) CKSEG1ADDR(0x1d000000) >> 24) & COBALT_KEY_MASK)
26# define COBALT_KEY_CLEAR (1 << 1)
27# define COBALT_KEY_LEFT (1 << 2)
28# define COBALT_KEY_UP (1 << 3)
29# define COBALT_KEY_DOWN (1 << 4)
30# define COBALT_KEY_RIGHT (1 << 5)
31# define COBALT_KEY_ENTER (1 << 6)
32# define COBALT_KEY_SELECT (1 << 7)
33# define COBALT_KEY_MASK 0xfe
34
35#endif /* __ASM_COBALT_H */ 22#endif /* __ASM_COBALT_H */
diff --git a/include/asm-mips/mach-cobalt/irq.h b/include/asm-mips/mach-cobalt/irq.h
index 179d0e850b59..57c8c9ac5851 100644
--- a/include/asm-mips/mach-cobalt/irq.h
+++ b/include/asm-mips/mach-cobalt/irq.h
@@ -35,7 +35,7 @@
35 * 4 - ethernet 35 * 4 - ethernet
36 * 5 - 16550 UART 36 * 5 - 16550 UART
37 * 6 - cascade i8259 37 * 6 - cascade i8259
38 * 7 - CP0 counter (unused) 38 * 7 - CP0 counter
39 */ 39 */
40#define MIPS_CPU_IRQ_BASE 16 40#define MIPS_CPU_IRQ_BASE 16
41 41
@@ -48,7 +48,6 @@
48#define SCSI_IRQ (MIPS_CPU_IRQ_BASE + 5) 48#define SCSI_IRQ (MIPS_CPU_IRQ_BASE + 5)
49#define I8259_CASCADE_IRQ (MIPS_CPU_IRQ_BASE + 6) 49#define I8259_CASCADE_IRQ (MIPS_CPU_IRQ_BASE + 6)
50 50
51
52#define GT641XX_IRQ_BASE 24 51#define GT641XX_IRQ_BASE 24
53 52
54#include <asm/irq_gt641xx.h> 53#include <asm/irq_gt641xx.h>
diff --git a/include/asm-mips/mach-generic/timex.h b/include/asm-mips/mach-generic/timex.h
deleted file mode 100644
index 48b4cfaa0d50..000000000000
--- a/include/asm-mips/mach-generic/timex.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2005 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_GENERIC_TIMEX_H
9#define __ASM_MACH_GENERIC_TIMEX_H
10
11#define CLOCK_TICK_RATE 500000
12
13#endif /* __ASM_MACH_GENERIC_TIMEX_H */
diff --git a/include/asm-mips/mach-ip28/cpu-feature-overrides.h b/include/asm-mips/mach-ip28/cpu-feature-overrides.h
new file mode 100644
index 000000000000..9a53b326f848
--- /dev/null
+++ b/include/asm-mips/mach-ip28/cpu-feature-overrides.h
@@ -0,0 +1,50 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 Ralf Baechle
7 * 6/2004 pf
8 */
9#ifndef __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H
10#define __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H
11
12/*
13 * IP28 only comes with R10000 family processors all using the same config
14 */
15#define cpu_has_watch 1
16#define cpu_has_mips16 0
17#define cpu_has_divec 0
18#define cpu_has_vce 0
19#define cpu_has_cache_cdex_p 0
20#define cpu_has_cache_cdex_s 0
21#define cpu_has_prefetch 1
22#define cpu_has_mcheck 0
23#define cpu_has_ejtag 0
24
25#define cpu_has_llsc 1
26#define cpu_has_vtag_icache 0
27#define cpu_has_dc_aliases 0 /* see probe_pcache() */
28#define cpu_has_ic_fills_f_dc 0
29#define cpu_has_dsp 0
30#define cpu_icache_snoops_remote_store 1
31#define cpu_has_mipsmt 0
32#define cpu_has_userlocal 0
33
34#define cpu_has_nofpuex 0
35#define cpu_has_64bits 1
36
37#define cpu_has_4kex 1
38#define cpu_has_4k_cache 1
39
40#define cpu_has_inclusive_pcaches 1
41
42#define cpu_dcache_line_size() 32
43#define cpu_icache_line_size() 64
44
45#define cpu_has_mips32r1 0
46#define cpu_has_mips32r2 0
47#define cpu_has_mips64r1 0
48#define cpu_has_mips64r2 0
49
50#endif /* __ASM_MACH_IP28_CPU_FEATURE_OVERRIDES_H */
diff --git a/include/asm-mips/mach-ip28/ds1286.h b/include/asm-mips/mach-ip28/ds1286.h
new file mode 100644
index 000000000000..471bb9a33e0f
--- /dev/null
+++ b/include/asm-mips/mach-ip28/ds1286.h
@@ -0,0 +1,4 @@
1#ifndef __ASM_MACH_IP28_DS1286_H
2#define __ASM_MACH_IP28_DS1286_H
3#include <asm/mach-ip22/ds1286.h>
4#endif /* __ASM_MACH_IP28_DS1286_H */
diff --git a/include/asm-mips/mach-ip28/spaces.h b/include/asm-mips/mach-ip28/spaces.h
new file mode 100644
index 000000000000..05aabb27e5e7
--- /dev/null
+++ b/include/asm-mips/mach-ip28/spaces.h
@@ -0,0 +1,22 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994 - 1999, 2000, 03, 04 Ralf Baechle
7 * Copyright (C) 2000, 2002 Maciej W. Rozycki
8 * Copyright (C) 1990, 1999, 2000 Silicon Graphics, Inc.
9 * 2004 pf
10 */
11#ifndef _ASM_MACH_IP28_SPACES_H
12#define _ASM_MACH_IP28_SPACES_H
13
14#define CAC_BASE 0xa800000000000000
15
16#define HIGHMEM_START (~0UL)
17
18#define PHYS_OFFSET _AC(0x20000000, UL)
19
20#include <asm/mach-generic/spaces.h>
21
22#endif /* _ASM_MACH_IP28_SPACES_H */
diff --git a/include/asm-mips/mach-qemu/war.h b/include/asm-mips/mach-ip28/war.h
index 0eaf0c548a47..a1baafab486a 100644
--- a/include/asm-mips/mach-qemu/war.h
+++ b/include/asm-mips/mach-ip28/war.h
@@ -5,8 +5,8 @@
5 * 5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org> 6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf@linux-mips.org>
7 */ 7 */
8#ifndef __ASM_MIPS_MACH_QEMU_WAR_H 8#ifndef __ASM_MIPS_MACH_IP28_WAR_H
9#define __ASM_MIPS_MACH_QEMU_WAR_H 9#define __ASM_MIPS_MACH_IP28_WAR_H
10 10
11#define R4600_V1_INDEX_ICACHEOP_WAR 0 11#define R4600_V1_INDEX_ICACHEOP_WAR 0
12#define R4600_V1_HIT_CACHEOP_WAR 0 12#define R4600_V1_HIT_CACHEOP_WAR 0
@@ -19,7 +19,7 @@
19#define TX49XX_ICACHE_INDEX_INV_WAR 0 19#define TX49XX_ICACHE_INDEX_INV_WAR 0
20#define RM9000_CDEX_SMP_WAR 0 20#define RM9000_CDEX_SMP_WAR 0
21#define ICACHE_REFILLS_WORKAROUND_WAR 0 21#define ICACHE_REFILLS_WORKAROUND_WAR 0
22#define R10000_LLSC_WAR 0 22#define R10000_LLSC_WAR 1
23#define MIPS34K_MISSED_ITLB_WAR 0 23#define MIPS34K_MISSED_ITLB_WAR 0
24 24
25#endif /* __ASM_MIPS_MACH_QEMU_WAR_H */ 25#endif /* __ASM_MIPS_MACH_IP28_WAR_H */
diff --git a/include/asm-mips/mach-jazz/timex.h b/include/asm-mips/mach-jazz/timex.h
deleted file mode 100644
index 93affa33dfa8..000000000000
--- a/include/asm-mips/mach-jazz/timex.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_JAZZ_TIMEX_H
9#define __ASM_MACH_JAZZ_TIMEX_H
10
11/*
12 * Jazz is still using the R4030 100Hz counter
13 */
14#define CLOCK_TICK_RATE 100
15
16#endif /* __ASM_MACH_JAZZ_TIMEX_H */
diff --git a/include/asm-mips/mach-lasat/irq.h b/include/asm-mips/mach-lasat/irq.h
new file mode 100644
index 000000000000..da75f89f3723
--- /dev/null
+++ b/include/asm-mips/mach-lasat/irq.h
@@ -0,0 +1,13 @@
1#ifndef _ASM_MACH_LASAT_IRQ_H
2#define _ASM_MACH_LASAT_IRQ_H
3
4#define LASAT_CASCADE_IRQ (MIPS_CPU_IRQ_BASE + 0)
5
6#define LASAT_IRQ_BASE 8
7#define LASAT_IRQ_END 23
8
9#define NR_IRQS 24
10
11#include_next <irq.h>
12
13#endif /* _ASM_MACH_LASAT_IRQ_H */
diff --git a/include/asm-mips/mach-qemu/cpu-feature-overrides.h b/include/asm-mips/mach-qemu/cpu-feature-overrides.h
deleted file mode 100644
index d2daaed235d5..000000000000
--- a/include/asm-mips/mach-qemu/cpu-feature-overrides.h
+++ /dev/null
@@ -1,32 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 07 Ralf Baechle
7 */
8#ifndef __ASM_MACH_QEMU_CPU_FEATURE_OVERRIDES_H
9#define __ASM_MACH_QEMU_CPU_FEATURE_OVERRIDES_H
10
11/*
12 * QEMU only comes with a hazard-free MIPS32 processor, so things are easy.
13 */
14#define cpu_has_mips16 0
15#define cpu_has_divec 0
16#define cpu_has_cache_cdex_p 0
17#define cpu_has_prefetch 0
18#define cpu_has_mcheck 0
19#define cpu_has_ejtag 0
20
21#define cpu_has_llsc 1
22#define cpu_has_vtag_icache 0
23#define cpu_has_dc_aliases 0
24#define cpu_has_ic_fills_f_dc 0
25
26#define cpu_has_dsp 0
27#define cpu_has_mipsmt 0
28
29#define cpu_has_nofpuex 0
30#define cpu_has_64bits 0
31
32#endif /* __ASM_MACH_QEMU_CPU_FEATURE_OVERRIDES_H */
diff --git a/include/asm-mips/mach-qemu/timex.h b/include/asm-mips/mach-qemu/timex.h
deleted file mode 100644
index cd543693fb0a..000000000000
--- a/include/asm-mips/mach-qemu/timex.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2005 Daniel Jacobowitz
7 */
8#ifndef __ASM_MACH_QEMU_TIMEX_H
9#define __ASM_MACH_QEMU_TIMEX_H
10
11/*
12 * We use a simulated i8254 PIC...
13 */
14#define CLOCK_TICK_RATE 1193182
15
16#endif /* __ASM_MACH_QEMU_TIMEX_H */
diff --git a/include/asm-mips/mach-rm/timex.h b/include/asm-mips/mach-rm/timex.h
deleted file mode 100644
index 11ff6cb0f214..000000000000
--- a/include/asm-mips/mach-rm/timex.h
+++ /dev/null
@@ -1,13 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2005 by Ralf Baechle
7 */
8#ifndef __ASM_MACH_RM200_TIMEX_H
9#define __ASM_MACH_RM200_TIMEX_H
10
11#define CLOCK_TICK_RATE 1193182
12
13#endif /* __ASM_MACH_RM200_TIMEX_H */
diff --git a/include/asm-mips/mips-boards/generic.h b/include/asm-mips/mips-boards/generic.h
index d58977483534..1c39d339521e 100644
--- a/include/asm-mips/mips-boards/generic.h
+++ b/include/asm-mips/mips-boards/generic.h
@@ -97,10 +97,16 @@ extern int mips_revision_corid;
97 97
98extern int mips_revision_sconid; 98extern int mips_revision_sconid;
99 99
100extern void mips_reboot_setup(void);
101
100#ifdef CONFIG_PCI 102#ifdef CONFIG_PCI
101extern void mips_pcibios_init(void); 103extern void mips_pcibios_init(void);
102#else 104#else
103#define mips_pcibios_init() do { } while (0) 105#define mips_pcibios_init() do { } while (0)
104#endif 106#endif
105 107
108#ifdef CONFIG_KGDB
109extern void kgdb_config(void);
110#endif
111
106#endif /* __ASM_MIPS_BOARDS_GENERIC_H */ 112#endif /* __ASM_MIPS_BOARDS_GENERIC_H */
diff --git a/include/asm-mips/mipsprom.h b/include/asm-mips/mipsprom.h
index ce7cff7f1e8e..146d41b67adc 100644
--- a/include/asm-mips/mipsprom.h
+++ b/include/asm-mips/mipsprom.h
@@ -71,4 +71,6 @@
71#define PROM_NV_GET 53 /* XXX */ 71#define PROM_NV_GET 53 /* XXX */
72#define PROM_NV_SET 54 /* XXX */ 72#define PROM_NV_SET 54 /* XXX */
73 73
74extern char *prom_getenv(char *);
75
74#endif /* __ASM_MIPS_PROM_H */ 76#endif /* __ASM_MIPS_PROM_H */
diff --git a/include/asm-mips/pmc-sierra/msp71xx/msp_regs.h b/include/asm-mips/pmc-sierra/msp71xx/msp_regs.h
index 0b56f55206c6..603eb737b4a8 100644
--- a/include/asm-mips/pmc-sierra/msp71xx/msp_regs.h
+++ b/include/asm-mips/pmc-sierra/msp71xx/msp_regs.h
@@ -585,11 +585,7 @@
585 * UART defines * 585 * UART defines *
586 *************************************************************************** 586 ***************************************************************************
587 */ 587 */
588#ifndef CONFIG_MSP_FPGA
589#define MSP_BASE_BAUD 25000000 588#define MSP_BASE_BAUD 25000000
590#else
591#define MSP_BASE_BAUD 6000000
592#endif
593#define MSP_UART_REG_LEN 0x20 589#define MSP_UART_REG_LEN 0x20
594 590
595/* 591/*
diff --git a/include/asm-mips/r4kcache.h b/include/asm-mips/r4kcache.h
index 2b8466ffd3ca..4c140db36786 100644
--- a/include/asm-mips/r4kcache.h
+++ b/include/asm-mips/r4kcache.h
@@ -403,6 +403,13 @@ __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 64)
403__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64) 403__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
404__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128) 404__BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 128)
405 405
406__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 16)
407__BUILD_BLAST_CACHE(inv_d, dcache, Index_Writeback_Inv_D, Hit_Invalidate_D, 32)
408__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 16)
409__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 32)
410__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 64)
411__BUILD_BLAST_CACHE(inv_s, scache, Index_Writeback_Inv_SD, Hit_Invalidate_SD, 128)
412
406/* build blast_xxx_range, protected_blast_xxx_range */ 413/* build blast_xxx_range, protected_blast_xxx_range */
407#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \ 414#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop, prot) \
408static inline void prot##blast_##pfx##cache##_range(unsigned long start, \ 415static inline void prot##blast_##pfx##cache##_range(unsigned long start, \
diff --git a/include/asm-mips/sgi/ioc.h b/include/asm-mips/sgi/ioc.h
index f3e3dc9bb732..343ed15f8dc4 100644
--- a/include/asm-mips/sgi/ioc.h
+++ b/include/asm-mips/sgi/ioc.h
@@ -138,8 +138,8 @@ struct sgioc_regs {
138 u8 _sysid[3]; 138 u8 _sysid[3];
139 volatile u8 sysid; 139 volatile u8 sysid;
140#define SGIOC_SYSID_FULLHOUSE 0x01 140#define SGIOC_SYSID_FULLHOUSE 0x01
141#define SGIOC_SYSID_BOARDREV(x) ((x & 0xe0) > 5) 141#define SGIOC_SYSID_BOARDREV(x) (((x) & 0x1e) >> 1)
142#define SGIOC_SYSID_CHIPREV(x) ((x & 0x1e) > 1) 142#define SGIOC_SYSID_CHIPREV(x) (((x) & 0xe0) >> 5)
143 u32 _unused2; 143 u32 _unused2;
144 u8 _read[3]; 144 u8 _read[3];
145 volatile u8 read; 145 volatile u8 read;
diff --git a/include/asm-mips/sibyte/board.h b/include/asm-mips/sibyte/board.h
index da198a1c8c81..25372ae0e814 100644
--- a/include/asm-mips/sibyte/board.h
+++ b/include/asm-mips/sibyte/board.h
@@ -19,10 +19,8 @@
19#ifndef _SIBYTE_BOARD_H 19#ifndef _SIBYTE_BOARD_H
20#define _SIBYTE_BOARD_H 20#define _SIBYTE_BOARD_H
21 21
22#if defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_PTSWARM) || \ 22#if defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_CRHONE) || \
23 defined(CONFIG_SIBYTE_PT1120) || defined(CONFIG_SIBYTE_PT1125) || \ 23 defined(CONFIG_SIBYTE_CRHINE) || defined(CONFIG_SIBYTE_LITTLESUR)
24 defined(CONFIG_SIBYTE_CRHONE) || defined(CONFIG_SIBYTE_CRHINE) || \
25 defined(CONFIG_SIBYTE_LITTLESUR)
26#include <asm/sibyte/swarm.h> 24#include <asm/sibyte/swarm.h>
27#endif 25#endif
28 26
diff --git a/include/asm-mips/sibyte/sb1250.h b/include/asm-mips/sibyte/sb1250.h
index 0dad844a3b5b..80c1a052662a 100644
--- a/include/asm-mips/sibyte/sb1250.h
+++ b/include/asm-mips/sibyte/sb1250.h
@@ -48,12 +48,10 @@ extern unsigned int zbbus_mhz;
48extern void sb1250_time_init(void); 48extern void sb1250_time_init(void);
49extern void sb1250_mask_irq(int cpu, int irq); 49extern void sb1250_mask_irq(int cpu, int irq);
50extern void sb1250_unmask_irq(int cpu, int irq); 50extern void sb1250_unmask_irq(int cpu, int irq);
51extern void sb1250_smp_finish(void);
52 51
53extern void bcm1480_time_init(void); 52extern void bcm1480_time_init(void);
54extern void bcm1480_mask_irq(int cpu, int irq); 53extern void bcm1480_mask_irq(int cpu, int irq);
55extern void bcm1480_unmask_irq(int cpu, int irq); 54extern void bcm1480_unmask_irq(int cpu, int irq);
56extern void bcm1480_smp_finish(void);
57 55
58#define AT_spin \ 56#define AT_spin \
59 __asm__ __volatile__ ( \ 57 __asm__ __volatile__ ( \
diff --git a/include/asm-mips/sibyte/swarm.h b/include/asm-mips/sibyte/swarm.h
index 540865fa7ec3..114d9d29ca9d 100644
--- a/include/asm-mips/sibyte/swarm.h
+++ b/include/asm-mips/sibyte/swarm.h
@@ -26,24 +26,6 @@
26#define SIBYTE_HAVE_PCMCIA 1 26#define SIBYTE_HAVE_PCMCIA 1
27#define SIBYTE_HAVE_IDE 1 27#define SIBYTE_HAVE_IDE 1
28#endif 28#endif
29#ifdef CONFIG_SIBYTE_PTSWARM
30#define SIBYTE_BOARD_NAME "PTSWARM"
31#define SIBYTE_HAVE_PCMCIA 1
32#define SIBYTE_HAVE_IDE 1
33#define SIBYTE_DEFAULT_CONSOLE "ttyS0,115200"
34#endif
35#ifdef CONFIG_SIBYTE_PT1120
36#define SIBYTE_BOARD_NAME "PT1120"
37#define SIBYTE_HAVE_PCMCIA 1
38#define SIBYTE_HAVE_IDE 1
39#define SIBYTE_DEFAULT_CONSOLE "ttyS0,115200"
40#endif
41#ifdef CONFIG_SIBYTE_PT1125
42#define SIBYTE_BOARD_NAME "PT1125"
43#define SIBYTE_HAVE_PCMCIA 1
44#define SIBYTE_HAVE_IDE 1
45#define SIBYTE_DEFAULT_CONSOLE "ttyS0,115200"
46#endif
47#ifdef CONFIG_SIBYTE_LITTLESUR 29#ifdef CONFIG_SIBYTE_LITTLESUR
48#define SIBYTE_BOARD_NAME "BCM91250C2 (LittleSur)" 30#define SIBYTE_BOARD_NAME "BCM91250C2 (LittleSur)"
49#define SIBYTE_HAVE_PCMCIA 0 31#define SIBYTE_HAVE_PCMCIA 0
diff --git a/include/asm-mips/smp-ops.h b/include/asm-mips/smp-ops.h
new file mode 100644
index 000000000000..b17fdfb5d818
--- /dev/null
+++ b/include/asm-mips/smp-ops.h
@@ -0,0 +1,56 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General
3 * Public License. See the file "COPYING" in the main directory of this
4 * archive for more details.
5 *
6 * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
7 * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
8 * Copyright (C) 2000, 2001, 2002 Ralf Baechle
9 * Copyright (C) 2000, 2001 Broadcom Corporation
10 */
11#ifndef __ASM_SMP_OPS_H
12#define __ASM_SMP_OPS_H
13
14#ifdef CONFIG_SMP
15
16#include <linux/cpumask.h>
17
18struct plat_smp_ops {
19 void (*send_ipi_single)(int cpu, unsigned int action);
20 void (*send_ipi_mask)(cpumask_t mask, unsigned int action);
21 void (*init_secondary)(void);
22 void (*smp_finish)(void);
23 void (*cpus_done)(void);
24 void (*boot_secondary)(int cpu, struct task_struct *idle);
25 void (*smp_setup)(void);
26 void (*prepare_cpus)(unsigned int max_cpus);
27};
28
29extern void register_smp_ops(struct plat_smp_ops *ops);
30
31static inline void plat_smp_setup(void)
32{
33 extern struct plat_smp_ops *mp_ops; /* private */
34
35 mp_ops->smp_setup();
36}
37
38#else /* !CONFIG_SMP */
39
40struct plat_smp_ops;
41
42static inline void plat_smp_setup(void)
43{
44 /* UP, nothing to do ... */
45}
46
47static inline void register_smp_ops(struct plat_smp_ops *ops)
48{
49}
50
51#endif /* !CONFIG_SMP */
52
53extern struct plat_smp_ops up_smp_ops;
54extern struct plat_smp_ops vsmp_smp_ops;
55
56#endif /* __ASM_SMP_OPS_H */
diff --git a/include/asm-mips/smp.h b/include/asm-mips/smp.h
index dc770025a9b0..84fef1aeec0c 100644
--- a/include/asm-mips/smp.h
+++ b/include/asm-mips/smp.h
@@ -11,14 +11,16 @@
11#ifndef __ASM_SMP_H 11#ifndef __ASM_SMP_H
12#define __ASM_SMP_H 12#define __ASM_SMP_H
13 13
14
15#ifdef CONFIG_SMP
16
17#include <linux/bitops.h> 14#include <linux/bitops.h>
18#include <linux/linkage.h> 15#include <linux/linkage.h>
19#include <linux/threads.h> 16#include <linux/threads.h>
20#include <linux/cpumask.h> 17#include <linux/cpumask.h>
18
21#include <asm/atomic.h> 19#include <asm/atomic.h>
20#include <asm/smp-ops.h>
21
22extern int smp_num_siblings;
23extern cpumask_t cpu_sibling_map[];
22 24
23#define raw_smp_processor_id() (current_thread_info()->cpu) 25#define raw_smp_processor_id() (current_thread_info()->cpu)
24 26
@@ -49,56 +51,6 @@ extern struct call_data_struct *call_data;
49extern cpumask_t phys_cpu_present_map; 51extern cpumask_t phys_cpu_present_map;
50#define cpu_possible_map phys_cpu_present_map 52#define cpu_possible_map phys_cpu_present_map
51 53
52/*
53 * These are defined by the board-specific code.
54 */
55
56/*
57 * Cause the function described by call_data to be executed on the passed
58 * cpu. When the function has finished, increment the finished field of
59 * call_data.
60 */
61extern void core_send_ipi(int cpu, unsigned int action);
62
63static inline void core_send_ipi_mask(cpumask_t mask, unsigned int action)
64{
65 unsigned int i;
66
67 for_each_cpu_mask(i, mask)
68 core_send_ipi(i, action);
69}
70
71
72/*
73 * Firmware CPU startup hook
74 */
75extern void prom_boot_secondary(int cpu, struct task_struct *idle);
76
77/*
78 * After we've done initial boot, this function is called to allow the
79 * board code to clean up state, if needed
80 */
81extern void prom_init_secondary(void);
82
83/*
84 * Populate cpu_possible_map before smp_init, called from setup_arch.
85 */
86extern void plat_smp_setup(void);
87
88/*
89 * Called in smp_prepare_cpus.
90 */
91extern void plat_prepare_cpus(unsigned int max_cpus);
92
93/*
94 * Last chance for the board code to finish SMP initialization before
95 * the CPU is "online".
96 */
97extern void prom_smp_finish(void);
98
99/* Hook for after all CPUs are online */
100extern void prom_cpus_done(void);
101
102extern void asmlinkage smp_bootstrap(void); 54extern void asmlinkage smp_bootstrap(void);
103 55
104/* 56/*
@@ -108,11 +60,11 @@ extern void asmlinkage smp_bootstrap(void);
108 */ 60 */
109static inline void smp_send_reschedule(int cpu) 61static inline void smp_send_reschedule(int cpu)
110{ 62{
111 core_send_ipi(cpu, SMP_RESCHEDULE_YOURSELF); 63 extern struct plat_smp_ops *mp_ops; /* private */
64
65 mp_ops->send_ipi_single(cpu, SMP_RESCHEDULE_YOURSELF);
112} 66}
113 67
114extern asmlinkage void smp_call_function_interrupt(void); 68extern asmlinkage void smp_call_function_interrupt(void);
115 69
116#endif /* CONFIG_SMP */
117
118#endif /* __ASM_SMP_H */ 70#endif /* __ASM_SMP_H */
diff --git a/include/asm-mips/smtc_ipi.h b/include/asm-mips/smtc_ipi.h
index e09131a6127d..8ce517574340 100644
--- a/include/asm-mips/smtc_ipi.h
+++ b/include/asm-mips/smtc_ipi.h
@@ -49,7 +49,7 @@ struct smtc_ipi_q {
49 49
50static inline void smtc_ipi_nq(struct smtc_ipi_q *q, struct smtc_ipi *p) 50static inline void smtc_ipi_nq(struct smtc_ipi_q *q, struct smtc_ipi *p)
51{ 51{
52 long flags; 52 unsigned long flags;
53 53
54 spin_lock_irqsave(&q->lock, flags); 54 spin_lock_irqsave(&q->lock, flags);
55 if (q->head == NULL) 55 if (q->head == NULL)
@@ -98,7 +98,7 @@ static inline struct smtc_ipi *smtc_ipi_dq(struct smtc_ipi_q *q)
98 98
99static inline void smtc_ipi_req(struct smtc_ipi_q *q, struct smtc_ipi *p) 99static inline void smtc_ipi_req(struct smtc_ipi_q *q, struct smtc_ipi *p)
100{ 100{
101 long flags; 101 unsigned long flags;
102 102
103 spin_lock_irqsave(&q->lock, flags); 103 spin_lock_irqsave(&q->lock, flags);
104 if (q->head == NULL) { 104 if (q->head == NULL) {
@@ -114,7 +114,7 @@ static inline void smtc_ipi_req(struct smtc_ipi_q *q, struct smtc_ipi *p)
114 114
115static inline int smtc_ipi_qdepth(struct smtc_ipi_q *q) 115static inline int smtc_ipi_qdepth(struct smtc_ipi_q *q)
116{ 116{
117 long flags; 117 unsigned long flags;
118 int retval; 118 int retval;
119 119
120 spin_lock_irqsave(&q->lock, flags); 120 spin_lock_irqsave(&q->lock, flags);
diff --git a/include/asm-mips/sni.h b/include/asm-mips/sni.h
index af081457f847..e716447e5e03 100644
--- a/include/asm-mips/sni.h
+++ b/include/asm-mips/sni.h
@@ -35,23 +35,23 @@ extern unsigned int sni_brd_type;
35#define SNI_CPU_M8050 0x0b 35#define SNI_CPU_M8050 0x0b
36#define SNI_CPU_M8053 0x0d 36#define SNI_CPU_M8053 0x0d
37 37
38#define SNI_PORT_BASE 0xb4000000 38#define SNI_PORT_BASE CKSEG1ADDR(0xb4000000)
39 39
40#ifndef __MIPSEL__ 40#ifndef __MIPSEL__
41/* 41/*
42 * ASIC PCI registers for big endian configuration. 42 * ASIC PCI registers for big endian configuration.
43 */ 43 */
44#define PCIMT_UCONF 0xbfff0004 44#define PCIMT_UCONF CKSEG1ADDR(0xbfff0004)
45#define PCIMT_IOADTIMEOUT2 0xbfff000c 45#define PCIMT_IOADTIMEOUT2 CKSEG1ADDR(0xbfff000c)
46#define PCIMT_IOMEMCONF 0xbfff0014 46#define PCIMT_IOMEMCONF CKSEG1ADDR(0xbfff0014)
47#define PCIMT_IOMMU 0xbfff001c 47#define PCIMT_IOMMU CKSEG1ADDR(0xbfff001c)
48#define PCIMT_IOADTIMEOUT1 0xbfff0024 48#define PCIMT_IOADTIMEOUT1 CKSEG1ADDR(0xbfff0024)
49#define PCIMT_DMAACCESS 0xbfff002c 49#define PCIMT_DMAACCESS CKSEG1ADDR(0xbfff002c)
50#define PCIMT_DMAHIT 0xbfff0034 50#define PCIMT_DMAHIT CKSEG1ADDR(0xbfff0034)
51#define PCIMT_ERRSTATUS 0xbfff003c 51#define PCIMT_ERRSTATUS CKSEG1ADDR(0xbfff003c)
52#define PCIMT_ERRADDR 0xbfff0044 52#define PCIMT_ERRADDR CKSEG1ADDR(0xbfff0044)
53#define PCIMT_SYNDROME 0xbfff004c 53#define PCIMT_SYNDROME CKSEG1ADDR(0xbfff004c)
54#define PCIMT_ITPEND 0xbfff0054 54#define PCIMT_ITPEND CKSEG1ADDR(0xbfff0054)
55#define IT_INT2 0x01 55#define IT_INT2 0x01
56#define IT_INTD 0x02 56#define IT_INTD 0x02
57#define IT_INTC 0x04 57#define IT_INTC 0x04
@@ -60,32 +60,32 @@ extern unsigned int sni_brd_type;
60#define IT_EISA 0x20 60#define IT_EISA 0x20
61#define IT_SCSI 0x40 61#define IT_SCSI 0x40
62#define IT_ETH 0x80 62#define IT_ETH 0x80
63#define PCIMT_IRQSEL 0xbfff005c 63#define PCIMT_IRQSEL CKSEG1ADDR(0xbfff005c)
64#define PCIMT_TESTMEM 0xbfff0064 64#define PCIMT_TESTMEM CKSEG1ADDR(0xbfff0064)
65#define PCIMT_ECCREG 0xbfff006c 65#define PCIMT_ECCREG CKSEG1ADDR(0xbfff006c)
66#define PCIMT_CONFIG_ADDRESS 0xbfff0074 66#define PCIMT_CONFIG_ADDRESS CKSEG1ADDR(0xbfff0074)
67#define PCIMT_ASIC_ID 0xbfff007c /* read */ 67#define PCIMT_ASIC_ID CKSEG1ADDR(0xbfff007c) /* read */
68#define PCIMT_SOFT_RESET 0xbfff007c /* write */ 68#define PCIMT_SOFT_RESET CKSEG1ADDR(0xbfff007c) /* write */
69#define PCIMT_PIA_OE 0xbfff0084 69#define PCIMT_PIA_OE CKSEG1ADDR(0xbfff0084)
70#define PCIMT_PIA_DATAOUT 0xbfff008c 70#define PCIMT_PIA_DATAOUT CKSEG1ADDR(0xbfff008c)
71#define PCIMT_PIA_DATAIN 0xbfff0094 71#define PCIMT_PIA_DATAIN CKSEG1ADDR(0xbfff0094)
72#define PCIMT_CACHECONF 0xbfff009c 72#define PCIMT_CACHECONF CKSEG1ADDR(0xbfff009c)
73#define PCIMT_INVSPACE 0xbfff00a4 73#define PCIMT_INVSPACE CKSEG1ADDR(0xbfff00a4)
74#else 74#else
75/* 75/*
76 * ASIC PCI registers for little endian configuration. 76 * ASIC PCI registers for little endian configuration.
77 */ 77 */
78#define PCIMT_UCONF 0xbfff0000 78#define PCIMT_UCONF CKSEG1ADDR(0xbfff0000)
79#define PCIMT_IOADTIMEOUT2 0xbfff0008 79#define PCIMT_IOADTIMEOUT2 CKSEG1ADDR(0xbfff0008)
80#define PCIMT_IOMEMCONF 0xbfff0010 80#define PCIMT_IOMEMCONF CKSEG1ADDR(0xbfff0010)
81#define PCIMT_IOMMU 0xbfff0018 81#define PCIMT_IOMMU CKSEG1ADDR(0xbfff0018)
82#define PCIMT_IOADTIMEOUT1 0xbfff0020 82#define PCIMT_IOADTIMEOUT1 CKSEG1ADDR(0xbfff0020)
83#define PCIMT_DMAACCESS 0xbfff0028 83#define PCIMT_DMAACCESS CKSEG1ADDR(0xbfff0028)
84#define PCIMT_DMAHIT 0xbfff0030 84#define PCIMT_DMAHIT CKSEG1ADDR(0xbfff0030)
85#define PCIMT_ERRSTATUS 0xbfff0038 85#define PCIMT_ERRSTATUS CKSEG1ADDR(0xbfff0038)
86#define PCIMT_ERRADDR 0xbfff0040 86#define PCIMT_ERRADDR CKSEG1ADDR(0xbfff0040)
87#define PCIMT_SYNDROME 0xbfff0048 87#define PCIMT_SYNDROME CKSEG1ADDR(0xbfff0048)
88#define PCIMT_ITPEND 0xbfff0050 88#define PCIMT_ITPEND CKSEG1ADDR(0xbfff0050)
89#define IT_INT2 0x01 89#define IT_INT2 0x01
90#define IT_INTD 0x02 90#define IT_INTD 0x02
91#define IT_INTC 0x04 91#define IT_INTC 0x04
@@ -94,20 +94,20 @@ extern unsigned int sni_brd_type;
94#define IT_EISA 0x20 94#define IT_EISA 0x20
95#define IT_SCSI 0x40 95#define IT_SCSI 0x40
96#define IT_ETH 0x80 96#define IT_ETH 0x80
97#define PCIMT_IRQSEL 0xbfff0058 97#define PCIMT_IRQSEL CKSEG1ADDR(0xbfff0058)
98#define PCIMT_TESTMEM 0xbfff0060 98#define PCIMT_TESTMEM CKSEG1ADDR(0xbfff0060)
99#define PCIMT_ECCREG 0xbfff0068 99#define PCIMT_ECCREG CKSEG1ADDR(0xbfff0068)
100#define PCIMT_CONFIG_ADDRESS 0xbfff0070 100#define PCIMT_CONFIG_ADDRESS CKSEG1ADDR(0xbfff0070)
101#define PCIMT_ASIC_ID 0xbfff0078 /* read */ 101#define PCIMT_ASIC_ID CKSEG1ADDR(0xbfff0078) /* read */
102#define PCIMT_SOFT_RESET 0xbfff0078 /* write */ 102#define PCIMT_SOFT_RESET CKSEG1ADDR(0xbfff0078) /* write */
103#define PCIMT_PIA_OE 0xbfff0080 103#define PCIMT_PIA_OE CKSEG1ADDR(0xbfff0080)
104#define PCIMT_PIA_DATAOUT 0xbfff0088 104#define PCIMT_PIA_DATAOUT CKSEG1ADDR(0xbfff0088)
105#define PCIMT_PIA_DATAIN 0xbfff0090 105#define PCIMT_PIA_DATAIN CKSEG1ADDR(0xbfff0090)
106#define PCIMT_CACHECONF 0xbfff0098 106#define PCIMT_CACHECONF CKSEG1ADDR(0xbfff0098)
107#define PCIMT_INVSPACE 0xbfff00a0 107#define PCIMT_INVSPACE CKSEG1ADDR(0xbfff00a0)
108#endif 108#endif
109 109
110#define PCIMT_PCI_CONF 0xbfff0100 110#define PCIMT_PCI_CONF CKSEG1ADDR(0xbfff0100)
111 111
112/* 112/*
113 * Data port for the PCI bus in IO space 113 * Data port for the PCI bus in IO space
@@ -117,34 +117,34 @@ extern unsigned int sni_brd_type;
117/* 117/*
118 * Board specific registers 118 * Board specific registers
119 */ 119 */
120#define PCIMT_CSMSR 0xbfd00000 120#define PCIMT_CSMSR CKSEG1ADDR(0xbfd00000)
121#define PCIMT_CSSWITCH 0xbfd10000 121#define PCIMT_CSSWITCH CKSEG1ADDR(0xbfd10000)
122#define PCIMT_CSITPEND 0xbfd20000 122#define PCIMT_CSITPEND CKSEG1ADDR(0xbfd20000)
123#define PCIMT_AUTO_PO_EN 0xbfd30000 123#define PCIMT_AUTO_PO_EN CKSEG1ADDR(0xbfd30000)
124#define PCIMT_CLR_TEMP 0xbfd40000 124#define PCIMT_CLR_TEMP CKSEG1ADDR(0xbfd40000)
125#define PCIMT_AUTO_PO_DIS 0xbfd50000 125#define PCIMT_AUTO_PO_DIS CKSEG1ADDR(0xbfd50000)
126#define PCIMT_EXMSR 0xbfd60000 126#define PCIMT_EXMSR CKSEG1ADDR(0xbfd60000)
127#define PCIMT_UNUSED1 0xbfd70000 127#define PCIMT_UNUSED1 CKSEG1ADDR(0xbfd70000)
128#define PCIMT_CSWCSM 0xbfd80000 128#define PCIMT_CSWCSM CKSEG1ADDR(0xbfd80000)
129#define PCIMT_UNUSED2 0xbfd90000 129#define PCIMT_UNUSED2 CKSEG1ADDR(0xbfd90000)
130#define PCIMT_CSLED 0xbfda0000 130#define PCIMT_CSLED CKSEG1ADDR(0xbfda0000)
131#define PCIMT_CSMAPISA 0xbfdb0000 131#define PCIMT_CSMAPISA CKSEG1ADDR(0xbfdb0000)
132#define PCIMT_CSRSTBP 0xbfdc0000 132#define PCIMT_CSRSTBP CKSEG1ADDR(0xbfdc0000)
133#define PCIMT_CLRPOFF 0xbfdd0000 133#define PCIMT_CLRPOFF CKSEG1ADDR(0xbfdd0000)
134#define PCIMT_CSTIMER 0xbfde0000 134#define PCIMT_CSTIMER CKSEG1ADDR(0xbfde0000)
135#define PCIMT_PWDN 0xbfdf0000 135#define PCIMT_PWDN CKSEG1ADDR(0xbfdf0000)
136 136
137/* 137/*
138 * A20R based boards 138 * A20R based boards
139 */ 139 */
140#define A20R_PT_CLOCK_BASE 0xbc040000 140#define A20R_PT_CLOCK_BASE CKSEG1ADDR(0xbc040000)
141#define A20R_PT_TIM0_ACK 0xbc050000 141#define A20R_PT_TIM0_ACK CKSEG1ADDR(0xbc050000)
142#define A20R_PT_TIM1_ACK 0xbc060000 142#define A20R_PT_TIM1_ACK CKSEG1ADDR(0xbc060000)
143 143
144#define SNI_A20R_IRQ_BASE MIPS_CPU_IRQ_BASE 144#define SNI_A20R_IRQ_BASE MIPS_CPU_IRQ_BASE
145#define SNI_A20R_IRQ_TIMER (SNI_A20R_IRQ_BASE+5) 145#define SNI_A20R_IRQ_TIMER (SNI_A20R_IRQ_BASE+5)
146 146
147#define SNI_PCIT_INT_REG 0xbfff000c 147#define SNI_PCIT_INT_REG CKSEG1ADDR(0xbfff000c)
148 148
149#define SNI_PCIT_INT_START 24 149#define SNI_PCIT_INT_START 24
150#define SNI_PCIT_INT_END 30 150#define SNI_PCIT_INT_END 30
@@ -186,10 +186,30 @@ extern unsigned int sni_brd_type;
186/* 186/*
187 * Base address for the mapped 16mb EISA bus segment. 187 * Base address for the mapped 16mb EISA bus segment.
188 */ 188 */
189#define PCIMT_EISA_BASE 0xb0000000 189#define PCIMT_EISA_BASE CKSEG1ADDR(0xb0000000)
190 190
191/* PCI EISA Interrupt acknowledge */ 191/* PCI EISA Interrupt acknowledge */
192#define PCIMT_INT_ACKNOWLEDGE 0xba000000 192#define PCIMT_INT_ACKNOWLEDGE CKSEG1ADDR(0xba000000)
193
194/*
195 * SNI ID PROM
196 *
197 * SNI_IDPROM_MEMSIZE Memsize in 16MB quantities
198 * SNI_IDPROM_BRDTYPE Board Type
199 * SNI_IDPROM_CPUTYPE CPU Type on RM400
200 */
201#ifdef CONFIG_CPU_BIG_ENDIAN
202#define __SNI_END 0
203#endif
204#ifdef CONFIG_CPU_LITTLE_ENDIAN
205#define __SNI_END 3
206#endif
207#define SNI_IDPROM_BASE CKSEG1ADDR(0x1ff00000)
208#define SNI_IDPROM_MEMSIZE (SNI_IDPROM_BASE + (0x28 ^ __SNI_END))
209#define SNI_IDPROM_BRDTYPE (SNI_IDPROM_BASE + (0x29 ^ __SNI_END))
210#define SNI_IDPROM_CPUTYPE (SNI_IDPROM_BASE + (0x30 ^ __SNI_END))
211
212#define SNI_IDPROM_SIZE 0x1000
193 213
194/* board specific init functions */ 214/* board specific init functions */
195extern void sni_a20r_init(void); 215extern void sni_a20r_init(void);
@@ -207,6 +227,9 @@ extern void sni_pcimt_irq_init(void);
207/* timer inits */ 227/* timer inits */
208extern void sni_cpu_time_init(void); 228extern void sni_cpu_time_init(void);
209 229
230/* eisa init for RM200/400 */
231extern int sni_eisa_root_init(void);
232
210/* common irq stuff */ 233/* common irq stuff */
211extern void (*sni_hwint)(void); 234extern void (*sni_hwint)(void);
212extern struct irqaction sni_isa_irq; 235extern struct irqaction sni_isa_irq;
diff --git a/include/asm-mips/socket.h b/include/asm-mips/socket.h
index 95945689b1c6..63f60254d308 100644
--- a/include/asm-mips/socket.h
+++ b/include/asm-mips/socket.h
@@ -73,6 +73,8 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */
73#define SO_TIMESTAMPNS 35 73#define SO_TIMESTAMPNS 35
74#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 74#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
75 75
76#define SO_MARK 36
77
76#ifdef __KERNEL__ 78#ifdef __KERNEL__
77 79
78/** sock_type - Socket types 80/** sock_type - Socket types
diff --git a/include/asm-mips/stackframe.h b/include/asm-mips/stackframe.h
index fb41a8d76392..051e1af0bb95 100644
--- a/include/asm-mips/stackframe.h
+++ b/include/asm-mips/stackframe.h
@@ -6,6 +6,7 @@
6 * Copyright (C) 1994, 95, 96, 99, 2001 Ralf Baechle 6 * Copyright (C) 1994, 95, 96, 99, 2001 Ralf Baechle
7 * Copyright (C) 1994, 1995, 1996 Paul M. Antoine. 7 * Copyright (C) 1994, 1995, 1996 Paul M. Antoine.
8 * Copyright (C) 1999 Silicon Graphics, Inc. 8 * Copyright (C) 1999 Silicon Graphics, Inc.
9 * Copyright (C) 2007 Maciej W. Rozycki
9 */ 10 */
10#ifndef _ASM_STACKFRAME_H 11#ifndef _ASM_STACKFRAME_H
11#define _ASM_STACKFRAME_H 12#define _ASM_STACKFRAME_H
@@ -145,8 +146,16 @@
145 .set reorder 146 .set reorder
146 /* Called from user mode, new stack. */ 147 /* Called from user mode, new stack. */
147 get_saved_sp 148 get_saved_sp
149#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
1488: move k0, sp 1508: move k0, sp
149 PTR_SUBU sp, k1, PT_SIZE 151 PTR_SUBU sp, k1, PT_SIZE
152#else
153 .set at=k0
1548: PTR_SUBU k1, PT_SIZE
155 .set noat
156 move k0, sp
157 move sp, k1
158#endif
150 LONG_S k0, PT_R29(sp) 159 LONG_S k0, PT_R29(sp)
151 LONG_S $3, PT_R3(sp) 160 LONG_S $3, PT_R3(sp)
152 /* 161 /*
diff --git a/include/asm-mips/system.h b/include/asm-mips/system.h
index 90e4b403f531..a944eda4faf5 100644
--- a/include/asm-mips/system.h
+++ b/include/asm-mips/system.h
@@ -68,11 +68,15 @@ do { \
68 if (cpu_has_dsp) \ 68 if (cpu_has_dsp) \
69 __save_dsp(prev); \ 69 __save_dsp(prev); \
70 (last) = resume(prev, next, task_thread_info(next)); \ 70 (last) = resume(prev, next, task_thread_info(next)); \
71} while (0)
72
73#define finish_arch_switch(prev) \
74do { \
71 if (cpu_has_dsp) \ 75 if (cpu_has_dsp) \
72 __restore_dsp(current); \ 76 __restore_dsp(current); \
73 if (cpu_has_userlocal) \ 77 if (cpu_has_userlocal) \
74 write_c0_userlocal(task_thread_info(current)->tp_value);\ 78 write_c0_userlocal(current_thread_info()->tp_value); \
75} while(0) 79} while (0)
76 80
77static inline unsigned long __xchg_u32(volatile int * m, unsigned int val) 81static inline unsigned long __xchg_u32(volatile int * m, unsigned int val)
78{ 82{
@@ -205,8 +209,6 @@ extern void *set_except_vector(int n, void *addr);
205extern unsigned long ebase; 209extern unsigned long ebase;
206extern void per_cpu_trap_init(void); 210extern void per_cpu_trap_init(void);
207 211
208extern int stop_a_enabled;
209
210/* 212/*
211 * See include/asm-ia64/system.h; prevents deadlock on SMP 213 * See include/asm-ia64/system.h; prevents deadlock on SMP
212 * systems. 214 * systems.
diff --git a/include/asm-mips/time.h b/include/asm-mips/time.h
index bc47af313bcd..a8fd16e1981f 100644
--- a/include/asm-mips/time.h
+++ b/include/asm-mips/time.h
@@ -10,15 +10,10 @@
10 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your 11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version. 12 * option) any later version.
13 *
14 * Please refer to Documentation/mips/time.README.
15 */ 13 */
16#ifndef _ASM_TIME_H 14#ifndef _ASM_TIME_H
17#define _ASM_TIME_H 15#define _ASM_TIME_H
18 16
19#include <linux/interrupt.h>
20#include <linux/linkage.h>
21#include <linux/ptrace.h>
22#include <linux/rtc.h> 17#include <linux/rtc.h>
23#include <linux/spinlock.h> 18#include <linux/spinlock.h>
24#include <linux/clockchips.h> 19#include <linux/clockchips.h>
@@ -36,34 +31,13 @@ extern int rtc_mips_set_time(unsigned long);
36extern int rtc_mips_set_mmss(unsigned long); 31extern int rtc_mips_set_mmss(unsigned long);
37 32
38/* 33/*
39 * Timer interrupt functions.
40 * mips_timer_state is needed for high precision timer calibration.
41 * mips_timer_ack may be NULL if the interrupt is self-recoverable.
42 */
43extern int (*mips_timer_state)(void);
44
45/*
46 * High precision timer clocksource.
47 * If .read is NULL, an R4k-compatible timer setup is attempted.
48 */
49extern struct clocksource clocksource_mips;
50
51/*
52 * profiling and process accouting is done separately in local_timer_interrupt
53 */
54extern void local_timer_interrupt(int irq, void *dev_id);
55
56/*
57 * board specific routines required by time_init(). 34 * board specific routines required by time_init().
58 */ 35 */
59struct irqaction;
60extern void plat_time_init(void); 36extern void plat_time_init(void);
61extern void plat_timer_setup(struct irqaction *irq);
62 37
63/* 38/*
64 * mips_hpt_frequency - must be set if you intend to use an R4k-compatible 39 * mips_hpt_frequency - must be set if you intend to use an R4k-compatible
65 * counter as a timer interrupt source; otherwise it can be set up 40 * counter as a timer interrupt source.
66 * automagically with an aid of mips_timer_state.
67 */ 41 */
68extern unsigned int mips_hpt_frequency; 42extern unsigned int mips_hpt_frequency;
69 43
@@ -77,9 +51,22 @@ extern int (*perf_irq)(void);
77 * Initialize the calling CPU's compare interrupt as clockevent device 51 * Initialize the calling CPU's compare interrupt as clockevent device
78 */ 52 */
79#ifdef CONFIG_CEVT_R4K 53#ifdef CONFIG_CEVT_R4K
80extern void mips_clockevent_init(void); 54extern int mips_clockevent_init(void);
55extern unsigned int __weak get_c0_compare_int(void);
56#else
57static inline int mips_clockevent_init(void)
58{
59 return -ENXIO;
60}
61#endif
62
63/*
64 * Initialize the count register as a clocksource
65 */
66#ifdef CONFIG_CEVT_R4K
67extern void init_mips_clocksource(void);
81#else 68#else
82static inline void mips_clockevent_init(void) 69static inline void init_mips_clocksource(void)
83{ 70{
84} 71}
85#endif 72#endif
diff --git a/include/asm-mips/timex.h b/include/asm-mips/timex.h
index 87c68ae76ff8..6529704aa73a 100644
--- a/include/asm-mips/timex.h
+++ b/include/asm-mips/timex.h
@@ -13,27 +13,12 @@
13#include <asm/mipsregs.h> 13#include <asm/mipsregs.h>
14 14
15/* 15/*
16 * This is the frequency of the timer used for Linux's timer interrupt. 16 * This is the clock rate of the i8253 PIT. A MIPS system may not have
17 * The value should be defined as accurate as possible or under certain 17 * a PIT by the symbol is used all over the kernel including some APIs.
18 * circumstances Linux timekeeping might become inaccurate or fail. 18 * So keeping it defined to the number for the PIT is the only sane thing
19 * 19 * for now.
20 * For many system the exact clockrate of the timer isn't known but due to
21 * the way this value is used we can get away with a wrong value as long
22 * as this value is:
23 *
24 * - a multiple of HZ
25 * - a divisor of the actual rate
26 *
27 * 500000 is a good such cheat value.
28 *
29 * The obscure number 1193182 is the same as used by the original i8254
30 * time in legacy PC hardware; the chip unfortunately also found in a
31 * bunch of MIPS systems. The last remaining user of the i8254 for the
32 * timer interrupt is the RM200; it's a very standard system so there is
33 * no reason to make this a separate architecture.
34 */ 20 */
35 21#define CLOCK_TICK_RATE 1193182
36#include <timex.h>
37 22
38/* 23/*
39 * Standard way to access the cycle counter. 24 * Standard way to access the cycle counter.
@@ -50,7 +35,7 @@ typedef unsigned int cycles_t;
50 35
51static inline cycles_t get_cycles(void) 36static inline cycles_t get_cycles(void)
52{ 37{
53 return read_c0_count(); 38 return 0;
54} 39}
55 40
56#endif /* __KERNEL__ */ 41#endif /* __KERNEL__ */
diff --git a/include/asm-mips/topology.h b/include/asm-mips/topology.h
index 0440fb9f2180..259145e07e97 100644
--- a/include/asm-mips/topology.h
+++ b/include/asm-mips/topology.h
@@ -1 +1,17 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2007 by Ralf Baechle
7 */
8#ifndef __ASM_TOPOLOGY_H
9#define __ASM_TOPOLOGY_H
10
1#include <topology.h> 11#include <topology.h>
12
13#ifdef CONFIG_SMP
14#define smt_capable() (smp_num_siblings > 1)
15#endif
16
17#endif /* __ASM_TOPOLOGY_H */
diff --git a/include/asm-mips/tx4927/tx4927_pci.h b/include/asm-mips/tx4927/tx4927_pci.h
index f98b2bb719d5..0be77df70f2b 100644
--- a/include/asm-mips/tx4927/tx4927_pci.h
+++ b/include/asm-mips/tx4927/tx4927_pci.h
@@ -9,6 +9,8 @@
9#define __ASM_TX4927_TX4927_PCI_H 9#define __ASM_TX4927_TX4927_PCI_H
10 10
11#define TX4927_CCFG_TOE 0x00004000 11#define TX4927_CCFG_TOE 0x00004000
12#define TX4927_CCFG_WR 0x00008000
13#define TX4927_CCFG_TINTDIS 0x01000000
12 14
13#define TX4927_PCIMEM 0x08000000 15#define TX4927_PCIMEM 0x08000000
14#define TX4927_PCIMEM_SIZE 0x08000000 16#define TX4927_PCIMEM_SIZE 0x08000000
@@ -20,6 +22,8 @@
20#define TX4927_PCIC_REG 0xff1fd000 22#define TX4927_PCIC_REG 0xff1fd000
21#define TX4927_CCFG_REG 0xff1fe000 23#define TX4927_CCFG_REG 0xff1fe000
22#define TX4927_IRC_REG 0xff1ff600 24#define TX4927_IRC_REG 0xff1ff600
25#define TX4927_NR_TMR 3
26#define TX4927_TMR_REG(ch) (0xff1ff000 + (ch) * 0x100)
23#define TX4927_CE3 0x17f00000 /* 1M */ 27#define TX4927_CE3 0x17f00000 /* 1M */
24#define TX4927_PCIRESET_ADDR 0xbc00f006 28#define TX4927_PCIRESET_ADDR 0xbc00f006
25#define TX4927_PCI_CLK_ADDR (KSEG1 + TX4927_CE3 + 0x00040020) 29#define TX4927_PCI_CLK_ADDR (KSEG1 + TX4927_CE3 + 0x00040020)
diff --git a/include/asm-mips/tx4938/tx4938.h b/include/asm-mips/tx4938/tx4938.h
index 650b010761f9..f7c448b90578 100644
--- a/include/asm-mips/tx4938/tx4938.h
+++ b/include/asm-mips/tx4938/tx4938.h
@@ -641,7 +641,6 @@ struct tx4938_ccfg_reg {
641#define tx4938_pcicptr ((struct tx4938_pcic_reg *)TX4938_PCIC_REG) 641#define tx4938_pcicptr ((struct tx4938_pcic_reg *)TX4938_PCIC_REG)
642#define tx4938_pcic1ptr ((struct tx4938_pcic_reg *)TX4938_PCIC1_REG) 642#define tx4938_pcic1ptr ((struct tx4938_pcic_reg *)TX4938_PCIC1_REG)
643#define tx4938_ccfgptr ((struct tx4938_ccfg_reg *)TX4938_CCFG_REG) 643#define tx4938_ccfgptr ((struct tx4938_ccfg_reg *)TX4938_CCFG_REG)
644#define tx4938_tmrptr(ch) ((struct tx4938_tmr_reg *)TX4938_TMR_REG(ch))
645#define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch)) 644#define tx4938_sioptr(ch) ((struct tx4938_sio_reg *)TX4938_SIO_REG(ch))
646#define tx4938_pioptr ((struct tx4938_pio_reg *)TX4938_PIO_REG) 645#define tx4938_pioptr ((struct tx4938_pio_reg *)TX4938_PIO_REG)
647#define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG) 646#define tx4938_aclcptr ((struct tx4938_aclc_reg *)TX4938_ACLC_REG)
diff --git a/include/asm-mips/txx9tmr.h b/include/asm-mips/txx9tmr.h
new file mode 100644
index 000000000000..67f70a8f09bd
--- /dev/null
+++ b/include/asm-mips/txx9tmr.h
@@ -0,0 +1,67 @@
1/*
2 * include/asm-mips/txx9tmr.h
3 * TX39/TX49 timer controller definitions.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */
9#ifndef __ASM_TXX9TMR_H
10#define __ASM_TXX9TMR_H
11
12#include <linux/types.h>
13
14struct txx9_tmr_reg {
15 u32 tcr;
16 u32 tisr;
17 u32 cpra;
18 u32 cprb;
19 u32 itmr;
20 u32 unused0[3];
21 u32 ccdr;
22 u32 unused1[3];
23 u32 pgmr;
24 u32 unused2[3];
25 u32 wtmr;
26 u32 unused3[43];
27 u32 trr;
28};
29
30/* TMTCR : Timer Control */
31#define TXx9_TMTCR_TCE 0x00000080
32#define TXx9_TMTCR_CCDE 0x00000040
33#define TXx9_TMTCR_CRE 0x00000020
34#define TXx9_TMTCR_ECES 0x00000008
35#define TXx9_TMTCR_CCS 0x00000004
36#define TXx9_TMTCR_TMODE_MASK 0x00000003
37#define TXx9_TMTCR_TMODE_ITVL 0x00000000
38#define TXx9_TMTCR_TMODE_PGEN 0x00000001
39#define TXx9_TMTCR_TMODE_WDOG 0x00000002
40
41/* TMTISR : Timer Int. Status */
42#define TXx9_TMTISR_TPIBS 0x00000004
43#define TXx9_TMTISR_TPIAS 0x00000002
44#define TXx9_TMTISR_TIIS 0x00000001
45
46/* TMITMR : Interval Timer Mode */
47#define TXx9_TMITMR_TIIE 0x00008000
48#define TXx9_TMITMR_TZCE 0x00000001
49
50/* TMWTMR : Watchdog Timer Mode */
51#define TXx9_TMWTMR_TWIE 0x00008000
52#define TXx9_TMWTMR_WDIS 0x00000080
53#define TXx9_TMWTMR_TWC 0x00000001
54
55void txx9_clocksource_init(unsigned long baseaddr,
56 unsigned int imbusclk);
57void txx9_clockevent_init(unsigned long baseaddr, int irq,
58 unsigned int imbusclk);
59void txx9_tmr_init(unsigned long baseaddr);
60
61#ifdef CONFIG_CPU_TX39XX
62#define TXX9_TIMER_BITS 24
63#else
64#define TXX9_TIMER_BITS 32
65#endif
66
67#endif /* __ASM_TXX9TMR_H */
diff --git a/include/asm-mips/uaccess.h b/include/asm-mips/uaccess.h
index c30c718994c9..66523d610950 100644
--- a/include/asm-mips/uaccess.h
+++ b/include/asm-mips/uaccess.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 03, 04 by Ralf Baechle 6 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 03, 04 by Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2007 Maciej W. Rozycki
8 */ 9 */
9#ifndef _ASM_UACCESS_H 10#ifndef _ASM_UACCESS_H
10#define _ASM_UACCESS_H 11#define _ASM_UACCESS_H
@@ -387,6 +388,12 @@ extern void __put_user_unknown(void);
387 "jal\t" #destination "\n\t" 388 "jal\t" #destination "\n\t"
388#endif 389#endif
389 390
391#ifndef CONFIG_CPU_DADDI_WORKAROUNDS
392#define DADDI_SCRATCH "$0"
393#else
394#define DADDI_SCRATCH "$3"
395#endif
396
390extern size_t __copy_user(void *__to, const void *__from, size_t __n); 397extern size_t __copy_user(void *__to, const void *__from, size_t __n);
391 398
392#define __invoke_copy_to_user(to, from, n) \ 399#define __invoke_copy_to_user(to, from, n) \
@@ -403,7 +410,7 @@ extern size_t __copy_user(void *__to, const void *__from, size_t __n);
403 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 410 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
404 : \ 411 : \
405 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 412 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \
406 "memory"); \ 413 DADDI_SCRATCH, "memory"); \
407 __cu_len_r; \ 414 __cu_len_r; \
408}) 415})
409 416
@@ -512,7 +519,7 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
512 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 519 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
513 : \ 520 : \
514 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 521 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \
515 "memory"); \ 522 DADDI_SCRATCH, "memory"); \
516 __cu_len_r; \ 523 __cu_len_r; \
517}) 524})
518 525
@@ -535,7 +542,7 @@ extern size_t __copy_user_inatomic(void *__to, const void *__from, size_t __n);
535 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \ 542 : "+r" (__cu_to_r), "+r" (__cu_from_r), "+r" (__cu_len_r) \
536 : \ 543 : \
537 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \ 544 : "$8", "$9", "$10", "$11", "$12", "$15", "$24", "$31", \
538 "memory"); \ 545 DADDI_SCRATCH, "memory"); \
539 __cu_len_r; \ 546 __cu_len_r; \
540}) 547})
541 548
diff --git a/include/asm-mips/war.h b/include/asm-mips/war.h
index d2808edfd4e9..22361d5e3bf0 100644
--- a/include/asm-mips/war.h
+++ b/include/asm-mips/war.h
@@ -4,6 +4,7 @@
4 * for more details. 4 * for more details.
5 * 5 *
6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle 6 * Copyright (C) 2002, 2004, 2007 by Ralf Baechle
7 * Copyright (C) 2007 Maciej W. Rozycki
7 */ 8 */
8#ifndef _ASM_WAR_H 9#ifndef _ASM_WAR_H
9#define _ASM_WAR_H 10#define _ASM_WAR_H
@@ -11,6 +12,67 @@
11#include <war.h> 12#include <war.h>
12 13
13/* 14/*
15 * Work around certain R4000 CPU errata (as implemented by GCC):
16 *
17 * - A double-word or a variable shift may give an incorrect result
18 * if executed immediately after starting an integer division:
19 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
20 * erratum #28
21 * "MIPS R4000MC Errata, Processor Revision 2.2 and 3.0", erratum
22 * #19
23 *
24 * - A double-word or a variable shift may give an incorrect result
25 * if executed while an integer multiplication is in progress:
26 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
27 * errata #16 & #28
28 *
29 * - An integer division may give an incorrect result if started in
30 * a delay slot of a taken branch or a jump:
31 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
32 * erratum #52
33 */
34#ifdef CONFIG_CPU_R4000_WORKAROUNDS
35#define R4000_WAR 1
36#else
37#define R4000_WAR 0
38#endif
39
40/*
41 * Work around certain R4400 CPU errata (as implemented by GCC):
42 *
43 * - A double-word or a variable shift may give an incorrect result
44 * if executed immediately after starting an integer division:
45 * "MIPS R4400MC Errata, Processor Revision 1.0", erratum #10
46 * "MIPS R4400MC Errata, Processor Revision 2.0 & 3.0", erratum #4
47 */
48#ifdef CONFIG_CPU_R4400_WORKAROUNDS
49#define R4400_WAR 1
50#else
51#define R4400_WAR 0
52#endif
53
54/*
55 * Work around the "daddi" and "daddiu" CPU errata:
56 *
57 * - The `daddi' instruction fails to trap on overflow.
58 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
59 * erratum #23
60 *
61 * - The `daddiu' instruction can produce an incorrect result.
62 * "MIPS R4000PC/SC Errata, Processor Revision 2.2 and 3.0",
63 * erratum #41
64 * "MIPS R4000MC Errata, Processor Revision 2.2 and 3.0", erratum
65 * #15
66 * "MIPS R4400PC/SC Errata, Processor Revision 1.0", erratum #7
67 * "MIPS R4400MC Errata, Processor Revision 1.0", erratum #5
68 */
69#ifdef CONFIG_CPU_DADDI_WORKAROUNDS
70#define DADDI_WAR 1
71#else
72#define DADDI_WAR 0
73#endif
74
75/*
14 * Another R4600 erratum. Due to the lack of errata information the exact 76 * Another R4600 erratum. Due to the lack of errata information the exact
15 * technical details aren't known. I've experimentally found that disabling 77 * technical details aren't known. I've experimentally found that disabling
16 * interrupts during indexed I-cache flushes seems to be sufficient to deal 78 * interrupts during indexed I-cache flushes seems to be sufficient to deal
diff --git a/include/asm-parisc/agp.h b/include/asm-parisc/agp.h
index 9f61d4eb6c01..9651660da639 100644
--- a/include/asm-parisc/agp.h
+++ b/include/asm-parisc/agp.h
@@ -9,7 +9,6 @@
9 9
10#define map_page_into_agp(page) /* nothing */ 10#define map_page_into_agp(page) /* nothing */
11#define unmap_page_from_agp(page) /* nothing */ 11#define unmap_page_from_agp(page) /* nothing */
12#define flush_agp_mappings() /* nothing */
13#define flush_agp_cache() mb() 12#define flush_agp_cache() mb()
14 13
15/* Convert a physical address to an address suitable for the GART. */ 14/* Convert a physical address to an address suitable for the GART. */
diff --git a/include/asm-parisc/pdc.h b/include/asm-parisc/pdc.h
index 5e0c3ca5450b..deda8c311373 100644
--- a/include/asm-parisc/pdc.h
+++ b/include/asm-parisc/pdc.h
@@ -645,8 +645,7 @@ int pdc_soft_power_button(int sw_control);
645void pdc_io_reset(void); 645void pdc_io_reset(void);
646void pdc_io_reset_devices(void); 646void pdc_io_reset_devices(void);
647int pdc_iodc_getc(void); 647int pdc_iodc_getc(void);
648void pdc_iodc_putc(unsigned char c); 648int pdc_iodc_print(unsigned char *str, unsigned count);
649void pdc_iodc_outc(unsigned char c);
650void pdc_printf(const char *fmt, ...); 649void pdc_printf(const char *fmt, ...);
651 650
652void pdc_emergency_unlock(void); 651void pdc_emergency_unlock(void);
diff --git a/include/asm-parisc/socket.h b/include/asm-parisc/socket.h
index 99e868f6a8f5..69a7a0d30b02 100644
--- a/include/asm-parisc/socket.h
+++ b/include/asm-parisc/socket.h
@@ -52,4 +52,6 @@
52#define SO_PEERSEC 0x401d 52#define SO_PEERSEC 0x401d
53#define SO_PASSSEC 0x401e 53#define SO_PASSSEC 0x401e
54 54
55#define SO_MARK 0x401f
56
55#endif /* _ASM_SOCKET_H */ 57#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-powerpc/8xx_immap.h b/include/asm-powerpc/8xx_immap.h
index 1311cefdfd30..4b0e15206006 100644
--- a/include/asm-powerpc/8xx_immap.h
+++ b/include/asm-powerpc/8xx_immap.h
@@ -123,7 +123,7 @@ typedef struct mem_ctlr {
123#define OR_G5LA 0x00000400 /* Output #GPL5 on #GPL_A5 */ 123#define OR_G5LA 0x00000400 /* Output #GPL5 on #GPL_A5 */
124#define OR_G5LS 0x00000200 /* Drive #GPL high on falling edge of...*/ 124#define OR_G5LS 0x00000200 /* Drive #GPL high on falling edge of...*/
125#define OR_BI 0x00000100 /* Burst inhibit */ 125#define OR_BI 0x00000100 /* Burst inhibit */
126#define OR_SCY_MSK 0x000000f0 /* Cycle Lenght in Clocks */ 126#define OR_SCY_MSK 0x000000f0 /* Cycle Length in Clocks */
127#define OR_SCY_0_CLK 0x00000000 /* 0 clock cycles wait states */ 127#define OR_SCY_0_CLK 0x00000000 /* 0 clock cycles wait states */
128#define OR_SCY_1_CLK 0x00000010 /* 1 clock cycles wait states */ 128#define OR_SCY_1_CLK 0x00000010 /* 1 clock cycles wait states */
129#define OR_SCY_2_CLK 0x00000020 /* 2 clock cycles wait states */ 129#define OR_SCY_2_CLK 0x00000020 /* 2 clock cycles wait states */
diff --git a/include/asm-powerpc/agp.h b/include/asm-powerpc/agp.h
index e5ccaca2f5a4..86455c4c31ee 100644
--- a/include/asm-powerpc/agp.h
+++ b/include/asm-powerpc/agp.h
@@ -6,7 +6,6 @@
6 6
7#define map_page_into_agp(page) 7#define map_page_into_agp(page)
8#define unmap_page_from_agp(page) 8#define unmap_page_from_agp(page)
9#define flush_agp_mappings()
10#define flush_agp_cache() mb() 9#define flush_agp_cache() mb()
11 10
12/* Convert a physical address to an address suitable for the GART. */ 11/* Convert a physical address to an address suitable for the GART. */
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h
index 733b4af7f4f1..220d9a781ab9 100644
--- a/include/asm-powerpc/bitops.h
+++ b/include/asm-powerpc/bitops.h
@@ -359,6 +359,8 @@ static __inline__ int test_le_bit(unsigned long nr,
359unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, 359unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
360 unsigned long size, unsigned long offset); 360 unsigned long size, unsigned long offset);
361 361
362unsigned long generic_find_next_le_bit(const unsigned long *addr,
363 unsigned long size, unsigned long offset);
362/* Bitmap functions for the ext2 filesystem */ 364/* Bitmap functions for the ext2 filesystem */
363 365
364#define ext2_set_bit(nr,addr) \ 366#define ext2_set_bit(nr,addr) \
@@ -378,6 +380,8 @@ unsigned long generic_find_next_zero_le_bit(const unsigned long *addr,
378#define ext2_find_next_zero_bit(addr, size, off) \ 380#define ext2_find_next_zero_bit(addr, size, off) \
379 generic_find_next_zero_le_bit((unsigned long*)addr, size, off) 381 generic_find_next_zero_le_bit((unsigned long*)addr, size, off)
380 382
383#define ext2_find_next_bit(addr, size, off) \
384 generic_find_next_le_bit((unsigned long *)addr, size, off)
381/* Bitmap functions for the minix filesystem. */ 385/* Bitmap functions for the minix filesystem. */
382 386
383#define minix_test_and_set_bit(nr,addr) \ 387#define minix_test_and_set_bit(nr,addr) \
diff --git a/include/asm-powerpc/cpm.h b/include/asm-powerpc/cpm.h
index 48df9f330e76..77e39dad9728 100644
--- a/include/asm-powerpc/cpm.h
+++ b/include/asm-powerpc/cpm.h
@@ -4,11 +4,85 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <linux/types.h> 5#include <linux/types.h>
6 6
7/* Buffer descriptors used by many of the CPM protocols. */
8typedef struct cpm_buf_desc {
9 ushort cbd_sc; /* Status and Control */
10 ushort cbd_datlen; /* Data length in buffer */
11 uint cbd_bufaddr; /* Buffer address in host memory */
12} cbd_t;
13
14/* Buffer descriptor control/status used by serial
15 */
16
17#define BD_SC_EMPTY (0x8000) /* Receive is empty */
18#define BD_SC_READY (0x8000) /* Transmit is ready */
19#define BD_SC_WRAP (0x2000) /* Last buffer descriptor */
20#define BD_SC_INTRPT (0x1000) /* Interrupt on change */
21#define BD_SC_LAST (0x0800) /* Last buffer in frame */
22#define BD_SC_TC (0x0400) /* Transmit CRC */
23#define BD_SC_CM (0x0200) /* Continous mode */
24#define BD_SC_ID (0x0100) /* Rec'd too many idles */
25#define BD_SC_P (0x0100) /* xmt preamble */
26#define BD_SC_BR (0x0020) /* Break received */
27#define BD_SC_FR (0x0010) /* Framing error */
28#define BD_SC_PR (0x0008) /* Parity error */
29#define BD_SC_NAK (0x0004) /* NAK - did not respond */
30#define BD_SC_OV (0x0002) /* Overrun */
31#define BD_SC_UN (0x0002) /* Underrun */
32#define BD_SC_CD (0x0001) /* */
33#define BD_SC_CL (0x0001) /* Collision */
34
35/* Buffer descriptor control/status used by Ethernet receive.
36 * Common to SCC and FCC.
37 */
38#define BD_ENET_RX_EMPTY (0x8000)
39#define BD_ENET_RX_WRAP (0x2000)
40#define BD_ENET_RX_INTR (0x1000)
41#define BD_ENET_RX_LAST (0x0800)
42#define BD_ENET_RX_FIRST (0x0400)
43#define BD_ENET_RX_MISS (0x0100)
44#define BD_ENET_RX_BC (0x0080) /* FCC Only */
45#define BD_ENET_RX_MC (0x0040) /* FCC Only */
46#define BD_ENET_RX_LG (0x0020)
47#define BD_ENET_RX_NO (0x0010)
48#define BD_ENET_RX_SH (0x0008)
49#define BD_ENET_RX_CR (0x0004)
50#define BD_ENET_RX_OV (0x0002)
51#define BD_ENET_RX_CL (0x0001)
52#define BD_ENET_RX_STATS (0x01ff) /* All status bits */
53
54/* Buffer descriptor control/status used by Ethernet transmit.
55 * Common to SCC and FCC.
56 */
57#define BD_ENET_TX_READY (0x8000)
58#define BD_ENET_TX_PAD (0x4000)
59#define BD_ENET_TX_WRAP (0x2000)
60#define BD_ENET_TX_INTR (0x1000)
61#define BD_ENET_TX_LAST (0x0800)
62#define BD_ENET_TX_TC (0x0400)
63#define BD_ENET_TX_DEF (0x0200)
64#define BD_ENET_TX_HB (0x0100)
65#define BD_ENET_TX_LC (0x0080)
66#define BD_ENET_TX_RL (0x0040)
67#define BD_ENET_TX_RCMASK (0x003c)
68#define BD_ENET_TX_UN (0x0002)
69#define BD_ENET_TX_CSL (0x0001)
70#define BD_ENET_TX_STATS (0x03ff) /* All status bits */
71
72/* Buffer descriptor control/status used by Transparent mode SCC.
73 */
74#define BD_SCC_TX_LAST (0x0800)
75
76/* Buffer descriptor control/status used by I2C.
77 */
78#define BD_I2C_START (0x0400)
79
7int cpm_muram_init(void); 80int cpm_muram_init(void);
8unsigned long cpm_muram_alloc(unsigned long size, unsigned long align); 81unsigned long cpm_muram_alloc(unsigned long size, unsigned long align);
9int cpm_muram_free(unsigned long offset); 82int cpm_muram_free(unsigned long offset);
10unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size); 83unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);
11void __iomem *cpm_muram_addr(unsigned long offset); 84void __iomem *cpm_muram_addr(unsigned long offset);
12dma_addr_t cpm_muram_dma(void __iomem *addr); 85dma_addr_t cpm_muram_dma(void __iomem *addr);
86int cpm_command(u32 command, u8 opcode);
13 87
14#endif 88#endif
diff --git a/include/asm-powerpc/commproc.h b/include/asm-powerpc/cpm1.h
index 0307c84a5c1d..b2ebd6ac6dae 100644
--- a/include/asm-powerpc/commproc.h
+++ b/include/asm-powerpc/cpm1.h
@@ -14,8 +14,8 @@
14 * IDMA1 space. The remaining DP RAM is available for buffer descriptors 14 * IDMA1 space. The remaining DP RAM is available for buffer descriptors
15 * or other use. 15 * or other use.
16 */ 16 */
17#ifndef __CPM_8XX__ 17#ifndef __CPM1__
18#define __CPM_8XX__ 18#define __CPM1__
19 19
20#include <asm/8xx_immap.h> 20#include <asm/8xx_immap.h>
21#include <asm/ptrace.h> 21#include <asm/ptrace.h>
@@ -82,42 +82,14 @@ extern int cpm_dpfree(unsigned long offset);
82extern unsigned long cpm_dpalloc_fixed(unsigned long offset, uint size, uint align); 82extern unsigned long cpm_dpalloc_fixed(unsigned long offset, uint size, uint align);
83extern void cpm_dpdump(void); 83extern void cpm_dpdump(void);
84extern void *cpm_dpram_addr(unsigned long offset); 84extern void *cpm_dpram_addr(unsigned long offset);
85extern uint cpm_dpram_phys(u8* addr); 85extern uint cpm_dpram_phys(u8 *addr);
86#endif 86#endif
87 87
88extern void cpm_setbrg(uint brg, uint rate); 88extern void cpm_setbrg(uint brg, uint rate);
89 89
90extern uint m8xx_cpm_hostalloc(uint size); 90extern void cpm_load_patch(cpm8xx_t *cp);
91extern int m8xx_cpm_hostfree(uint start);
92extern void m8xx_cpm_hostdump(void);
93 91
94extern void cpm_load_patch(volatile immap_t *immr); 92extern void cpm_reset(void);
95
96/* Buffer descriptors used by many of the CPM protocols.
97*/
98typedef struct cpm_buf_desc {
99 ushort cbd_sc; /* Status and Control */
100 ushort cbd_datlen; /* Data length in buffer */
101 uint cbd_bufaddr; /* Buffer address in host memory */
102} cbd_t;
103
104#define BD_SC_EMPTY ((ushort)0x8000) /* Receive is empty */
105#define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */
106#define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */
107#define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */
108#define BD_SC_LAST ((ushort)0x0800) /* Last buffer in frame */
109#define BD_SC_TC ((ushort)0x0400) /* Transmit CRC */
110#define BD_SC_CM ((ushort)0x0200) /* Continous mode */
111#define BD_SC_ID ((ushort)0x0100) /* Rec'd too many idles */
112#define BD_SC_P ((ushort)0x0100) /* xmt preamble */
113#define BD_SC_BR ((ushort)0x0020) /* Break received */
114#define BD_SC_FR ((ushort)0x0010) /* Framing error */
115#define BD_SC_PR ((ushort)0x0008) /* Parity error */
116#define BD_SC_NAK ((ushort)0x0004) /* NAK - did not respond */
117#define BD_SC_OV ((ushort)0x0002) /* Overrun */
118#define BD_SC_UN ((ushort)0x0002) /* Underrun */
119#define BD_SC_CD ((ushort)0x0001) /* ?? */
120#define BD_SC_CL ((ushort)0x0001) /* Collision */
121 93
122/* Parameter RAM offsets. 94/* Parameter RAM offsets.
123*/ 95*/
@@ -448,41 +420,6 @@ typedef struct scc_enet {
448#define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */ 420#define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */
449#define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */ 421#define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */
450 422
451/* Buffer descriptor control/status used by Ethernet receive.
452*/
453#define BD_ENET_RX_EMPTY ((ushort)0x8000)
454#define BD_ENET_RX_WRAP ((ushort)0x2000)
455#define BD_ENET_RX_INTR ((ushort)0x1000)
456#define BD_ENET_RX_LAST ((ushort)0x0800)
457#define BD_ENET_RX_FIRST ((ushort)0x0400)
458#define BD_ENET_RX_MISS ((ushort)0x0100)
459#define BD_ENET_RX_LG ((ushort)0x0020)
460#define BD_ENET_RX_NO ((ushort)0x0010)
461#define BD_ENET_RX_SH ((ushort)0x0008)
462#define BD_ENET_RX_CR ((ushort)0x0004)
463#define BD_ENET_RX_OV ((ushort)0x0002)
464#define BD_ENET_RX_CL ((ushort)0x0001)
465#define BD_ENET_RX_BC ((ushort)0x0080) /* DA is Broadcast */
466#define BD_ENET_RX_MC ((ushort)0x0040) /* DA is Multicast */
467#define BD_ENET_RX_STATS ((ushort)0x013f) /* All status bits */
468
469/* Buffer descriptor control/status used by Ethernet transmit.
470*/
471#define BD_ENET_TX_READY ((ushort)0x8000)
472#define BD_ENET_TX_PAD ((ushort)0x4000)
473#define BD_ENET_TX_WRAP ((ushort)0x2000)
474#define BD_ENET_TX_INTR ((ushort)0x1000)
475#define BD_ENET_TX_LAST ((ushort)0x0800)
476#define BD_ENET_TX_TC ((ushort)0x0400)
477#define BD_ENET_TX_DEF ((ushort)0x0200)
478#define BD_ENET_TX_HB ((ushort)0x0100)
479#define BD_ENET_TX_LC ((ushort)0x0080)
480#define BD_ENET_TX_RL ((ushort)0x0040)
481#define BD_ENET_TX_RCMASK ((ushort)0x003c)
482#define BD_ENET_TX_UN ((ushort)0x0002)
483#define BD_ENET_TX_CSL ((ushort)0x0001)
484#define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */
485
486/* SCC as UART 423/* SCC as UART
487*/ 424*/
488typedef struct scc_uart { 425typedef struct scc_uart {
@@ -551,8 +488,6 @@ typedef struct scc_trans {
551 uint st_cmask; /* Constant mask for CRC */ 488 uint st_cmask; /* Constant mask for CRC */
552} scc_trans_t; 489} scc_trans_t;
553 490
554#define BD_SCC_TX_LAST ((ushort)0x0800)
555
556/* IIC parameter RAM. 491/* IIC parameter RAM.
557*/ 492*/
558typedef struct iic { 493typedef struct iic {
@@ -576,8 +511,6 @@ typedef struct iic {
576 char res2[2]; /* Reserved */ 511 char res2[2]; /* Reserved */
577} iic_t; 512} iic_t;
578 513
579#define BD_IIC_START ((ushort)0x0400)
580
581/* SPI parameter RAM. 514/* SPI parameter RAM.
582*/ 515*/
583typedef struct spi { 516typedef struct spi {
@@ -693,14 +626,11 @@ typedef struct risc_timer_pram {
693#define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */ 626#define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */
694#define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */ 627#define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */
695#define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */ 628#define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */
696#define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrrupt */ 629#define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrupt */
697#define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */ 630#define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */
698#define CICR_IEN ((uint)0x00000080) /* Int. enable */ 631#define CICR_IEN ((uint)0x00000080) /* Int. enable */
699#define CICR_SPS ((uint)0x00000001) /* SCC Spread */ 632#define CICR_SPS ((uint)0x00000001) /* SCC Spread */
700 633
701extern void cpm_install_handler(int vec, void (*handler)(void *), void *dev_id);
702extern void cpm_free_handler(int vec);
703
704#define IMAP_ADDR (get_immrbase()) 634#define IMAP_ADDR (get_immrbase())
705 635
706#define CPM_PIN_INPUT 0 636#define CPM_PIN_INPUT 0
@@ -752,4 +682,4 @@ enum cpm_clk {
752 682
753int cpm1_clk_setup(enum cpm_clk_target target, int clock, int mode); 683int cpm1_clk_setup(enum cpm_clk_target target, int clock, int mode);
754 684
755#endif /* __CPM_8XX__ */ 685#endif /* __CPM1__ */
diff --git a/include/asm-powerpc/cpm2.h b/include/asm-powerpc/cpm2.h
index f1112c15ef96..b93a53eb55c1 100644
--- a/include/asm-powerpc/cpm2.h
+++ b/include/asm-powerpc/cpm2.h
@@ -132,29 +132,6 @@ extern void cpm_setbrg(uint brg, uint rate);
132extern void cpm2_fastbrg(uint brg, uint rate, int div16); 132extern void cpm2_fastbrg(uint brg, uint rate, int div16);
133extern void cpm2_reset(void); 133extern void cpm2_reset(void);
134 134
135
136/* Buffer descriptors used by many of the CPM protocols.
137*/
138typedef struct cpm_buf_desc {
139 ushort cbd_sc; /* Status and Control */
140 ushort cbd_datlen; /* Data length in buffer */
141 uint cbd_bufaddr; /* Buffer address in host memory */
142} cbd_t;
143
144#define BD_SC_EMPTY ((ushort)0x8000) /* Receive is empty */
145#define BD_SC_READY ((ushort)0x8000) /* Transmit is ready */
146#define BD_SC_WRAP ((ushort)0x2000) /* Last buffer descriptor */
147#define BD_SC_INTRPT ((ushort)0x1000) /* Interrupt on change */
148#define BD_SC_LAST ((ushort)0x0800) /* Last buffer in frame */
149#define BD_SC_CM ((ushort)0x0200) /* Continous mode */
150#define BD_SC_ID ((ushort)0x0100) /* Rec'd too many idles */
151#define BD_SC_P ((ushort)0x0100) /* xmt preamble */
152#define BD_SC_BR ((ushort)0x0020) /* Break received */
153#define BD_SC_FR ((ushort)0x0010) /* Framing error */
154#define BD_SC_PR ((ushort)0x0008) /* Parity error */
155#define BD_SC_OV ((ushort)0x0002) /* Overrun */
156#define BD_SC_CD ((ushort)0x0001) /* ?? */
157
158/* Function code bits, usually generic to devices. 135/* Function code bits, usually generic to devices.
159*/ 136*/
160#define CPMFCR_GBL ((u_char)0x20) /* Set memory snooping */ 137#define CPMFCR_GBL ((u_char)0x20) /* Set memory snooping */
@@ -456,43 +433,6 @@ typedef struct scc_enet {
456#define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */ 433#define SCC_PSMR_NIB22 ((ushort)0x000a) /* Start frame search */
457#define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */ 434#define SCC_PSMR_FDE ((ushort)0x0001) /* Full duplex enable */
458 435
459/* Buffer descriptor control/status used by Ethernet receive.
460 * Common to SCC and FCC.
461 */
462#define BD_ENET_RX_EMPTY ((ushort)0x8000)
463#define BD_ENET_RX_WRAP ((ushort)0x2000)
464#define BD_ENET_RX_INTR ((ushort)0x1000)
465#define BD_ENET_RX_LAST ((ushort)0x0800)
466#define BD_ENET_RX_FIRST ((ushort)0x0400)
467#define BD_ENET_RX_MISS ((ushort)0x0100)
468#define BD_ENET_RX_BC ((ushort)0x0080) /* FCC Only */
469#define BD_ENET_RX_MC ((ushort)0x0040) /* FCC Only */
470#define BD_ENET_RX_LG ((ushort)0x0020)
471#define BD_ENET_RX_NO ((ushort)0x0010)
472#define BD_ENET_RX_SH ((ushort)0x0008)
473#define BD_ENET_RX_CR ((ushort)0x0004)
474#define BD_ENET_RX_OV ((ushort)0x0002)
475#define BD_ENET_RX_CL ((ushort)0x0001)
476#define BD_ENET_RX_STATS ((ushort)0x01ff) /* All status bits */
477
478/* Buffer descriptor control/status used by Ethernet transmit.
479 * Common to SCC and FCC.
480 */
481#define BD_ENET_TX_READY ((ushort)0x8000)
482#define BD_ENET_TX_PAD ((ushort)0x4000)
483#define BD_ENET_TX_WRAP ((ushort)0x2000)
484#define BD_ENET_TX_INTR ((ushort)0x1000)
485#define BD_ENET_TX_LAST ((ushort)0x0800)
486#define BD_ENET_TX_TC ((ushort)0x0400)
487#define BD_ENET_TX_DEF ((ushort)0x0200)
488#define BD_ENET_TX_HB ((ushort)0x0100)
489#define BD_ENET_TX_LC ((ushort)0x0080)
490#define BD_ENET_TX_RL ((ushort)0x0040)
491#define BD_ENET_TX_RCMASK ((ushort)0x003c)
492#define BD_ENET_TX_UN ((ushort)0x0002)
493#define BD_ENET_TX_CSL ((ushort)0x0001)
494#define BD_ENET_TX_STATS ((ushort)0x03ff) /* All status bits */
495
496/* SCC as UART 436/* SCC as UART
497*/ 437*/
498typedef struct scc_uart { 438typedef struct scc_uart {
@@ -562,8 +502,6 @@ typedef struct scc_trans {
562 uint st_cmask; /* Constant mask for CRC */ 502 uint st_cmask; /* Constant mask for CRC */
563} scc_trans_t; 503} scc_trans_t;
564 504
565#define BD_SCC_TX_LAST ((ushort)0x0800)
566
567/* How about some FCCs..... 505/* How about some FCCs.....
568*/ 506*/
569#define FCC_GFMR_DIAG_NORM ((uint)0x00000000) 507#define FCC_GFMR_DIAG_NORM ((uint)0x00000000)
@@ -769,8 +707,6 @@ typedef struct spi {
769 707
770#define SPI_EB ((u_char)0x10) /* big endian byte order */ 708#define SPI_EB ((u_char)0x10) /* big endian byte order */
771 709
772#define BD_IIC_START ((ushort)0x0400)
773
774/* IDMA parameter RAM 710/* IDMA parameter RAM
775*/ 711*/
776typedef struct idma { 712typedef struct idma {
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index 9d74338e3dec..528ef183c221 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -57,6 +57,14 @@ enum powerpc_pmc_type {
57 PPC_PMC_PA6T = 2, 57 PPC_PMC_PA6T = 2,
58}; 58};
59 59
60struct pt_regs;
61
62extern int machine_check_generic(struct pt_regs *regs);
63extern int machine_check_4xx(struct pt_regs *regs);
64extern int machine_check_440A(struct pt_regs *regs);
65extern int machine_check_e500(struct pt_regs *regs);
66extern int machine_check_e200(struct pt_regs *regs);
67
60/* NOTE WELL: Update identify_cpu() if fields are added or removed! */ 68/* NOTE WELL: Update identify_cpu() if fields are added or removed! */
61struct cpu_spec { 69struct cpu_spec {
62 /* CPU is matched via (PVR & pvr_mask) == pvr_value */ 70 /* CPU is matched via (PVR & pvr_mask) == pvr_value */
@@ -97,6 +105,11 @@ struct cpu_spec {
97 105
98 /* Name of processor class, for the ELF AT_PLATFORM entry */ 106 /* Name of processor class, for the ELF AT_PLATFORM entry */
99 char *platform; 107 char *platform;
108
109 /* Processor specific machine check handling. Return negative
110 * if the error is fatal, 1 if it was fully recovered and 0 to
111 * pass up (not CPU originated) */
112 int (*machine_check)(struct pt_regs *regs);
100}; 113};
101 114
102extern struct cpu_spec *cur_cpu_spec; 115extern struct cpu_spec *cur_cpu_spec;
@@ -138,6 +151,7 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
138#define CPU_FTR_FPU_UNAVAILABLE ASM_CONST(0x0000000000800000) 151#define CPU_FTR_FPU_UNAVAILABLE ASM_CONST(0x0000000000800000)
139#define CPU_FTR_UNIFIED_ID_CACHE ASM_CONST(0x0000000001000000) 152#define CPU_FTR_UNIFIED_ID_CACHE ASM_CONST(0x0000000001000000)
140#define CPU_FTR_SPE ASM_CONST(0x0000000002000000) 153#define CPU_FTR_SPE ASM_CONST(0x0000000002000000)
154#define CPU_FTR_NEED_PAIRED_STWCX ASM_CONST(0x0000000004000000)
141 155
142/* 156/*
143 * Add the 64-bit processor unique features in the top half of the word; 157 * Add the 64-bit processor unique features in the top half of the word;
@@ -261,25 +275,25 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
261#define CPU_FTRS_7450_20 (CPU_FTR_COMMON | \ 275#define CPU_FTRS_7450_20 (CPU_FTR_COMMON | \
262 CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 276 CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
263 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 277 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
264 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE) 278 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE | CPU_FTR_NEED_PAIRED_STWCX)
265#define CPU_FTRS_7450_21 (CPU_FTR_COMMON | \ 279#define CPU_FTRS_7450_21 (CPU_FTR_COMMON | \
266 CPU_FTR_USE_TB | \ 280 CPU_FTR_USE_TB | \
267 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 281 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
268 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 282 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
269 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP | \ 283 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP | \
270 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE) 284 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE | CPU_FTR_NEED_PAIRED_STWCX)
271#define CPU_FTRS_7450_23 (CPU_FTR_COMMON | \ 285#define CPU_FTRS_7450_23 (CPU_FTR_COMMON | \
272 CPU_FTR_USE_TB | \ 286 CPU_FTR_USE_TB | CPU_FTR_NEED_PAIRED_STWCX | \
273 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 287 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
274 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 288 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
275 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE) 289 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE)
276#define CPU_FTRS_7455_1 (CPU_FTR_COMMON | \ 290#define CPU_FTRS_7455_1 (CPU_FTR_COMMON | \
277 CPU_FTR_USE_TB | \ 291 CPU_FTR_USE_TB | CPU_FTR_NEED_PAIRED_STWCX | \
278 CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR | \ 292 CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR | \
279 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_HAS_HIGH_BATS | \ 293 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_HAS_HIGH_BATS | \
280 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE) 294 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE)
281#define CPU_FTRS_7455_20 (CPU_FTR_COMMON | \ 295#define CPU_FTRS_7455_20 (CPU_FTR_COMMON | \
282 CPU_FTR_USE_TB | \ 296 CPU_FTR_USE_TB | CPU_FTR_NEED_PAIRED_STWCX | \
283 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 297 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
284 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 298 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
285 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP | \ 299 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP | \
@@ -289,31 +303,32 @@ extern void do_feature_fixups(unsigned long value, void *fixup_start,
289 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 303 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
290 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 304 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
291 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \ 305 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \
292 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE) 306 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE | CPU_FTR_NEED_PAIRED_STWCX)
293#define CPU_FTRS_7447_10 (CPU_FTR_COMMON | \ 307#define CPU_FTRS_7447_10 (CPU_FTR_COMMON | \
294 CPU_FTR_USE_TB | \ 308 CPU_FTR_USE_TB | \
295 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 309 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
296 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 310 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
297 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \ 311 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \
298 CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC | CPU_FTR_PPC_LE) 312 CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC | CPU_FTR_PPC_LE | \
313 CPU_FTR_NEED_PAIRED_STWCX)
299#define CPU_FTRS_7447 (CPU_FTR_COMMON | \ 314#define CPU_FTRS_7447 (CPU_FTR_COMMON | \
300 CPU_FTR_USE_TB | \ 315 CPU_FTR_USE_TB | \
301 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 316 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
302 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 317 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
303 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \ 318 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \
304 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE) 319 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE | CPU_FTR_NEED_PAIRED_STWCX)
305#define CPU_FTRS_7447A (CPU_FTR_COMMON | \ 320#define CPU_FTRS_7447A (CPU_FTR_COMMON | \
306 CPU_FTR_USE_TB | \ 321 CPU_FTR_USE_TB | \
307 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 322 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
308 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 323 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
309 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \ 324 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \
310 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE) 325 CPU_FTR_NEED_COHERENT | CPU_FTR_PPC_LE | CPU_FTR_NEED_PAIRED_STWCX)
311#define CPU_FTRS_7448 (CPU_FTR_COMMON | \ 326#define CPU_FTRS_7448 (CPU_FTR_COMMON | \
312 CPU_FTR_USE_TB | \ 327 CPU_FTR_USE_TB | \
313 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \ 328 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | \
314 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \ 329 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | \
315 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \ 330 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS | \
316 CPU_FTR_PPC_LE) 331 CPU_FTR_PPC_LE | CPU_FTR_NEED_PAIRED_STWCX)
317#define CPU_FTRS_82XX (CPU_FTR_COMMON | \ 332#define CPU_FTRS_82XX (CPU_FTR_COMMON | \
318 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB) 333 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB)
319#define CPU_FTRS_G2_LE (CPU_FTR_COMMON | CPU_FTR_MAYBE_CAN_DOZE | \ 334#define CPU_FTRS_G2_LE (CPU_FTR_COMMON | CPU_FTR_MAYBE_CAN_DOZE | \
diff --git a/include/asm-powerpc/cputhreads.h b/include/asm-powerpc/cputhreads.h
new file mode 100644
index 000000000000..8485c28b5f47
--- /dev/null
+++ b/include/asm-powerpc/cputhreads.h
@@ -0,0 +1,71 @@
1#ifndef _ASM_POWERPC_CPUTHREADS_H
2#define _ASM_POWERPC_CPUTHREADS_H
3
4#include <linux/cpumask.h>
5
6/*
7 * Mapping of threads to cores
8 */
9
10#ifdef CONFIG_SMP
11extern int threads_per_core;
12extern int threads_shift;
13extern cpumask_t threads_core_mask;
14#else
15#define threads_per_core 1
16#define threads_shift 0
17#define threads_core_mask (CPU_MASK_CPU0)
18#endif
19
20/* cpu_thread_mask_to_cores - Return a cpumask of one per cores
21 * hit by the argument
22 *
23 * @threads: a cpumask of threads
24 *
25 * This function returns a cpumask which will have one "cpu" (or thread)
26 * bit set for each core that has at least one thread set in the argument.
27 *
28 * This can typically be used for things like IPI for tlb invalidations
29 * since those need to be done only once per core/TLB
30 */
31static inline cpumask_t cpu_thread_mask_to_cores(cpumask_t threads)
32{
33 cpumask_t tmp, res;
34 int i;
35
36 res = CPU_MASK_NONE;
37 for (i = 0; i < NR_CPUS; i += threads_per_core) {
38 cpus_shift_right(tmp, threads_core_mask, i);
39 if (cpus_intersects(threads, tmp))
40 cpu_set(i, res);
41 }
42 return res;
43}
44
45static inline int cpu_nr_cores(void)
46{
47 return NR_CPUS >> threads_shift;
48}
49
50static inline cpumask_t cpu_online_cores_map(void)
51{
52 return cpu_thread_mask_to_cores(cpu_online_map);
53}
54
55static inline int cpu_thread_to_core(int cpu)
56{
57 return cpu >> threads_shift;
58}
59
60static inline int cpu_thread_in_core(int cpu)
61{
62 return cpu & (threads_per_core - 1);
63}
64
65static inline int cpu_first_thread_in_core(int cpu)
66{
67 return cpu & ~(threads_per_core - 1);
68}
69
70#endif /* _ASM_POWERPC_CPUTHREADS_H */
71
diff --git a/include/asm-powerpc/dcr-native.h b/include/asm-powerpc/dcr-native.h
index 8dbb1ab0aa04..af5fb31af559 100644
--- a/include/asm-powerpc/dcr-native.h
+++ b/include/asm-powerpc/dcr-native.h
@@ -22,6 +22,8 @@
22#ifdef __KERNEL__ 22#ifdef __KERNEL__
23#ifndef __ASSEMBLY__ 23#ifndef __ASSEMBLY__
24 24
25#include <linux/spinlock.h>
26
25typedef struct { 27typedef struct {
26 unsigned int base; 28 unsigned int base;
27} dcr_host_t; 29} dcr_host_t;
@@ -55,20 +57,28 @@ do { \
55} while (0) 57} while (0)
56 58
57/* R/W of indirect DCRs make use of standard naming conventions for DCRs */ 59/* R/W of indirect DCRs make use of standard naming conventions for DCRs */
58#define mfdcri(base, reg) \ 60extern spinlock_t dcr_ind_lock;
59({ \ 61
60 mtdcr(base ## _CFGADDR, base ## _ ## reg); \ 62#define mfdcri(base, reg) \
61 mfdcr(base ## _CFGDATA); \ 63({ \
64 unsigned long flags; \
65 unsigned int val; \
66 spin_lock_irqsave(&dcr_ind_lock, flags); \
67 mtdcr(DCRN_ ## base ## _CONFIG_ADDR, reg); \
68 val = mfdcr(DCRN_ ## base ## _CONFIG_DATA); \
69 spin_unlock_irqrestore(&dcr_ind_lock, flags); \
70 val; \
62}) 71})
63 72
64#define mtdcri(base, reg, data) \ 73#define mtdcri(base, reg, data) \
65do { \ 74do { \
66 mtdcr(base ## _CFGADDR, base ## _ ## reg); \ 75 unsigned long flags; \
67 mtdcr(base ## _CFGDATA, data); \ 76 spin_lock_irqsave(&dcr_ind_lock, flags); \
77 mtdcr(DCRN_ ## base ## _CONFIG_ADDR, reg); \
78 mtdcr(DCRN_ ## base ## _CONFIG_DATA, data); \
79 spin_unlock_irqrestore(&dcr_ind_lock, flags); \
68} while (0) 80} while (0)
69 81
70#endif /* __ASSEMBLY__ */ 82#endif /* __ASSEMBLY__ */
71#endif /* __KERNEL__ */ 83#endif /* __KERNEL__ */
72#endif /* _ASM_POWERPC_DCR_NATIVE_H */ 84#endif /* _ASM_POWERPC_DCR_NATIVE_H */
73
74
diff --git a/include/asm-powerpc/dcr-regs.h b/include/asm-powerpc/dcr-regs.h
new file mode 100644
index 000000000000..9f1fb98fcdc6
--- /dev/null
+++ b/include/asm-powerpc/dcr-regs.h
@@ -0,0 +1,71 @@
1/*
2 * Common DCR / SDR / CPR register definitions used on various IBM/AMCC
3 * 4xx processors
4 *
5 * Copyright 2007 Benjamin Herrenschmidt, IBM Corp
6 * <benh@kernel.crashing.org>
7 *
8 * Mostly lifted from asm-ppc/ibm4xx.h by
9 *
10 * Copyright (c) 1999 Grant Erickson <grant@lcse.umn.edu>
11 *
12 */
13
14#ifndef __DCR_REGS_H__
15#define __DCR_REGS_H__
16
17/*
18 * Most DCRs used for controlling devices such as the MAL, DMA engine,
19 * etc... are obtained for the device tree.
20 *
21 * The definitions in this files are fixed DCRs and indirect DCRs that
22 * are commonly used outside of specific drivers or refer to core
23 * common registers that may occasionally have to be tweaked outside
24 * of the driver main register set
25 */
26
27/* CPRs (440GX and 440SP/440SPe) */
28#define DCRN_CPR0_CONFIG_ADDR 0xc
29#define DCRN_CPR0_CONFIG_DATA 0xd
30
31/* SDRs (440GX and 440SP/440SPe) */
32#define DCRN_SDR0_CONFIG_ADDR 0xe
33#define DCRN_SDR0_CONFIG_DATA 0xf
34
35#define SDR0_PFC0 0x4100
36#define SDR0_PFC1 0x4101
37#define SDR0_PFC1_EPS 0x1c00000
38#define SDR0_PFC1_EPS_SHIFT 22
39#define SDR0_PFC1_RMII 0x02000000
40#define SDR0_MFR 0x4300
41#define SDR0_MFR_TAH0 0x80000000 /* TAHOE0 Enable */
42#define SDR0_MFR_TAH1 0x40000000 /* TAHOE1 Enable */
43#define SDR0_MFR_PCM 0x10000000 /* PPC440GP irq compat mode */
44#define SDR0_MFR_ECS 0x08000000 /* EMAC int clk */
45#define SDR0_MFR_T0TXFL 0x00080000
46#define SDR0_MFR_T0TXFH 0x00040000
47#define SDR0_MFR_T1TXFL 0x00020000
48#define SDR0_MFR_T1TXFH 0x00010000
49#define SDR0_MFR_E0TXFL 0x00008000
50#define SDR0_MFR_E0TXFH 0x00004000
51#define SDR0_MFR_E0RXFL 0x00002000
52#define SDR0_MFR_E0RXFH 0x00001000
53#define SDR0_MFR_E1TXFL 0x00000800
54#define SDR0_MFR_E1TXFH 0x00000400
55#define SDR0_MFR_E1RXFL 0x00000200
56#define SDR0_MFR_E1RXFH 0x00000100
57#define SDR0_MFR_E2TXFL 0x00000080
58#define SDR0_MFR_E2TXFH 0x00000040
59#define SDR0_MFR_E2RXFL 0x00000020
60#define SDR0_MFR_E2RXFH 0x00000010
61#define SDR0_MFR_E3TXFL 0x00000008
62#define SDR0_MFR_E3TXFH 0x00000004
63#define SDR0_MFR_E3RXFL 0x00000002
64#define SDR0_MFR_E3RXFH 0x00000001
65#define SDR0_UART0 0x0120
66#define SDR0_UART1 0x0121
67#define SDR0_UART2 0x0122
68#define SDR0_UART3 0x0123
69#define SDR0_CUST0 0x4000
70
71#endif /* __DCR_REGS_H__ */
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
index ff52013c0e2d..bbefb69bfb67 100644
--- a/include/asm-powerpc/dma-mapping.h
+++ b/include/asm-powerpc/dma-mapping.h
@@ -76,6 +76,11 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
76 return dev->archdata.dma_ops; 76 return dev->archdata.dma_ops;
77} 77}
78 78
79static inline void set_dma_ops(struct device *dev, struct dma_mapping_ops *ops)
80{
81 dev->archdata.dma_ops = ops;
82}
83
79static inline int dma_supported(struct device *dev, u64 mask) 84static inline int dma_supported(struct device *dev, u64 mask)
80{ 85{
81 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 86 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
@@ -87,6 +92,9 @@ static inline int dma_supported(struct device *dev, u64 mask)
87 return dma_ops->dma_supported(dev, mask); 92 return dma_ops->dma_supported(dev, mask);
88} 93}
89 94
95/* We have our own implementation of pci_set_dma_mask() */
96#define HAVE_ARCH_PCI_SET_DMA_MASK
97
90static inline int dma_set_mask(struct device *dev, u64 dma_mask) 98static inline int dma_set_mask(struct device *dev, u64 dma_mask)
91{ 99{
92 struct dma_mapping_ops *dma_ops = get_dma_ops(dev); 100 struct dma_mapping_ops *dma_ops = get_dma_ops(dev);
@@ -186,8 +194,6 @@ static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
186extern struct dma_mapping_ops dma_iommu_ops; 194extern struct dma_mapping_ops dma_iommu_ops;
187extern struct dma_mapping_ops dma_direct_ops; 195extern struct dma_mapping_ops dma_direct_ops;
188 196
189extern unsigned long dma_direct_offset;
190
191#else /* CONFIG_PPC64 */ 197#else /* CONFIG_PPC64 */
192 198
193#define dma_supported(dev, mask) (1) 199#define dma_supported(dev, mask) (1)
diff --git a/include/asm-powerpc/firmware.h b/include/asm-powerpc/firmware.h
index 3671c128f271..1e41bd1c8502 100644
--- a/include/asm-powerpc/firmware.h
+++ b/include/asm-powerpc/firmware.h
@@ -64,7 +64,7 @@ enum {
64 FW_FEATURE_PS3_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1, 64 FW_FEATURE_PS3_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
65 FW_FEATURE_PS3_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1, 65 FW_FEATURE_PS3_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_PS3_LV1,
66 FW_FEATURE_CELLEB_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_BEAT, 66 FW_FEATURE_CELLEB_POSSIBLE = FW_FEATURE_LPAR | FW_FEATURE_BEAT,
67 FW_FEATURE_CELLEB_ALWAYS = FW_FEATURE_LPAR | FW_FEATURE_BEAT, 67 FW_FEATURE_CELLEB_ALWAYS = 0,
68 FW_FEATURE_NATIVE_POSSIBLE = 0, 68 FW_FEATURE_NATIVE_POSSIBLE = 0,
69 FW_FEATURE_NATIVE_ALWAYS = 0, 69 FW_FEATURE_NATIVE_ALWAYS = 0,
70 FW_FEATURE_POSSIBLE = 70 FW_FEATURE_POSSIBLE =
diff --git a/include/asm-powerpc/ide.h b/include/asm-powerpc/ide.h
index fd7f5a430f0a..6d50310ecaea 100644
--- a/include/asm-powerpc/ide.h
+++ b/include/asm-powerpc/ide.h
@@ -42,9 +42,6 @@ struct ide_machdep_calls {
42 42
43extern struct ide_machdep_calls ppc_ide_md; 43extern struct ide_machdep_calls ppc_ide_md;
44 44
45#undef SUPPORT_SLOW_DATA_PORTS
46#define SUPPORT_SLOW_DATA_PORTS 0
47
48#define IDE_ARCH_OBSOLETE_DEFAULTS 45#define IDE_ARCH_OBSOLETE_DEFAULTS
49 46
50static __inline__ int ide_default_irq(unsigned long base) 47static __inline__ int ide_default_irq(unsigned long base)
diff --git a/include/asm-powerpc/immap_86xx.h b/include/asm-powerpc/immap_86xx.h
index 0ad4e653d464..0f165e59c326 100644
--- a/include/asm-powerpc/immap_86xx.h
+++ b/include/asm-powerpc/immap_86xx.h
@@ -89,14 +89,14 @@ struct ccsr_guts {
89 * them. 89 * them.
90 * 90 *
91 * guts: Pointer to GUTS structure 91 * guts: Pointer to GUTS structure
92 * co: The DMA controller (1 or 2) 92 * co: The DMA controller (0 or 1)
93 * ch: The channel on the DMA controller (0, 1, 2, or 3) 93 * ch: The channel on the DMA controller (0, 1, 2, or 3)
94 * device: The device to set as the source (CCSR_GUTS_DMACR_DEV_xx) 94 * device: The device to set as the source (CCSR_GUTS_DMACR_DEV_xx)
95 */ 95 */
96static inline void guts_set_dmacr(struct ccsr_guts __iomem *guts, 96static inline void guts_set_dmacr(struct ccsr_guts __iomem *guts,
97 unsigned int co, unsigned int ch, unsigned int device) 97 unsigned int co, unsigned int ch, unsigned int device)
98{ 98{
99 unsigned int shift = 16 + (8 * (2 - co) + 2 * (3 - ch)); 99 unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch));
100 100
101 clrsetbits_be32(&guts->dmacr, 3 << shift, device << shift); 101 clrsetbits_be32(&guts->dmacr, 3 << shift, device << shift);
102} 102}
@@ -118,6 +118,27 @@ static inline void guts_set_dmacr(struct ccsr_guts __iomem *guts,
118#define CCSR_GUTS_PMUXCR_DMA1_0 0x00000002 118#define CCSR_GUTS_PMUXCR_DMA1_0 0x00000002
119#define CCSR_GUTS_PMUXCR_DMA1_3 0x00000001 119#define CCSR_GUTS_PMUXCR_DMA1_3 0x00000001
120 120
121/*
122 * Set the DMA external control bits in the GUTS
123 *
124 * The DMA external control bits in the PMUXCR are only meaningful for
125 * channels 0 and 3. Any other channels are ignored.
126 *
127 * guts: Pointer to GUTS structure
128 * co: The DMA controller (0 or 1)
129 * ch: The channel on the DMA controller (0, 1, 2, or 3)
130 * value: the new value for the bit (0 or 1)
131 */
132static inline void guts_set_pmuxcr_dma(struct ccsr_guts __iomem *guts,
133 unsigned int co, unsigned int ch, unsigned int value)
134{
135 if ((ch == 0) || (ch == 3)) {
136 unsigned int shift = 2 * (co + 1) - (ch & 1) - 1;
137
138 clrsetbits_be32(&guts->pmuxcr, 1 << shift, value << shift);
139 }
140}
141
121#define CCSR_GUTS_CLKDVDR_PXCKEN 0x80000000 142#define CCSR_GUTS_CLKDVDR_PXCKEN 0x80000000
122#define CCSR_GUTS_CLKDVDR_SSICKEN 0x20000000 143#define CCSR_GUTS_CLKDVDR_SSICKEN 0x20000000
123#define CCSR_GUTS_CLKDVDR_PXCKINV 0x10000000 144#define CCSR_GUTS_CLKDVDR_PXCKINV 0x10000000
diff --git a/include/asm-powerpc/immap_qe.h b/include/asm-powerpc/immap_qe.h
index aba9806b31c9..82a452615097 100644
--- a/include/asm-powerpc/immap_qe.h
+++ b/include/asm-powerpc/immap_qe.h
@@ -393,9 +393,39 @@ struct dbg {
393 u8 res2[0x48]; 393 u8 res2[0x48];
394} __attribute__ ((packed)); 394} __attribute__ ((packed));
395 395
396/* RISC Special Registers (Trap and Breakpoint) */ 396/*
397 * RISC Special Registers (Trap and Breakpoint). These are described in
398 * the QE Developer's Handbook.
399 */
397struct rsp { 400struct rsp {
398 u32 reg[0x40]; /* 64 32-bit registers */ 401 __be32 tibcr[16]; /* Trap/instruction breakpoint control regs */
402 u8 res0[64];
403 __be32 ibcr0;
404 __be32 ibs0;
405 __be32 ibcnr0;
406 u8 res1[4];
407 __be32 ibcr1;
408 __be32 ibs1;
409 __be32 ibcnr1;
410 __be32 npcr;
411 __be32 dbcr;
412 __be32 dbar;
413 __be32 dbamr;
414 __be32 dbsr;
415 __be32 dbcnr;
416 u8 res2[12];
417 __be32 dbdr_h;
418 __be32 dbdr_l;
419 __be32 dbdmr_h;
420 __be32 dbdmr_l;
421 __be32 bsr;
422 __be32 bor;
423 __be32 bior;
424 u8 res3[4];
425 __be32 iatr[4];
426 __be32 eccr; /* Exception control configuration register */
427 __be32 eicr;
428 u8 res4[0x100-0xf8];
399} __attribute__ ((packed)); 429} __attribute__ ((packed));
400 430
401struct qe_immap { 431struct qe_immap {
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
index e44cdfc8493a..7be26f615755 100644
--- a/include/asm-powerpc/io.h
+++ b/include/asm-powerpc/io.h
@@ -50,15 +50,16 @@ extern int check_legacy_ioport(unsigned long base_port);
50#define PCI_DRAM_OFFSET pci_dram_offset 50#define PCI_DRAM_OFFSET pci_dram_offset
51#else 51#else
52#define _IO_BASE pci_io_base 52#define _IO_BASE pci_io_base
53#define _ISA_MEM_BASE 0 53#define _ISA_MEM_BASE isa_mem_base
54#define PCI_DRAM_OFFSET 0 54#define PCI_DRAM_OFFSET 0
55#endif 55#endif
56 56
57extern unsigned long isa_io_base; 57extern unsigned long isa_io_base;
58extern unsigned long isa_mem_base;
59extern unsigned long pci_io_base; 58extern unsigned long pci_io_base;
60extern unsigned long pci_dram_offset; 59extern unsigned long pci_dram_offset;
61 60
61extern resource_size_t isa_mem_base;
62
62#if defined(CONFIG_PPC32) && defined(CONFIG_PPC_INDIRECT_IO) 63#if defined(CONFIG_PPC32) && defined(CONFIG_PPC_INDIRECT_IO)
63#error CONFIG_PPC_INDIRECT_IO is not yet supported on 32 bits 64#error CONFIG_PPC_INDIRECT_IO is not yet supported on 32 bits
64#endif 65#endif
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
index 4a82fdccee92..7a3cef785abd 100644
--- a/include/asm-powerpc/iommu.h
+++ b/include/asm-powerpc/iommu.h
@@ -69,10 +69,9 @@ struct iommu_table {
69}; 69};
70 70
71struct scatterlist; 71struct scatterlist;
72struct device_node;
73 72
74/* Frees table for an individual device node */ 73/* Frees table for an individual device node */
75extern void iommu_free_table(struct device_node *dn); 74extern void iommu_free_table(struct iommu_table *tbl, const char *node_name);
76 75
77/* Initializes an iommu_table based in values set in the passed-in 76/* Initializes an iommu_table based in values set in the passed-in
78 * structure 77 * structure
diff --git a/include/asm-powerpc/ipic.h b/include/asm-powerpc/ipic.h
index edec79dcb7c1..8ff08be00146 100644
--- a/include/asm-powerpc/ipic.h
+++ b/include/asm-powerpc/ipic.h
@@ -20,11 +20,13 @@
20 20
21/* Flags when we init the IPIC */ 21/* Flags when we init the IPIC */
22#define IPIC_SPREADMODE_GRP_A 0x00000001 22#define IPIC_SPREADMODE_GRP_A 0x00000001
23#define IPIC_SPREADMODE_GRP_D 0x00000002 23#define IPIC_SPREADMODE_GRP_B 0x00000002
24#define IPIC_SPREADMODE_MIX_A 0x00000004 24#define IPIC_SPREADMODE_GRP_C 0x00000004
25#define IPIC_SPREADMODE_MIX_B 0x00000008 25#define IPIC_SPREADMODE_GRP_D 0x00000008
26#define IPIC_DISABLE_MCP_OUT 0x00000010 26#define IPIC_SPREADMODE_MIX_A 0x00000010
27#define IPIC_IRQ0_MCP 0x00000020 27#define IPIC_SPREADMODE_MIX_B 0x00000020
28#define IPIC_DISABLE_MCP_OUT 0x00000040
29#define IPIC_IRQ0_MCP 0x00000080
28 30
29/* IPIC registers offsets */ 31/* IPIC registers offsets */
30#define IPIC_SICFR 0x00 /* System Global Interrupt Configuration Register */ 32#define IPIC_SICFR 0x00 /* System Global Interrupt Configuration Register */
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index 1392db456523..b5c03127a9b9 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -483,218 +483,6 @@ static __inline__ int irq_canonicalize(int irq)
483 */ 483 */
484#define mk_int_int_mask(IL) (1 << (7 - (IL/2))) 484#define mk_int_int_mask(IL) (1 << (7 - (IL/2)))
485 485
486#elif defined(CONFIG_83xx)
487#include <asm/mpc83xx.h>
488
489#define NR_IRQS (NR_IPIC_INTS)
490
491#elif defined(CONFIG_85xx)
492/* Now include the board configuration specific associations.
493*/
494#include <asm/mpc85xx.h>
495
496/* The MPC8548 openpic has 48 internal interrupts and 12 external
497 * interrupts.
498 *
499 * We are "flattening" the interrupt vectors of the cascaded CPM
500 * so that we can uniquely identify any interrupt source with a
501 * single integer.
502 */
503#define NR_CPM_INTS 64
504#define NR_EPIC_INTS 60
505#ifndef NR_8259_INTS
506#define NR_8259_INTS 0
507#endif
508#define NUM_8259_INTERRUPTS NR_8259_INTS
509
510#ifndef CPM_IRQ_OFFSET
511#define CPM_IRQ_OFFSET 0
512#endif
513
514#define NR_IRQS (NR_EPIC_INTS + NR_CPM_INTS + NR_8259_INTS)
515
516/* Internal IRQs on MPC85xx OpenPIC */
517
518#ifndef MPC85xx_OPENPIC_IRQ_OFFSET
519#ifdef CONFIG_CPM2
520#define MPC85xx_OPENPIC_IRQ_OFFSET (CPM_IRQ_OFFSET + NR_CPM_INTS)
521#else
522#define MPC85xx_OPENPIC_IRQ_OFFSET 0
523#endif
524#endif
525
526/* Not all of these exist on all MPC85xx implementations */
527#define MPC85xx_IRQ_L2CACHE ( 0 + MPC85xx_OPENPIC_IRQ_OFFSET)
528#define MPC85xx_IRQ_ECM ( 1 + MPC85xx_OPENPIC_IRQ_OFFSET)
529#define MPC85xx_IRQ_DDR ( 2 + MPC85xx_OPENPIC_IRQ_OFFSET)
530#define MPC85xx_IRQ_LBIU ( 3 + MPC85xx_OPENPIC_IRQ_OFFSET)
531#define MPC85xx_IRQ_DMA0 ( 4 + MPC85xx_OPENPIC_IRQ_OFFSET)
532#define MPC85xx_IRQ_DMA1 ( 5 + MPC85xx_OPENPIC_IRQ_OFFSET)
533#define MPC85xx_IRQ_DMA2 ( 6 + MPC85xx_OPENPIC_IRQ_OFFSET)
534#define MPC85xx_IRQ_DMA3 ( 7 + MPC85xx_OPENPIC_IRQ_OFFSET)
535#define MPC85xx_IRQ_PCI1 ( 8 + MPC85xx_OPENPIC_IRQ_OFFSET)
536#define MPC85xx_IRQ_PCI2 ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET)
537#define MPC85xx_IRQ_RIO_ERROR ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET)
538#define MPC85xx_IRQ_RIO_BELL (10 + MPC85xx_OPENPIC_IRQ_OFFSET)
539#define MPC85xx_IRQ_RIO_TX (11 + MPC85xx_OPENPIC_IRQ_OFFSET)
540#define MPC85xx_IRQ_RIO_RX (12 + MPC85xx_OPENPIC_IRQ_OFFSET)
541#define MPC85xx_IRQ_TSEC1_TX (13 + MPC85xx_OPENPIC_IRQ_OFFSET)
542#define MPC85xx_IRQ_TSEC1_RX (14 + MPC85xx_OPENPIC_IRQ_OFFSET)
543#define MPC85xx_IRQ_TSEC3_TX (15 + MPC85xx_OPENPIC_IRQ_OFFSET)
544#define MPC85xx_IRQ_TSEC3_RX (16 + MPC85xx_OPENPIC_IRQ_OFFSET)
545#define MPC85xx_IRQ_TSEC3_ERROR (17 + MPC85xx_OPENPIC_IRQ_OFFSET)
546#define MPC85xx_IRQ_TSEC1_ERROR (18 + MPC85xx_OPENPIC_IRQ_OFFSET)
547#define MPC85xx_IRQ_TSEC2_TX (19 + MPC85xx_OPENPIC_IRQ_OFFSET)
548#define MPC85xx_IRQ_TSEC2_RX (20 + MPC85xx_OPENPIC_IRQ_OFFSET)
549#define MPC85xx_IRQ_TSEC4_TX (21 + MPC85xx_OPENPIC_IRQ_OFFSET)
550#define MPC85xx_IRQ_TSEC4_RX (22 + MPC85xx_OPENPIC_IRQ_OFFSET)
551#define MPC85xx_IRQ_TSEC4_ERROR (23 + MPC85xx_OPENPIC_IRQ_OFFSET)
552#define MPC85xx_IRQ_TSEC2_ERROR (24 + MPC85xx_OPENPIC_IRQ_OFFSET)
553#define MPC85xx_IRQ_FEC (25 + MPC85xx_OPENPIC_IRQ_OFFSET)
554#define MPC85xx_IRQ_DUART (26 + MPC85xx_OPENPIC_IRQ_OFFSET)
555#define MPC85xx_IRQ_IIC1 (27 + MPC85xx_OPENPIC_IRQ_OFFSET)
556#define MPC85xx_IRQ_PERFMON (28 + MPC85xx_OPENPIC_IRQ_OFFSET)
557#define MPC85xx_IRQ_SEC2 (29 + MPC85xx_OPENPIC_IRQ_OFFSET)
558#define MPC85xx_IRQ_CPM (30 + MPC85xx_OPENPIC_IRQ_OFFSET)
559
560/* The 12 external interrupt lines */
561#define MPC85xx_IRQ_EXT0 (48 + MPC85xx_OPENPIC_IRQ_OFFSET)
562#define MPC85xx_IRQ_EXT1 (49 + MPC85xx_OPENPIC_IRQ_OFFSET)
563#define MPC85xx_IRQ_EXT2 (50 + MPC85xx_OPENPIC_IRQ_OFFSET)
564#define MPC85xx_IRQ_EXT3 (51 + MPC85xx_OPENPIC_IRQ_OFFSET)
565#define MPC85xx_IRQ_EXT4 (52 + MPC85xx_OPENPIC_IRQ_OFFSET)
566#define MPC85xx_IRQ_EXT5 (53 + MPC85xx_OPENPIC_IRQ_OFFSET)
567#define MPC85xx_IRQ_EXT6 (54 + MPC85xx_OPENPIC_IRQ_OFFSET)
568#define MPC85xx_IRQ_EXT7 (55 + MPC85xx_OPENPIC_IRQ_OFFSET)
569#define MPC85xx_IRQ_EXT8 (56 + MPC85xx_OPENPIC_IRQ_OFFSET)
570#define MPC85xx_IRQ_EXT9 (57 + MPC85xx_OPENPIC_IRQ_OFFSET)
571#define MPC85xx_IRQ_EXT10 (58 + MPC85xx_OPENPIC_IRQ_OFFSET)
572#define MPC85xx_IRQ_EXT11 (59 + MPC85xx_OPENPIC_IRQ_OFFSET)
573
574/* CPM related interrupts */
575#define SIU_INT_ERROR ((uint)0x00+CPM_IRQ_OFFSET)
576#define SIU_INT_I2C ((uint)0x01+CPM_IRQ_OFFSET)
577#define SIU_INT_SPI ((uint)0x02+CPM_IRQ_OFFSET)
578#define SIU_INT_RISC ((uint)0x03+CPM_IRQ_OFFSET)
579#define SIU_INT_SMC1 ((uint)0x04+CPM_IRQ_OFFSET)
580#define SIU_INT_SMC2 ((uint)0x05+CPM_IRQ_OFFSET)
581#define SIU_INT_USB ((uint)0x0b+CPM_IRQ_OFFSET)
582#define SIU_INT_TIMER1 ((uint)0x0c+CPM_IRQ_OFFSET)
583#define SIU_INT_TIMER2 ((uint)0x0d+CPM_IRQ_OFFSET)
584#define SIU_INT_TIMER3 ((uint)0x0e+CPM_IRQ_OFFSET)
585#define SIU_INT_TIMER4 ((uint)0x0f+CPM_IRQ_OFFSET)
586#define SIU_INT_FCC1 ((uint)0x20+CPM_IRQ_OFFSET)
587#define SIU_INT_FCC2 ((uint)0x21+CPM_IRQ_OFFSET)
588#define SIU_INT_FCC3 ((uint)0x22+CPM_IRQ_OFFSET)
589#define SIU_INT_MCC1 ((uint)0x24+CPM_IRQ_OFFSET)
590#define SIU_INT_MCC2 ((uint)0x25+CPM_IRQ_OFFSET)
591#define SIU_INT_SCC1 ((uint)0x28+CPM_IRQ_OFFSET)
592#define SIU_INT_SCC2 ((uint)0x29+CPM_IRQ_OFFSET)
593#define SIU_INT_SCC3 ((uint)0x2a+CPM_IRQ_OFFSET)
594#define SIU_INT_SCC4 ((uint)0x2b+CPM_IRQ_OFFSET)
595#define SIU_INT_PC15 ((uint)0x30+CPM_IRQ_OFFSET)
596#define SIU_INT_PC14 ((uint)0x31+CPM_IRQ_OFFSET)
597#define SIU_INT_PC13 ((uint)0x32+CPM_IRQ_OFFSET)
598#define SIU_INT_PC12 ((uint)0x33+CPM_IRQ_OFFSET)
599#define SIU_INT_PC11 ((uint)0x34+CPM_IRQ_OFFSET)
600#define SIU_INT_PC10 ((uint)0x35+CPM_IRQ_OFFSET)
601#define SIU_INT_PC9 ((uint)0x36+CPM_IRQ_OFFSET)
602#define SIU_INT_PC8 ((uint)0x37+CPM_IRQ_OFFSET)
603#define SIU_INT_PC7 ((uint)0x38+CPM_IRQ_OFFSET)
604#define SIU_INT_PC6 ((uint)0x39+CPM_IRQ_OFFSET)
605#define SIU_INT_PC5 ((uint)0x3a+CPM_IRQ_OFFSET)
606#define SIU_INT_PC4 ((uint)0x3b+CPM_IRQ_OFFSET)
607#define SIU_INT_PC3 ((uint)0x3c+CPM_IRQ_OFFSET)
608#define SIU_INT_PC2 ((uint)0x3d+CPM_IRQ_OFFSET)
609#define SIU_INT_PC1 ((uint)0x3e+CPM_IRQ_OFFSET)
610#define SIU_INT_PC0 ((uint)0x3f+CPM_IRQ_OFFSET)
611
612#elif defined(CONFIG_PPC_86xx)
613#include <asm/mpc86xx.h>
614
615#define NR_EPIC_INTS 48
616#ifndef NR_8259_INTS
617#define NR_8259_INTS 16 /*ULI 1575 can route 12 interrupts */
618#endif
619#define NUM_8259_INTERRUPTS NR_8259_INTS
620
621#ifndef I8259_OFFSET
622#define I8259_OFFSET 0
623#endif
624
625#define NR_IRQS 256
626
627/* Internal IRQs on MPC86xx OpenPIC */
628
629#ifndef MPC86xx_OPENPIC_IRQ_OFFSET
630#define MPC86xx_OPENPIC_IRQ_OFFSET NR_8259_INTS
631#endif
632
633/* The 48 internal sources */
634#define MPC86xx_IRQ_NULL ( 0 + MPC86xx_OPENPIC_IRQ_OFFSET)
635#define MPC86xx_IRQ_MCM ( 1 + MPC86xx_OPENPIC_IRQ_OFFSET)
636#define MPC86xx_IRQ_DDR ( 2 + MPC86xx_OPENPIC_IRQ_OFFSET)
637#define MPC86xx_IRQ_LBC ( 3 + MPC86xx_OPENPIC_IRQ_OFFSET)
638#define MPC86xx_IRQ_DMA0 ( 4 + MPC86xx_OPENPIC_IRQ_OFFSET)
639#define MPC86xx_IRQ_DMA1 ( 5 + MPC86xx_OPENPIC_IRQ_OFFSET)
640#define MPC86xx_IRQ_DMA2 ( 6 + MPC86xx_OPENPIC_IRQ_OFFSET)
641#define MPC86xx_IRQ_DMA3 ( 7 + MPC86xx_OPENPIC_IRQ_OFFSET)
642
643/* no 10,11 */
644#define MPC86xx_IRQ_UART2 (12 + MPC86xx_OPENPIC_IRQ_OFFSET)
645#define MPC86xx_IRQ_TSEC1_TX (13 + MPC86xx_OPENPIC_IRQ_OFFSET)
646#define MPC86xx_IRQ_TSEC1_RX (14 + MPC86xx_OPENPIC_IRQ_OFFSET)
647#define MPC86xx_IRQ_TSEC3_TX (15 + MPC86xx_OPENPIC_IRQ_OFFSET)
648#define MPC86xx_IRQ_TSEC3_RX (16 + MPC86xx_OPENPIC_IRQ_OFFSET)
649#define MPC86xx_IRQ_TSEC3_ERROR (17 + MPC86xx_OPENPIC_IRQ_OFFSET)
650#define MPC86xx_IRQ_TSEC1_ERROR (18 + MPC86xx_OPENPIC_IRQ_OFFSET)
651#define MPC86xx_IRQ_TSEC2_TX (19 + MPC86xx_OPENPIC_IRQ_OFFSET)
652#define MPC86xx_IRQ_TSEC2_RX (20 + MPC86xx_OPENPIC_IRQ_OFFSET)
653#define MPC86xx_IRQ_TSEC4_TX (21 + MPC86xx_OPENPIC_IRQ_OFFSET)
654#define MPC86xx_IRQ_TSEC4_RX (22 + MPC86xx_OPENPIC_IRQ_OFFSET)
655#define MPC86xx_IRQ_TSEC4_ERROR (23 + MPC86xx_OPENPIC_IRQ_OFFSET)
656#define MPC86xx_IRQ_TSEC2_ERROR (24 + MPC86xx_OPENPIC_IRQ_OFFSET)
657/* no 25 */
658#define MPC86xx_IRQ_UART1 (26 + MPC86xx_OPENPIC_IRQ_OFFSET)
659#define MPC86xx_IRQ_IIC (27 + MPC86xx_OPENPIC_IRQ_OFFSET)
660#define MPC86xx_IRQ_PERFMON (28 + MPC86xx_OPENPIC_IRQ_OFFSET)
661/* no 29,30,31 */
662#define MPC86xx_IRQ_SRIO_ERROR (32 + MPC86xx_OPENPIC_IRQ_OFFSET)
663#define MPC86xx_IRQ_SRIO_OUT_BELL (33 + MPC86xx_OPENPIC_IRQ_OFFSET)
664#define MPC86xx_IRQ_SRIO_IN_BELL (34 + MPC86xx_OPENPIC_IRQ_OFFSET)
665/* no 35,36 */
666#define MPC86xx_IRQ_SRIO_OUT_MSG1 (37 + MPC86xx_OPENPIC_IRQ_OFFSET)
667#define MPC86xx_IRQ_SRIO_IN_MSG1 (38 + MPC86xx_OPENPIC_IRQ_OFFSET)
668#define MPC86xx_IRQ_SRIO_OUT_MSG2 (39 + MPC86xx_OPENPIC_IRQ_OFFSET)
669#define MPC86xx_IRQ_SRIO_IN_MSG2 (40 + MPC86xx_OPENPIC_IRQ_OFFSET)
670
671/* The 12 external interrupt lines */
672#define MPC86xx_IRQ_EXT_BASE 48
673#define MPC86xx_IRQ_EXT0 (0 + MPC86xx_IRQ_EXT_BASE \
674 + MPC86xx_OPENPIC_IRQ_OFFSET)
675#define MPC86xx_IRQ_EXT1 (1 + MPC86xx_IRQ_EXT_BASE \
676 + MPC86xx_OPENPIC_IRQ_OFFSET)
677#define MPC86xx_IRQ_EXT2 (2 + MPC86xx_IRQ_EXT_BASE \
678 + MPC86xx_OPENPIC_IRQ_OFFSET)
679#define MPC86xx_IRQ_EXT3 (3 + MPC86xx_IRQ_EXT_BASE \
680 + MPC86xx_OPENPIC_IRQ_OFFSET)
681#define MPC86xx_IRQ_EXT4 (4 + MPC86xx_IRQ_EXT_BASE \
682 + MPC86xx_OPENPIC_IRQ_OFFSET)
683#define MPC86xx_IRQ_EXT5 (5 + MPC86xx_IRQ_EXT_BASE \
684 + MPC86xx_OPENPIC_IRQ_OFFSET)
685#define MPC86xx_IRQ_EXT6 (6 + MPC86xx_IRQ_EXT_BASE \
686 + MPC86xx_OPENPIC_IRQ_OFFSET)
687#define MPC86xx_IRQ_EXT7 (7 + MPC86xx_IRQ_EXT_BASE \
688 + MPC86xx_OPENPIC_IRQ_OFFSET)
689#define MPC86xx_IRQ_EXT8 (8 + MPC86xx_IRQ_EXT_BASE \
690 + MPC86xx_OPENPIC_IRQ_OFFSET)
691#define MPC86xx_IRQ_EXT9 (9 + MPC86xx_IRQ_EXT_BASE \
692 + MPC86xx_OPENPIC_IRQ_OFFSET)
693#define MPC86xx_IRQ_EXT10 (10 + MPC86xx_IRQ_EXT_BASE \
694 + MPC86xx_OPENPIC_IRQ_OFFSET)
695#define MPC86xx_IRQ_EXT11 (11 + MPC86xx_IRQ_EXT_BASE \
696 + MPC86xx_OPENPIC_IRQ_OFFSET)
697
698#else /* CONFIG_40x + CONFIG_8xx */ 486#else /* CONFIG_40x + CONFIG_8xx */
699/* 487/*
700 * this is the # irq's for all ppc arch's (pmac/chrp/prep) 488 * this is the # irq's for all ppc arch's (pmac/chrp/prep)
diff --git a/include/asm-powerpc/iseries/hv_lp_event.h b/include/asm-powerpc/iseries/hv_lp_event.h
index 6ce2ce1e2690..8f5da7d77202 100644
--- a/include/asm-powerpc/iseries/hv_lp_event.h
+++ b/include/asm-powerpc/iseries/hv_lp_event.h
@@ -78,7 +78,7 @@ extern int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
78 78
79/* 79/*
80 * Close an Lp Event Path for a type and partition 80 * Close an Lp Event Path for a type and partition
81 * returns 0 on sucess 81 * returns 0 on success
82 */ 82 */
83extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex); 83extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
84 84
diff --git a/include/asm-powerpc/kexec.h b/include/asm-powerpc/kexec.h
index b6f817b8ba3d..701857bc8e24 100644
--- a/include/asm-powerpc/kexec.h
+++ b/include/asm-powerpc/kexec.h
@@ -123,6 +123,9 @@ struct pt_regs;
123extern void default_machine_kexec(struct kimage *image); 123extern void default_machine_kexec(struct kimage *image);
124extern int default_machine_kexec_prepare(struct kimage *image); 124extern int default_machine_kexec_prepare(struct kimage *image);
125extern void default_machine_crash_shutdown(struct pt_regs *regs); 125extern void default_machine_crash_shutdown(struct pt_regs *regs);
126typedef void (*crash_shutdown_t)(void);
127extern int crash_shutdown_register(crash_shutdown_t handler);
128extern int crash_shutdown_unregister(crash_shutdown_t handler);
126 129
127extern void machine_kexec_simple(struct kimage *image); 130extern void machine_kexec_simple(struct kimage *image);
128extern void crash_kexec_secondary(struct pt_regs *regs); 131extern void crash_kexec_secondary(struct pt_regs *regs);
diff --git a/include/asm-powerpc/lmb.h b/include/asm-powerpc/lmb.h
index b5f9f4c9c294..5d1dc48a0bb8 100644
--- a/include/asm-powerpc/lmb.h
+++ b/include/asm-powerpc/lmb.h
@@ -51,6 +51,7 @@ extern unsigned long __init __lmb_alloc_base(unsigned long size,
51extern unsigned long __init lmb_phys_mem_size(void); 51extern unsigned long __init lmb_phys_mem_size(void);
52extern unsigned long __init lmb_end_of_DRAM(void); 52extern unsigned long __init lmb_end_of_DRAM(void);
53extern void __init lmb_enforce_memory_limit(unsigned long memory_limit); 53extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
54extern int __init lmb_is_reserved(unsigned long addr);
54 55
55extern void lmb_dump_all(void); 56extern void lmb_dump_all(void);
56 57
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
index 6968f4300dca..0872ec228c1e 100644
--- a/include/asm-powerpc/machdep.h
+++ b/include/asm-powerpc/machdep.h
@@ -204,6 +204,13 @@ struct machdep_calls {
204 /* 204 /*
205 * optional PCI "hooks" 205 * optional PCI "hooks"
206 */ 206 */
207 /* Called in indirect_* to avoid touching devices */
208 int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
209
210 /* Called at then very end of pcibios_init() */
211 void (*pcibios_after_init)(void);
212
213#endif /* CONFIG_PPC32 */
207 214
208 /* Called after PPC generic resource fixup to perform 215 /* Called after PPC generic resource fixup to perform
209 machine specific fixups */ 216 machine specific fixups */
@@ -212,18 +219,9 @@ struct machdep_calls {
212 /* Called for each PCI bus in the system when it's probed */ 219 /* Called for each PCI bus in the system when it's probed */
213 void (*pcibios_fixup_bus)(struct pci_bus *); 220 void (*pcibios_fixup_bus)(struct pci_bus *);
214 221
215 /* Called when pci_enable_device() is called (initial=0) or 222 /* Called when pci_enable_device() is called. Returns 0 to
216 * when a device with no assigned resource is found (initial=1). 223 * allow assignment/enabling of the device. */
217 * Returns 0 to allow assignment/enabling of the device. */ 224 int (*pcibios_enable_device_hook)(struct pci_dev *);
218 int (*pcibios_enable_device_hook)(struct pci_dev *, int initial);
219
220 /* Called in indirect_* to avoid touching devices */
221 int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char);
222
223 /* Called at then very end of pcibios_init() */
224 void (*pcibios_after_init)(void);
225
226#endif /* CONFIG_PPC32 */
227 225
228 /* Called to shutdown machine specific hardware not already controlled 226 /* Called to shutdown machine specific hardware not already controlled
229 * by other drivers. 227 * by other drivers.
@@ -253,6 +251,16 @@ struct machdep_calls {
253 */ 251 */
254 void (*machine_kexec)(struct kimage *image); 252 void (*machine_kexec)(struct kimage *image);
255#endif /* CONFIG_KEXEC */ 253#endif /* CONFIG_KEXEC */
254
255#ifdef CONFIG_SUSPEND
256 /* These are called to disable and enable, respectively, IRQs when
257 * entering a suspend state. If NULL, then the generic versions
258 * will be called. The generic versions disable/enable the
259 * decrementer along with interrupts.
260 */
261 void (*suspend_disable_irqs)(void);
262 void (*suspend_enable_irqs)(void);
263#endif
256}; 264};
257 265
258extern void power4_idle(void); 266extern void power4_idle(void);
@@ -326,5 +334,31 @@ static inline void log_error(char *buf, unsigned int err_type, int fatal)
326 ppc_md.log_error(buf, err_type, fatal); 334 ppc_md.log_error(buf, err_type, fatal);
327} 335}
328 336
337#define __define_machine_initcall(mach,level,fn,id) \
338 static int __init __machine_initcall_##mach##_##fn(void) { \
339 if (machine_is(mach)) return fn(); \
340 return 0; \
341 } \
342 __define_initcall(level,__machine_initcall_##mach##_##fn,id);
343
344#define machine_core_initcall(mach,fn) __define_machine_initcall(mach,"1",fn,1)
345#define machine_core_initcall_sync(mach,fn) __define_machine_initcall(mach,"1s",fn,1s)
346#define machine_postcore_initcall(mach,fn) __define_machine_initcall(mach,"2",fn,2)
347#define machine_postcore_initcall_sync(mach,fn) __define_machine_initcall(mach,"2s",fn,2s)
348#define machine_arch_initcall(mach,fn) __define_machine_initcall(mach,"3",fn,3)
349#define machine_arch_initcall_sync(mach,fn) __define_machine_initcall(mach,"3s",fn,3s)
350#define machine_subsys_initcall(mach,fn) __define_machine_initcall(mach,"4",fn,4)
351#define machine_subsys_initcall_sync(mach,fn) __define_machine_initcall(mach,"4s",fn,4s)
352#define machine_fs_initcall(mach,fn) __define_machine_initcall(mach,"5",fn,5)
353#define machine_fs_initcall_sync(mach,fn) __define_machine_initcall(mach,"5s",fn,5s)
354#define machine_rootfs_initcall(mach,fn) __define_machine_initcall(mach,"rootfs",fn,rootfs)
355#define machine_device_initcall(mach,fn) __define_machine_initcall(mach,"6",fn,6)
356#define machine_device_initcall_sync(mach,fn) __define_machine_initcall(mach,"6s",fn,6s)
357#define machine_late_initcall(mach,fn) __define_machine_initcall(mach,"7",fn,7)
358#define machine_late_initcall_sync(mach,fn) __define_machine_initcall(mach,"7s",fn,7s)
359
360void generic_suspend_disable_irqs(void);
361void generic_suspend_enable_irqs(void);
362
329#endif /* __KERNEL__ */ 363#endif /* __KERNEL__ */
330#endif /* _ASM_POWERPC_MACHDEP_H */ 364#endif /* _ASM_POWERPC_MACHDEP_H */
diff --git a/include/asm-powerpc/mmu-hash64.h b/include/asm-powerpc/mmu-hash64.h
index 82328dec2b52..2864fa3989ea 100644
--- a/include/asm-powerpc/mmu-hash64.h
+++ b/include/asm-powerpc/mmu-hash64.h
@@ -80,7 +80,7 @@ extern char initial_stab[];
80#define HPTE_V_AVPN_SHIFT 7 80#define HPTE_V_AVPN_SHIFT 7
81#define HPTE_V_AVPN ASM_CONST(0x3fffffffffffff80) 81#define HPTE_V_AVPN ASM_CONST(0x3fffffffffffff80)
82#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT) 82#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
83#define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & 0xffffffffffffff80)) 83#define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & 0xffffffffffffff80UL))
84#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010) 84#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010)
85#define HPTE_V_LOCK ASM_CONST(0x0000000000000008) 85#define HPTE_V_LOCK ASM_CONST(0x0000000000000008)
86#define HPTE_V_LARGE ASM_CONST(0x0000000000000004) 86#define HPTE_V_LARGE ASM_CONST(0x0000000000000004)
@@ -180,6 +180,7 @@ extern int mmu_vmalloc_psize;
180extern int mmu_io_psize; 180extern int mmu_io_psize;
181extern int mmu_kernel_ssize; 181extern int mmu_kernel_ssize;
182extern int mmu_highuser_ssize; 182extern int mmu_highuser_ssize;
183extern u16 mmu_slb_size;
183 184
184/* 185/*
185 * If the processor supports 64k normal pages but not 64k cache 186 * If the processor supports 64k normal pages but not 64k cache
@@ -264,7 +265,7 @@ static inline unsigned long hpt_hash(unsigned long va, unsigned int shift,
264 265
265extern int __hash_page_4K(unsigned long ea, unsigned long access, 266extern int __hash_page_4K(unsigned long ea, unsigned long access,
266 unsigned long vsid, pte_t *ptep, unsigned long trap, 267 unsigned long vsid, pte_t *ptep, unsigned long trap,
267 unsigned int local, int ssize); 268 unsigned int local, int ssize, int subpage_prot);
268extern int __hash_page_64K(unsigned long ea, unsigned long access, 269extern int __hash_page_64K(unsigned long ea, unsigned long access,
269 unsigned long vsid, pte_t *ptep, unsigned long trap, 270 unsigned long vsid, pte_t *ptep, unsigned long trap,
270 unsigned int local, int ssize); 271 unsigned int local, int ssize);
@@ -277,6 +278,8 @@ extern int hash_huge_page(struct mm_struct *mm, unsigned long access,
277extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend, 278extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
278 unsigned long pstart, unsigned long mode, 279 unsigned long pstart, unsigned long mode,
279 int psize, int ssize); 280 int psize, int ssize);
281extern void set_huge_psize(int psize);
282extern void demote_segment_4k(struct mm_struct *mm, unsigned long addr);
280 283
281extern void htab_initialize(void); 284extern void htab_initialize(void);
282extern void htab_initialize_secondary(void); 285extern void htab_initialize_secondary(void);
diff --git a/include/asm-powerpc/mpc52xx.h b/include/asm-powerpc/mpc52xx.h
index fcb2ebbfddbc..81ef10b6b672 100644
--- a/include/asm-powerpc/mpc52xx.h
+++ b/include/asm-powerpc/mpc52xx.h
@@ -248,19 +248,25 @@ struct mpc52xx_cdm {
248 248
249#ifndef __ASSEMBLY__ 249#ifndef __ASSEMBLY__
250 250
251extern void __iomem * mpc52xx_find_and_map(const char *); 251/* mpc52xx_common.c */
252extern void __iomem * mpc52xx_find_and_map_path(const char *path);
253extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node); 252extern unsigned int mpc52xx_find_ipb_freq(struct device_node *node);
254extern void mpc5200_setup_xlb_arbiter(void); 253extern void mpc5200_setup_xlb_arbiter(void);
255extern void mpc52xx_declare_of_platform_devices(void); 254extern void mpc52xx_declare_of_platform_devices(void);
255extern void mpc52xx_map_common_devices(void);
256extern int mpc52xx_set_psc_clkdiv(int psc_id, int clkdiv);
257extern void mpc52xx_restart(char *cmd);
256 258
259/* mpc52xx_pic.c */
257extern void mpc52xx_init_irq(void); 260extern void mpc52xx_init_irq(void);
258extern unsigned int mpc52xx_get_irq(void); 261extern unsigned int mpc52xx_get_irq(void);
259 262
263/* mpc52xx_pci.c */
264#ifdef CONFIG_PCI
260extern int __init mpc52xx_add_bridge(struct device_node *node); 265extern int __init mpc52xx_add_bridge(struct device_node *node);
261 266extern void __init mpc52xx_setup_pci(void);
262extern void __init mpc52xx_map_wdt(void); 267#else
263extern void mpc52xx_restart(char *cmd); 268static inline void mpc52xx_setup_pci(void) { }
269#endif
264 270
265#endif /* __ASSEMBLY__ */ 271#endif /* __ASSEMBLY__ */
266 272
diff --git a/include/asm-powerpc/mpc52xx_psc.h b/include/asm-powerpc/mpc52xx_psc.h
index 26690d2b32f5..bea42b95390f 100644
--- a/include/asm-powerpc/mpc52xx_psc.h
+++ b/include/asm-powerpc/mpc52xx_psc.h
@@ -153,6 +153,9 @@ struct mpc52xx_psc {
153 u8 reserved16[3]; 153 u8 reserved16[3];
154 u8 irfdr; /* PSC + 0x54 */ 154 u8 irfdr; /* PSC + 0x54 */
155 u8 reserved17[3]; 155 u8 reserved17[3];
156};
157
158struct mpc52xx_psc_fifo {
156 u16 rfnum; /* PSC + 0x58 */ 159 u16 rfnum; /* PSC + 0x58 */
157 u16 reserved18; 160 u16 reserved18;
158 u16 tfnum; /* PSC + 0x5c */ 161 u16 tfnum; /* PSC + 0x5c */
diff --git a/include/asm-powerpc/mpc8260.h b/include/asm-powerpc/mpc8260.h
index e0d480790e12..03317e1e6185 100644
--- a/include/asm-powerpc/mpc8260.h
+++ b/include/asm-powerpc/mpc8260.h
@@ -8,6 +8,7 @@
8#ifndef __ASM_POWERPC_MPC8260_H__ 8#ifndef __ASM_POWERPC_MPC8260_H__
9#define __ASM_POWERPC_MPC8260_H__ 9#define __ASM_POWERPC_MPC8260_H__
10 10
11#define MPC82XX_BCR_PLDP 0x00800000 /* Pipeline Maximum Depth */
11 12
12#ifdef CONFIG_8260 13#ifdef CONFIG_8260
13 14
diff --git a/include/asm-powerpc/mpc8xx.h b/include/asm-powerpc/mpc8xx.h
index 2be014b6f57c..98f3c4f17328 100644
--- a/include/asm-powerpc/mpc8xx.h
+++ b/include/asm-powerpc/mpc8xx.h
@@ -4,29 +4,9 @@
4 * file that has to include MPC8xx configuration, they all include 4 * file that has to include MPC8xx configuration, they all include
5 * this one and the configuration switching is done here. 5 * this one and the configuration switching is done here.
6 */ 6 */
7#ifdef __KERNEL__
8#ifndef __CONFIG_8xx_DEFS 7#ifndef __CONFIG_8xx_DEFS
9#define __CONFIG_8xx_DEFS 8#define __CONFIG_8xx_DEFS
10 9
11
12#ifdef CONFIG_8xx
13
14#ifdef CONFIG_FADS
15#include <platforms/fads.h>
16#endif
17
18#if defined(CONFIG_MPC86XADS)
19#include <platforms/8xx/mpc86xads.h>
20#endif
21
22#if defined(CONFIG_MPC885ADS)
23#include <platforms/8xx/mpc885ads.h>
24#endif
25
26#ifdef CONFIG_PCMCIA_M8XX
27extern struct mpc8xx_pcmcia_ops m8xx_pcmcia_ops; 10extern struct mpc8xx_pcmcia_ops m8xx_pcmcia_ops;
28#endif
29 11
30#endif /* CONFIG_8xx */
31#endif /* __CONFIG_8xx_DEFS */ 12#endif /* __CONFIG_8xx_DEFS */
32#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
index ae84dde3bc7f..943c5a3fac8a 100644
--- a/include/asm-powerpc/mpic.h
+++ b/include/asm-powerpc/mpic.h
@@ -22,7 +22,9 @@
22#define MPIC_GREG_GLOBAL_CONF_0 0x00020 22#define MPIC_GREG_GLOBAL_CONF_0 0x00020
23#define MPIC_GREG_GCONF_RESET 0x80000000 23#define MPIC_GREG_GCONF_RESET 0x80000000
24#define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000 24#define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000
25#define MPIC_GREG_GCONF_NO_BIAS 0x10000000
25#define MPIC_GREG_GCONF_BASE_MASK 0x000fffff 26#define MPIC_GREG_GCONF_BASE_MASK 0x000fffff
27#define MPIC_GREG_GCONF_MCK 0x08000000
26#define MPIC_GREG_GLOBAL_CONF_1 0x00030 28#define MPIC_GREG_GLOBAL_CONF_1 0x00030
27#define MPIC_GREG_GLOBAL_CONF_1_SIE 0x08000000 29#define MPIC_GREG_GLOBAL_CONF_1_SIE 0x08000000
28#define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK 0x70000000 30#define MPIC_GREG_GLOBAL_CONF_1_CLK_RATIO_MASK 0x70000000
@@ -78,6 +80,7 @@
78#define MPIC_CPU_WHOAMI_MASK 0x0000001f 80#define MPIC_CPU_WHOAMI_MASK 0x0000001f
79#define MPIC_CPU_INTACK 0x000a0 81#define MPIC_CPU_INTACK 0x000a0
80#define MPIC_CPU_EOI 0x000b0 82#define MPIC_CPU_EOI 0x000b0
83#define MPIC_CPU_MCACK 0x000c0
81 84
82/* 85/*
83 * Per-source registers 86 * Per-source registers
@@ -141,6 +144,7 @@
141#define TSI108_CPU_WHOAMI 0xffffffff 144#define TSI108_CPU_WHOAMI 0xffffffff
142#define TSI108_CPU_INTACK 0x00004 145#define TSI108_CPU_INTACK 0x00004
143#define TSI108_CPU_EOI 0x00008 146#define TSI108_CPU_EOI 0x00008
147#define TSI108_CPU_MCACK 0x00004 /* Doesn't really exist here */
144 148
145/* 149/*
146 * Per-source registers 150 * Per-source registers
@@ -183,6 +187,7 @@ enum {
183 MPIC_IDX_CPU_WHOAMI, 187 MPIC_IDX_CPU_WHOAMI,
184 MPIC_IDX_CPU_INTACK, 188 MPIC_IDX_CPU_INTACK,
185 MPIC_IDX_CPU_EOI, 189 MPIC_IDX_CPU_EOI,
190 MPIC_IDX_CPU_MCACK,
186 191
187 MPIC_IDX_IRQ_BASE, 192 MPIC_IDX_IRQ_BASE,
188 MPIC_IDX_IRQ_STRIDE, 193 MPIC_IDX_IRQ_STRIDE,
@@ -344,6 +349,10 @@ struct mpic
344#define MPIC_USES_DCR 0x00000080 349#define MPIC_USES_DCR 0x00000080
345/* MPIC has 11-bit vector fields (or larger) */ 350/* MPIC has 11-bit vector fields (or larger) */
346#define MPIC_LARGE_VECTORS 0x00000100 351#define MPIC_LARGE_VECTORS 0x00000100
352/* Enable delivery of prio 15 interrupts as MCK instead of EE */
353#define MPIC_ENABLE_MCK 0x00000200
354/* Disable bias among target selection, spread interrupts evenly */
355#define MPIC_NO_BIAS 0x00000400
347 356
348/* MPIC HW modification ID */ 357/* MPIC HW modification ID */
349#define MPIC_REGSET_MASK 0xf0000000 358#define MPIC_REGSET_MASK 0xf0000000
@@ -447,10 +456,19 @@ extern void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask);
447/* Send a message (IPI) to a given target (cpu number or MSG_*) */ 456/* Send a message (IPI) to a given target (cpu number or MSG_*) */
448void smp_mpic_message_pass(int target, int msg); 457void smp_mpic_message_pass(int target, int msg);
449 458
459/* Unmask a specific virq */
460extern void mpic_unmask_irq(unsigned int irq);
461/* Mask a specific virq */
462extern void mpic_mask_irq(unsigned int irq);
463/* EOI a specific virq */
464extern void mpic_end_irq(unsigned int irq);
465
450/* Fetch interrupt from a given mpic */ 466/* Fetch interrupt from a given mpic */
451extern unsigned int mpic_get_one_irq(struct mpic *mpic); 467extern unsigned int mpic_get_one_irq(struct mpic *mpic);
452/* This one gets to the primary mpic */ 468/* This one gets from the primary mpic */
453extern unsigned int mpic_get_irq(void); 469extern unsigned int mpic_get_irq(void);
470/* Fetch Machine Check interrupt from primary mpic */
471extern unsigned int mpic_get_mcirq(void);
454 472
455/* Set the EPIC clock ratio */ 473/* Set the EPIC clock ratio */
456void mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio); 474void mpic_set_clk_ratio(struct mpic *mpic, u32 clock_ratio);
diff --git a/include/asm-powerpc/nvram.h b/include/asm-powerpc/nvram.h
index 9877982508bf..4e7059cc6113 100644
--- a/include/asm-powerpc/nvram.h
+++ b/include/asm-powerpc/nvram.h
@@ -10,6 +10,8 @@
10#ifndef _ASM_POWERPC_NVRAM_H 10#ifndef _ASM_POWERPC_NVRAM_H
11#define _ASM_POWERPC_NVRAM_H 11#define _ASM_POWERPC_NVRAM_H
12 12
13#include <linux/errno.h>
14
13#define NVRW_CNT 0x20 15#define NVRW_CNT 0x20
14#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */ 16#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
15#define NVRAM_BLOCK_LEN 16 17#define NVRAM_BLOCK_LEN 16
@@ -71,7 +73,16 @@ extern int nvram_clear_error_log(void);
71extern struct nvram_partition *nvram_find_partition(int sig, const char *name); 73extern struct nvram_partition *nvram_find_partition(int sig, const char *name);
72 74
73extern int pSeries_nvram_init(void); 75extern int pSeries_nvram_init(void);
76
77#ifdef CONFIG_MMIO_NVRAM
74extern int mmio_nvram_init(void); 78extern int mmio_nvram_init(void);
79#else
80static inline int mmio_nvram_init(void)
81{
82 return -ENODEV;
83}
84#endif
85
75#endif /* __KERNEL__ */ 86#endif /* __KERNEL__ */
76 87
77/* PowerMac specific nvram stuffs */ 88/* PowerMac specific nvram stuffs */
diff --git a/include/asm-powerpc/of_platform.h b/include/asm-powerpc/of_platform.h
index 80e6fad28b4f..18659ef72139 100644
--- a/include/asm-powerpc/of_platform.h
+++ b/include/asm-powerpc/of_platform.h
@@ -15,8 +15,14 @@
15#include <linux/of_platform.h> 15#include <linux/of_platform.h>
16 16
17/* Platform drivers register/unregister */ 17/* Platform drivers register/unregister */
18extern int of_register_platform_driver(struct of_platform_driver *drv); 18static inline int of_register_platform_driver(struct of_platform_driver *drv)
19extern void of_unregister_platform_driver(struct of_platform_driver *drv); 19{
20 return of_register_driver(drv, &of_platform_bus_type);
21}
22static inline void of_unregister_platform_driver(struct of_platform_driver *drv)
23{
24 of_unregister_driver(drv);
25}
20 26
21/* Platform devices and busses creation */ 27/* Platform devices and busses creation */
22extern struct of_device *of_platform_device_create(struct device_node *np, 28extern struct of_device *of_platform_device_create(struct device_node *np,
@@ -26,9 +32,11 @@ extern struct of_device *of_platform_device_create(struct device_node *np,
26#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1) 32#define OF_NO_DEEP_PROBE ((struct of_device_id *)-1)
27 33
28extern int of_platform_bus_probe(struct device_node *root, 34extern int of_platform_bus_probe(struct device_node *root,
29 struct of_device_id *matches, 35 const struct of_device_id *matches,
30 struct device *parent); 36 struct device *parent);
31 37
32extern struct of_device *of_find_device_by_phandle(phandle ph); 38extern struct of_device *of_find_device_by_phandle(phandle ph);
33 39
40extern void of_instantiate_rtc(void);
41
34#endif /* _ASM_POWERPC_OF_PLATFORM_H */ 42#endif /* _ASM_POWERPC_OF_PLATFORM_H */
diff --git a/include/asm-powerpc/page_32.h b/include/asm-powerpc/page_32.h
index 374d0db37e1c..17110aff26e7 100644
--- a/include/asm-powerpc/page_32.h
+++ b/include/asm-powerpc/page_32.h
@@ -6,6 +6,10 @@
6 6
7#define PPC_MEMSTART 0 7#define PPC_MEMSTART 0
8 8
9#ifdef CONFIG_NOT_COHERENT_CACHE
10#define ARCH_KMALLOC_MINALIGN L1_CACHE_BYTES
11#endif
12
9#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
10/* 14/*
11 * The basic type of a PTE - 64 bits for those CPUs with > 32 bit 15 * The basic type of a PTE - 64 bits for those CPUs with > 32 bit
diff --git a/include/asm-powerpc/pasemi_dma.h b/include/asm-powerpc/pasemi_dma.h
new file mode 100644
index 000000000000..b4526ff3a50d
--- /dev/null
+++ b/include/asm-powerpc/pasemi_dma.h
@@ -0,0 +1,467 @@
1/*
2 * Copyright (C) 2006 PA Semi, Inc
3 *
4 * Hardware register layout and descriptor formats for the on-board
5 * DMA engine on PA Semi PWRficient. Used by ethernet, function and security
6 * drivers.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef ASM_PASEMI_DMA_H
23#define ASM_PASEMI_DMA_H
24
25/* status register layout in IOB region, at 0xfb800000 */
26struct pasdma_status {
27 u64 rx_sta[64]; /* RX channel status */
28 u64 tx_sta[20]; /* TX channel status */
29};
30
31
32/* All these registers live in the PCI configuration space for the DMA PCI
33 * device. Use the normal PCI config access functions for them.
34 */
35enum {
36 PAS_DMA_CAP_TXCH = 0x44, /* Transmit Channel Info */
37 PAS_DMA_CAP_RXCH = 0x48, /* Transmit Channel Info */
38 PAS_DMA_CAP_IFI = 0x4c, /* Interface Info */
39 PAS_DMA_COM_TXCMD = 0x100, /* Transmit Command Register */
40 PAS_DMA_COM_TXSTA = 0x104, /* Transmit Status Register */
41 PAS_DMA_COM_RXCMD = 0x108, /* Receive Command Register */
42 PAS_DMA_COM_RXSTA = 0x10c, /* Receive Status Register */
43};
44
45
46#define PAS_DMA_CAP_TXCH_TCHN_M 0x00ff0000 /* # of TX channels */
47#define PAS_DMA_CAP_TXCH_TCHN_S 16
48
49#define PAS_DMA_CAP_RXCH_RCHN_M 0x00ff0000 /* # of RX channels */
50#define PAS_DMA_CAP_RXCH_RCHN_S 16
51
52#define PAS_DMA_CAP_IFI_IOFF_M 0xff000000 /* Cfg reg for intf pointers */
53#define PAS_DMA_CAP_IFI_IOFF_S 24
54#define PAS_DMA_CAP_IFI_NIN_M 0x00ff0000 /* # of interfaces */
55#define PAS_DMA_CAP_IFI_NIN_S 16
56
57#define PAS_DMA_COM_TXCMD_EN 0x00000001 /* enable */
58#define PAS_DMA_COM_TXSTA_ACT 0x00000001 /* active */
59#define PAS_DMA_COM_RXCMD_EN 0x00000001 /* enable */
60#define PAS_DMA_COM_RXSTA_ACT 0x00000001 /* active */
61
62
63/* Per-interface and per-channel registers */
64#define _PAS_DMA_RXINT_STRIDE 0x20
65#define PAS_DMA_RXINT_RCMDSTA(i) (0x200+(i)*_PAS_DMA_RXINT_STRIDE)
66#define PAS_DMA_RXINT_RCMDSTA_EN 0x00000001
67#define PAS_DMA_RXINT_RCMDSTA_ST 0x00000002
68#define PAS_DMA_RXINT_RCMDSTA_MBT 0x00000008
69#define PAS_DMA_RXINT_RCMDSTA_MDR 0x00000010
70#define PAS_DMA_RXINT_RCMDSTA_MOO 0x00000020
71#define PAS_DMA_RXINT_RCMDSTA_MBP 0x00000040
72#define PAS_DMA_RXINT_RCMDSTA_BT 0x00000800
73#define PAS_DMA_RXINT_RCMDSTA_DR 0x00001000
74#define PAS_DMA_RXINT_RCMDSTA_OO 0x00002000
75#define PAS_DMA_RXINT_RCMDSTA_BP 0x00004000
76#define PAS_DMA_RXINT_RCMDSTA_TB 0x00008000
77#define PAS_DMA_RXINT_RCMDSTA_ACT 0x00010000
78#define PAS_DMA_RXINT_RCMDSTA_DROPS_M 0xfffe0000
79#define PAS_DMA_RXINT_RCMDSTA_DROPS_S 17
80#define PAS_DMA_RXINT_CFG(i) (0x204+(i)*_PAS_DMA_RXINT_STRIDE)
81#define PAS_DMA_RXINT_CFG_RBP 0x80000000
82#define PAS_DMA_RXINT_CFG_ITRR 0x40000000
83#define PAS_DMA_RXINT_CFG_DHL_M 0x07000000
84#define PAS_DMA_RXINT_CFG_DHL_S 24
85#define PAS_DMA_RXINT_CFG_DHL(x) (((x) << PAS_DMA_RXINT_CFG_DHL_S) & \
86 PAS_DMA_RXINT_CFG_DHL_M)
87#define PAS_DMA_RXINT_CFG_ITR 0x00400000
88#define PAS_DMA_RXINT_CFG_LW 0x00200000
89#define PAS_DMA_RXINT_CFG_L2 0x00100000
90#define PAS_DMA_RXINT_CFG_HEN 0x00080000
91#define PAS_DMA_RXINT_CFG_WIF 0x00000002
92#define PAS_DMA_RXINT_CFG_WIL 0x00000001
93
94#define PAS_DMA_RXINT_INCR(i) (0x210+(i)*_PAS_DMA_RXINT_STRIDE)
95#define PAS_DMA_RXINT_INCR_INCR_M 0x0000ffff
96#define PAS_DMA_RXINT_INCR_INCR_S 0
97#define PAS_DMA_RXINT_INCR_INCR(x) ((x) & 0x0000ffff)
98#define PAS_DMA_RXINT_BASEL(i) (0x218+(i)*_PAS_DMA_RXINT_STRIDE)
99#define PAS_DMA_RXINT_BASEL_BRBL(x) ((x) & ~0x3f)
100#define PAS_DMA_RXINT_BASEU(i) (0x21c+(i)*_PAS_DMA_RXINT_STRIDE)
101#define PAS_DMA_RXINT_BASEU_BRBH(x) ((x) & 0xfff)
102#define PAS_DMA_RXINT_BASEU_SIZ_M 0x3fff0000 /* # of cache lines worth of buffer ring */
103#define PAS_DMA_RXINT_BASEU_SIZ_S 16 /* 0 = 16K */
104#define PAS_DMA_RXINT_BASEU_SIZ(x) (((x) << PAS_DMA_RXINT_BASEU_SIZ_S) & \
105 PAS_DMA_RXINT_BASEU_SIZ_M)
106
107
108#define _PAS_DMA_TXCHAN_STRIDE 0x20 /* Size per channel */
109#define _PAS_DMA_TXCHAN_TCMDSTA 0x300 /* Command / Status */
110#define _PAS_DMA_TXCHAN_CFG 0x304 /* Configuration */
111#define _PAS_DMA_TXCHAN_DSCRBU 0x308 /* Descriptor BU Allocation */
112#define _PAS_DMA_TXCHAN_INCR 0x310 /* Descriptor increment */
113#define _PAS_DMA_TXCHAN_CNT 0x314 /* Descriptor count/offset */
114#define _PAS_DMA_TXCHAN_BASEL 0x318 /* Descriptor ring base (low) */
115#define _PAS_DMA_TXCHAN_BASEU 0x31c /* (high) */
116#define PAS_DMA_TXCHAN_TCMDSTA(c) (0x300+(c)*_PAS_DMA_TXCHAN_STRIDE)
117#define PAS_DMA_TXCHAN_TCMDSTA_EN 0x00000001 /* Enabled */
118#define PAS_DMA_TXCHAN_TCMDSTA_ST 0x00000002 /* Stop interface */
119#define PAS_DMA_TXCHAN_TCMDSTA_ACT 0x00010000 /* Active */
120#define PAS_DMA_TXCHAN_TCMDSTA_SZ 0x00000800
121#define PAS_DMA_TXCHAN_TCMDSTA_DB 0x00000400
122#define PAS_DMA_TXCHAN_TCMDSTA_DE 0x00000200
123#define PAS_DMA_TXCHAN_TCMDSTA_DA 0x00000100
124#define PAS_DMA_TXCHAN_CFG(c) (0x304+(c)*_PAS_DMA_TXCHAN_STRIDE)
125#define PAS_DMA_TXCHAN_CFG_TY_IFACE 0x00000000 /* Type = interface */
126#define PAS_DMA_TXCHAN_CFG_TATTR_M 0x0000003c
127#define PAS_DMA_TXCHAN_CFG_TATTR_S 2
128#define PAS_DMA_TXCHAN_CFG_TATTR(x) (((x) << PAS_DMA_TXCHAN_CFG_TATTR_S) & \
129 PAS_DMA_TXCHAN_CFG_TATTR_M)
130#define PAS_DMA_TXCHAN_CFG_WT_M 0x000001c0
131#define PAS_DMA_TXCHAN_CFG_WT_S 6
132#define PAS_DMA_TXCHAN_CFG_WT(x) (((x) << PAS_DMA_TXCHAN_CFG_WT_S) & \
133 PAS_DMA_TXCHAN_CFG_WT_M)
134#define PAS_DMA_TXCHAN_CFG_TRD 0x00010000 /* translate data */
135#define PAS_DMA_TXCHAN_CFG_TRR 0x00008000 /* translate rings */
136#define PAS_DMA_TXCHAN_CFG_UP 0x00004000 /* update tx descr when sent */
137#define PAS_DMA_TXCHAN_CFG_CL 0x00002000 /* Clean last line */
138#define PAS_DMA_TXCHAN_CFG_CF 0x00001000 /* Clean first line */
139#define PAS_DMA_TXCHAN_INCR(c) (0x310+(c)*_PAS_DMA_TXCHAN_STRIDE)
140#define PAS_DMA_TXCHAN_BASEL(c) (0x318+(c)*_PAS_DMA_TXCHAN_STRIDE)
141#define PAS_DMA_TXCHAN_BASEL_BRBL_M 0xffffffc0
142#define PAS_DMA_TXCHAN_BASEL_BRBL_S 0
143#define PAS_DMA_TXCHAN_BASEL_BRBL(x) (((x) << PAS_DMA_TXCHAN_BASEL_BRBL_S) & \
144 PAS_DMA_TXCHAN_BASEL_BRBL_M)
145#define PAS_DMA_TXCHAN_BASEU(c) (0x31c+(c)*_PAS_DMA_TXCHAN_STRIDE)
146#define PAS_DMA_TXCHAN_BASEU_BRBH_M 0x00000fff
147#define PAS_DMA_TXCHAN_BASEU_BRBH_S 0
148#define PAS_DMA_TXCHAN_BASEU_BRBH(x) (((x) << PAS_DMA_TXCHAN_BASEU_BRBH_S) & \
149 PAS_DMA_TXCHAN_BASEU_BRBH_M)
150/* # of cache lines worth of buffer ring */
151#define PAS_DMA_TXCHAN_BASEU_SIZ_M 0x3fff0000
152#define PAS_DMA_TXCHAN_BASEU_SIZ_S 16 /* 0 = 16K */
153#define PAS_DMA_TXCHAN_BASEU_SIZ(x) (((x) << PAS_DMA_TXCHAN_BASEU_SIZ_S) & \
154 PAS_DMA_TXCHAN_BASEU_SIZ_M)
155
156#define _PAS_DMA_RXCHAN_STRIDE 0x20 /* Size per channel */
157#define _PAS_DMA_RXCHAN_CCMDSTA 0x800 /* Command / Status */
158#define _PAS_DMA_RXCHAN_CFG 0x804 /* Configuration */
159#define _PAS_DMA_RXCHAN_INCR 0x810 /* Descriptor increment */
160#define _PAS_DMA_RXCHAN_CNT 0x814 /* Descriptor count/offset */
161#define _PAS_DMA_RXCHAN_BASEL 0x818 /* Descriptor ring base (low) */
162#define _PAS_DMA_RXCHAN_BASEU 0x81c /* (high) */
163#define PAS_DMA_RXCHAN_CCMDSTA(c) (0x800+(c)*_PAS_DMA_RXCHAN_STRIDE)
164#define PAS_DMA_RXCHAN_CCMDSTA_EN 0x00000001 /* Enabled */
165#define PAS_DMA_RXCHAN_CCMDSTA_ST 0x00000002 /* Stop interface */
166#define PAS_DMA_RXCHAN_CCMDSTA_ACT 0x00010000 /* Active */
167#define PAS_DMA_RXCHAN_CCMDSTA_DU 0x00020000
168#define PAS_DMA_RXCHAN_CCMDSTA_OD 0x00002000
169#define PAS_DMA_RXCHAN_CCMDSTA_FD 0x00001000
170#define PAS_DMA_RXCHAN_CCMDSTA_DT 0x00000800
171#define PAS_DMA_RXCHAN_CFG(c) (0x804+(c)*_PAS_DMA_RXCHAN_STRIDE)
172#define PAS_DMA_RXCHAN_CFG_CTR 0x00000400
173#define PAS_DMA_RXCHAN_CFG_HBU_M 0x00000380
174#define PAS_DMA_RXCHAN_CFG_HBU_S 7
175#define PAS_DMA_RXCHAN_CFG_HBU(x) (((x) << PAS_DMA_RXCHAN_CFG_HBU_S) & \
176 PAS_DMA_RXCHAN_CFG_HBU_M)
177#define PAS_DMA_RXCHAN_INCR(c) (0x810+(c)*_PAS_DMA_RXCHAN_STRIDE)
178#define PAS_DMA_RXCHAN_BASEL(c) (0x818+(c)*_PAS_DMA_RXCHAN_STRIDE)
179#define PAS_DMA_RXCHAN_BASEL_BRBL_M 0xffffffc0
180#define PAS_DMA_RXCHAN_BASEL_BRBL_S 0
181#define PAS_DMA_RXCHAN_BASEL_BRBL(x) (((x) << PAS_DMA_RXCHAN_BASEL_BRBL_S) & \
182 PAS_DMA_RXCHAN_BASEL_BRBL_M)
183#define PAS_DMA_RXCHAN_BASEU(c) (0x81c+(c)*_PAS_DMA_RXCHAN_STRIDE)
184#define PAS_DMA_RXCHAN_BASEU_BRBH_M 0x00000fff
185#define PAS_DMA_RXCHAN_BASEU_BRBH_S 0
186#define PAS_DMA_RXCHAN_BASEU_BRBH(x) (((x) << PAS_DMA_RXCHAN_BASEU_BRBH_S) & \
187 PAS_DMA_RXCHAN_BASEU_BRBH_M)
188/* # of cache lines worth of buffer ring */
189#define PAS_DMA_RXCHAN_BASEU_SIZ_M 0x3fff0000
190#define PAS_DMA_RXCHAN_BASEU_SIZ_S 16 /* 0 = 16K */
191#define PAS_DMA_RXCHAN_BASEU_SIZ(x) (((x) << PAS_DMA_RXCHAN_BASEU_SIZ_S) & \
192 PAS_DMA_RXCHAN_BASEU_SIZ_M)
193
194#define PAS_STATUS_PCNT_M 0x000000000000ffffull
195#define PAS_STATUS_PCNT_S 0
196#define PAS_STATUS_DCNT_M 0x00000000ffff0000ull
197#define PAS_STATUS_DCNT_S 16
198#define PAS_STATUS_BPCNT_M 0x0000ffff00000000ull
199#define PAS_STATUS_BPCNT_S 32
200#define PAS_STATUS_CAUSE_M 0xf000000000000000ull
201#define PAS_STATUS_TIMER 0x1000000000000000ull
202#define PAS_STATUS_ERROR 0x2000000000000000ull
203#define PAS_STATUS_SOFT 0x4000000000000000ull
204#define PAS_STATUS_INT 0x8000000000000000ull
205
206#define PAS_IOB_COM_PKTHDRCNT 0x120
207#define PAS_IOB_COM_PKTHDRCNT_PKTHDR1_M 0x0fff0000
208#define PAS_IOB_COM_PKTHDRCNT_PKTHDR1_S 16
209#define PAS_IOB_COM_PKTHDRCNT_PKTHDR0_M 0x00000fff
210#define PAS_IOB_COM_PKTHDRCNT_PKTHDR0_S 0
211
212#define PAS_IOB_DMA_RXCH_CFG(i) (0x1100 + (i)*4)
213#define PAS_IOB_DMA_RXCH_CFG_CNTTH_M 0x00000fff
214#define PAS_IOB_DMA_RXCH_CFG_CNTTH_S 0
215#define PAS_IOB_DMA_RXCH_CFG_CNTTH(x) (((x) << PAS_IOB_DMA_RXCH_CFG_CNTTH_S) & \
216 PAS_IOB_DMA_RXCH_CFG_CNTTH_M)
217#define PAS_IOB_DMA_TXCH_CFG(i) (0x1200 + (i)*4)
218#define PAS_IOB_DMA_TXCH_CFG_CNTTH_M 0x00000fff
219#define PAS_IOB_DMA_TXCH_CFG_CNTTH_S 0
220#define PAS_IOB_DMA_TXCH_CFG_CNTTH(x) (((x) << PAS_IOB_DMA_TXCH_CFG_CNTTH_S) & \
221 PAS_IOB_DMA_TXCH_CFG_CNTTH_M)
222#define PAS_IOB_DMA_RXCH_STAT(i) (0x1300 + (i)*4)
223#define PAS_IOB_DMA_RXCH_STAT_INTGEN 0x00001000
224#define PAS_IOB_DMA_RXCH_STAT_CNTDEL_M 0x00000fff
225#define PAS_IOB_DMA_RXCH_STAT_CNTDEL_S 0
226#define PAS_IOB_DMA_RXCH_STAT_CNTDEL(x) (((x) << PAS_IOB_DMA_RXCH_STAT_CNTDEL_S) &\
227 PAS_IOB_DMA_RXCH_STAT_CNTDEL_M)
228#define PAS_IOB_DMA_TXCH_STAT(i) (0x1400 + (i)*4)
229#define PAS_IOB_DMA_TXCH_STAT_INTGEN 0x00001000
230#define PAS_IOB_DMA_TXCH_STAT_CNTDEL_M 0x00000fff
231#define PAS_IOB_DMA_TXCH_STAT_CNTDEL_S 0
232#define PAS_IOB_DMA_TXCH_STAT_CNTDEL(x) (((x) << PAS_IOB_DMA_TXCH_STAT_CNTDEL_S) &\
233 PAS_IOB_DMA_TXCH_STAT_CNTDEL_M)
234#define PAS_IOB_DMA_RXCH_RESET(i) (0x1500 + (i)*4)
235#define PAS_IOB_DMA_RXCH_RESET_PCNT_M 0xffff0000
236#define PAS_IOB_DMA_RXCH_RESET_PCNT_S 16
237#define PAS_IOB_DMA_RXCH_RESET_PCNT(x) (((x) << PAS_IOB_DMA_RXCH_RESET_PCNT_S) & \
238 PAS_IOB_DMA_RXCH_RESET_PCNT_M)
239#define PAS_IOB_DMA_RXCH_RESET_PCNTRST 0x00000020
240#define PAS_IOB_DMA_RXCH_RESET_DCNTRST 0x00000010
241#define PAS_IOB_DMA_RXCH_RESET_TINTC 0x00000008
242#define PAS_IOB_DMA_RXCH_RESET_DINTC 0x00000004
243#define PAS_IOB_DMA_RXCH_RESET_SINTC 0x00000002
244#define PAS_IOB_DMA_RXCH_RESET_PINTC 0x00000001
245#define PAS_IOB_DMA_TXCH_RESET(i) (0x1600 + (i)*4)
246#define PAS_IOB_DMA_TXCH_RESET_PCNT_M 0xffff0000
247#define PAS_IOB_DMA_TXCH_RESET_PCNT_S 16
248#define PAS_IOB_DMA_TXCH_RESET_PCNT(x) (((x) << PAS_IOB_DMA_TXCH_RESET_PCNT_S) & \
249 PAS_IOB_DMA_TXCH_RESET_PCNT_M)
250#define PAS_IOB_DMA_TXCH_RESET_PCNTRST 0x00000020
251#define PAS_IOB_DMA_TXCH_RESET_DCNTRST 0x00000010
252#define PAS_IOB_DMA_TXCH_RESET_TINTC 0x00000008
253#define PAS_IOB_DMA_TXCH_RESET_DINTC 0x00000004
254#define PAS_IOB_DMA_TXCH_RESET_SINTC 0x00000002
255#define PAS_IOB_DMA_TXCH_RESET_PINTC 0x00000001
256
257#define PAS_IOB_DMA_COM_TIMEOUTCFG 0x1700
258#define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M 0x00ffffff
259#define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S 0
260#define PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT(x) (((x) << PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_S) & \
261 PAS_IOB_DMA_COM_TIMEOUTCFG_TCNT_M)
262
263/* Transmit descriptor fields */
264#define XCT_MACTX_T 0x8000000000000000ull
265#define XCT_MACTX_ST 0x4000000000000000ull
266#define XCT_MACTX_NORES 0x0000000000000000ull
267#define XCT_MACTX_8BRES 0x1000000000000000ull
268#define XCT_MACTX_24BRES 0x2000000000000000ull
269#define XCT_MACTX_40BRES 0x3000000000000000ull
270#define XCT_MACTX_I 0x0800000000000000ull
271#define XCT_MACTX_O 0x0400000000000000ull
272#define XCT_MACTX_E 0x0200000000000000ull
273#define XCT_MACTX_VLAN_M 0x0180000000000000ull
274#define XCT_MACTX_VLAN_NOP 0x0000000000000000ull
275#define XCT_MACTX_VLAN_REMOVE 0x0080000000000000ull
276#define XCT_MACTX_VLAN_INSERT 0x0100000000000000ull
277#define XCT_MACTX_VLAN_REPLACE 0x0180000000000000ull
278#define XCT_MACTX_CRC_M 0x0060000000000000ull
279#define XCT_MACTX_CRC_NOP 0x0000000000000000ull
280#define XCT_MACTX_CRC_INSERT 0x0020000000000000ull
281#define XCT_MACTX_CRC_PAD 0x0040000000000000ull
282#define XCT_MACTX_CRC_REPLACE 0x0060000000000000ull
283#define XCT_MACTX_SS 0x0010000000000000ull
284#define XCT_MACTX_LLEN_M 0x00007fff00000000ull
285#define XCT_MACTX_LLEN_S 32ull
286#define XCT_MACTX_LLEN(x) ((((long)(x)) << XCT_MACTX_LLEN_S) & \
287 XCT_MACTX_LLEN_M)
288#define XCT_MACTX_IPH_M 0x00000000f8000000ull
289#define XCT_MACTX_IPH_S 27ull
290#define XCT_MACTX_IPH(x) ((((long)(x)) << XCT_MACTX_IPH_S) & \
291 XCT_MACTX_IPH_M)
292#define XCT_MACTX_IPO_M 0x0000000007c00000ull
293#define XCT_MACTX_IPO_S 22ull
294#define XCT_MACTX_IPO(x) ((((long)(x)) << XCT_MACTX_IPO_S) & \
295 XCT_MACTX_IPO_M)
296#define XCT_MACTX_CSUM_M 0x0000000000000060ull
297#define XCT_MACTX_CSUM_NOP 0x0000000000000000ull
298#define XCT_MACTX_CSUM_TCP 0x0000000000000040ull
299#define XCT_MACTX_CSUM_UDP 0x0000000000000060ull
300#define XCT_MACTX_V6 0x0000000000000010ull
301#define XCT_MACTX_C 0x0000000000000004ull
302#define XCT_MACTX_AL2 0x0000000000000002ull
303
304/* Receive descriptor fields */
305#define XCT_MACRX_T 0x8000000000000000ull
306#define XCT_MACRX_ST 0x4000000000000000ull
307#define XCT_MACRX_RR_M 0x3000000000000000ull
308#define XCT_MACRX_RR_NORES 0x0000000000000000ull
309#define XCT_MACRX_RR_8BRES 0x1000000000000000ull
310#define XCT_MACRX_O 0x0400000000000000ull
311#define XCT_MACRX_E 0x0200000000000000ull
312#define XCT_MACRX_FF 0x0100000000000000ull
313#define XCT_MACRX_PF 0x0080000000000000ull
314#define XCT_MACRX_OB 0x0040000000000000ull
315#define XCT_MACRX_OD 0x0020000000000000ull
316#define XCT_MACRX_FS 0x0010000000000000ull
317#define XCT_MACRX_NB_M 0x000fc00000000000ull
318#define XCT_MACRX_NB_S 46ULL
319#define XCT_MACRX_NB(x) ((((long)(x)) << XCT_MACRX_NB_S) & \
320 XCT_MACRX_NB_M)
321#define XCT_MACRX_LLEN_M 0x00003fff00000000ull
322#define XCT_MACRX_LLEN_S 32ULL
323#define XCT_MACRX_LLEN(x) ((((long)(x)) << XCT_MACRX_LLEN_S) & \
324 XCT_MACRX_LLEN_M)
325#define XCT_MACRX_CRC 0x0000000080000000ull
326#define XCT_MACRX_LEN_M 0x0000000060000000ull
327#define XCT_MACRX_LEN_TOOSHORT 0x0000000020000000ull
328#define XCT_MACRX_LEN_BELOWMIN 0x0000000040000000ull
329#define XCT_MACRX_LEN_TRUNC 0x0000000060000000ull
330#define XCT_MACRX_CAST_M 0x0000000018000000ull
331#define XCT_MACRX_CAST_UNI 0x0000000000000000ull
332#define XCT_MACRX_CAST_MULTI 0x0000000008000000ull
333#define XCT_MACRX_CAST_BROAD 0x0000000010000000ull
334#define XCT_MACRX_CAST_PAUSE 0x0000000018000000ull
335#define XCT_MACRX_VLC_M 0x0000000006000000ull
336#define XCT_MACRX_FM 0x0000000001000000ull
337#define XCT_MACRX_HTY_M 0x0000000000c00000ull
338#define XCT_MACRX_HTY_IPV4_OK 0x0000000000000000ull
339#define XCT_MACRX_HTY_IPV6 0x0000000000400000ull
340#define XCT_MACRX_HTY_IPV4_BAD 0x0000000000800000ull
341#define XCT_MACRX_HTY_NONIP 0x0000000000c00000ull
342#define XCT_MACRX_IPP_M 0x00000000003f0000ull
343#define XCT_MACRX_IPP_S 16
344#define XCT_MACRX_CSUM_M 0x000000000000ffffull
345#define XCT_MACRX_CSUM_S 0
346
347#define XCT_PTR_T 0x8000000000000000ull
348#define XCT_PTR_LEN_M 0x7ffff00000000000ull
349#define XCT_PTR_LEN_S 44
350#define XCT_PTR_LEN(x) ((((long)(x)) << XCT_PTR_LEN_S) & \
351 XCT_PTR_LEN_M)
352#define XCT_PTR_ADDR_M 0x00000fffffffffffull
353#define XCT_PTR_ADDR_S 0
354#define XCT_PTR_ADDR(x) ((((long)(x)) << XCT_PTR_ADDR_S) & \
355 XCT_PTR_ADDR_M)
356
357/* Receive interface 8byte result fields */
358#define XCT_RXRES_8B_L4O_M 0xff00000000000000ull
359#define XCT_RXRES_8B_L4O_S 56
360#define XCT_RXRES_8B_RULE_M 0x00ffff0000000000ull
361#define XCT_RXRES_8B_RULE_S 40
362#define XCT_RXRES_8B_EVAL_M 0x000000ffff000000ull
363#define XCT_RXRES_8B_EVAL_S 24
364#define XCT_RXRES_8B_HTYPE_M 0x0000000000f00000ull
365#define XCT_RXRES_8B_HASH_M 0x00000000000fffffull
366#define XCT_RXRES_8B_HASH_S 0
367
368/* Receive interface buffer fields */
369#define XCT_RXB_LEN_M 0x0ffff00000000000ull
370#define XCT_RXB_LEN_S 44
371#define XCT_RXB_LEN(x) ((((long)(x)) << XCT_RXB_LEN_S) & \
372 XCT_RXB_LEN_M)
373#define XCT_RXB_ADDR_M 0x00000fffffffffffull
374#define XCT_RXB_ADDR_S 0
375#define XCT_RXB_ADDR(x) ((((long)(x)) << XCT_RXB_ADDR_S) & \
376 XCT_RXB_ADDR_M)
377
378/* Copy descriptor fields */
379#define XCT_COPY_T 0x8000000000000000ull
380#define XCT_COPY_ST 0x4000000000000000ull
381#define XCT_COPY_RR_M 0x3000000000000000ull
382#define XCT_COPY_RR_NORES 0x0000000000000000ull
383#define XCT_COPY_RR_8BRES 0x1000000000000000ull
384#define XCT_COPY_RR_24BRES 0x2000000000000000ull
385#define XCT_COPY_RR_40BRES 0x3000000000000000ull
386#define XCT_COPY_I 0x0800000000000000ull
387#define XCT_COPY_O 0x0400000000000000ull
388#define XCT_COPY_E 0x0200000000000000ull
389#define XCT_COPY_STY_ZERO 0x01c0000000000000ull
390#define XCT_COPY_DTY_PREF 0x0038000000000000ull
391#define XCT_COPY_LLEN_M 0x0007ffff00000000ull
392#define XCT_COPY_LLEN_S 32
393#define XCT_COPY_LLEN(x) ((((long)(x)) << XCT_COPY_LLEN_S) & \
394 XCT_COPY_LLEN_M)
395#define XCT_COPY_SE 0x0000000000000001ull
396
397/* Control descriptor fields */
398#define CTRL_CMD_T 0x8000000000000000ull
399#define CTRL_CMD_META_EVT 0x2000000000000000ull
400#define CTRL_CMD_O 0x0400000000000000ull
401#define CTRL_CMD_REG_M 0x000000000000000full
402#define CTRL_CMD_REG_S 0
403#define CTRL_CMD_REG(x) ((((long)(x)) << CTRL_CMD_REG_S) & \
404 CTRL_CMD_REG_M)
405
406
407
408/* Prototypes for the shared DMA functions in the platform code. */
409
410/* DMA TX Channel type. Right now only limitations used are event types 0/1,
411 * for event-triggered DMA transactions.
412 */
413
414enum pasemi_dmachan_type {
415 RXCHAN = 0, /* Any RX chan */
416 TXCHAN = 1, /* Any TX chan */
417 TXCHAN_EVT0 = 0x1001, /* TX chan in event class 0 (chan 0-9) */
418 TXCHAN_EVT1 = 0x2001, /* TX chan in event class 1 (chan 10-19) */
419};
420
421struct pasemi_dmachan {
422 int chno; /* Channel number */
423 enum pasemi_dmachan_type chan_type; /* TX / RX */
424 u64 *status; /* Ptr to cacheable status */
425 int irq; /* IRQ used by channel */
426 unsigned int ring_size; /* size of allocated ring */
427 dma_addr_t ring_dma; /* DMA address for ring */
428 u64 *ring_virt; /* Virt address for ring */
429 void *priv; /* Ptr to start of client struct */
430};
431
432/* Read/write the different registers in the I/O Bridge, Ethernet
433 * and DMA Controller
434 */
435extern unsigned int pasemi_read_iob_reg(unsigned int reg);
436extern void pasemi_write_iob_reg(unsigned int reg, unsigned int val);
437
438extern unsigned int pasemi_read_mac_reg(int intf, unsigned int reg);
439extern void pasemi_write_mac_reg(int intf, unsigned int reg, unsigned int val);
440
441extern unsigned int pasemi_read_dma_reg(unsigned int reg);
442extern void pasemi_write_dma_reg(unsigned int reg, unsigned int val);
443
444/* Channel management routines */
445
446extern void *pasemi_dma_alloc_chan(enum pasemi_dmachan_type type,
447 int total_size, int offset);
448extern void pasemi_dma_free_chan(struct pasemi_dmachan *chan);
449
450extern void pasemi_dma_start_chan(const struct pasemi_dmachan *chan,
451 const u32 cmdsta);
452extern int pasemi_dma_stop_chan(const struct pasemi_dmachan *chan);
453
454/* Common routines to allocate rings and buffers */
455
456extern int pasemi_dma_alloc_ring(struct pasemi_dmachan *chan, int ring_size);
457extern void pasemi_dma_free_ring(struct pasemi_dmachan *chan);
458
459extern void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
460 dma_addr_t *handle);
461extern void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
462 dma_addr_t *handle);
463
464/* Initialize the library, must be called before any other functions */
465extern int pasemi_dma_init(void);
466
467#endif /* ASM_PASEMI_DMA_H */
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h
index dc318458b5fe..e5802c62f428 100644
--- a/include/asm-powerpc/pci-bridge.h
+++ b/include/asm-powerpc/pci-bridge.h
@@ -1,15 +1,42 @@
1#ifndef _ASM_POWERPC_PCI_BRIDGE_H 1#ifndef _ASM_POWERPC_PCI_BRIDGE_H
2#define _ASM_POWERPC_PCI_BRIDGE_H 2#define _ASM_POWERPC_PCI_BRIDGE_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4/*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
5#include <linux/pci.h> 10#include <linux/pci.h>
6#include <linux/list.h> 11#include <linux/list.h>
7#include <linux/ioport.h> 12#include <linux/ioport.h>
8 13
9#ifndef CONFIG_PPC64
10
11struct device_node; 14struct device_node;
12struct pci_controller; 15
16extern unsigned int ppc_pci_flags;
17enum {
18 /* Force re-assigning all resources (ignore firmware
19 * setup completely)
20 */
21 PPC_PCI_REASSIGN_ALL_RSRC = 0x00000001,
22
23 /* Re-assign all bus numbers */
24 PPC_PCI_REASSIGN_ALL_BUS = 0x00000002,
25
26 /* Do not try to assign, just use existing setup */
27 PPC_PCI_PROBE_ONLY = 0x00000004,
28
29 /* Don't bother with ISA alignment unless the bridge has
30 * ISA forwarding enabled
31 */
32 PPC_PCI_CAN_SKIP_ISA_ALIGN = 0x00000008,
33
34 /* Enable domain numbers in /proc */
35 PPC_PCI_ENABLE_PROC_DOMAINS = 0x00000010,
36 /* ... except for domain 0 */
37 PPC_PCI_COMPAT_DOMAIN_0 = 0x00000020,
38};
39
13 40
14/* 41/*
15 * Structure of a PCI controller (host bridge) 42 * Structure of a PCI controller (host bridge)
@@ -17,26 +44,41 @@ struct pci_controller;
17struct pci_controller { 44struct pci_controller {
18 struct pci_bus *bus; 45 struct pci_bus *bus;
19 char is_dynamic; 46 char is_dynamic;
20 void *arch_data; 47#ifdef CONFIG_PPC64
48 int node;
49#endif
50 struct device_node *dn;
21 struct list_head list_node; 51 struct list_head list_node;
22 struct device *parent; 52 struct device *parent;
23 53
24 int first_busno; 54 int first_busno;
25 int last_busno; 55 int last_busno;
56#ifndef CONFIG_PPC64
26 int self_busno; 57 int self_busno;
58#endif
27 59
28 void __iomem *io_base_virt; 60 void __iomem *io_base_virt;
61#ifdef CONFIG_PPC64
62 void *io_base_alloc;
63#endif
29 resource_size_t io_base_phys; 64 resource_size_t io_base_phys;
65#ifndef CONFIG_PPC64
66 resource_size_t pci_io_size;
67#endif
30 68
31 /* Some machines (PReP) have a non 1:1 mapping of 69 /* Some machines (PReP) have a non 1:1 mapping of
32 * the PCI memory space in the CPU bus space 70 * the PCI memory space in the CPU bus space
33 */ 71 */
34 resource_size_t pci_mem_offset; 72 resource_size_t pci_mem_offset;
73#ifdef CONFIG_PPC64
74 unsigned long pci_io_size;
75#endif
35 76
36 struct pci_ops *ops; 77 struct pci_ops *ops;
37 volatile unsigned int __iomem *cfg_addr; 78 unsigned int __iomem *cfg_addr;
38 volatile void __iomem *cfg_data; 79 void __iomem *cfg_data;
39 80
81#ifndef CONFIG_PPC64
40 /* 82 /*
41 * Used for variants of PCI indirect handling and possible quirks: 83 * Used for variants of PCI indirect handling and possible quirks:
42 * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1 84 * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1
@@ -51,21 +93,30 @@ struct pci_controller {
51 * set. 93 * set.
52 * BIG_ENDIAN - cfg_addr is a big endian register 94 * BIG_ENDIAN - cfg_addr is a big endian register
53 */ 95 */
54#define PPC_INDIRECT_TYPE_SET_CFG_TYPE (0x00000001) 96#define PPC_INDIRECT_TYPE_SET_CFG_TYPE 0x00000001
55#define PPC_INDIRECT_TYPE_EXT_REG (0x00000002) 97#define PPC_INDIRECT_TYPE_EXT_REG 0x00000002
56#define PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS (0x00000004) 98#define PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS 0x00000004
57#define PPC_INDIRECT_TYPE_NO_PCIE_LINK (0x00000008) 99#define PPC_INDIRECT_TYPE_NO_PCIE_LINK 0x00000008
58#define PPC_INDIRECT_TYPE_BIG_ENDIAN (0x00000010) 100#define PPC_INDIRECT_TYPE_BIG_ENDIAN 0x00000010
59 u32 indirect_type; 101 u32 indirect_type;
60 102#endif /* !CONFIG_PPC64 */
61 /* Currently, we limit ourselves to 1 IO range and 3 mem 103 /* Currently, we limit ourselves to 1 IO range and 3 mem
62 * ranges since the common pci_bus structure can't handle more 104 * ranges since the common pci_bus structure can't handle more
63 */ 105 */
64 struct resource io_resource; 106 struct resource io_resource;
65 struct resource mem_resources[3]; 107 struct resource mem_resources[3];
66 int global_number; /* PCI domain number */ 108 int global_number; /* PCI domain number */
109#ifdef CONFIG_PPC64
110 unsigned long buid;
111 unsigned long dma_window_base_cur;
112 unsigned long dma_window_size;
113
114 void *private_data;
115#endif /* CONFIG_PPC64 */
67}; 116};
68 117
118#ifndef CONFIG_PPC64
119
69static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) 120static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
70{ 121{
71 return bus->sysdata; 122 return bus->sysdata;
@@ -81,18 +132,18 @@ static inline int isa_vaddr_is_ioport(void __iomem *address)
81 132
82/* These are used for config access before all the PCI probing 133/* These are used for config access before all the PCI probing
83 has been done. */ 134 has been done. */
84int early_read_config_byte(struct pci_controller *hose, int bus, int dev_fn, 135extern int early_read_config_byte(struct pci_controller *hose, int bus,
85 int where, u8 *val); 136 int dev_fn, int where, u8 *val);
86int early_read_config_word(struct pci_controller *hose, int bus, int dev_fn, 137extern int early_read_config_word(struct pci_controller *hose, int bus,
87 int where, u16 *val); 138 int dev_fn, int where, u16 *val);
88int early_read_config_dword(struct pci_controller *hose, int bus, int dev_fn, 139extern int early_read_config_dword(struct pci_controller *hose, int bus,
89 int where, u32 *val); 140 int dev_fn, int where, u32 *val);
90int early_write_config_byte(struct pci_controller *hose, int bus, int dev_fn, 141extern int early_write_config_byte(struct pci_controller *hose, int bus,
91 int where, u8 val); 142 int dev_fn, int where, u8 val);
92int early_write_config_word(struct pci_controller *hose, int bus, int dev_fn, 143extern int early_write_config_word(struct pci_controller *hose, int bus,
93 int where, u16 val); 144 int dev_fn, int where, u16 val);
94int early_write_config_dword(struct pci_controller *hose, int bus, int dev_fn, 145extern int early_write_config_dword(struct pci_controller *hose, int bus,
95 int where, u32 val); 146 int dev_fn, int where, u32 val);
96 147
97extern int early_find_capability(struct pci_controller *hose, int bus, 148extern int early_find_capability(struct pci_controller *hose, int bus,
98 int dev_fn, int cap); 149 int dev_fn, int cap);
@@ -101,87 +152,33 @@ extern void setup_indirect_pci(struct pci_controller* hose,
101 resource_size_t cfg_addr, 152 resource_size_t cfg_addr,
102 resource_size_t cfg_data, u32 flags); 153 resource_size_t cfg_data, u32 flags);
103extern void setup_grackle(struct pci_controller *hose); 154extern void setup_grackle(struct pci_controller *hose);
104extern void __init update_bridge_resource(struct pci_dev *dev, 155#else /* CONFIG_PPC64 */
105 struct resource *res);
106
107#else
108
109
110/*
111 * This program is free software; you can redistribute it and/or
112 * modify it under the terms of the GNU General Public License
113 * as published by the Free Software Foundation; either version
114 * 2 of the License, or (at your option) any later version.
115 */
116
117/*
118 * Structure of a PCI controller (host bridge)
119 */
120struct pci_controller {
121 struct pci_bus *bus;
122 char is_dynamic;
123 int node;
124 void *arch_data;
125 struct list_head list_node;
126 struct device *parent;
127
128 int first_busno;
129 int last_busno;
130
131 void __iomem *io_base_virt;
132 void *io_base_alloc;
133 resource_size_t io_base_phys;
134
135 /* Some machines have a non 1:1 mapping of
136 * the PCI memory space in the CPU bus space
137 */
138 resource_size_t pci_mem_offset;
139 unsigned long pci_io_size;
140
141 struct pci_ops *ops;
142 volatile unsigned int __iomem *cfg_addr;
143 volatile void __iomem *cfg_data;
144
145 /* Currently, we limit ourselves to 1 IO range and 3 mem
146 * ranges since the common pci_bus structure can't handle more
147 */
148 struct resource io_resource;
149 struct resource mem_resources[3];
150 int global_number;
151 unsigned long buid;
152 unsigned long dma_window_base_cur;
153 unsigned long dma_window_size;
154
155 void *private_data;
156};
157 156
158/* 157/*
159 * PCI stuff, for nodes representing PCI devices, pointed to 158 * PCI stuff, for nodes representing PCI devices, pointed to
160 * by device_node->data. 159 * by device_node->data.
161 */ 160 */
162struct pci_controller;
163struct iommu_table; 161struct iommu_table;
164 162
165struct pci_dn { 163struct pci_dn {
166 int busno; /* pci bus number */ 164 int busno; /* pci bus number */
167 int bussubno; /* pci subordinate bus number */
168 int devfn; /* pci device and function number */ 165 int devfn; /* pci device and function number */
169 int class_code; /* pci device class */
170 166
171 struct pci_controller *phb; /* for pci devices */ 167 struct pci_controller *phb; /* for pci devices */
172 struct iommu_table *iommu_table; /* for phb's or bridges */ 168 struct iommu_table *iommu_table; /* for phb's or bridges */
173 struct pci_dev *pcidev; /* back-pointer to the pci device */
174 struct device_node *node; /* back-pointer to the device_node */ 169 struct device_node *node; /* back-pointer to the device_node */
175 170
176 int pci_ext_config_space; /* for pci devices */ 171 int pci_ext_config_space; /* for pci devices */
177 172
178#ifdef CONFIG_EEH 173#ifdef CONFIG_EEH
174 struct pci_dev *pcidev; /* back-pointer to the pci device */
175 int class_code; /* pci device class */
179 int eeh_mode; /* See eeh.h for possible EEH_MODEs */ 176 int eeh_mode; /* See eeh.h for possible EEH_MODEs */
180 int eeh_config_addr; 177 int eeh_config_addr;
181 int eeh_pe_config_addr; /* new-style partition endpoint address */ 178 int eeh_pe_config_addr; /* new-style partition endpoint address */
182 int eeh_check_count; /* # times driver ignored error */ 179 int eeh_check_count; /* # times driver ignored error */
183 int eeh_freeze_count; /* # times this device froze up. */ 180 int eeh_freeze_count; /* # times this device froze up. */
184 int eeh_false_positives; /* # times this device reported #ff's */ 181 int eeh_false_positives; /* # times this device reported #ff's */
185 u32 config_space[16]; /* saved PCI config space */ 182 u32 config_space[16]; /* saved PCI config space */
186#endif 183#endif
187}; 184};
@@ -189,7 +186,7 @@ struct pci_dn {
189/* Get the pointer to a device_node's pci_dn */ 186/* Get the pointer to a device_node's pci_dn */
190#define PCI_DN(dn) ((struct pci_dn *) (dn)->data) 187#define PCI_DN(dn) ((struct pci_dn *) (dn)->data)
191 188
192struct device_node *fetch_dev_dn(struct pci_dev *dev); 189extern struct device_node *fetch_dev_dn(struct pci_dev *dev);
193 190
194/* Get a device_node from a pci_dev. This code must be fast except 191/* Get a device_node from a pci_dev. This code must be fast except
195 * in the case where the sysdata is incorrect and needs to be fixed 192 * in the case where the sysdata is incorrect and needs to be fixed
@@ -227,14 +224,14 @@ static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
227} 224}
228 225
229/** Find the bus corresponding to the indicated device node */ 226/** Find the bus corresponding to the indicated device node */
230struct pci_bus * pcibios_find_pci_bus(struct device_node *dn); 227extern struct pci_bus *pcibios_find_pci_bus(struct device_node *dn);
231 228
232/** Remove all of the PCI devices under this bus */ 229/** Remove all of the PCI devices under this bus */
233void pcibios_remove_pci_devices(struct pci_bus *bus); 230extern void pcibios_remove_pci_devices(struct pci_bus *bus);
234 231
235/** Discover new pci devices under this bus, and add them */ 232/** Discover new pci devices under this bus, and add them */
236void pcibios_add_pci_devices(struct pci_bus * bus); 233extern void pcibios_add_pci_devices(struct pci_bus *bus);
237void pcibios_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus); 234extern void pcibios_fixup_new_pci_devices(struct pci_bus *bus);
238 235
239extern int pcibios_remove_root_bus(struct pci_controller *phb); 236extern int pcibios_remove_root_bus(struct pci_controller *phb);
240 237
@@ -246,7 +243,6 @@ static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
246 return PCI_DN(busdn)->phb; 243 return PCI_DN(busdn)->phb;
247} 244}
248 245
249extern void pcibios_free_controller(struct pci_controller *phb);
250 246
251extern void isa_bridge_find_early(struct pci_controller *hose); 247extern void isa_bridge_find_early(struct pci_controller *hose);
252 248
@@ -271,20 +267,20 @@ extern int pcibios_map_io_space(struct pci_bus *bus);
271#define PHB_SET_NODE(PHB, NODE) ((PHB)->node = -1) 267#define PHB_SET_NODE(PHB, NODE) ((PHB)->node = -1)
272#endif 268#endif
273 269
274#endif /* CONFIG_PPC64 */ 270#endif /* CONFIG_PPC64 */
275 271
276/* Get the PCI host controller for an OF device */ 272/* Get the PCI host controller for an OF device */
277extern struct pci_controller* 273extern struct pci_controller *pci_find_hose_for_OF_device(
278pci_find_hose_for_OF_device(struct device_node* node); 274 struct device_node* node);
279 275
280/* Fill up host controller resources from the OF node */ 276/* Fill up host controller resources from the OF node */
281extern void 277extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
282pci_process_bridge_OF_ranges(struct pci_controller *hose, 278 struct device_node *dev, int primary);
283 struct device_node *dev, int primary); 279
280/* Allocate & free a PCI host bridge structure */
281extern struct pci_controller *pcibios_alloc_controller(struct device_node *dev);
282extern void pcibios_free_controller(struct pci_controller *phb);
284 283
285/* Allocate a new PCI host bridge structure */
286extern struct pci_controller *
287pcibios_alloc_controller(struct device_node *dev);
288#ifdef CONFIG_PCI 284#ifdef CONFIG_PCI
289extern unsigned long pci_address_to_pio(phys_addr_t address); 285extern unsigned long pci_address_to_pio(phys_addr_t address);
290extern int pcibios_vaddr_is_ioport(void __iomem *address); 286extern int pcibios_vaddr_is_ioport(void __iomem *address);
@@ -297,9 +293,7 @@ static inline int pcibios_vaddr_is_ioport(void __iomem *address)
297{ 293{
298 return 0; 294 return 0;
299} 295}
300#endif 296#endif /* CONFIG_PCI */
301
302 297
303 298#endif /* __KERNEL__ */
304#endif /* __KERNEL__ */ 299#endif /* _ASM_POWERPC_PCI_BRIDGE_H */
305#endif
diff --git a/include/asm-powerpc/pci.h b/include/asm-powerpc/pci.h
index 7b11765c6865..a05a942b1c25 100644
--- a/include/asm-powerpc/pci.h
+++ b/include/asm-powerpc/pci.h
@@ -36,11 +36,10 @@ struct pci_dev;
36 36
37/* 37/*
38 * Set this to 1 if you want the kernel to re-assign all PCI 38 * Set this to 1 if you want the kernel to re-assign all PCI
39 * bus numbers 39 * bus numbers (don't do that on ppc64 yet !)
40 */ 40 */
41extern int pci_assign_all_buses; 41#define pcibios_assign_all_busses() (ppc_pci_flags & \
42#define pcibios_assign_all_busses() (pci_assign_all_buses) 42 PPC_PCI_REASSIGN_ALL_BUS)
43
44#define pcibios_scan_all_fns(a, b) 0 43#define pcibios_scan_all_fns(a, b) 0
45 44
46static inline void pcibios_set_master(struct pci_dev *dev) 45static inline void pcibios_set_master(struct pci_dev *dev)
@@ -95,9 +94,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
95#define get_pci_dma_ops() NULL 94#define get_pci_dma_ops() NULL
96#endif 95#endif
97 96
98/* Decide whether to display the domain number in /proc */
99extern int pci_proc_domain(struct pci_bus *bus);
100
101#else /* 32-bit */ 97#else /* 32-bit */
102 98
103#ifdef CONFIG_PCI 99#ifdef CONFIG_PCI
@@ -109,17 +105,14 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
109 *strategy_parameter = ~0UL; 105 *strategy_parameter = ~0UL;
110} 106}
111#endif 107#endif
112
113/* Set the name of the bus as it appears in /proc/bus/pci */
114static inline int pci_proc_domain(struct pci_bus *bus)
115{
116 return 0;
117}
118
119#endif /* CONFIG_PPC64 */ 108#endif /* CONFIG_PPC64 */
120 109
121extern int pci_domain_nr(struct pci_bus *bus); 110extern int pci_domain_nr(struct pci_bus *bus);
122 111
112/* Decide whether to display the domain number in /proc */
113extern int pci_proc_domain(struct pci_bus *bus);
114
115
123struct vm_area_struct; 116struct vm_area_struct;
124/* Map a range of PCI memory or I/O space for a device into user space */ 117/* Map a range of PCI memory or I/O space for a device into user space */
125int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma, 118int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
@@ -199,13 +192,12 @@ static inline struct resource *pcibios_select_root(struct pci_dev *pdev,
199 return root; 192 return root;
200} 193}
201 194
202extern void pcibios_fixup_device_resources(struct pci_dev *dev,
203 struct pci_bus *bus);
204
205extern void pcibios_setup_new_device(struct pci_dev *dev); 195extern void pcibios_setup_new_device(struct pci_dev *dev);
206 196
207extern void pcibios_claim_one_bus(struct pci_bus *b); 197extern void pcibios_claim_one_bus(struct pci_bus *b);
208 198
199extern void pcibios_resource_survey(void);
200
209extern struct pci_controller *init_phb_dynamic(struct device_node *dn); 201extern struct pci_controller *init_phb_dynamic(struct device_node *dn);
210 202
211extern struct pci_dev *of_create_pci_dev(struct device_node *node, 203extern struct pci_dev *of_create_pci_dev(struct device_node *node,
@@ -229,5 +221,8 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
229 const struct resource *rsrc, 221 const struct resource *rsrc,
230 resource_size_t *start, resource_size_t *end); 222 resource_size_t *start, resource_size_t *end);
231 223
224extern void pcibios_do_bus_setup(struct pci_bus *bus);
225extern void pcibios_fixup_of_probed_bus(struct pci_bus *bus);
226
232#endif /* __KERNEL__ */ 227#endif /* __KERNEL__ */
233#endif /* __ASM_POWERPC_PCI_H */ 228#endif /* __ASM_POWERPC_PCI_H */
diff --git a/include/asm-powerpc/percpu.h b/include/asm-powerpc/percpu.h
index 6b229626d3ff..ccb0523eb3b4 100644
--- a/include/asm-powerpc/percpu.h
+++ b/include/asm-powerpc/percpu.h
@@ -13,54 +13,12 @@
13#include <asm/paca.h> 13#include <asm/paca.h>
14 14
15#define __per_cpu_offset(cpu) (paca[cpu].data_offset) 15#define __per_cpu_offset(cpu) (paca[cpu].data_offset)
16#define __my_cpu_offset() get_paca()->data_offset 16#define __my_cpu_offset get_paca()->data_offset
17#define per_cpu_offset(x) (__per_cpu_offset(x)) 17#define per_cpu_offset(x) (__per_cpu_offset(x))
18 18
19/* Separate out the type, so (int[3], foo) works. */ 19#endif /* CONFIG_SMP */
20#define DEFINE_PER_CPU(type, name) \ 20#endif /* __powerpc64__ */
21 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
22 21
23#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
24 __attribute__((__section__(".data.percpu.shared_aligned"))) \
25 __typeof__(type) per_cpu__##name \
26 ____cacheline_aligned_in_smp
27
28/* var is in discarded region: offset to particular copy we want */
29#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
30#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()))
31#define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, local_paca->data_offset))
32
33/* A macro to avoid #include hell... */
34#define percpu_modcopy(pcpudst, src, size) \
35do { \
36 unsigned int __i; \
37 for_each_possible_cpu(__i) \
38 memcpy((pcpudst)+__per_cpu_offset(__i), \
39 (src), (size)); \
40} while (0)
41
42extern void setup_per_cpu_areas(void);
43
44#else /* ! SMP */
45
46#define DEFINE_PER_CPU(type, name) \
47 __typeof__(type) per_cpu__##name
48#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
49 DEFINE_PER_CPU(type, name)
50
51#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
52#define __get_cpu_var(var) per_cpu__##var
53#define __raw_get_cpu_var(var) per_cpu__##var
54
55#endif /* SMP */
56
57#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
58
59#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
60#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
61
62#else
63#include <asm-generic/percpu.h> 22#include <asm-generic/percpu.h>
64#endif
65 23
66#endif /* _ASM_POWERPC_PERCPU_H_ */ 24#endif /* _ASM_POWERPC_PERCPU_H_ */
diff --git a/include/asm-powerpc/pgalloc-64.h b/include/asm-powerpc/pgalloc-64.h
index 94d0294341d6..43214c8085b7 100644
--- a/include/asm-powerpc/pgalloc-64.h
+++ b/include/asm-powerpc/pgalloc-64.h
@@ -12,6 +12,10 @@
12#include <linux/cpumask.h> 12#include <linux/cpumask.h>
13#include <linux/percpu.h> 13#include <linux/percpu.h>
14 14
15#ifndef CONFIG_PPC_SUBPAGE_PROT
16static inline void subpage_prot_free(pgd_t *pgd) {}
17#endif
18
15extern struct kmem_cache *pgtable_cache[]; 19extern struct kmem_cache *pgtable_cache[];
16 20
17#define PGD_CACHE_NUM 0 21#define PGD_CACHE_NUM 0
@@ -27,6 +31,7 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm)
27 31
28static inline void pgd_free(pgd_t *pgd) 32static inline void pgd_free(pgd_t *pgd)
29{ 33{
34 subpage_prot_free(pgd);
30 kmem_cache_free(pgtable_cache[PGD_CACHE_NUM], pgd); 35 kmem_cache_free(pgtable_cache[PGD_CACHE_NUM], pgd);
31} 36}
32 37
diff --git a/include/asm-powerpc/pgtable-64k.h b/include/asm-powerpc/pgtable-64k.h
index bd54b772fbc6..1cbd6b377eea 100644
--- a/include/asm-powerpc/pgtable-64k.h
+++ b/include/asm-powerpc/pgtable-64k.h
@@ -13,12 +13,49 @@
13#define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE) 13#define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE)
14#define PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE) 14#define PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE)
15#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE) 15#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
16#endif /* __ASSEMBLY__ */
17 16
18#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE) 17#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)
19#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE) 18#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)
20#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE) 19#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE)
21 20
21#ifdef CONFIG_PPC_SUBPAGE_PROT
22/*
23 * For the sub-page protection option, we extend the PGD with one of
24 * these. Basically we have a 3-level tree, with the top level being
25 * the protptrs array. To optimize speed and memory consumption when
26 * only addresses < 4GB are being protected, pointers to the first
27 * four pages of sub-page protection words are stored in the low_prot
28 * array.
29 * Each page of sub-page protection words protects 1GB (4 bytes
30 * protects 64k). For the 3-level tree, each page of pointers then
31 * protects 8TB.
32 */
33struct subpage_prot_table {
34 unsigned long maxaddr; /* only addresses < this are protected */
35 unsigned int **protptrs[2];
36 unsigned int *low_prot[4];
37};
38
39#undef PGD_TABLE_SIZE
40#define PGD_TABLE_SIZE ((sizeof(pgd_t) << PGD_INDEX_SIZE) + \
41 sizeof(struct subpage_prot_table))
42
43#define SBP_L1_BITS (PAGE_SHIFT - 2)
44#define SBP_L2_BITS (PAGE_SHIFT - 3)
45#define SBP_L1_COUNT (1 << SBP_L1_BITS)
46#define SBP_L2_COUNT (1 << SBP_L2_BITS)
47#define SBP_L2_SHIFT (PAGE_SHIFT + SBP_L1_BITS)
48#define SBP_L3_SHIFT (SBP_L2_SHIFT + SBP_L2_BITS)
49
50extern void subpage_prot_free(pgd_t *pgd);
51
52static inline struct subpage_prot_table *pgd_subpage_prot(pgd_t *pgd)
53{
54 return (struct subpage_prot_table *)(pgd + PTRS_PER_PGD);
55}
56#endif /* CONFIG_PPC_SUBPAGE_PROT */
57#endif /* __ASSEMBLY__ */
58
22/* With 4k base page size, hugepage PTEs go at the PMD level */ 59/* With 4k base page size, hugepage PTEs go at the PMD level */
23#define MIN_HUGEPTE_SHIFT PAGE_SHIFT 60#define MIN_HUGEPTE_SHIFT PAGE_SHIFT
24 61
diff --git a/include/asm-powerpc/pgtable-ppc32.h b/include/asm-powerpc/pgtable-ppc32.h
index 86a54a4a8a2a..d1332bbcbd9b 100644
--- a/include/asm-powerpc/pgtable-ppc32.h
+++ b/include/asm-powerpc/pgtable-ppc32.h
@@ -11,6 +11,11 @@
11extern unsigned long va_to_phys(unsigned long address); 11extern unsigned long va_to_phys(unsigned long address);
12extern pte_t *va_to_pte(unsigned long address); 12extern pte_t *va_to_pte(unsigned long address);
13extern unsigned long ioremap_bot, ioremap_base; 13extern unsigned long ioremap_bot, ioremap_base;
14
15#ifdef CONFIG_44x
16extern int icache_44x_need_flush;
17#endif
18
14#endif /* __ASSEMBLY__ */ 19#endif /* __ASSEMBLY__ */
15 20
16/* 21/*
@@ -81,6 +86,11 @@ extern unsigned long ioremap_bot, ioremap_base;
81 * entries per page directory level: our page-table tree is two-level, so 86 * entries per page directory level: our page-table tree is two-level, so
82 * we don't really have any PMD directory. 87 * we don't really have any PMD directory.
83 */ 88 */
89#ifndef __ASSEMBLY__
90#define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_SHIFT)
91#define PGD_TABLE_SIZE (sizeof(pgd_t) << (32 - PGDIR_SHIFT))
92#endif /* __ASSEMBLY__ */
93
84#define PTRS_PER_PTE (1 << PTE_SHIFT) 94#define PTRS_PER_PTE (1 << PTE_SHIFT)
85#define PTRS_PER_PMD 1 95#define PTRS_PER_PMD 1
86#define PTRS_PER_PGD (1 << (32 - PGDIR_SHIFT)) 96#define PTRS_PER_PGD (1 << (32 - PGDIR_SHIFT))
@@ -562,6 +572,10 @@ static inline unsigned long pte_update(pte_t *p, unsigned long clr,
562 : "=&r" (old), "=&r" (tmp), "=m" (*p) 572 : "=&r" (old), "=&r" (tmp), "=m" (*p)
563 : "r" (p), "r" (clr), "r" (set), "m" (*p) 573 : "r" (p), "r" (clr), "r" (set), "m" (*p)
564 : "cc" ); 574 : "cc" );
575#ifdef CONFIG_44x
576 if ((old & _PAGE_USER) && (old & _PAGE_HWEXEC))
577 icache_44x_need_flush = 1;
578#endif
565 return old; 579 return old;
566} 580}
567#else 581#else
@@ -582,6 +596,10 @@ static inline unsigned long long pte_update(pte_t *p, unsigned long clr,
582 : "=&r" (old), "=&r" (tmp), "=m" (*p) 596 : "=&r" (old), "=&r" (tmp), "=m" (*p)
583 : "r" (p), "r" ((unsigned long)(p) + 4), "r" (clr), "r" (set), "m" (*p) 597 : "r" (p), "r" ((unsigned long)(p) + 4), "r" (clr), "r" (set), "m" (*p)
584 : "cc" ); 598 : "cc" );
599#ifdef CONFIG_44x
600 if ((old & _PAGE_USER) && (old & _PAGE_HWEXEC))
601 icache_44x_need_flush = 1;
602#endif
585 return old; 603 return old;
586} 604}
587#endif 605#endif
diff --git a/include/asm-powerpc/ppc-pci.h b/include/asm-powerpc/ppc-pci.h
index b847aa10074b..854ab713f56c 100644
--- a/include/asm-powerpc/ppc-pci.h
+++ b/include/asm-powerpc/ppc-pci.h
@@ -22,7 +22,6 @@ extern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary);
22 22
23 23
24extern struct list_head hose_list; 24extern struct list_head hose_list;
25extern int global_phb_number;
26 25
27extern void find_and_init_phbs(void); 26extern void find_and_init_phbs(void);
28 27
@@ -47,9 +46,6 @@ extern void init_pci_config_tokens (void);
47extern unsigned long get_phb_buid (struct device_node *); 46extern unsigned long get_phb_buid (struct device_node *);
48extern int rtas_setup_phb(struct pci_controller *phb); 47extern int rtas_setup_phb(struct pci_controller *phb);
49 48
50/* From iSeries PCI */
51extern void iSeries_pcibios_init(void);
52
53extern unsigned long pci_probe_only; 49extern unsigned long pci_probe_only;
54 50
55/* ---- EEH internal-use-only related routines ---- */ 51/* ---- EEH internal-use-only related routines ---- */
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 925e2d384bb3..78b7b0d494c0 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -202,6 +202,10 @@ static inline unsigned long of_read_ulong(const u32 *cell, int size)
202 */ 202 */
203extern u64 of_translate_address(struct device_node *np, const u32 *addr); 203extern u64 of_translate_address(struct device_node *np, const u32 *addr);
204 204
205/* Translate a DMA address from device space to CPU space */
206extern u64 of_translate_dma_address(struct device_node *dev,
207 const u32 *in_addr);
208
205/* Extract an address from a device, returns the region size and 209/* Extract an address from a device, returns the region size and
206 * the address space flags too. The PCI version uses a BAR number 210 * the address space flags too. The PCI version uses a BAR number
207 * instead of an absolute index 211 * instead of an absolute index
diff --git a/include/asm-powerpc/ps3.h b/include/asm-powerpc/ps3.h
index f577a16c6728..2b693673eff4 100644
--- a/include/asm-powerpc/ps3.h
+++ b/include/asm-powerpc/ps3.h
@@ -24,6 +24,7 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/types.h> 25#include <linux/types.h>
26#include <linux/device.h> 26#include <linux/device.h>
27#include "cell-pmu.h"
27 28
28union ps3_firmware_version { 29union ps3_firmware_version {
29 u64 raw; 30 u64 raw;
@@ -317,6 +318,7 @@ enum ps3_match_id {
317 PS3_MATCH_ID_STOR_FLASH = 8, 318 PS3_MATCH_ID_STOR_FLASH = 8,
318 PS3_MATCH_ID_SOUND = 9, 319 PS3_MATCH_ID_SOUND = 9,
319 PS3_MATCH_ID_GRAPHICS = 10, 320 PS3_MATCH_ID_GRAPHICS = 10,
321 PS3_MATCH_ID_LPM = 11,
320}; 322};
321 323
322#define PS3_MODULE_ALIAS_EHCI "ps3:1" 324#define PS3_MODULE_ALIAS_EHCI "ps3:1"
@@ -329,11 +331,13 @@ enum ps3_match_id {
329#define PS3_MODULE_ALIAS_STOR_FLASH "ps3:8" 331#define PS3_MODULE_ALIAS_STOR_FLASH "ps3:8"
330#define PS3_MODULE_ALIAS_SOUND "ps3:9" 332#define PS3_MODULE_ALIAS_SOUND "ps3:9"
331#define PS3_MODULE_ALIAS_GRAPHICS "ps3:10" 333#define PS3_MODULE_ALIAS_GRAPHICS "ps3:10"
334#define PS3_MODULE_ALIAS_LPM "ps3:11"
332 335
333enum ps3_system_bus_device_type { 336enum ps3_system_bus_device_type {
334 PS3_DEVICE_TYPE_IOC0 = 1, 337 PS3_DEVICE_TYPE_IOC0 = 1,
335 PS3_DEVICE_TYPE_SB, 338 PS3_DEVICE_TYPE_SB,
336 PS3_DEVICE_TYPE_VUART, 339 PS3_DEVICE_TYPE_VUART,
340 PS3_DEVICE_TYPE_LPM,
337}; 341};
338 342
339/** 343/**
@@ -344,12 +348,17 @@ struct ps3_system_bus_device {
344 enum ps3_match_id match_id; 348 enum ps3_match_id match_id;
345 enum ps3_system_bus_device_type dev_type; 349 enum ps3_system_bus_device_type dev_type;
346 350
347 unsigned int bus_id; /* SB */ 351 u64 bus_id; /* SB */
348 unsigned int dev_id; /* SB */ 352 u64 dev_id; /* SB */
349 unsigned int interrupt_id; /* SB */ 353 unsigned int interrupt_id; /* SB */
350 struct ps3_dma_region *d_region; /* SB, IOC0 */ 354 struct ps3_dma_region *d_region; /* SB, IOC0 */
351 struct ps3_mmio_region *m_region; /* SB, IOC0*/ 355 struct ps3_mmio_region *m_region; /* SB, IOC0*/
352 unsigned int port_number; /* VUART */ 356 unsigned int port_number; /* VUART */
357 struct { /* LPM */
358 u64 node_id;
359 u64 pu_id;
360 u64 rights;
361 } lpm;
353 362
354/* struct iommu_table *iommu_table; -- waiting for BenH's cleanups */ 363/* struct iommu_table *iommu_table; -- waiting for BenH's cleanups */
355 struct device core; 364 struct device core;
@@ -438,5 +447,66 @@ struct ps3_prealloc {
438extern struct ps3_prealloc ps3fb_videomemory; 447extern struct ps3_prealloc ps3fb_videomemory;
439extern struct ps3_prealloc ps3flash_bounce_buffer; 448extern struct ps3_prealloc ps3flash_bounce_buffer;
440 449
450/* logical performance monitor */
451
452/**
453 * enum ps3_lpm_rights - Rigths granted by the system policy module.
454 *
455 * @PS3_LPM_RIGHTS_USE_LPM: The right to use the lpm.
456 * @PS3_LPM_RIGHTS_USE_TB: The right to use the internal trace buffer.
457 */
458
459enum ps3_lpm_rights {
460 PS3_LPM_RIGHTS_USE_LPM = 0x001,
461 PS3_LPM_RIGHTS_USE_TB = 0x100,
462};
463
464/**
465 * enum ps3_lpm_tb_type - Type of trace buffer lv1 should use.
466 *
467 * @PS3_LPM_TB_TYPE_NONE: Do not use a trace buffer.
468 * @PS3_LPM_RIGHTS_USE_TB: Use the lv1 internal trace buffer. Must have
469 * rights @PS3_LPM_RIGHTS_USE_TB.
470 */
471
472enum ps3_lpm_tb_type {
473 PS3_LPM_TB_TYPE_NONE = 0,
474 PS3_LPM_TB_TYPE_INTERNAL = 1,
475};
476
477int ps3_lpm_open(enum ps3_lpm_tb_type tb_type, void *tb_cache,
478 u64 tb_cache_size);
479int ps3_lpm_close(void);
480int ps3_lpm_copy_tb(unsigned long offset, void *buf, unsigned long count,
481 unsigned long *bytes_copied);
482int ps3_lpm_copy_tb_to_user(unsigned long offset, void __user *buf,
483 unsigned long count, unsigned long *bytes_copied);
484void ps3_set_bookmark(u64 bookmark);
485void ps3_set_pm_bookmark(u64 tag, u64 incident, u64 th_id);
486int ps3_set_signal(u64 rtas_signal_group, u8 signal_bit, u16 sub_unit,
487 u8 bus_word);
488
489u32 ps3_read_phys_ctr(u32 cpu, u32 phys_ctr);
490void ps3_write_phys_ctr(u32 cpu, u32 phys_ctr, u32 val);
491u32 ps3_read_ctr(u32 cpu, u32 ctr);
492void ps3_write_ctr(u32 cpu, u32 ctr, u32 val);
493
494u32 ps3_read_pm07_control(u32 cpu, u32 ctr);
495void ps3_write_pm07_control(u32 cpu, u32 ctr, u32 val);
496u32 ps3_read_pm(u32 cpu, enum pm_reg_name reg);
497void ps3_write_pm(u32 cpu, enum pm_reg_name reg, u32 val);
498
499u32 ps3_get_ctr_size(u32 cpu, u32 phys_ctr);
500void ps3_set_ctr_size(u32 cpu, u32 phys_ctr, u32 ctr_size);
501
502void ps3_enable_pm(u32 cpu);
503void ps3_disable_pm(u32 cpu);
504void ps3_enable_pm_interrupts(u32 cpu, u32 thread, u32 mask);
505void ps3_disable_pm_interrupts(u32 cpu);
506
507u32 ps3_get_and_clear_pm_interrupts(u32 cpu);
508void ps3_sync_irq(int node);
509u32 ps3_get_hw_thread_id(int cpu);
510u64 ps3_get_spe_id(void *arg);
441 511
442#endif 512#endif
diff --git a/include/asm-powerpc/ptrace.h b/include/asm-powerpc/ptrace.h
index 13fccc5a4119..ffc150f602b8 100644
--- a/include/asm-powerpc/ptrace.h
+++ b/include/asm-powerpc/ptrace.h
@@ -106,7 +106,8 @@ extern int ptrace_put_reg(struct task_struct *task, int regno,
106 */ 106 */
107#define FULL_REGS(regs) (((regs)->trap & 1) == 0) 107#define FULL_REGS(regs) (((regs)->trap & 1) == 0)
108#ifndef __powerpc64__ 108#ifndef __powerpc64__
109#define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) == 0) 109#define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) != 0)
110#define IS_MCHECK_EXC(regs) (((regs)->trap & 4) != 0)
110#endif /* ! __powerpc64__ */ 111#endif /* ! __powerpc64__ */
111#define TRAP(regs) ((regs)->trap & ~0xF) 112#define TRAP(regs) ((regs)->trap & ~0xF)
112#ifdef __powerpc64__ 113#ifdef __powerpc64__
@@ -119,6 +120,13 @@ do { \
119} while (0) 120} while (0)
120#endif /* __powerpc64__ */ 121#endif /* __powerpc64__ */
121 122
123/*
124 * These are defined as per linux/ptrace.h, which see.
125 */
126#define arch_has_single_step() (1)
127extern void user_enable_single_step(struct task_struct *);
128extern void user_disable_single_step(struct task_struct *);
129
122#endif /* __ASSEMBLY__ */ 130#endif /* __ASSEMBLY__ */
123 131
124#endif /* __KERNEL__ */ 132#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/qe.h b/include/asm-powerpc/qe.h
index 0dabe46a29d2..430dc77b35fc 100644
--- a/include/asm-powerpc/qe.h
+++ b/include/asm-powerpc/qe.h
@@ -28,6 +28,52 @@
28#define MEM_PART_SECONDARY 1 28#define MEM_PART_SECONDARY 1
29#define MEM_PART_MURAM 2 29#define MEM_PART_MURAM 2
30 30
31/* Clocks and BRGs */
32enum qe_clock {
33 QE_CLK_NONE = 0,
34 QE_BRG1, /* Baud Rate Generator 1 */
35 QE_BRG2, /* Baud Rate Generator 2 */
36 QE_BRG3, /* Baud Rate Generator 3 */
37 QE_BRG4, /* Baud Rate Generator 4 */
38 QE_BRG5, /* Baud Rate Generator 5 */
39 QE_BRG6, /* Baud Rate Generator 6 */
40 QE_BRG7, /* Baud Rate Generator 7 */
41 QE_BRG8, /* Baud Rate Generator 8 */
42 QE_BRG9, /* Baud Rate Generator 9 */
43 QE_BRG10, /* Baud Rate Generator 10 */
44 QE_BRG11, /* Baud Rate Generator 11 */
45 QE_BRG12, /* Baud Rate Generator 12 */
46 QE_BRG13, /* Baud Rate Generator 13 */
47 QE_BRG14, /* Baud Rate Generator 14 */
48 QE_BRG15, /* Baud Rate Generator 15 */
49 QE_BRG16, /* Baud Rate Generator 16 */
50 QE_CLK1, /* Clock 1 */
51 QE_CLK2, /* Clock 2 */
52 QE_CLK3, /* Clock 3 */
53 QE_CLK4, /* Clock 4 */
54 QE_CLK5, /* Clock 5 */
55 QE_CLK6, /* Clock 6 */
56 QE_CLK7, /* Clock 7 */
57 QE_CLK8, /* Clock 8 */
58 QE_CLK9, /* Clock 9 */
59 QE_CLK10, /* Clock 10 */
60 QE_CLK11, /* Clock 11 */
61 QE_CLK12, /* Clock 12 */
62 QE_CLK13, /* Clock 13 */
63 QE_CLK14, /* Clock 14 */
64 QE_CLK15, /* Clock 15 */
65 QE_CLK16, /* Clock 16 */
66 QE_CLK17, /* Clock 17 */
67 QE_CLK18, /* Clock 18 */
68 QE_CLK19, /* Clock 19 */
69 QE_CLK20, /* Clock 20 */
70 QE_CLK21, /* Clock 21 */
71 QE_CLK22, /* Clock 22 */
72 QE_CLK23, /* Clock 23 */
73 QE_CLK24, /* Clock 24 */
74 QE_CLK_DUMMY
75};
76
31/* Export QE common operations */ 77/* Export QE common operations */
32extern void qe_reset(void); 78extern void qe_reset(void);
33extern int par_io_init(struct device_node *np); 79extern int par_io_init(struct device_node *np);
@@ -38,7 +84,8 @@ extern int par_io_data_set(u8 port, u8 pin, u8 val);
38 84
39/* QE internal API */ 85/* QE internal API */
40int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input); 86int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input);
41void qe_setbrg(unsigned int brg, unsigned int rate, unsigned int multiplier); 87enum qe_clock qe_clock_source(const char *source);
88int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier);
42int qe_get_snum(void); 89int qe_get_snum(void);
43void qe_put_snum(u8 snum); 90void qe_put_snum(u8 snum);
44unsigned long qe_muram_alloc(int size, int align); 91unsigned long qe_muram_alloc(int size, int align);
@@ -47,6 +94,58 @@ unsigned long qe_muram_alloc_fixed(unsigned long offset, int size);
47void qe_muram_dump(void); 94void qe_muram_dump(void);
48void *qe_muram_addr(unsigned long offset); 95void *qe_muram_addr(unsigned long offset);
49 96
97/* Structure that defines QE firmware binary files.
98 *
99 * See Documentation/powerpc/qe-firmware.txt for a description of these
100 * fields.
101 */
102struct qe_firmware {
103 struct qe_header {
104 __be32 length; /* Length of the entire structure, in bytes */
105 u8 magic[3]; /* Set to { 'Q', 'E', 'F' } */
106 u8 version; /* Version of this layout. First ver is '1' */
107 } header;
108 u8 id[62]; /* Null-terminated identifier string */
109 u8 split; /* 0 = shared I-RAM, 1 = split I-RAM */
110 u8 count; /* Number of microcode[] structures */
111 struct {
112 __be16 model; /* The SOC model */
113 u8 major; /* The SOC revision major */
114 u8 minor; /* The SOC revision minor */
115 } __attribute__ ((packed)) soc;
116 u8 padding[4]; /* Reserved, for alignment */
117 __be64 extended_modes; /* Extended modes */
118 __be32 vtraps[8]; /* Virtual trap addresses */
119 u8 reserved[4]; /* Reserved, for future expansion */
120 struct qe_microcode {
121 u8 id[32]; /* Null-terminated identifier */
122 __be32 traps[16]; /* Trap addresses, 0 == ignore */
123 __be32 eccr; /* The value for the ECCR register */
124 __be32 iram_offset; /* Offset into I-RAM for the code */
125 __be32 count; /* Number of 32-bit words of the code */
126 __be32 code_offset; /* Offset of the actual microcode */
127 u8 major; /* The microcode version major */
128 u8 minor; /* The microcode version minor */
129 u8 revision; /* The microcode version revision */
130 u8 padding; /* Reserved, for alignment */
131 u8 reserved[4]; /* Reserved, for future expansion */
132 } __attribute__ ((packed)) microcode[1];
133 /* All microcode binaries should be located here */
134 /* CRC32 should be located here, after the microcode binaries */
135} __attribute__ ((packed));
136
137struct qe_firmware_info {
138 char id[64]; /* Firmware name */
139 u32 vtraps[8]; /* Virtual trap addresses */
140 u64 extended_modes; /* Extended modes */
141};
142
143/* Upload a firmware to the QE */
144int qe_upload_firmware(const struct qe_firmware *firmware);
145
146/* Obtain information on the uploaded firmware */
147struct qe_firmware_info *qe_get_firmware_info(void);
148
50/* Buffer descriptors */ 149/* Buffer descriptors */
51struct qe_bd { 150struct qe_bd {
52 __be16 status; 151 __be16 status;
@@ -129,52 +228,6 @@ enum comm_dir {
129 COMM_DIR_RX_AND_TX = 3 228 COMM_DIR_RX_AND_TX = 3
130}; 229};
131 230
132/* Clocks and BRGs */
133enum qe_clock {
134 QE_CLK_NONE = 0,
135 QE_BRG1, /* Baud Rate Generator 1 */
136 QE_BRG2, /* Baud Rate Generator 2 */
137 QE_BRG3, /* Baud Rate Generator 3 */
138 QE_BRG4, /* Baud Rate Generator 4 */
139 QE_BRG5, /* Baud Rate Generator 5 */
140 QE_BRG6, /* Baud Rate Generator 6 */
141 QE_BRG7, /* Baud Rate Generator 7 */
142 QE_BRG8, /* Baud Rate Generator 8 */
143 QE_BRG9, /* Baud Rate Generator 9 */
144 QE_BRG10, /* Baud Rate Generator 10 */
145 QE_BRG11, /* Baud Rate Generator 11 */
146 QE_BRG12, /* Baud Rate Generator 12 */
147 QE_BRG13, /* Baud Rate Generator 13 */
148 QE_BRG14, /* Baud Rate Generator 14 */
149 QE_BRG15, /* Baud Rate Generator 15 */
150 QE_BRG16, /* Baud Rate Generator 16 */
151 QE_CLK1, /* Clock 1 */
152 QE_CLK2, /* Clock 2 */
153 QE_CLK3, /* Clock 3 */
154 QE_CLK4, /* Clock 4 */
155 QE_CLK5, /* Clock 5 */
156 QE_CLK6, /* Clock 6 */
157 QE_CLK7, /* Clock 7 */
158 QE_CLK8, /* Clock 8 */
159 QE_CLK9, /* Clock 9 */
160 QE_CLK10, /* Clock 10 */
161 QE_CLK11, /* Clock 11 */
162 QE_CLK12, /* Clock 12 */
163 QE_CLK13, /* Clock 13 */
164 QE_CLK14, /* Clock 14 */
165 QE_CLK15, /* Clock 15 */
166 QE_CLK16, /* Clock 16 */
167 QE_CLK17, /* Clock 17 */
168 QE_CLK18, /* Clock 18 */
169 QE_CLK19, /* Clock 19 */
170 QE_CLK20, /* Clock 20 */
171 QE_CLK21, /* Clock 21 */
172 QE_CLK22, /* Clock 22 */
173 QE_CLK23, /* Clock 23 */
174 QE_CLK24, /* Clock 24 */
175 QE_CLK_DUMMY,
176};
177
178/* QE CMXUCR Registers. 231/* QE CMXUCR Registers.
179 * There are two UCCs represented in each of the four CMXUCR registers. 232 * There are two UCCs represented in each of the four CMXUCR registers.
180 * These values are for the UCC in the LSBs 233 * These values are for the UCC in the LSBs
@@ -328,6 +381,15 @@ enum qe_clock {
328 381
329#define QE_SDEBCR_BA_MASK 0x01FFFFFF 382#define QE_SDEBCR_BA_MASK 0x01FFFFFF
330 383
384/* Communication Processor */
385#define QE_CP_CERCR_MEE 0x8000 /* Multi-user RAM ECC enable */
386#define QE_CP_CERCR_IEE 0x4000 /* Instruction RAM ECC enable */
387#define QE_CP_CERCR_CIR 0x0800 /* Common instruction RAM */
388
389/* I-RAM */
390#define QE_IRAM_IADD_AIE 0x80000000 /* Auto Increment Enable */
391#define QE_IRAM_IADD_BADDR 0x00080000 /* Base Address */
392
331/* UPC */ 393/* UPC */
332#define UPGCR_PROTOCOL 0x80000000 /* protocol ul2 or pl2 */ 394#define UPGCR_PROTOCOL 0x80000000 /* protocol ul2 or pl2 */
333#define UPGCR_TMS 0x40000000 /* Transmit master/slave mode */ 395#define UPGCR_TMS 0x40000000 /* Transmit master/slave mode */
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
index e775ff1ca413..2408a29507e5 100644
--- a/include/asm-powerpc/reg.h
+++ b/include/asm-powerpc/reg.h
@@ -553,6 +553,7 @@
553#define SPRN_PA6T_BTCR 978 /* Breakpoint and Tagging Control Register */ 553#define SPRN_PA6T_BTCR 978 /* Breakpoint and Tagging Control Register */
554#define SPRN_PA6T_IMAAT 979 /* Instruction Match Array Action Table */ 554#define SPRN_PA6T_IMAAT 979 /* Instruction Match Array Action Table */
555#define SPRN_PA6T_PCCR 1019 /* Power Counter Control Register */ 555#define SPRN_PA6T_PCCR 1019 /* Power Counter Control Register */
556#define SPRN_BKMK 1020 /* Cell Bookmark Register */
556#define SPRN_PA6T_RPCCR 1021 /* Retire PC Trace Control Register */ 557#define SPRN_PA6T_RPCCR 1021 /* Retire PC Trace Control Register */
557 558
558 559
@@ -691,12 +692,6 @@
691#define PV_BE 0x0070 692#define PV_BE 0x0070
692#define PV_PA6T 0x0090 693#define PV_PA6T 0x0090
693 694
694/*
695 * Number of entries in the SLB. If this ever changes we should handle
696 * it with a use a cpu feature fixup.
697 */
698#define SLB_NUM_ENTRIES 64
699
700/* Macros for setting and retrieving special purpose registers */ 695/* Macros for setting and retrieving special purpose registers */
701#ifndef __ASSEMBLY__ 696#ifndef __ASSEMBLY__
702#define mfmsr() ({unsigned long rval; \ 697#define mfmsr() ({unsigned long rval; \
diff --git a/include/asm-powerpc/reg_booke.h b/include/asm-powerpc/reg_booke.h
index 8fdc2b47afb9..0405ef479814 100644
--- a/include/asm-powerpc/reg_booke.h
+++ b/include/asm-powerpc/reg_booke.h
@@ -123,16 +123,23 @@
123#define SPRN_SPEFSCR 0x200 /* SPE & Embedded FP Status & Control */ 123#define SPRN_SPEFSCR 0x200 /* SPE & Embedded FP Status & Control */
124#define SPRN_BBEAR 0x201 /* Branch Buffer Entry Address Register */ 124#define SPRN_BBEAR 0x201 /* Branch Buffer Entry Address Register */
125#define SPRN_BBTAR 0x202 /* Branch Buffer Target Address Register */ 125#define SPRN_BBTAR 0x202 /* Branch Buffer Target Address Register */
126#define SPRN_ATB 0x20E /* Alternate Time Base */
127#define SPRN_ATBL 0x20E /* Alternate Time Base Lower */
128#define SPRN_ATBU 0x20F /* Alternate Time Base Upper */
126#define SPRN_IVOR32 0x210 /* Interrupt Vector Offset Register 32 */ 129#define SPRN_IVOR32 0x210 /* Interrupt Vector Offset Register 32 */
127#define SPRN_IVOR33 0x211 /* Interrupt Vector Offset Register 33 */ 130#define SPRN_IVOR33 0x211 /* Interrupt Vector Offset Register 33 */
128#define SPRN_IVOR34 0x212 /* Interrupt Vector Offset Register 34 */ 131#define SPRN_IVOR34 0x212 /* Interrupt Vector Offset Register 34 */
129#define SPRN_IVOR35 0x213 /* Interrupt Vector Offset Register 35 */ 132#define SPRN_IVOR35 0x213 /* Interrupt Vector Offset Register 35 */
133#define SPRN_IVOR36 0x214 /* Interrupt Vector Offset Register 36 */
134#define SPRN_IVOR37 0x215 /* Interrupt Vector Offset Register 37 */
130#define SPRN_MCSRR0 0x23A /* Machine Check Save and Restore Register 0 */ 135#define SPRN_MCSRR0 0x23A /* Machine Check Save and Restore Register 0 */
131#define SPRN_MCSRR1 0x23B /* Machine Check Save and Restore Register 1 */ 136#define SPRN_MCSRR1 0x23B /* Machine Check Save and Restore Register 1 */
132#define SPRN_MCSR 0x23C /* Machine Check Status Register */ 137#define SPRN_MCSR 0x23C /* Machine Check Status Register */
133#define SPRN_MCAR 0x23D /* Machine Check Address Register */ 138#define SPRN_MCAR 0x23D /* Machine Check Address Register */
134#define SPRN_DSRR0 0x23E /* Debug Save and Restore Register 0 */ 139#define SPRN_DSRR0 0x23E /* Debug Save and Restore Register 0 */
135#define SPRN_DSRR1 0x23F /* Debug Save and Restore Register 1 */ 140#define SPRN_DSRR1 0x23F /* Debug Save and Restore Register 1 */
141#define SPRN_SPRG8 0x25C /* Special Purpose Register General 8 */
142#define SPRN_SPRG9 0x25D /* Special Purpose Register General 9 */
136#define SPRN_MAS0 0x270 /* MMU Assist Register 0 */ 143#define SPRN_MAS0 0x270 /* MMU Assist Register 0 */
137#define SPRN_MAS1 0x271 /* MMU Assist Register 1 */ 144#define SPRN_MAS1 0x271 /* MMU Assist Register 1 */
138#define SPRN_MAS2 0x272 /* MMU Assist Register 2 */ 145#define SPRN_MAS2 0x272 /* MMU Assist Register 2 */
@@ -140,15 +147,18 @@
140#define SPRN_MAS4 0x274 /* MMU Assist Register 4 */ 147#define SPRN_MAS4 0x274 /* MMU Assist Register 4 */
141#define SPRN_MAS5 0x275 /* MMU Assist Register 5 */ 148#define SPRN_MAS5 0x275 /* MMU Assist Register 5 */
142#define SPRN_MAS6 0x276 /* MMU Assist Register 6 */ 149#define SPRN_MAS6 0x276 /* MMU Assist Register 6 */
143#define SPRN_MAS7 0x3b0 /* MMU Assist Register 7 */
144#define SPRN_PID1 0x279 /* Process ID Register 1 */ 150#define SPRN_PID1 0x279 /* Process ID Register 1 */
145#define SPRN_PID2 0x27A /* Process ID Register 2 */ 151#define SPRN_PID2 0x27A /* Process ID Register 2 */
146#define SPRN_TLB0CFG 0x2B0 /* TLB 0 Config Register */ 152#define SPRN_TLB0CFG 0x2B0 /* TLB 0 Config Register */
147#define SPRN_TLB1CFG 0x2B1 /* TLB 1 Config Register */ 153#define SPRN_TLB1CFG 0x2B1 /* TLB 1 Config Register */
154#define SPRN_EPR 0x2BE /* External Proxy Register */
148#define SPRN_CCR1 0x378 /* Core Configuration Register 1 */ 155#define SPRN_CCR1 0x378 /* Core Configuration Register 1 */
149#define SPRN_ZPR 0x3B0 /* Zone Protection Register (40x) */ 156#define SPRN_ZPR 0x3B0 /* Zone Protection Register (40x) */
157#define SPRN_MAS7 0x3B0 /* MMU Assist Register 7 */
150#define SPRN_MMUCR 0x3B2 /* MMU Control Register */ 158#define SPRN_MMUCR 0x3B2 /* MMU Control Register */
151#define SPRN_CCR0 0x3B3 /* Core Configuration Register 0 */ 159#define SPRN_CCR0 0x3B3 /* Core Configuration Register 0 */
160#define SPRN_EPLC 0x3B3 /* External Process ID Load Context */
161#define SPRN_EPSC 0x3B4 /* External Process ID Store Context */
152#define SPRN_SGR 0x3B9 /* Storage Guarded Register */ 162#define SPRN_SGR 0x3B9 /* Storage Guarded Register */
153#define SPRN_DCWR 0x3BA /* Data Cache Write-thru Register */ 163#define SPRN_DCWR 0x3BA /* Data Cache Write-thru Register */
154#define SPRN_SLER 0x3BB /* Little-endian real mode */ 164#define SPRN_SLER 0x3BB /* Little-endian real mode */
@@ -159,6 +169,7 @@
159#define SPRN_L1CSR0 0x3F2 /* L1 Cache Control and Status Register 0 */ 169#define SPRN_L1CSR0 0x3F2 /* L1 Cache Control and Status Register 0 */
160#define SPRN_L1CSR1 0x3F3 /* L1 Cache Control and Status Register 1 */ 170#define SPRN_L1CSR1 0x3F3 /* L1 Cache Control and Status Register 1 */
161#define SPRN_PIT 0x3DB /* Programmable Interval Timer */ 171#define SPRN_PIT 0x3DB /* Programmable Interval Timer */
172#define SPRN_BUCSR 0x3F5 /* Branch Unit Control and Status */
162#define SPRN_DCCR 0x3FA /* Data Cache Cacheability Register */ 173#define SPRN_DCCR 0x3FA /* Data Cache Cacheability Register */
163#define SPRN_ICCR 0x3FB /* Instruction Cache Cacheability Register */ 174#define SPRN_ICCR 0x3FB /* Instruction Cache Cacheability Register */
164#define SPRN_SVR 0x3FF /* System Version Register */ 175#define SPRN_SVR 0x3FF /* System Version Register */
@@ -207,7 +218,6 @@
207#define CCR1_TCS 0x00000080 /* Timer Clock Select */ 218#define CCR1_TCS 0x00000080 /* Timer Clock Select */
208 219
209/* Bit definitions for the MCSR. */ 220/* Bit definitions for the MCSR. */
210#ifdef CONFIG_440A
211#define MCSR_MCS 0x80000000 /* Machine Check Summary */ 221#define MCSR_MCS 0x80000000 /* Machine Check Summary */
212#define MCSR_IB 0x40000000 /* Instruction PLB Error */ 222#define MCSR_IB 0x40000000 /* Instruction PLB Error */
213#define MCSR_DRB 0x20000000 /* Data Read PLB Error */ 223#define MCSR_DRB 0x20000000 /* Data Read PLB Error */
@@ -217,7 +227,7 @@
217#define MCSR_DCSP 0x02000000 /* D-Cache Search Parity Error */ 227#define MCSR_DCSP 0x02000000 /* D-Cache Search Parity Error */
218#define MCSR_DCFP 0x01000000 /* D-Cache Flush Parity Error */ 228#define MCSR_DCFP 0x01000000 /* D-Cache Flush Parity Error */
219#define MCSR_IMPE 0x00800000 /* Imprecise Machine Check Exception */ 229#define MCSR_IMPE 0x00800000 /* Imprecise Machine Check Exception */
220#endif 230
221#ifdef CONFIG_E500 231#ifdef CONFIG_E500
222#define MCSR_MCP 0x80000000UL /* Machine Check Input Pin */ 232#define MCSR_MCP 0x80000000UL /* Machine Check Input Pin */
223#define MCSR_ICPERR 0x40000000UL /* I-Cache Parity Error */ 233#define MCSR_ICPERR 0x40000000UL /* I-Cache Parity Error */
@@ -293,7 +303,7 @@
293#define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */ 303#define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */
294#define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */ 304#define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */
295#define ESR_PIL 0x08000000 /* Program Exception - Illegal */ 305#define ESR_PIL 0x08000000 /* Program Exception - Illegal */
296#define ESR_PPR 0x04000000 /* Program Exception - Priveleged */ 306#define ESR_PPR 0x04000000 /* Program Exception - Privileged */
297#define ESR_PTR 0x02000000 /* Program Exception - Trap */ 307#define ESR_PTR 0x02000000 /* Program Exception - Trap */
298#define ESR_FP 0x01000000 /* Floating Point Operation */ 308#define ESR_FP 0x01000000 /* Floating Point Operation */
299#define ESR_DST 0x00800000 /* Storage Exception - Data miss */ 309#define ESR_DST 0x00800000 /* Storage Exception - Data miss */
diff --git a/include/asm-powerpc/setjmp.h b/include/asm-powerpc/setjmp.h
new file mode 100644
index 000000000000..279d03a1eec6
--- /dev/null
+++ b/include/asm-powerpc/setjmp.h
@@ -0,0 +1,18 @@
1/*
2 * Copyright © 2008 Michael Neuling IBM Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 *
9 */
10#ifndef _ASM_POWERPC_SETJMP_H
11#define _ASM_POWERPC_SETJMP_H
12
13#define JMP_BUF_LEN 23
14
15extern long setjmp(long *);
16extern void longjmp(long *, long);
17
18#endif /* _ASM_POWERPC_SETJMP_H */
diff --git a/include/asm-powerpc/smu.h b/include/asm-powerpc/smu.h
index e49f644ca63a..7ae2753da565 100644
--- a/include/asm-powerpc/smu.h
+++ b/include/asm-powerpc/smu.h
@@ -22,7 +22,7 @@
22 * Partition info commands 22 * Partition info commands
23 * 23 *
24 * These commands are used to retrieve the sdb-partition-XX datas from 24 * These commands are used to retrieve the sdb-partition-XX datas from
25 * the SMU. The lenght is always 2. First byte is the subcommand code 25 * the SMU. The length is always 2. First byte is the subcommand code
26 * and second byte is the partition ID. 26 * and second byte is the partition ID.
27 * 27 *
28 * The reply is 6 bytes: 28 * The reply is 6 bytes:
@@ -173,12 +173,12 @@
173 * Power supply control 173 * Power supply control
174 * 174 *
175 * The "sub" command is an ASCII string in the data, the 175 * The "sub" command is an ASCII string in the data, the
176 * data lenght is that of the string. 176 * data length is that of the string.
177 * 177 *
178 * The VSLEW command can be used to get or set the voltage slewing. 178 * The VSLEW command can be used to get or set the voltage slewing.
179 * - lenght 5 (only "VSLEW") : it returns "DONE" and 3 bytes of 179 * - length 5 (only "VSLEW") : it returns "DONE" and 3 bytes of
180 * reply at data offset 6, 7 and 8. 180 * reply at data offset 6, 7 and 8.
181 * - lenght 8 ("VSLEWxyz") has 3 additional bytes appended, and is 181 * - length 8 ("VSLEWxyz") has 3 additional bytes appended, and is
182 * used to set the voltage slewing point. The SMU replies with "DONE" 182 * used to set the voltage slewing point. The SMU replies with "DONE"
183 * I yet have to figure out their exact meaning of those 3 bytes in 183 * I yet have to figure out their exact meaning of those 3 bytes in
184 * both cases. They seem to be: 184 * both cases. They seem to be:
@@ -201,20 +201,90 @@
201 */ 201 */
202#define SMU_CMD_READ_ADC 0xd8 202#define SMU_CMD_READ_ADC 0xd8
203 203
204
204/* Misc commands 205/* Misc commands
205 * 206 *
206 * This command seem to be a grab bag of various things 207 * This command seem to be a grab bag of various things
208 *
209 * Parameters:
210 * 1: subcommand
207 */ 211 */
208#define SMU_CMD_MISC_df_COMMAND 0xdf 212#define SMU_CMD_MISC_df_COMMAND 0xdf
209#define SMU_CMD_MISC_df_SET_DISPLAY_LIT 0x02 /* i: 1 byte */ 213
214/*
215 * Sets "system ready" status
216 *
217 * I did not yet understand how it exactly works or what it does.
218 *
219 * Guessing from OF code, 0x02 activates the display backlight. Apple uses/used
220 * the same codebase for all OF versions. On PowerBooks, this command would
221 * enable the backlight. For the G5s, it only activates the front LED. However,
222 * don't take this for granted.
223 *
224 * Parameters:
225 * 2: status [0x00, 0x01 or 0x02]
226 */
227#define SMU_CMD_MISC_df_SET_DISPLAY_LIT 0x02
228
229/*
230 * Sets mode of power switch.
231 *
232 * What this actually does is not yet known. Maybe it enables some interrupt.
233 *
234 * Parameters:
235 * 2: enable power switch? [0x00 or 0x01]
236 * 3 (optional): enable nmi? [0x00 or 0x01]
237 *
238 * Returns:
239 * If parameter 2 is 0x00 and parameter 3 is not specified, returns wether
240 * NMI is enabled. Otherwise unknown.
241 */
210#define SMU_CMD_MISC_df_NMI_OPTION 0x04 242#define SMU_CMD_MISC_df_NMI_OPTION 0x04
211 243
244/* Sets LED dimm offset.
245 *
246 * The front LED dimms itself during sleep. Its brightness (or, well, the PWM
247 * frequency) depends on current time. Therefore, the SMU needs to know the
248 * timezone.
249 *
250 * Parameters:
251 * 2-8: unknown (BCD coding)
252 */
253#define SMU_CMD_MISC_df_DIMM_OFFSET 0x99
254
255
212/* 256/*
213 * Version info commands 257 * Version info commands
214 * 258 *
215 * I haven't quite tried to figure out how these work 259 * Parameters:
260 * 1 (optional): Specifies version part to retrieve
261 *
262 * Returns:
263 * Version value
216 */ 264 */
217#define SMU_CMD_VERSION_COMMAND 0xea 265#define SMU_CMD_VERSION_COMMAND 0xea
266#define SMU_VERSION_RUNNING 0x00
267#define SMU_VERSION_BASE 0x01
268#define SMU_VERSION_UPDATE 0x02
269
270
271/*
272 * Switches
273 *
274 * These are switches whose status seems to be known to the SMU.
275 *
276 * Parameters:
277 * none
278 *
279 * Result:
280 * Switch bits (ORed, see below)
281 */
282#define SMU_CMD_SWITCHES 0xdc
283
284/* Switches bits */
285#define SMU_SWITCH_CASE_CLOSED 0x01
286#define SMU_SWITCH_AC_POWER 0x04
287#define SMU_SWITCH_POWER_SWITCH 0x08
218 288
219 289
220/* 290/*
@@ -243,10 +313,64 @@
243 */ 313 */
244#define SMU_CMD_MISC_ee_COMMAND 0xee 314#define SMU_CMD_MISC_ee_COMMAND 0xee
245#define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02 315#define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02
246#define SMU_CMD_MISC_ee_LEDS_CTRL 0x04 /* i: 00 (00,01) [00] */ 316
317/* Retrieves currently used watts.
318 *
319 * Parameters:
320 * 1: 0x03 (Meaning unknown)
321 */
322#define SMU_CMD_MISC_ee_GET_WATTS 0x03
323
324#define SMU_CMD_MISC_ee_LEDS_CTRL 0x04 /* i: 00 (00,01) [00] */
247#define SMU_CMD_MISC_ee_GET_DATA 0x05 /* i: 00 , o: ?? */ 325#define SMU_CMD_MISC_ee_GET_DATA 0x05 /* i: 00 , o: ?? */
248 326
249 327
328/*
329 * Power related commands
330 *
331 * Parameters:
332 * 1: subcommand
333 */
334#define SMU_CMD_POWER_EVENTS_COMMAND 0x8f
335
336/* SMU_POWER_EVENTS subcommands */
337enum {
338 SMU_PWR_GET_POWERUP_EVENTS = 0x00,
339 SMU_PWR_SET_POWERUP_EVENTS = 0x01,
340 SMU_PWR_CLR_POWERUP_EVENTS = 0x02,
341 SMU_PWR_GET_WAKEUP_EVENTS = 0x03,
342 SMU_PWR_SET_WAKEUP_EVENTS = 0x04,
343 SMU_PWR_CLR_WAKEUP_EVENTS = 0x05,
344
345 /*
346 * Get last shutdown cause
347 *
348 * Returns:
349 * 1 byte (signed char): Last shutdown cause. Exact meaning unknown.
350 */
351 SMU_PWR_LAST_SHUTDOWN_CAUSE = 0x07,
352
353 /*
354 * Sets or gets server ID. Meaning or use is unknown.
355 *
356 * Parameters:
357 * 2 (optional): Set server ID (1 byte)
358 *
359 * Returns:
360 * 1 byte (server ID?)
361 */
362 SMU_PWR_SERVER_ID = 0x08,
363};
364
365/* Power events wakeup bits */
366enum {
367 SMU_PWR_WAKEUP_KEY = 0x01, /* Wake on key press */
368 SMU_PWR_WAKEUP_AC_INSERT = 0x02, /* Wake on AC adapter plug */
369 SMU_PWR_WAKEUP_AC_CHANGE = 0x04,
370 SMU_PWR_WAKEUP_LID_OPEN = 0x08,
371 SMU_PWR_WAKEUP_RING = 0x10,
372};
373
250 374
251/* 375/*
252 * - Kernel side interface - 376 * - Kernel side interface -
@@ -564,13 +688,13 @@ struct smu_user_cmd_hdr
564 688
565 __u8 cmd; /* SMU command byte */ 689 __u8 cmd; /* SMU command byte */
566 __u8 pad[3]; /* padding */ 690 __u8 pad[3]; /* padding */
567 __u32 data_len; /* Lenght of data following */ 691 __u32 data_len; /* Length of data following */
568}; 692};
569 693
570struct smu_user_reply_hdr 694struct smu_user_reply_hdr
571{ 695{
572 __u32 status; /* Command status */ 696 __u32 status; /* Command status */
573 __u32 reply_len; /* Lenght of data follwing */ 697 __u32 reply_len; /* Length of data follwing */
574}; 698};
575 699
576#endif /* _SMU_H */ 700#endif /* _SMU_H */
diff --git a/include/asm-powerpc/socket.h b/include/asm-powerpc/socket.h
index 403e9fde2eb5..f5a4e168e498 100644
--- a/include/asm-powerpc/socket.h
+++ b/include/asm-powerpc/socket.h
@@ -59,4 +59,6 @@
59#define SO_TIMESTAMPNS 35 59#define SO_TIMESTAMPNS 35
60#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 60#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
61 61
62#define SO_MARK 36
63
62#endif /* _ASM_POWERPC_SOCKET_H */ 64#endif /* _ASM_POWERPC_SOCKET_H */
diff --git a/include/asm-powerpc/sparsemem.h b/include/asm-powerpc/sparsemem.h
index 48ad807a0b8a..e8b493d52b4f 100644
--- a/include/asm-powerpc/sparsemem.h
+++ b/include/asm-powerpc/sparsemem.h
@@ -10,13 +10,8 @@
10 */ 10 */
11#define SECTION_SIZE_BITS 24 11#define SECTION_SIZE_BITS 24
12 12
13#if defined(CONFIG_PS3_USE_LPAR_ADDR)
14#define MAX_PHYSADDR_BITS 47
15#define MAX_PHYSMEM_BITS 47
16#else
17#define MAX_PHYSADDR_BITS 44 13#define MAX_PHYSADDR_BITS 44
18#define MAX_PHYSMEM_BITS 44 14#define MAX_PHYSMEM_BITS 44
19#endif
20 15
21#ifdef CONFIG_MEMORY_HOTPLUG 16#ifdef CONFIG_MEMORY_HOTPLUG
22extern void create_section_mapping(unsigned long start, unsigned long end); 17extern void create_section_mapping(unsigned long start, unsigned long end);
diff --git a/include/asm-powerpc/spu.h b/include/asm-powerpc/spu.h
index b1accce77bb5..f07c99ba5d13 100644
--- a/include/asm-powerpc/spu.h
+++ b/include/asm-powerpc/spu.h
@@ -104,6 +104,7 @@
104 104
105struct spu_context; 105struct spu_context;
106struct spu_runqueue; 106struct spu_runqueue;
107struct spu_lscsa;
107struct device_node; 108struct device_node;
108 109
109enum spu_utilization_state { 110enum spu_utilization_state {
@@ -145,7 +146,6 @@ struct spu {
145 void (* ibox_callback)(struct spu *spu); 146 void (* ibox_callback)(struct spu *spu);
146 void (* stop_callback)(struct spu *spu); 147 void (* stop_callback)(struct spu *spu);
147 void (* mfc_callback)(struct spu *spu); 148 void (* mfc_callback)(struct spu *spu);
148 void (* dma_callback)(struct spu *spu, int type);
149 149
150 char irq_c0[8]; 150 char irq_c0[8];
151 char irq_c1[8]; 151 char irq_c1[8];
@@ -196,10 +196,11 @@ struct cbe_spu_info {
196extern struct cbe_spu_info cbe_spu_info[]; 196extern struct cbe_spu_info cbe_spu_info[];
197 197
198void spu_init_channels(struct spu *spu); 198void spu_init_channels(struct spu *spu);
199int spu_irq_class_0_bottom(struct spu *spu);
200int spu_irq_class_1_bottom(struct spu *spu);
201void spu_irq_setaffinity(struct spu *spu, int cpu); 199void spu_irq_setaffinity(struct spu *spu, int cpu);
202 200
201void spu_setup_kernel_slbs(struct spu *spu, struct spu_lscsa *lscsa,
202 void *code, int code_size);
203
203#ifdef CONFIG_KEXEC 204#ifdef CONFIG_KEXEC
204void crash_register_spus(struct list_head *list); 205void crash_register_spus(struct list_head *list);
205#else 206#else
@@ -210,6 +211,7 @@ static inline void crash_register_spus(struct list_head *list)
210 211
211extern void spu_invalidate_slbs(struct spu *spu); 212extern void spu_invalidate_slbs(struct spu *spu);
212extern void spu_associate_mm(struct spu *spu, struct mm_struct *mm); 213extern void spu_associate_mm(struct spu *spu, struct mm_struct *mm);
214int spu_64k_pages_available(void);
213 215
214/* Calls from the memory management to the SPU */ 216/* Calls from the memory management to the SPU */
215struct mm_struct; 217struct mm_struct;
@@ -246,6 +248,7 @@ struct spufs_calls {
246 __u32 __user *ustatus); 248 __u32 __user *ustatus);
247 int (*coredump_extra_notes_size)(void); 249 int (*coredump_extra_notes_size)(void);
248 int (*coredump_extra_notes_write)(struct file *file, loff_t *foffset); 250 int (*coredump_extra_notes_write)(struct file *file, loff_t *foffset);
251 void (*notify_spus_active)(void);
249 struct module *owner; 252 struct module *owner;
250}; 253};
251 254
@@ -278,6 +281,8 @@ void spu_remove_sysdev_attr(struct sysdev_attribute *attr);
278int spu_add_sysdev_attr_group(struct attribute_group *attrs); 281int spu_add_sysdev_attr_group(struct attribute_group *attrs);
279void spu_remove_sysdev_attr_group(struct attribute_group *attrs); 282void spu_remove_sysdev_attr_group(struct attribute_group *attrs);
280 283
284int spu_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
285 unsigned long dsisr, unsigned *flt);
281 286
282/* 287/*
283 * Notifier blocks: 288 * Notifier blocks:
@@ -298,8 +303,11 @@ struct notifier_block;
298int spu_switch_event_register(struct notifier_block * n); 303int spu_switch_event_register(struct notifier_block * n);
299int spu_switch_event_unregister(struct notifier_block * n); 304int spu_switch_event_unregister(struct notifier_block * n);
300 305
306extern void notify_spus_active(void);
307extern void do_notify_spus_active(void);
308
301/* 309/*
302 * This defines the Local Store, Problem Area and Privlege Area of an SPU. 310 * This defines the Local Store, Problem Area and Privilege Area of an SPU.
303 */ 311 */
304 312
305union mfc_tag_size_class_cmd { 313union mfc_tag_size_class_cmd {
@@ -520,8 +528,24 @@ struct spu_priv1 {
520#define CLASS2_ENABLE_SPU_STOP_INTR 0x2L 528#define CLASS2_ENABLE_SPU_STOP_INTR 0x2L
521#define CLASS2_ENABLE_SPU_HALT_INTR 0x4L 529#define CLASS2_ENABLE_SPU_HALT_INTR 0x4L
522#define CLASS2_ENABLE_SPU_DMA_TAG_GROUP_COMPLETE_INTR 0x8L 530#define CLASS2_ENABLE_SPU_DMA_TAG_GROUP_COMPLETE_INTR 0x8L
531#define CLASS2_ENABLE_MAILBOX_THRESHOLD_INTR 0x10L
523 u8 pad_0x118_0x140[0x28]; /* 0x118 */ 532 u8 pad_0x118_0x140[0x28]; /* 0x118 */
524 u64 int_stat_RW[3]; /* 0x140 */ 533 u64 int_stat_RW[3]; /* 0x140 */
534#define CLASS0_DMA_ALIGNMENT_INTR 0x1L
535#define CLASS0_INVALID_DMA_COMMAND_INTR 0x2L
536#define CLASS0_SPU_ERROR_INTR 0x4L
537#define CLASS0_INTR_MASK 0x7L
538#define CLASS1_SEGMENT_FAULT_INTR 0x1L
539#define CLASS1_STORAGE_FAULT_INTR 0x2L
540#define CLASS1_LS_COMPARE_SUSPEND_ON_GET_INTR 0x4L
541#define CLASS1_LS_COMPARE_SUSPEND_ON_PUT_INTR 0x8L
542#define CLASS1_INTR_MASK 0xfL
543#define CLASS2_MAILBOX_INTR 0x1L
544#define CLASS2_SPU_STOP_INTR 0x2L
545#define CLASS2_SPU_HALT_INTR 0x4L
546#define CLASS2_SPU_DMA_TAG_GROUP_COMPLETE_INTR 0x8L
547#define CLASS2_MAILBOX_THRESHOLD_INTR 0x10L
548#define CLASS2_INTR_MASK 0x1fL
525 u8 pad_0x158_0x180[0x28]; /* 0x158 */ 549 u8 pad_0x158_0x180[0x28]; /* 0x158 */
526 u64 int_route_RW; /* 0x180 */ 550 u64 int_route_RW; /* 0x180 */
527 551
diff --git a/include/asm-powerpc/spu_csa.h b/include/asm-powerpc/spu_csa.h
index e87794d5d4ea..0ab6bff86078 100644
--- a/include/asm-powerpc/spu_csa.h
+++ b/include/asm-powerpc/spu_csa.h
@@ -194,7 +194,7 @@ struct spu_priv1_collapsed {
194}; 194};
195 195
196/* 196/*
197 * struct spu_priv2_collapsed - condensed priviliged 2 area, w/o pads. 197 * struct spu_priv2_collapsed - condensed privileged 2 area, w/o pads.
198 */ 198 */
199struct spu_priv2_collapsed { 199struct spu_priv2_collapsed {
200 u64 slb_index_W; 200 u64 slb_index_W;
@@ -254,20 +254,11 @@ struct spu_state {
254 u64 spu_chnldata_RW[32]; 254 u64 spu_chnldata_RW[32];
255 u32 spu_mailbox_data[4]; 255 u32 spu_mailbox_data[4];
256 u32 pu_mailbox_data[1]; 256 u32 pu_mailbox_data[1];
257 u64 dar, dsisr; 257 u64 dar, dsisr, class_0_pending;
258 unsigned long suspend_time; 258 unsigned long suspend_time;
259 spinlock_t register_lock; 259 spinlock_t register_lock;
260}; 260};
261 261
262extern int spu_init_csa(struct spu_state *csa);
263extern void spu_fini_csa(struct spu_state *csa);
264extern int spu_save(struct spu_state *prev, struct spu *spu);
265extern int spu_restore(struct spu_state *new, struct spu *spu);
266extern int spu_switch(struct spu_state *prev, struct spu_state *new,
267 struct spu *spu);
268extern int spu_alloc_lscsa(struct spu_state *csa);
269extern void spu_free_lscsa(struct spu_state *csa);
270
271#endif /* !__SPU__ */ 262#endif /* !__SPU__ */
272#endif /* __KERNEL__ */ 263#endif /* __KERNEL__ */
273#endif /* !__ASSEMBLY__ */ 264#endif /* !__ASSEMBLY__ */
diff --git a/include/asm-powerpc/spu_priv1.h b/include/asm-powerpc/spu_priv1.h
index 0f37c7c90820..25020a34ce7f 100644
--- a/include/asm-powerpc/spu_priv1.h
+++ b/include/asm-powerpc/spu_priv1.h
@@ -24,6 +24,7 @@
24#include <linux/types.h> 24#include <linux/types.h>
25 25
26struct spu; 26struct spu;
27struct spu_context;
27 28
28/* access to priv1 registers */ 29/* access to priv1 registers */
29 30
@@ -178,6 +179,8 @@ struct spu_management_ops {
178 int (*enumerate_spus)(int (*fn)(void *data)); 179 int (*enumerate_spus)(int (*fn)(void *data));
179 int (*create_spu)(struct spu *spu, void *data); 180 int (*create_spu)(struct spu *spu, void *data);
180 int (*destroy_spu)(struct spu *spu); 181 int (*destroy_spu)(struct spu *spu);
182 void (*enable_spu)(struct spu_context *ctx);
183 void (*disable_spu)(struct spu_context *ctx);
181 int (*init_affinity)(void); 184 int (*init_affinity)(void);
182}; 185};
183 186
@@ -207,6 +210,18 @@ spu_init_affinity (void)
207 return spu_management_ops->init_affinity(); 210 return spu_management_ops->init_affinity();
208} 211}
209 212
213static inline void
214spu_enable_spu (struct spu_context *ctx)
215{
216 spu_management_ops->enable_spu(ctx);
217}
218
219static inline void
220spu_disable_spu (struct spu_context *ctx)
221{
222 spu_management_ops->disable_spu(ctx);
223}
224
210/* 225/*
211 * The declarations folowing are put here for convenience 226 * The declarations folowing are put here for convenience
212 * and only intended to be used by the platform setup code. 227 * and only intended to be used by the platform setup code.
diff --git a/include/asm-powerpc/systbl.h b/include/asm-powerpc/systbl.h
index cc6d87228258..0c8b0d679139 100644
--- a/include/asm-powerpc/systbl.h
+++ b/include/asm-powerpc/systbl.h
@@ -308,8 +308,9 @@ COMPAT_SYS_SPU(move_pages)
308SYSCALL_SPU(getcpu) 308SYSCALL_SPU(getcpu)
309COMPAT_SYS(epoll_pwait) 309COMPAT_SYS(epoll_pwait)
310COMPAT_SYS_SPU(utimensat) 310COMPAT_SYS_SPU(utimensat)
311COMPAT_SYS(fallocate)
312COMPAT_SYS_SPU(signalfd) 311COMPAT_SYS_SPU(signalfd)
313COMPAT_SYS_SPU(timerfd) 312COMPAT_SYS_SPU(timerfd)
314SYSCALL_SPU(eventfd) 313SYSCALL_SPU(eventfd)
315COMPAT_SYS_SPU(sync_file_range2) 314COMPAT_SYS_SPU(sync_file_range2)
315COMPAT_SYS(fallocate)
316SYSCALL(subpage_prot)
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index 87be8c3bc9cb..bc9739dff5e7 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -169,6 +169,8 @@ extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long);
169extern void bad_page_fault(struct pt_regs *, unsigned long, int); 169extern void bad_page_fault(struct pt_regs *, unsigned long, int);
170extern int die(const char *, struct pt_regs *, long); 170extern int die(const char *, struct pt_regs *, long);
171extern void _exception(int, struct pt_regs *, int, unsigned long); 171extern void _exception(int, struct pt_regs *, int, unsigned long);
172extern void _nmask_and_or_msr(unsigned long nmask, unsigned long or_val);
173
172#ifdef CONFIG_BOOKE_WDT 174#ifdef CONFIG_BOOKE_WDT
173extern u32 booke_wdt_enabled; 175extern u32 booke_wdt_enabled;
174extern u32 booke_wdt_period; 176extern u32 booke_wdt_period;
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index f05895522f7f..ce5de6e0e690 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -176,25 +176,31 @@ static inline unsigned int get_dec(void)
176#endif 176#endif
177} 177}
178 178
179/*
180 * Note: Book E and 4xx processors differ from other PowerPC processors
181 * in when the decrementer generates its interrupt: on the 1 to 0
182 * transition for Book E/4xx, but on the 0 to -1 transition for others.
183 */
179static inline void set_dec(int val) 184static inline void set_dec(int val)
180{ 185{
181#if defined(CONFIG_40x) 186#if defined(CONFIG_40x)
182 mtspr(SPRN_PIT, val); 187 mtspr(SPRN_PIT, val);
183#elif defined(CONFIG_8xx_CPU6) 188#elif defined(CONFIG_8xx_CPU6)
184 set_dec_cpu6(val); 189 set_dec_cpu6(val - 1);
185#else 190#else
191#ifndef CONFIG_BOOKE
192 --val;
193#endif
186#ifdef CONFIG_PPC_ISERIES 194#ifdef CONFIG_PPC_ISERIES
187 int cur_dec;
188
189 if (firmware_has_feature(FW_FEATURE_ISERIES) && 195 if (firmware_has_feature(FW_FEATURE_ISERIES) &&
190 get_lppaca()->shared_proc) { 196 get_lppaca()->shared_proc) {
191 get_lppaca()->virtual_decr = val; 197 get_lppaca()->virtual_decr = val;
192 cur_dec = get_dec(); 198 if (get_dec() > val)
193 if (cur_dec > val)
194 HvCall_setVirtualDecr(); 199 HvCall_setVirtualDecr();
195 } else 200 return;
201 }
196#endif 202#endif
197 mtspr(SPRN_DEC, val); 203 mtspr(SPRN_DEC, val);
198#endif /* not 40x or 8xx_CPU6 */ 204#endif /* not 40x or 8xx_CPU6 */
199} 205}
200 206
@@ -231,18 +237,14 @@ struct cpu_usage {
231 237
232DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array); 238DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array);
233 239
234#ifdef CONFIG_VIRT_CPU_ACCOUNTING
235extern void account_process_vtime(struct task_struct *tsk);
236#else
237#define account_process_vtime(tsk) do { } while (0)
238#endif
239
240#if defined(CONFIG_VIRT_CPU_ACCOUNTING) 240#if defined(CONFIG_VIRT_CPU_ACCOUNTING)
241extern void calculate_steal_time(void); 241extern void calculate_steal_time(void);
242extern void snapshot_timebases(void); 242extern void snapshot_timebases(void);
243#define account_process_vtime(tsk) account_process_tick(tsk, 0)
243#else 244#else
244#define calculate_steal_time() do { } while (0) 245#define calculate_steal_time() do { } while (0)
245#define snapshot_timebases() do { } while (0) 246#define snapshot_timebases() do { } while (0)
247#define account_process_vtime(tsk) do { } while (0)
246#endif 248#endif
247 249
248extern void secondary_cpu_time_init(void); 250extern void secondary_cpu_time_init(void);
diff --git a/include/asm-powerpc/tlbflush.h b/include/asm-powerpc/tlbflush.h
index b6b036ccee34..5c9108147644 100644
--- a/include/asm-powerpc/tlbflush.h
+++ b/include/asm-powerpc/tlbflush.h
@@ -1,5 +1,6 @@
1#ifndef _ASM_POWERPC_TLBFLUSH_H 1#ifndef _ASM_POWERPC_TLBFLUSH_H
2#define _ASM_POWERPC_TLBFLUSH_H 2#define _ASM_POWERPC_TLBFLUSH_H
3
3/* 4/*
4 * TLB flushing: 5 * TLB flushing:
5 * 6 *
@@ -16,9 +17,6 @@
16 */ 17 */
17#ifdef __KERNEL__ 18#ifdef __KERNEL__
18 19
19struct mm_struct;
20struct vm_area_struct;
21
22#if defined(CONFIG_4xx) || defined(CONFIG_8xx) || defined(CONFIG_FSL_BOOKE) 20#if defined(CONFIG_4xx) || defined(CONFIG_8xx) || defined(CONFIG_FSL_BOOKE)
23/* 21/*
24 * TLB flushing for software loaded TLB chips 22 * TLB flushing for software loaded TLB chips
@@ -28,7 +26,9 @@ struct vm_area_struct;
28 * specific tlbie's 26 * specific tlbie's
29 */ 27 */
30 28
31extern void _tlbie(unsigned long address); 29#include <linux/mm.h>
30
31extern void _tlbie(unsigned long address, unsigned int pid);
32 32
33#if defined(CONFIG_40x) || defined(CONFIG_8xx) 33#if defined(CONFIG_40x) || defined(CONFIG_8xx)
34#define _tlbia() asm volatile ("tlbia; sync" : : : "memory") 34#define _tlbia() asm volatile ("tlbia; sync" : : : "memory")
@@ -44,13 +44,13 @@ static inline void flush_tlb_mm(struct mm_struct *mm)
44static inline void flush_tlb_page(struct vm_area_struct *vma, 44static inline void flush_tlb_page(struct vm_area_struct *vma,
45 unsigned long vmaddr) 45 unsigned long vmaddr)
46{ 46{
47 _tlbie(vmaddr); 47 _tlbie(vmaddr, vma ? vma->vm_mm->context.id : 0);
48} 48}
49 49
50static inline void flush_tlb_page_nohash(struct vm_area_struct *vma, 50static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
51 unsigned long vmaddr) 51 unsigned long vmaddr)
52{ 52{
53 _tlbie(vmaddr); 53 _tlbie(vmaddr, vma ? vma->vm_mm->context.id : 0);
54} 54}
55 55
56static inline void flush_tlb_range(struct vm_area_struct *vma, 56static inline void flush_tlb_range(struct vm_area_struct *vma,
diff --git a/include/asm-powerpc/udbg.h b/include/asm-powerpc/udbg.h
index a9e0b0ebcb0f..6418ceea44b7 100644
--- a/include/asm-powerpc/udbg.h
+++ b/include/asm-powerpc/udbg.h
@@ -48,6 +48,7 @@ extern void __init udbg_init_rtas_console(void);
48extern void __init udbg_init_debug_beat(void); 48extern void __init udbg_init_debug_beat(void);
49extern void __init udbg_init_btext(void); 49extern void __init udbg_init_btext(void);
50extern void __init udbg_init_44x_as1(void); 50extern void __init udbg_init_44x_as1(void);
51extern void __init udbg_init_40x_realmode(void);
51extern void __init udbg_init_cpm(void); 52extern void __init udbg_init_cpm(void);
52 53
53#endif /* __KERNEL__ */ 54#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
index 97d82b6a9406..fedc4b8e49e2 100644
--- a/include/asm-powerpc/unistd.h
+++ b/include/asm-powerpc/unistd.h
@@ -332,10 +332,11 @@
332#define __NR_eventfd 307 332#define __NR_eventfd 307
333#define __NR_sync_file_range2 308 333#define __NR_sync_file_range2 308
334#define __NR_fallocate 309 334#define __NR_fallocate 309
335#define __NR_subpage_prot 310
335 336
336#ifdef __KERNEL__ 337#ifdef __KERNEL__
337 338
338#define __NR_syscalls 310 339#define __NR_syscalls 311
339 340
340#define __NR__exit __NR_exit 341#define __NR__exit __NR_exit
341#define NR_syscalls __NR_syscalls 342#define NR_syscalls __NR_syscalls
diff --git a/include/asm-powerpc/vdso_datapage.h b/include/asm-powerpc/vdso_datapage.h
index 8a94f0eba5e9..f01393224b52 100644
--- a/include/asm-powerpc/vdso_datapage.h
+++ b/include/asm-powerpc/vdso_datapage.h
@@ -77,6 +77,10 @@ struct vdso_data {
77 /* those additional ones don't have to be located anywhere 77 /* those additional ones don't have to be located anywhere
78 * special as they were not part of the original systemcfg 78 * special as they were not part of the original systemcfg
79 */ 79 */
80 __u32 dcache_block_size; /* L1 d-cache block size */
81 __u32 icache_block_size; /* L1 i-cache block size */
82 __u32 dcache_log_block_size; /* L1 d-cache log block size */
83 __u32 icache_log_block_size; /* L1 i-cache log block size */
80 __s32 wtom_clock_sec; /* Wall to monotonic clock */ 84 __s32 wtom_clock_sec; /* Wall to monotonic clock */
81 __s32 wtom_clock_nsec; 85 __s32 wtom_clock_nsec;
82 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */ 86 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */
@@ -99,6 +103,10 @@ struct vdso_data {
99 __s32 wtom_clock_sec; /* Wall to monotonic clock */ 103 __s32 wtom_clock_sec; /* Wall to monotonic clock */
100 __s32 wtom_clock_nsec; 104 __s32 wtom_clock_nsec;
101 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */ 105 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
106 __u32 dcache_block_size; /* L1 d-cache block size */
107 __u32 icache_block_size; /* L1 i-cache block size */
108 __u32 dcache_log_block_size; /* L1 d-cache log block size */
109 __u32 icache_log_block_size; /* L1 i-cache log block size */
102}; 110};
103 111
104#endif /* CONFIG_PPC64 */ 112#endif /* CONFIG_PPC64 */
diff --git a/include/asm-ppc/8xx_immap.h b/include/asm-ppc/8xx_immap.h
index 1311cefdfd30..4b0e15206006 100644
--- a/include/asm-ppc/8xx_immap.h
+++ b/include/asm-ppc/8xx_immap.h
@@ -123,7 +123,7 @@ typedef struct mem_ctlr {
123#define OR_G5LA 0x00000400 /* Output #GPL5 on #GPL_A5 */ 123#define OR_G5LA 0x00000400 /* Output #GPL5 on #GPL_A5 */
124#define OR_G5LS 0x00000200 /* Drive #GPL high on falling edge of...*/ 124#define OR_G5LS 0x00000200 /* Drive #GPL high on falling edge of...*/
125#define OR_BI 0x00000100 /* Burst inhibit */ 125#define OR_BI 0x00000100 /* Burst inhibit */
126#define OR_SCY_MSK 0x000000f0 /* Cycle Lenght in Clocks */ 126#define OR_SCY_MSK 0x000000f0 /* Cycle Length in Clocks */
127#define OR_SCY_0_CLK 0x00000000 /* 0 clock cycles wait states */ 127#define OR_SCY_0_CLK 0x00000000 /* 0 clock cycles wait states */
128#define OR_SCY_1_CLK 0x00000010 /* 1 clock cycles wait states */ 128#define OR_SCY_1_CLK 0x00000010 /* 1 clock cycles wait states */
129#define OR_SCY_2_CLK 0x00000020 /* 2 clock cycles wait states */ 129#define OR_SCY_2_CLK 0x00000020 /* 2 clock cycles wait states */
diff --git a/include/asm-ppc/commproc.h b/include/asm-ppc/cpm1.h
index 397248705e0e..03035acd85c6 100644
--- a/include/asm-ppc/commproc.h
+++ b/include/asm-ppc/cpm1.h
@@ -14,8 +14,8 @@
14 * IDMA1 space. The remaining DP RAM is available for buffer descriptors 14 * IDMA1 space. The remaining DP RAM is available for buffer descriptors
15 * or other use. 15 * or other use.
16 */ 16 */
17#ifndef __CPM_8XX__ 17#ifndef __CPM1__
18#define __CPM_8XX__ 18#define __CPM1__
19 19
20#include <asm/8xx_immap.h> 20#include <asm/8xx_immap.h>
21#include <asm/ptrace.h> 21#include <asm/ptrace.h>
@@ -72,13 +72,9 @@ extern int cpm_dpfree(unsigned long offset);
72extern unsigned long cpm_dpalloc_fixed(unsigned long offset, uint size, uint align); 72extern unsigned long cpm_dpalloc_fixed(unsigned long offset, uint size, uint align);
73extern void cpm_dpdump(void); 73extern void cpm_dpdump(void);
74extern void *cpm_dpram_addr(unsigned long offset); 74extern void *cpm_dpram_addr(unsigned long offset);
75extern uint cpm_dpram_phys(u8* addr); 75extern uint cpm_dpram_phys(u8 *addr);
76extern void cpm_setbrg(uint brg, uint rate); 76extern void cpm_setbrg(uint brg, uint rate);
77 77
78extern uint m8xx_cpm_hostalloc(uint size);
79extern int m8xx_cpm_hostfree(uint start);
80extern void m8xx_cpm_hostdump(void);
81
82extern void cpm_load_patch(volatile immap_t *immr); 78extern void cpm_load_patch(volatile immap_t *immr);
83 79
84/* Buffer descriptors used by many of the CPM protocols. 80/* Buffer descriptors used by many of the CPM protocols.
@@ -681,7 +677,7 @@ typedef struct risc_timer_pram {
681#define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */ 677#define CICR_SCC_SCC3 ((uint)0x00200000) /* SCC3 @ SCCc */
682#define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */ 678#define CICR_SCB_SCC2 ((uint)0x00040000) /* SCC2 @ SCCb */
683#define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */ 679#define CICR_SCA_SCC1 ((uint)0x00000000) /* SCC1 @ SCCa */
684#define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrrupt */ 680#define CICR_IRL_MASK ((uint)0x0000e000) /* Core interrupt */
685#define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */ 681#define CICR_HP_MASK ((uint)0x00001f00) /* Hi-pri int. */
686#define CICR_IEN ((uint)0x00000080) /* Int. enable */ 682#define CICR_IEN ((uint)0x00000080) /* Int. enable */
687#define CICR_SPS ((uint)0x00000001) /* SCC Spread */ 683#define CICR_SPS ((uint)0x00000001) /* SCC Spread */
@@ -689,4 +685,4 @@ typedef struct risc_timer_pram {
689extern void cpm_install_handler(int vec, void (*handler)(void *), void *dev_id); 685extern void cpm_install_handler(int vec, void (*handler)(void *), void *dev_id);
690extern void cpm_free_handler(int vec); 686extern void cpm_free_handler(int vec);
691 687
692#endif /* __CPM_8XX__ */ 688#endif /* __CPM1__ */
diff --git a/include/asm-ppc/cpm2.h b/include/asm-ppc/cpm2.h
index 12a2860f9a9c..4c538228e42f 100644
--- a/include/asm-ppc/cpm2.h
+++ b/include/asm-ppc/cpm2.h
@@ -90,7 +90,7 @@
90 */ 90 */
91#define CPM_DATAONLY_BASE ((uint)128) 91#define CPM_DATAONLY_BASE ((uint)128)
92#define CPM_DP_NOSPACE ((uint)0x7fffffff) 92#define CPM_DP_NOSPACE ((uint)0x7fffffff)
93#if defined(CONFIG_8272) || defined(CONFIG_MPC8555) 93#if defined(CONFIG_8272)
94#define CPM_DATAONLY_SIZE ((uint)(8 * 1024) - CPM_DATAONLY_BASE) 94#define CPM_DATAONLY_SIZE ((uint)(8 * 1024) - CPM_DATAONLY_BASE)
95#define CPM_FCC_SPECIAL_BASE ((uint)0x00009000) 95#define CPM_FCC_SPECIAL_BASE ((uint)0x00009000)
96#else 96#else
diff --git a/include/asm-ppc/immap_85xx.h b/include/asm-ppc/immap_85xx.h
deleted file mode 100644
index 9383d0c13ff8..000000000000
--- a/include/asm-ppc/immap_85xx.h
+++ /dev/null
@@ -1,126 +0,0 @@
1/*
2 * include/asm-ppc/immap_85xx.h
3 *
4 * MPC85xx Internal Memory Map
5 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 *
8 * Copyright 2004 Freescale Semiconductor, Inc
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 *
15 */
16
17#ifdef __KERNEL__
18#ifndef __ASM_IMMAP_85XX_H__
19#define __ASM_IMMAP_85XX_H__
20
21/* Eventually this should define all the IO block registers in 85xx */
22
23/* PCI Registers */
24typedef struct ccsr_pci {
25 uint cfg_addr; /* 0x.000 - PCI Configuration Address Register */
26 uint cfg_data; /* 0x.004 - PCI Configuration Data Register */
27 uint int_ack; /* 0x.008 - PCI Interrupt Acknowledge Register */
28 char res1[3060];
29 uint potar0; /* 0x.c00 - PCI Outbound Transaction Address Register 0 */
30 uint potear0; /* 0x.c04 - PCI Outbound Translation Extended Address Register 0 */
31 uint powbar0; /* 0x.c08 - PCI Outbound Window Base Address Register 0 */
32 char res2[4];
33 uint powar0; /* 0x.c10 - PCI Outbound Window Attributes Register 0 */
34 char res3[12];
35 uint potar1; /* 0x.c20 - PCI Outbound Transaction Address Register 1 */
36 uint potear1; /* 0x.c24 - PCI Outbound Translation Extended Address Register 1 */
37 uint powbar1; /* 0x.c28 - PCI Outbound Window Base Address Register 1 */
38 char res4[4];
39 uint powar1; /* 0x.c30 - PCI Outbound Window Attributes Register 1 */
40 char res5[12];
41 uint potar2; /* 0x.c40 - PCI Outbound Transaction Address Register 2 */
42 uint potear2; /* 0x.c44 - PCI Outbound Translation Extended Address Register 2 */
43 uint powbar2; /* 0x.c48 - PCI Outbound Window Base Address Register 2 */
44 char res6[4];
45 uint powar2; /* 0x.c50 - PCI Outbound Window Attributes Register 2 */
46 char res7[12];
47 uint potar3; /* 0x.c60 - PCI Outbound Transaction Address Register 3 */
48 uint potear3; /* 0x.c64 - PCI Outbound Translation Extended Address Register 3 */
49 uint powbar3; /* 0x.c68 - PCI Outbound Window Base Address Register 3 */
50 char res8[4];
51 uint powar3; /* 0x.c70 - PCI Outbound Window Attributes Register 3 */
52 char res9[12];
53 uint potar4; /* 0x.c80 - PCI Outbound Transaction Address Register 4 */
54 uint potear4; /* 0x.c84 - PCI Outbound Translation Extended Address Register 4 */
55 uint powbar4; /* 0x.c88 - PCI Outbound Window Base Address Register 4 */
56 char res10[4];
57 uint powar4; /* 0x.c90 - PCI Outbound Window Attributes Register 4 */
58 char res11[268];
59 uint pitar3; /* 0x.da0 - PCI Inbound Translation Address Register 3 */
60 char res12[4];
61 uint piwbar3; /* 0x.da8 - PCI Inbound Window Base Address Register 3 */
62 uint piwbear3; /* 0x.dac - PCI Inbound Window Base Extended Address Register 3 */
63 uint piwar3; /* 0x.db0 - PCI Inbound Window Attributes Register 3 */
64 char res13[12];
65 uint pitar2; /* 0x.dc0 - PCI Inbound Translation Address Register 2 */
66 char res14[4];
67 uint piwbar2; /* 0x.dc8 - PCI Inbound Window Base Address Register 2 */
68 uint piwbear2; /* 0x.dcc - PCI Inbound Window Base Extended Address Register 2 */
69 uint piwar2; /* 0x.dd0 - PCI Inbound Window Attributes Register 2 */
70 char res15[12];
71 uint pitar1; /* 0x.de0 - PCI Inbound Translation Address Register 1 */
72 char res16[4];
73 uint piwbar1; /* 0x.de8 - PCI Inbound Window Base Address Register 1 */
74 char res17[4];
75 uint piwar1; /* 0x.df0 - PCI Inbound Window Attributes Register 1 */
76 char res18[12];
77 uint err_dr; /* 0x.e00 - PCI Error Detect Register */
78 uint err_cap_dr; /* 0x.e04 - PCI Error Capture Disable Register */
79 uint err_en; /* 0x.e08 - PCI Error Enable Register */
80 uint err_attrib; /* 0x.e0c - PCI Error Attributes Capture Register */
81 uint err_addr; /* 0x.e10 - PCI Error Address Capture Register */
82 uint err_ext_addr; /* 0x.e14 - PCI Error Extended Address Capture Register */
83 uint err_dl; /* 0x.e18 - PCI Error Data Low Capture Register */
84 uint err_dh; /* 0x.e1c - PCI Error Data High Capture Register */
85 uint gas_timr; /* 0x.e20 - PCI Gasket Timer Register */
86 uint pci_timr; /* 0x.e24 - PCI Timer Register */
87 char res19[472];
88} ccsr_pci_t;
89
90/* Global Utility Registers */
91typedef struct ccsr_guts {
92 uint porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */
93 uint porbmsr; /* 0x.0004 - POR Boot Mode Status Register */
94 uint porimpscr; /* 0x.0008 - POR I/O Impedance Status and Control Register */
95 uint pordevsr; /* 0x.000c - POR I/O Device Status Register */
96 uint pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */
97 char res1[12];
98 uint gpporcr; /* 0x.0020 - General-Purpose POR Configuration Register */
99 char res2[12];
100 uint gpiocr; /* 0x.0030 - GPIO Control Register */
101 char res3[12];
102 uint gpoutdr; /* 0x.0040 - General-Purpose Output Data Register */
103 char res4[12];
104 uint gpindr; /* 0x.0050 - General-Purpose Input Data Register */
105 char res5[12];
106 uint pmuxcr; /* 0x.0060 - Alternate Function Signal Multiplex Control */
107 char res6[12];
108 uint devdisr; /* 0x.0070 - Device Disable Control */
109 char res7[12];
110 uint powmgtcsr; /* 0x.0080 - Power Management Status and Control Register */
111 char res8[12];
112 uint mcpsumr; /* 0x.0090 - Machine Check Summary Register */
113 char res9[12];
114 uint pvr; /* 0x.00a0 - Processor Version Register */
115 uint svr; /* 0x.00a4 - System Version Register */
116 char res10[3416];
117 uint clkocr; /* 0x.0e00 - Clock Out Select Register */
118 char res11[12];
119 uint ddrdllcr; /* 0x.0e10 - DDR DLL Control Register */
120 char res12[12];
121 uint lbcdllcr; /* 0x.0e20 - LBC DLL Control Register */
122 char res13[61916];
123} ccsr_guts_t;
124
125#endif /* __ASM_IMMAP_85XX_H__ */
126#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h
index 14584e505ed5..d46b57b589ae 100644
--- a/include/asm-ppc/mmu.h
+++ b/include/asm-ppc/mmu.h
@@ -383,6 +383,12 @@ typedef struct _P601_BAT {
383#define BOOKE_PAGESZ_256GB 14 383#define BOOKE_PAGESZ_256GB 14
384#define BOOKE_PAGESZ_1TB 15 384#define BOOKE_PAGESZ_1TB 15
385 385
386#ifndef CONFIG_SERIAL_TEXT_DEBUG
387#define PPC44x_EARLY_TLBS 1
388#else
389#define PPC44x_EARLY_TLBS 2
390#endif
391
386/* 392/*
387 * Freescale Book-E MMU support 393 * Freescale Book-E MMU support
388 */ 394 */
diff --git a/include/asm-ppc/mmu_context.h b/include/asm-ppc/mmu_context.h
index b2e25d8997bf..9f097e25b169 100644
--- a/include/asm-ppc/mmu_context.h
+++ b/include/asm-ppc/mmu_context.h
@@ -64,11 +64,6 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
64#define LAST_CONTEXT 255 64#define LAST_CONTEXT 255
65#define FIRST_CONTEXT 1 65#define FIRST_CONTEXT 1
66 66
67#elif defined(CONFIG_E200) || defined(CONFIG_E500)
68#define NO_CONTEXT 256
69#define LAST_CONTEXT 255
70#define FIRST_CONTEXT 1
71
72#else 67#else
73 68
74/* PPC 6xx, 7xx CPUs */ 69/* PPC 6xx, 7xx CPUs */
diff --git a/include/asm-ppc/mpc52xx_psc.h b/include/asm-ppc/mpc52xx_psc.h
index c82b8d49a7da..39fcd02cd4e8 100644
--- a/include/asm-ppc/mpc52xx_psc.h
+++ b/include/asm-ppc/mpc52xx_psc.h
@@ -159,6 +159,9 @@ struct mpc52xx_psc {
159 u8 reserved16[3]; 159 u8 reserved16[3];
160 u8 irfdr; /* PSC + 0x54 */ 160 u8 irfdr; /* PSC + 0x54 */
161 u8 reserved17[3]; 161 u8 reserved17[3];
162};
163
164struct mpc52xx_psc_fifo {
162 u16 rfnum; /* PSC + 0x58 */ 165 u16 rfnum; /* PSC + 0x58 */
163 u16 reserved18; 166 u16 reserved18;
164 u16 tfnum; /* PSC + 0x5c */ 167 u16 tfnum; /* PSC + 0x5c */
diff --git a/include/asm-ppc/mpc83xx.h b/include/asm-ppc/mpc83xx.h
deleted file mode 100644
index c3061972309b..000000000000
--- a/include/asm-ppc/mpc83xx.h
+++ /dev/null
@@ -1,107 +0,0 @@
1/*
2 * include/asm-ppc/mpc83xx.h
3 *
4 * MPC83xx definitions
5 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 *
8 * Copyright 2005 Freescale Semiconductor, Inc
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#ifdef __KERNEL__
17#ifndef __ASM_MPC83xx_H__
18#define __ASM_MPC83xx_H__
19
20#include <asm/mmu.h>
21
22#ifdef CONFIG_83xx
23
24#ifdef CONFIG_MPC834x_SYS
25#include <platforms/83xx/mpc834x_sys.h>
26#endif
27
28/*
29 * The "residual" board information structure the boot loader passes
30 * into the kernel.
31 */
32extern unsigned char __res[];
33
34/* Internal IRQs on MPC83xx OpenPIC */
35/* Not all of these exist on all MPC83xx implementations */
36
37#ifndef MPC83xx_IPIC_IRQ_OFFSET
38#define MPC83xx_IPIC_IRQ_OFFSET 0
39#endif
40
41#define NR_IPIC_INTS 128
42
43#define MPC83xx_IRQ_UART1 ( 9 + MPC83xx_IPIC_IRQ_OFFSET)
44#define MPC83xx_IRQ_UART2 (10 + MPC83xx_IPIC_IRQ_OFFSET)
45#define MPC83xx_IRQ_SEC2 (11 + MPC83xx_IPIC_IRQ_OFFSET)
46#define MPC83xx_IRQ_IIC1 (14 + MPC83xx_IPIC_IRQ_OFFSET)
47#define MPC83xx_IRQ_IIC2 (15 + MPC83xx_IPIC_IRQ_OFFSET)
48#define MPC83xx_IRQ_SPI (16 + MPC83xx_IPIC_IRQ_OFFSET)
49#define MPC83xx_IRQ_EXT1 (17 + MPC83xx_IPIC_IRQ_OFFSET)
50#define MPC83xx_IRQ_EXT2 (18 + MPC83xx_IPIC_IRQ_OFFSET)
51#define MPC83xx_IRQ_EXT3 (19 + MPC83xx_IPIC_IRQ_OFFSET)
52#define MPC83xx_IRQ_EXT4 (20 + MPC83xx_IPIC_IRQ_OFFSET)
53#define MPC83xx_IRQ_EXT5 (21 + MPC83xx_IPIC_IRQ_OFFSET)
54#define MPC83xx_IRQ_EXT6 (22 + MPC83xx_IPIC_IRQ_OFFSET)
55#define MPC83xx_IRQ_EXT7 (23 + MPC83xx_IPIC_IRQ_OFFSET)
56#define MPC83xx_IRQ_TSEC1_TX (32 + MPC83xx_IPIC_IRQ_OFFSET)
57#define MPC83xx_IRQ_TSEC1_RX (33 + MPC83xx_IPIC_IRQ_OFFSET)
58#define MPC83xx_IRQ_TSEC1_ERROR (34 + MPC83xx_IPIC_IRQ_OFFSET)
59#define MPC83xx_IRQ_TSEC2_TX (35 + MPC83xx_IPIC_IRQ_OFFSET)
60#define MPC83xx_IRQ_TSEC2_RX (36 + MPC83xx_IPIC_IRQ_OFFSET)
61#define MPC83xx_IRQ_TSEC2_ERROR (37 + MPC83xx_IPIC_IRQ_OFFSET)
62#define MPC83xx_IRQ_USB2_DR (38 + MPC83xx_IPIC_IRQ_OFFSET)
63#define MPC83xx_IRQ_USB2_MPH (39 + MPC83xx_IPIC_IRQ_OFFSET)
64#define MPC83xx_IRQ_EXT0 (48 + MPC83xx_IPIC_IRQ_OFFSET)
65#define MPC83xx_IRQ_RTC_SEC (64 + MPC83xx_IPIC_IRQ_OFFSET)
66#define MPC83xx_IRQ_PIT (65 + MPC83xx_IPIC_IRQ_OFFSET)
67#define MPC83xx_IRQ_PCI1 (66 + MPC83xx_IPIC_IRQ_OFFSET)
68#define MPC83xx_IRQ_PCI2 (67 + MPC83xx_IPIC_IRQ_OFFSET)
69#define MPC83xx_IRQ_RTC_ALR (68 + MPC83xx_IPIC_IRQ_OFFSET)
70#define MPC83xx_IRQ_MU (69 + MPC83xx_IPIC_IRQ_OFFSET)
71#define MPC83xx_IRQ_SBA (70 + MPC83xx_IPIC_IRQ_OFFSET)
72#define MPC83xx_IRQ_DMA (71 + MPC83xx_IPIC_IRQ_OFFSET)
73#define MPC83xx_IRQ_GTM4 (72 + MPC83xx_IPIC_IRQ_OFFSET)
74#define MPC83xx_IRQ_GTM8 (73 + MPC83xx_IPIC_IRQ_OFFSET)
75#define MPC83xx_IRQ_GPIO1 (74 + MPC83xx_IPIC_IRQ_OFFSET)
76#define MPC83xx_IRQ_GPIO2 (75 + MPC83xx_IPIC_IRQ_OFFSET)
77#define MPC83xx_IRQ_DDR (76 + MPC83xx_IPIC_IRQ_OFFSET)
78#define MPC83xx_IRQ_LBC (77 + MPC83xx_IPIC_IRQ_OFFSET)
79#define MPC83xx_IRQ_GTM2 (78 + MPC83xx_IPIC_IRQ_OFFSET)
80#define MPC83xx_IRQ_GTM6 (79 + MPC83xx_IPIC_IRQ_OFFSET)
81#define MPC83xx_IRQ_PMC (80 + MPC83xx_IPIC_IRQ_OFFSET)
82#define MPC83xx_IRQ_GTM3 (84 + MPC83xx_IPIC_IRQ_OFFSET)
83#define MPC83xx_IRQ_GTM7 (85 + MPC83xx_IPIC_IRQ_OFFSET)
84#define MPC83xx_IRQ_GTM1 (90 + MPC83xx_IPIC_IRQ_OFFSET)
85#define MPC83xx_IRQ_GTM5 (91 + MPC83xx_IPIC_IRQ_OFFSET)
86
87#define MPC83xx_CCSRBAR_SIZE (1024*1024)
88
89/* Let modules/drivers get at immrbar (physical) */
90extern phys_addr_t immrbar;
91
92enum ppc_sys_devices {
93 MPC83xx_TSEC1,
94 MPC83xx_TSEC2,
95 MPC83xx_IIC1,
96 MPC83xx_IIC2,
97 MPC83xx_DUART,
98 MPC83xx_SEC2,
99 MPC83xx_USB2_DR,
100 MPC83xx_USB2_MPH,
101 MPC83xx_MDIO,
102 NUM_PPC_SYS_DEVS,
103};
104
105#endif /* CONFIG_83xx */
106#endif /* __ASM_MPC83xx_H__ */
107#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
deleted file mode 100644
index d7e4a79d77fb..000000000000
--- a/include/asm-ppc/mpc85xx.h
+++ /dev/null
@@ -1,192 +0,0 @@
1/*
2 * include/asm-ppc/mpc85xx.h
3 *
4 * MPC85xx definitions
5 *
6 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
7 *
8 * Copyright 2004 Freescale Semiconductor, Inc
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#ifdef __KERNEL__
17#ifndef __ASM_MPC85xx_H__
18#define __ASM_MPC85xx_H__
19
20#include <asm/mmu.h>
21
22#ifdef CONFIG_85xx
23
24#ifdef CONFIG_MPC8540_ADS
25#include <platforms/85xx/mpc8540_ads.h>
26#endif
27#if defined(CONFIG_MPC8555_CDS) || defined(CONFIG_MPC8548_CDS)
28#include <platforms/85xx/mpc8555_cds.h>
29#endif
30#ifdef CONFIG_MPC85xx_CDS
31#include <platforms/85xx/mpc85xx_cds.h>
32#endif
33#ifdef CONFIG_MPC8560_ADS
34#include <platforms/85xx/mpc8560_ads.h>
35#endif
36#ifdef CONFIG_SBC8560
37#include <platforms/85xx/sbc8560.h>
38#endif
39#ifdef CONFIG_STX_GP3
40#include <platforms/85xx/stx_gp3.h>
41#endif
42#if defined(CONFIG_TQM8540) || defined(CONFIG_TQM8541) || \
43 defined(CONFIG_TQM8555) || defined(CONFIG_TQM8560)
44#include <platforms/85xx/tqm85xx.h>
45#endif
46
47/*
48 * The "residual" board information structure the boot loader passes
49 * into the kernel.
50 */
51extern unsigned char __res[];
52
53/* Offset from CCSRBAR */
54#define MPC85xx_CPM_OFFSET (0x80000)
55#define MPC85xx_CPM_SIZE (0x40000)
56#define MPC85xx_DMA_OFFSET (0x21000)
57#define MPC85xx_DMA_SIZE (0x01000)
58#define MPC85xx_DMA0_OFFSET (0x21100)
59#define MPC85xx_DMA0_SIZE (0x00080)
60#define MPC85xx_DMA1_OFFSET (0x21180)
61#define MPC85xx_DMA1_SIZE (0x00080)
62#define MPC85xx_DMA2_OFFSET (0x21200)
63#define MPC85xx_DMA2_SIZE (0x00080)
64#define MPC85xx_DMA3_OFFSET (0x21280)
65#define MPC85xx_DMA3_SIZE (0x00080)
66#define MPC85xx_ENET1_OFFSET (0x24000)
67#define MPC85xx_ENET1_SIZE (0x01000)
68#define MPC85xx_MIIM_OFFSET (0x24520)
69#define MPC85xx_MIIM_SIZE (0x00018)
70#define MPC85xx_ENET2_OFFSET (0x25000)
71#define MPC85xx_ENET2_SIZE (0x01000)
72#define MPC85xx_ENET3_OFFSET (0x26000)
73#define MPC85xx_ENET3_SIZE (0x01000)
74#define MPC85xx_GUTS_OFFSET (0xe0000)
75#define MPC85xx_GUTS_SIZE (0x01000)
76#define MPC85xx_IIC1_OFFSET (0x03000)
77#define MPC85xx_IIC1_SIZE (0x00100)
78#define MPC85xx_OPENPIC_OFFSET (0x40000)
79#define MPC85xx_OPENPIC_SIZE (0x40000)
80#define MPC85xx_PCI1_OFFSET (0x08000)
81#define MPC85xx_PCI1_SIZE (0x01000)
82#define MPC85xx_PCI2_OFFSET (0x09000)
83#define MPC85xx_PCI2_SIZE (0x01000)
84#define MPC85xx_PERFMON_OFFSET (0xe1000)
85#define MPC85xx_PERFMON_SIZE (0x01000)
86#define MPC85xx_SEC2_OFFSET (0x30000)
87#define MPC85xx_SEC2_SIZE (0x10000)
88#define MPC85xx_UART0_OFFSET (0x04500)
89#define MPC85xx_UART0_SIZE (0x00100)
90#define MPC85xx_UART1_OFFSET (0x04600)
91#define MPC85xx_UART1_SIZE (0x00100)
92
93#define MPC85xx_CCSRBAR_SIZE (1024*1024)
94
95/* Let modules/drivers get at CCSRBAR */
96extern phys_addr_t get_ccsrbar(void);
97
98#ifdef MODULE
99#define CCSRBAR get_ccsrbar()
100#else
101#define CCSRBAR BOARD_CCSRBAR
102#endif
103
104enum ppc_sys_devices {
105 MPC85xx_TSEC1,
106 MPC85xx_TSEC2,
107 MPC85xx_FEC,
108 MPC85xx_IIC1,
109 MPC85xx_DMA0,
110 MPC85xx_DMA1,
111 MPC85xx_DMA2,
112 MPC85xx_DMA3,
113 MPC85xx_DUART,
114 MPC85xx_PERFMON,
115 MPC85xx_SEC2,
116 MPC85xx_CPM_SPI,
117 MPC85xx_CPM_I2C,
118 MPC85xx_CPM_USB,
119 MPC85xx_CPM_SCC1,
120 MPC85xx_CPM_SCC2,
121 MPC85xx_CPM_SCC3,
122 MPC85xx_CPM_SCC4,
123 MPC85xx_CPM_FCC1,
124 MPC85xx_CPM_FCC2,
125 MPC85xx_CPM_FCC3,
126 MPC85xx_CPM_MCC1,
127 MPC85xx_CPM_MCC2,
128 MPC85xx_CPM_SMC1,
129 MPC85xx_CPM_SMC2,
130 MPC85xx_eTSEC1,
131 MPC85xx_eTSEC2,
132 MPC85xx_eTSEC3,
133 MPC85xx_eTSEC4,
134 MPC85xx_IIC2,
135 MPC85xx_MDIO,
136 NUM_PPC_SYS_DEVS,
137};
138
139/* Internal interrupts are all Level Sensitive, and Positive Polarity */
140#define MPC85XX_INTERNAL_IRQ_SENSES \
141 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 0 */ \
142 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 1 */ \
143 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 2 */ \
144 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 3 */ \
145 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 4 */ \
146 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 5 */ \
147 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 6 */ \
148 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 7 */ \
149 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 8 */ \
150 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 9 */ \
151 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 10 */ \
152 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 11 */ \
153 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 12 */ \
154 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 13 */ \
155 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 14 */ \
156 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 15 */ \
157 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 16 */ \
158 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 17 */ \
159 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 18 */ \
160 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 19 */ \
161 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 20 */ \
162 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 21 */ \
163 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 22 */ \
164 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 23 */ \
165 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 24 */ \
166 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 25 */ \
167 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 26 */ \
168 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 27 */ \
169 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 28 */ \
170 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 29 */ \
171 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 30 */ \
172 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 31 */ \
173 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 32 */ \
174 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 33 */ \
175 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 34 */ \
176 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 35 */ \
177 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 36 */ \
178 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 37 */ \
179 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 38 */ \
180 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 39 */ \
181 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 40 */ \
182 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 41 */ \
183 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 42 */ \
184 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 43 */ \
185 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 44 */ \
186 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 45 */ \
187 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE), /* Internal 46 */ \
188 (IRQ_SENSE_LEVEL | IRQ_POLARITY_POSITIVE) /* Internal 47 */
189
190#endif /* CONFIG_85xx */
191#endif /* __ASM_MPC85xx_H__ */
192#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
index 063ad91cbbcc..69347bdbb401 100644
--- a/include/asm-ppc/pgtable.h
+++ b/include/asm-ppc/pgtable.h
@@ -271,48 +271,6 @@ extern unsigned long ioremap_bot, ioremap_base;
271/* ERPN in a PTE never gets cleared, ignore it */ 271/* ERPN in a PTE never gets cleared, ignore it */
272#define _PTE_NONE_MASK 0xffffffff00000000ULL 272#define _PTE_NONE_MASK 0xffffffff00000000ULL
273 273
274#elif defined(CONFIG_FSL_BOOKE)
275/*
276 MMU Assist Register 3:
277
278 32 33 34 35 36 ... 50 51 52 53 54 55 56 57 58 59 60 61 62 63
279 RPN...................... 0 0 U0 U1 U2 U3 UX SX UW SW UR SR
280
281 - PRESENT *must* be in the bottom three bits because swap cache
282 entries use the top 29 bits.
283
284 - FILE *must* be in the bottom three bits because swap cache
285 entries use the top 29 bits.
286*/
287
288/* Definitions for FSL Book-E Cores */
289#define _PAGE_PRESENT 0x00001 /* S: PTE contains a translation */
290#define _PAGE_USER 0x00002 /* S: User page (maps to UR) */
291#define _PAGE_FILE 0x00002 /* S: when !present: nonlinear file mapping */
292#define _PAGE_ACCESSED 0x00004 /* S: Page referenced */
293#define _PAGE_HWWRITE 0x00008 /* H: Dirty & RW, set in exception */
294#define _PAGE_RW 0x00010 /* S: Write permission */
295#define _PAGE_HWEXEC 0x00020 /* H: UX permission */
296
297#define _PAGE_ENDIAN 0x00040 /* H: E bit */
298#define _PAGE_GUARDED 0x00080 /* H: G bit */
299#define _PAGE_COHERENT 0x00100 /* H: M bit */
300#define _PAGE_NO_CACHE 0x00200 /* H: I bit */
301#define _PAGE_WRITETHRU 0x00400 /* H: W bit */
302
303#ifdef CONFIG_PTE_64BIT
304#define _PAGE_DIRTY 0x08000 /* S: Page dirty */
305
306/* ERPN in a PTE never gets cleared, ignore it */
307#define _PTE_NONE_MASK 0xffffffffffff0000ULL
308#else
309#define _PAGE_DIRTY 0x00800 /* S: Page dirty */
310#endif
311
312#define _PMD_PRESENT 0
313#define _PMD_PRESENT_MASK (PAGE_MASK)
314#define _PMD_BAD (~PAGE_MASK)
315
316#elif defined(CONFIG_8xx) 274#elif defined(CONFIG_8xx)
317/* Definitions for 8xx embedded chips. */ 275/* Definitions for 8xx embedded chips. */
318#define _PAGE_PRESENT 0x0001 /* Page is valid */ 276#define _PAGE_PRESENT 0x0001 /* Page is valid */
@@ -484,11 +442,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
484 442
485/* in some case we want to additionaly adjust where the pfn is in the pte to 443/* in some case we want to additionaly adjust where the pfn is in the pte to
486 * allow room for more flags */ 444 * allow room for more flags */
487#if defined(CONFIG_FSL_BOOKE) && defined(CONFIG_PTE_64BIT)
488#define PFN_SHIFT_OFFSET (PAGE_SHIFT + 8)
489#else
490#define PFN_SHIFT_OFFSET (PAGE_SHIFT) 445#define PFN_SHIFT_OFFSET (PAGE_SHIFT)
491#endif
492 446
493#define pte_pfn(x) (pte_val(x) >> PFN_SHIFT_OFFSET) 447#define pte_pfn(x) (pte_val(x) >> PFN_SHIFT_OFFSET)
494#define pte_page(x) pfn_to_page(pte_pfn(x)) 448#define pte_page(x) pfn_to_page(pte_pfn(x))
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index de99e92d627b..d2fee41d600b 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -23,10 +23,6 @@
23 23
24#if defined(CONFIG_8260) 24#if defined(CONFIG_8260)
25#include <asm/mpc8260.h> 25#include <asm/mpc8260.h>
26#elif defined(CONFIG_83xx)
27#include <asm/mpc83xx.h>
28#elif defined(CONFIG_85xx)
29#include <asm/mpc85xx.h>
30#elif defined(CONFIG_8xx) 26#elif defined(CONFIG_8xx)
31#include <asm/mpc8xx.h> 27#include <asm/mpc8xx.h>
32#elif defined(CONFIG_PPC_MPC52xx) 28#elif defined(CONFIG_PPC_MPC52xx)
diff --git a/include/asm-ppc/ppcboot.h b/include/asm-ppc/ppcboot.h
index 6b7b63f71daa..3819e17cd7b0 100644
--- a/include/asm-ppc/ppcboot.h
+++ b/include/asm-ppc/ppcboot.h
@@ -38,8 +38,7 @@ typedef struct bd_info {
38 unsigned long bi_flashoffset; /* reserved area for startup monitor */ 38 unsigned long bi_flashoffset; /* reserved area for startup monitor */
39 unsigned long bi_sramstart; /* start of SRAM memory */ 39 unsigned long bi_sramstart; /* start of SRAM memory */
40 unsigned long bi_sramsize; /* size of SRAM memory */ 40 unsigned long bi_sramsize; /* size of SRAM memory */
41#if defined(CONFIG_8xx) || defined(CONFIG_CPM2) || defined(CONFIG_85xx) ||\ 41#if defined(CONFIG_8xx) || defined(CONFIG_CPM2)
42 defined(CONFIG_83xx)
43 unsigned long bi_immr_base; /* base of IMMR register */ 42 unsigned long bi_immr_base; /* base of IMMR register */
44#endif 43#endif
45#if defined(CONFIG_PPC_MPC52xx) 44#if defined(CONFIG_PPC_MPC52xx)
@@ -73,12 +72,11 @@ typedef struct bd_info {
73#if defined(CONFIG_HYMOD) 72#if defined(CONFIG_HYMOD)
74 hymod_conf_t bi_hymod_conf; /* hymod configuration information */ 73 hymod_conf_t bi_hymod_conf; /* hymod configuration information */
75#endif 74#endif
76#if defined(CONFIG_EVB64260) || defined(CONFIG_405EP) || defined(CONFIG_44x) || \ 75#if defined(CONFIG_EVB64260) || defined(CONFIG_405EP) || defined(CONFIG_44x)
77 defined(CONFIG_85xx) || defined(CONFIG_83xx)
78 /* second onboard ethernet port */ 76 /* second onboard ethernet port */
79 unsigned char bi_enet1addr[6]; 77 unsigned char bi_enet1addr[6];
80#endif 78#endif
81#if defined(CONFIG_EVB64260) || defined(CONFIG_440GX) || defined(CONFIG_85xx) 79#if defined(CONFIG_EVB64260) || defined(CONFIG_440GX)
82 /* third onboard ethernet ports */ 80 /* third onboard ethernet ports */
83 unsigned char bi_enet2addr[6]; 81 unsigned char bi_enet2addr[6];
84#endif 82#endif
diff --git a/include/asm-ppc/reg_booke.h b/include/asm-ppc/reg_booke.h
index 82948ed2744a..91e96af88bd8 100644
--- a/include/asm-ppc/reg_booke.h
+++ b/include/asm-ppc/reg_booke.h
@@ -207,7 +207,7 @@
207#define CCR1_TCS 0x00000080 /* Timer Clock Select */ 207#define CCR1_TCS 0x00000080 /* Timer Clock Select */
208 208
209/* Bit definitions for the MCSR. */ 209/* Bit definitions for the MCSR. */
210#ifdef CONFIG_440A 210#ifdef CONFIG_4xx
211#define MCSR_MCS 0x80000000 /* Machine Check Summary */ 211#define MCSR_MCS 0x80000000 /* Machine Check Summary */
212#define MCSR_IB 0x40000000 /* Instruction PLB Error */ 212#define MCSR_IB 0x40000000 /* Instruction PLB Error */
213#define MCSR_DRB 0x20000000 /* Data Read PLB Error */ 213#define MCSR_DRB 0x20000000 /* Data Read PLB Error */
@@ -218,32 +218,6 @@
218#define MCSR_DCFP 0x01000000 /* D-Cache Flush Parity Error */ 218#define MCSR_DCFP 0x01000000 /* D-Cache Flush Parity Error */
219#define MCSR_IMPE 0x00800000 /* Imprecise Machine Check Exception */ 219#define MCSR_IMPE 0x00800000 /* Imprecise Machine Check Exception */
220#endif 220#endif
221#ifdef CONFIG_E500
222#define MCSR_MCP 0x80000000UL /* Machine Check Input Pin */
223#define MCSR_ICPERR 0x40000000UL /* I-Cache Parity Error */
224#define MCSR_DCP_PERR 0x20000000UL /* D-Cache Push Parity Error */
225#define MCSR_DCPERR 0x10000000UL /* D-Cache Parity Error */
226#define MCSR_GL_CI 0x00010000UL /* Guarded Load or Cache-Inhibited stwcx. */
227#define MCSR_BUS_IAERR 0x00000080UL /* Instruction Address Error */
228#define MCSR_BUS_RAERR 0x00000040UL /* Read Address Error */
229#define MCSR_BUS_WAERR 0x00000020UL /* Write Address Error */
230#define MCSR_BUS_IBERR 0x00000010UL /* Instruction Data Error */
231#define MCSR_BUS_RBERR 0x00000008UL /* Read Data Bus Error */
232#define MCSR_BUS_WBERR 0x00000004UL /* Write Data Bus Error */
233#define MCSR_BUS_IPERR 0x00000002UL /* Instruction parity Error */
234#define MCSR_BUS_RPERR 0x00000001UL /* Read parity Error */
235#endif
236#ifdef CONFIG_E200
237#define MCSR_MCP 0x80000000UL /* Machine Check Input Pin */
238#define MCSR_CP_PERR 0x20000000UL /* Cache Push Parity Error */
239#define MCSR_CPERR 0x10000000UL /* Cache Parity Error */
240#define MCSR_EXCP_ERR 0x08000000UL /* ISI, ITLB, or Bus Error on 1st insn
241 fetch for an exception handler */
242#define MCSR_BUS_IRERR 0x00000010UL /* Read Bus Error on instruction fetch*/
243#define MCSR_BUS_DRERR 0x00000008UL /* Read Bus Error on data load */
244#define MCSR_BUS_WRERR 0x00000004UL /* Write Bus Error on buffered
245 store or cache line push */
246#endif
247 221
248/* Bit definitions for the DBSR. */ 222/* Bit definitions for the DBSR. */
249/* 223/*
@@ -283,7 +257,7 @@
283#define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */ 257#define ESR_IMCB 0x20000000 /* Instr. Machine Check - Bus error */
284#define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */ 258#define ESR_IMCT 0x10000000 /* Instr. Machine Check - Timeout */
285#define ESR_PIL 0x08000000 /* Program Exception - Illegal */ 259#define ESR_PIL 0x08000000 /* Program Exception - Illegal */
286#define ESR_PPR 0x04000000 /* Program Exception - Priveleged */ 260#define ESR_PPR 0x04000000 /* Program Exception - Privileged */
287#define ESR_PTR 0x02000000 /* Program Exception - Trap */ 261#define ESR_PTR 0x02000000 /* Program Exception - Trap */
288#define ESR_FP 0x01000000 /* Floating Point Operation */ 262#define ESR_FP 0x01000000 /* Floating Point Operation */
289#define ESR_DST 0x00800000 /* Storage Exception - Data miss */ 263#define ESR_DST 0x00800000 /* Storage Exception - Data miss */
diff --git a/include/asm-ppc/serial.h b/include/asm-ppc/serial.h
index 8fc1b546613d..d35ed10315b1 100644
--- a/include/asm-ppc/serial.h
+++ b/include/asm-ppc/serial.h
@@ -29,10 +29,6 @@
29#include <platforms/spruce.h> 29#include <platforms/spruce.h>
30#elif defined(CONFIG_4xx) 30#elif defined(CONFIG_4xx)
31#include <asm/ibm4xx.h> 31#include <asm/ibm4xx.h>
32#elif defined(CONFIG_83xx)
33#include <asm/mpc83xx.h>
34#elif defined(CONFIG_85xx)
35#include <asm/mpc85xx.h>
36#elif defined(CONFIG_RADSTONE_PPC7D) 32#elif defined(CONFIG_RADSTONE_PPC7D)
37#include <platforms/radstone_ppc7d.h> 33#include <platforms/radstone_ppc7d.h>
38#else 34#else
diff --git a/include/asm-s390/airq.h b/include/asm-s390/airq.h
new file mode 100644
index 000000000000..41d028cb52a4
--- /dev/null
+++ b/include/asm-s390/airq.h
@@ -0,0 +1,19 @@
1/*
2 * include/asm-s390/airq.h
3 *
4 * Copyright IBM Corp. 2002,2007
5 * Author(s): Ingo Adlung <adlung@de.ibm.com>
6 * Cornelia Huck <cornelia.huck@de.ibm.com>
7 * Arnd Bergmann <arndb@de.ibm.com>
8 * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
9 */
10
11#ifndef _ASM_S390_AIRQ_H
12#define _ASM_S390_AIRQ_H
13
14typedef void (*adapter_int_handler_t)(void *, void *);
15
16void *s390_register_adapter_interrupt(adapter_int_handler_t, void *);
17void s390_unregister_adapter_interrupt(void *);
18
19#endif /* _ASM_S390_AIRQ_H */
diff --git a/include/asm-s390/bitops.h b/include/asm-s390/bitops.h
index 34d9a6357c38..dba6fecad0be 100644
--- a/include/asm-s390/bitops.h
+++ b/include/asm-s390/bitops.h
@@ -772,6 +772,8 @@ static inline int sched_find_first_bit(unsigned long *b)
772 test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) 772 test_and_clear_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
773#define ext2_test_bit(nr, addr) \ 773#define ext2_test_bit(nr, addr) \
774 test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr) 774 test_bit((nr)^(__BITOPS_WORDSIZE - 8), (unsigned long *)addr)
775#define ext2_find_next_bit(addr, size, off) \
776 generic_find_next_le_bit((unsigned long *)(addr), (size), (off))
775 777
776#ifndef __s390x__ 778#ifndef __s390x__
777 779
diff --git a/include/asm-s390/cio.h b/include/asm-s390/cio.h
index 2f08c16e44ad..123b557c3ff4 100644
--- a/include/asm-s390/cio.h
+++ b/include/asm-s390/cio.h
@@ -24,8 +24,8 @@
24 * @fmt: format 24 * @fmt: format
25 * @pfch: prefetch 25 * @pfch: prefetch
26 * @isic: initial-status interruption control 26 * @isic: initial-status interruption control
27 * @alcc: adress-limit checking control 27 * @alcc: address-limit checking control
28 * @ssi: supress-suspended interruption 28 * @ssi: suppress-suspended interruption
29 * @zcc: zero condition code 29 * @zcc: zero condition code
30 * @ectl: extended control 30 * @ectl: extended control
31 * @pno: path not operational 31 * @pno: path not operational
diff --git a/include/asm-s390/dasd.h b/include/asm-s390/dasd.h
index 604f68fa6f56..3f002e13d024 100644
--- a/include/asm-s390/dasd.h
+++ b/include/asm-s390/dasd.h
@@ -105,7 +105,7 @@ typedef struct dasd_information_t {
105} dasd_information_t; 105} dasd_information_t;
106 106
107/* 107/*
108 * Read Subsystem Data - Perfomance Statistics 108 * Read Subsystem Data - Performance Statistics
109 */ 109 */
110typedef struct dasd_rssd_perf_stats_t { 110typedef struct dasd_rssd_perf_stats_t {
111 unsigned char invalid:1; 111 unsigned char invalid:1;
diff --git a/include/asm-s390/ipl.h b/include/asm-s390/ipl.h
index 2c40fd3a137f..c1b2e50392bb 100644
--- a/include/asm-s390/ipl.h
+++ b/include/asm-s390/ipl.h
@@ -83,6 +83,8 @@ extern u32 dump_prefix_page;
83extern unsigned int zfcpdump_prefix_array[]; 83extern unsigned int zfcpdump_prefix_array[];
84 84
85extern void do_reipl(void); 85extern void do_reipl(void);
86extern void do_halt(void);
87extern void do_poff(void);
86extern void ipl_save_parameters(void); 88extern void ipl_save_parameters(void);
87 89
88enum { 90enum {
@@ -118,7 +120,7 @@ struct ipl_info
118}; 120};
119 121
120extern struct ipl_info ipl_info; 122extern struct ipl_info ipl_info;
121extern void setup_ipl_info(void); 123extern void setup_ipl(void);
122 124
123/* 125/*
124 * DIAG 308 support 126 * DIAG 308 support
@@ -141,6 +143,10 @@ enum diag308_opt {
141 DIAG308_IPL_OPT_DUMP = 0x20, 143 DIAG308_IPL_OPT_DUMP = 0x20,
142}; 144};
143 145
146enum diag308_flags {
147 DIAG308_FLAGS_LP_VALID = 0x80,
148};
149
144enum diag308_rc { 150enum diag308_rc {
145 DIAG308_RC_OK = 1, 151 DIAG308_RC_OK = 1,
146}; 152};
diff --git a/include/asm-s390/mmu_context.h b/include/asm-s390/mmu_context.h
index 05b842126b99..a77d4ba3c8eb 100644
--- a/include/asm-s390/mmu_context.h
+++ b/include/asm-s390/mmu_context.h
@@ -12,10 +12,15 @@
12#include <asm/pgalloc.h> 12#include <asm/pgalloc.h>
13#include <asm-generic/mm_hooks.h> 13#include <asm-generic/mm_hooks.h>
14 14
15/* 15static inline int init_new_context(struct task_struct *tsk,
16 * get a new mmu context.. S390 don't know about contexts. 16 struct mm_struct *mm)
17 */ 17{
18#define init_new_context(tsk,mm) 0 18 mm->context = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS;
19#ifdef CONFIG_64BIT
20 mm->context |= _ASCE_TYPE_REGION3;
21#endif
22 return 0;
23}
19 24
20#define destroy_context(mm) do { } while (0) 25#define destroy_context(mm) do { } while (0)
21 26
@@ -27,19 +32,11 @@
27 32
28static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk) 33static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk)
29{ 34{
30 pgd_t *pgd = mm->pgd; 35 S390_lowcore.user_asce = mm->context | __pa(mm->pgd);
31 unsigned long asce_bits;
32
33 /* Calculate asce bits from the first pgd table entry. */
34 asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS;
35#ifdef CONFIG_64BIT
36 asce_bits |= _ASCE_TYPE_REGION3;
37#endif
38 S390_lowcore.user_asce = asce_bits | __pa(pgd);
39 if (switch_amode) { 36 if (switch_amode) {
40 /* Load primary space page table origin. */ 37 /* Load primary space page table origin. */
41 pgd_t *shadow_pgd = get_shadow_table(pgd) ? : pgd; 38 pgd_t *shadow_pgd = get_shadow_table(mm->pgd) ? : mm->pgd;
42 S390_lowcore.user_exec_asce = asce_bits | __pa(shadow_pgd); 39 S390_lowcore.user_exec_asce = mm->context | __pa(shadow_pgd);
43 asm volatile(LCTL_OPCODE" 1,1,%0\n" 40 asm volatile(LCTL_OPCODE" 1,1,%0\n"
44 : : "m" (S390_lowcore.user_exec_asce) ); 41 : : "m" (S390_lowcore.user_exec_asce) );
45 } else 42 } else
diff --git a/include/asm-s390/percpu.h b/include/asm-s390/percpu.h
index 545857e64443..408d60b4f75b 100644
--- a/include/asm-s390/percpu.h
+++ b/include/asm-s390/percpu.h
@@ -4,8 +4,6 @@
4#include <linux/compiler.h> 4#include <linux/compiler.h>
5#include <asm/lowcore.h> 5#include <asm/lowcore.h>
6 6
7#define __GENERIC_PER_CPU
8
9/* 7/*
10 * s390 uses its own implementation for per cpu data, the offset of 8 * s390 uses its own implementation for per cpu data, the offset of
11 * the cpu local data area is cached in the cpu's lowcore memory. 9 * the cpu local data area is cached in the cpu's lowcore memory.
@@ -15,67 +13,25 @@
15 */ 13 */
16#if defined(__s390x__) && defined(MODULE) 14#if defined(__s390x__) && defined(MODULE)
17 15
18#define __reloc_hide(var,offset) (*({ \ 16#define SHIFT_PERCPU_PTR(ptr,offset) (({ \
19 extern int simple_identifier_##var(void); \ 17 extern int simple_identifier_##var(void); \
20 unsigned long *__ptr; \ 18 unsigned long *__ptr; \
21 asm ( "larl %0,per_cpu__"#var"@GOTENT" \ 19 asm ( "larl %0, %1@GOTENT" \
22 : "=a" (__ptr) : "X" (per_cpu__##var) ); \ 20 : "=a" (__ptr) : "X" (ptr) ); \
23 (typeof(&per_cpu__##var))((*__ptr) + (offset)); })) 21 (typeof(ptr))((*__ptr) + (offset)); }))
24 22
25#else 23#else
26 24
27#define __reloc_hide(var, offset) (*({ \ 25#define SHIFT_PERCPU_PTR(ptr, offset) (({ \
28 extern int simple_identifier_##var(void); \ 26 extern int simple_identifier_##var(void); \
29 unsigned long __ptr; \ 27 unsigned long __ptr; \
30 asm ( "" : "=a" (__ptr) : "0" (&per_cpu__##var) ); \ 28 asm ( "" : "=a" (__ptr) : "0" (ptr) ); \
31 (typeof(&per_cpu__##var)) (__ptr + (offset)); })) 29 (typeof(ptr)) (__ptr + (offset)); }))
32 30
33#endif 31#endif
34 32
35#ifdef CONFIG_SMP 33#define __my_cpu_offset S390_lowcore.percpu_offset
36
37extern unsigned long __per_cpu_offset[NR_CPUS];
38
39/* Separate out the type, so (int[3], foo) works. */
40#define DEFINE_PER_CPU(type, name) \
41 __attribute__((__section__(".data.percpu"))) \
42 __typeof__(type) per_cpu__##name
43
44#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
45 __attribute__((__section__(".data.percpu.shared_aligned"))) \
46 __typeof__(type) per_cpu__##name \
47 ____cacheline_aligned_in_smp
48
49#define __get_cpu_var(var) __reloc_hide(var,S390_lowcore.percpu_offset)
50#define __raw_get_cpu_var(var) __reloc_hide(var,S390_lowcore.percpu_offset)
51#define per_cpu(var,cpu) __reloc_hide(var,__per_cpu_offset[cpu])
52#define per_cpu_offset(x) (__per_cpu_offset[x])
53
54/* A macro to avoid #include hell... */
55#define percpu_modcopy(pcpudst, src, size) \
56do { \
57 unsigned int __i; \
58 for_each_possible_cpu(__i) \
59 memcpy((pcpudst)+__per_cpu_offset[__i], \
60 (src), (size)); \
61} while (0)
62
63#else /* ! SMP */
64
65#define DEFINE_PER_CPU(type, name) \
66 __typeof__(type) per_cpu__##name
67#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
68 DEFINE_PER_CPU(type, name)
69
70#define __get_cpu_var(var) __reloc_hide(var,0)
71#define __raw_get_cpu_var(var) __reloc_hide(var,0)
72#define per_cpu(var,cpu) __reloc_hide(var,0)
73
74#endif /* SMP */
75
76#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
77 34
78#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var) 35#include <asm-generic/percpu.h>
79#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
80 36
81#endif /* __ARCH_S390_PERCPU__ */ 37#endif /* __ARCH_S390_PERCPU__ */
diff --git a/include/asm-s390/pgtable.h b/include/asm-s390/pgtable.h
index f2cc25b74adf..79b9eab1a0c7 100644
--- a/include/asm-s390/pgtable.h
+++ b/include/asm-s390/pgtable.h
@@ -104,41 +104,27 @@ extern char empty_zero_page[PAGE_SIZE];
104 104
105#ifndef __ASSEMBLY__ 105#ifndef __ASSEMBLY__
106/* 106/*
107 * Just any arbitrary offset to the start of the vmalloc VM area: the 107 * The vmalloc area will always be on the topmost area of the kernel
108 * current 8MB value just means that there will be a 8MB "hole" after the 108 * mapping. We reserve 96MB (31bit) / 1GB (64bit) for vmalloc,
109 * physical memory until the kernel virtual memory starts. That means that 109 * which should be enough for any sane case.
110 * any out-of-bounds memory accesses will hopefully be caught. 110 * By putting vmalloc at the top, we maximise the gap between physical
111 * The vmalloc() routines leaves a hole of 4kB between each vmalloced 111 * memory and vmalloc to catch misplaced memory accesses. As a side
112 * area for the same reason. ;) 112 * effect, this also makes sure that 64 bit module code cannot be used
113 * vmalloc area starts at 4GB to prevent syscall table entry exchanging 113 * as system call address.
114 * from modules.
115 */
116extern unsigned long vmalloc_end;
117
118#ifdef CONFIG_64BIT
119#define VMALLOC_ADDR (max(0x100000000UL, (unsigned long) high_memory))
120#else
121#define VMALLOC_ADDR ((unsigned long) high_memory)
122#endif
123#define VMALLOC_OFFSET (8*1024*1024)
124#define VMALLOC_START ((VMALLOC_ADDR + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1))
125#define VMALLOC_END vmalloc_end
126
127/*
128 * We need some free virtual space to be able to do vmalloc.
129 * VMALLOC_MIN_SIZE defines the minimum size of the vmalloc
130 * area. On a machine with 2GB memory we make sure that we
131 * have at least 128MB free space for vmalloc. On a machine
132 * with 4TB we make sure we have at least 128GB.
133 */ 114 */
134#ifndef __s390x__ 115#ifndef __s390x__
135#define VMALLOC_MIN_SIZE 0x8000000UL 116#define VMALLOC_START 0x78000000UL
136#define VMALLOC_END_INIT 0x80000000UL 117#define VMALLOC_END 0x7e000000UL
118#define VMEM_MAP_MAX 0x80000000UL
137#else /* __s390x__ */ 119#else /* __s390x__ */
138#define VMALLOC_MIN_SIZE 0x2000000000UL 120#define VMALLOC_START 0x3e000000000UL
139#define VMALLOC_END_INIT 0x40000000000UL 121#define VMALLOC_END 0x3e040000000UL
122#define VMEM_MAP_MAX 0x40000000000UL
140#endif /* __s390x__ */ 123#endif /* __s390x__ */
141 124
125#define VMEM_MAP ((struct page *) VMALLOC_END)
126#define VMEM_MAP_SIZE ((VMALLOC_START / PAGE_SIZE) * sizeof(struct page))
127
142/* 128/*
143 * A 31 bit pagetable entry of S390 has following format: 129 * A 31 bit pagetable entry of S390 has following format:
144 * | PFRA | | OS | 130 * | PFRA | | OS |
@@ -453,12 +439,12 @@ static inline int pgd_bad(pgd_t pgd) { return 0; }
453 439
454static inline int pud_present(pud_t pud) 440static inline int pud_present(pud_t pud)
455{ 441{
456 return pud_val(pud) & _REGION_ENTRY_ORIGIN; 442 return (pud_val(pud) & _REGION_ENTRY_ORIGIN) != 0UL;
457} 443}
458 444
459static inline int pud_none(pud_t pud) 445static inline int pud_none(pud_t pud)
460{ 446{
461 return pud_val(pud) & _REGION_ENTRY_INV; 447 return (pud_val(pud) & _REGION_ENTRY_INV) != 0UL;
462} 448}
463 449
464static inline int pud_bad(pud_t pud) 450static inline int pud_bad(pud_t pud)
@@ -471,12 +457,12 @@ static inline int pud_bad(pud_t pud)
471 457
472static inline int pmd_present(pmd_t pmd) 458static inline int pmd_present(pmd_t pmd)
473{ 459{
474 return pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN; 460 return (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN) != 0UL;
475} 461}
476 462
477static inline int pmd_none(pmd_t pmd) 463static inline int pmd_none(pmd_t pmd)
478{ 464{
479 return pmd_val(pmd) & _SEGMENT_ENTRY_INV; 465 return (pmd_val(pmd) & _SEGMENT_ENTRY_INV) != 0UL;
480} 466}
481 467
482static inline int pmd_bad(pmd_t pmd) 468static inline int pmd_bad(pmd_t pmd)
diff --git a/include/asm-s390/processor.h b/include/asm-s390/processor.h
index 21d40a19355e..c86b982aef5a 100644
--- a/include/asm-s390/processor.h
+++ b/include/asm-s390/processor.h
@@ -59,9 +59,6 @@ extern void s390_adjust_jiffies(void);
59extern void print_cpu_info(struct cpuinfo_S390 *); 59extern void print_cpu_info(struct cpuinfo_S390 *);
60extern int get_cpu_capability(unsigned int *); 60extern int get_cpu_capability(unsigned int *);
61 61
62/* Lazy FPU handling on uni-processor */
63extern struct task_struct *last_task_used_math;
64
65/* 62/*
66 * User space process size: 2GB for 31 bit, 4TB for 64 bit. 63 * User space process size: 2GB for 31 bit, 4TB for 64 bit.
67 */ 64 */
@@ -95,7 +92,6 @@ struct thread_struct {
95 unsigned long ksp; /* kernel stack pointer */ 92 unsigned long ksp; /* kernel stack pointer */
96 mm_segment_t mm_segment; 93 mm_segment_t mm_segment;
97 unsigned long prot_addr; /* address of protection-excep. */ 94 unsigned long prot_addr; /* address of protection-excep. */
98 unsigned int error_code; /* error-code of last prog-excep. */
99 unsigned int trap_no; 95 unsigned int trap_no;
100 per_struct per_info; 96 per_struct per_info;
101 /* Used to give failing instruction back to user for ieee exceptions */ 97 /* Used to give failing instruction back to user for ieee exceptions */
diff --git a/include/asm-s390/ptrace.h b/include/asm-s390/ptrace.h
index 332ee73688fc..61f6952f2e35 100644
--- a/include/asm-s390/ptrace.h
+++ b/include/asm-s390/ptrace.h
@@ -465,6 +465,14 @@ struct user_regs_struct
465#ifdef __KERNEL__ 465#ifdef __KERNEL__
466#define __ARCH_SYS_PTRACE 1 466#define __ARCH_SYS_PTRACE 1
467 467
468/*
469 * These are defined as per linux/ptrace.h, which see.
470 */
471#define arch_has_single_step() (1)
472struct task_struct;
473extern void user_enable_single_step(struct task_struct *);
474extern void user_disable_single_step(struct task_struct *);
475
468#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) 476#define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
469#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN) 477#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
470#define regs_return_value(regs)((regs)->gprs[2]) 478#define regs_return_value(regs)((regs)->gprs[2])
diff --git a/include/asm-s390/qdio.h b/include/asm-s390/qdio.h
index 74db1dc10a7d..4b8ff55f680e 100644
--- a/include/asm-s390/qdio.h
+++ b/include/asm-s390/qdio.h
@@ -184,7 +184,7 @@ struct qdr {
184#endif /* QDIO_32_BIT */ 184#endif /* QDIO_32_BIT */
185 unsigned long qiba; /* queue-information-block address */ 185 unsigned long qiba; /* queue-information-block address */
186 unsigned int res8; /* reserved */ 186 unsigned int res8; /* reserved */
187 unsigned int qkey : 4; /* queue-informatio-block key */ 187 unsigned int qkey : 4; /* queue-information-block key */
188 unsigned int res9 : 28; /* reserved */ 188 unsigned int res9 : 28; /* reserved */
189/* union _qd {*/ /* why this? */ 189/* union _qd {*/ /* why this? */
190 struct qdesfmt0 qdf0[126]; 190 struct qdesfmt0 qdf0[126];
diff --git a/include/asm-s390/rwsem.h b/include/asm-s390/rwsem.h
index 90f4eccaa290..9d2a17971805 100644
--- a/include/asm-s390/rwsem.h
+++ b/include/asm-s390/rwsem.h
@@ -91,8 +91,8 @@ struct rw_semaphore {
91#endif 91#endif
92 92
93#define __RWSEM_INITIALIZER(name) \ 93#define __RWSEM_INITIALIZER(name) \
94{ RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, LIST_HEAD_INIT((name).wait_list) \ 94 { RWSEM_UNLOCKED_VALUE, __SPIN_LOCK_UNLOCKED((name).wait.lock), \
95 __RWSEM_DEP_MAP_INIT(name) } 95 LIST_HEAD_INIT((name).wait_list) __RWSEM_DEP_MAP_INIT(name) }
96 96
97#define DECLARE_RWSEM(name) \ 97#define DECLARE_RWSEM(name) \
98 struct rw_semaphore name = __RWSEM_INITIALIZER(name) 98 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
diff --git a/include/asm-s390/sclp.h b/include/asm-s390/sclp.h
index cb9faf1ea5cf..b5f2843013a3 100644
--- a/include/asm-s390/sclp.h
+++ b/include/asm-s390/sclp.h
@@ -27,7 +27,25 @@ struct sclp_ipl_info {
27 char loadparm[LOADPARM_LEN]; 27 char loadparm[LOADPARM_LEN];
28}; 28};
29 29
30void sclp_readinfo_early(void); 30struct sclp_cpu_entry {
31 u8 address;
32 u8 reserved0[13];
33 u8 type;
34 u8 reserved1;
35} __attribute__((packed));
36
37struct sclp_cpu_info {
38 unsigned int configured;
39 unsigned int standby;
40 unsigned int combined;
41 int has_cpu_type;
42 struct sclp_cpu_entry cpu[255];
43};
44
45int sclp_get_cpu_info(struct sclp_cpu_info *info);
46int sclp_cpu_configure(u8 cpu);
47int sclp_cpu_deconfigure(u8 cpu);
48void sclp_read_info_early(void);
31void sclp_facilities_detect(void); 49void sclp_facilities_detect(void);
32unsigned long long sclp_memory_detect(void); 50unsigned long long sclp_memory_detect(void);
33int sclp_sdias_blk_count(void); 51int sclp_sdias_blk_count(void);
diff --git a/include/asm-s390/smp.h b/include/asm-s390/smp.h
index 07708c07701e..c7b74326a527 100644
--- a/include/asm-s390/smp.h
+++ b/include/asm-s390/smp.h
@@ -35,8 +35,6 @@ extern void machine_restart_smp(char *);
35extern void machine_halt_smp(void); 35extern void machine_halt_smp(void);
36extern void machine_power_off_smp(void); 36extern void machine_power_off_smp(void);
37 37
38extern void smp_setup_cpu_possible_map(void);
39
40#define NO_PROC_ID 0xFF /* No processor magic marker */ 38#define NO_PROC_ID 0xFF /* No processor magic marker */
41 39
42/* 40/*
@@ -92,6 +90,8 @@ extern void __cpu_die (unsigned int cpu);
92extern void cpu_die (void) __attribute__ ((noreturn)); 90extern void cpu_die (void) __attribute__ ((noreturn));
93extern int __cpu_up (unsigned int cpu); 91extern int __cpu_up (unsigned int cpu);
94 92
93extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
94 void *info, int wait);
95#endif 95#endif
96 96
97#ifndef CONFIG_SMP 97#ifndef CONFIG_SMP
@@ -103,7 +103,6 @@ static inline void smp_send_stop(void)
103 103
104#define hard_smp_processor_id() 0 104#define hard_smp_processor_id() 0
105#define smp_cpu_not_running(cpu) 1 105#define smp_cpu_not_running(cpu) 1
106#define smp_setup_cpu_possible_map() do { } while (0)
107#endif 106#endif
108 107
109extern union save_area *zfcpdump_save_areas[NR_CPUS + 1]; 108extern union save_area *zfcpdump_save_areas[NR_CPUS + 1];
diff --git a/include/asm-s390/socket.h b/include/asm-s390/socket.h
index 1161ebe3dec9..c786ab623b2d 100644
--- a/include/asm-s390/socket.h
+++ b/include/asm-s390/socket.h
@@ -60,4 +60,6 @@
60#define SO_TIMESTAMPNS 35 60#define SO_TIMESTAMPNS 35
61#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 61#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
62 62
63#define SO_MARK 36
64
63#endif /* _ASM_SOCKET_H */ 65#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-s390/spinlock.h b/include/asm-s390/spinlock.h
index 3fd43826fd0b..df84ae96915f 100644
--- a/include/asm-s390/spinlock.h
+++ b/include/asm-s390/spinlock.h
@@ -53,44 +53,48 @@ _raw_compare_and_swap(volatile unsigned int *lock,
53 */ 53 */
54 54
55#define __raw_spin_is_locked(x) ((x)->owner_cpu != 0) 55#define __raw_spin_is_locked(x) ((x)->owner_cpu != 0)
56#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
57#define __raw_spin_unlock_wait(lock) \ 56#define __raw_spin_unlock_wait(lock) \
58 do { while (__raw_spin_is_locked(lock)) \ 57 do { while (__raw_spin_is_locked(lock)) \
59 _raw_spin_relax(lock); } while (0) 58 _raw_spin_relax(lock); } while (0)
60 59
61extern void _raw_spin_lock_wait(raw_spinlock_t *, unsigned int pc); 60extern void _raw_spin_lock_wait(raw_spinlock_t *);
62extern int _raw_spin_trylock_retry(raw_spinlock_t *, unsigned int pc); 61extern void _raw_spin_lock_wait_flags(raw_spinlock_t *, unsigned long flags);
62extern int _raw_spin_trylock_retry(raw_spinlock_t *);
63extern void _raw_spin_relax(raw_spinlock_t *lock); 63extern void _raw_spin_relax(raw_spinlock_t *lock);
64 64
65static inline void __raw_spin_lock(raw_spinlock_t *lp) 65static inline void __raw_spin_lock(raw_spinlock_t *lp)
66{ 66{
67 unsigned long pc = 1 | (unsigned long) __builtin_return_address(0);
68 int old; 67 int old;
69 68
70 old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id()); 69 old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
71 if (likely(old == 0)) { 70 if (likely(old == 0))
72 lp->owner_pc = pc;
73 return; 71 return;
74 } 72 _raw_spin_lock_wait(lp);
75 _raw_spin_lock_wait(lp, pc); 73}
74
75static inline void __raw_spin_lock_flags(raw_spinlock_t *lp,
76 unsigned long flags)
77{
78 int old;
79
80 old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
81 if (likely(old == 0))
82 return;
83 _raw_spin_lock_wait_flags(lp, flags);
76} 84}
77 85
78static inline int __raw_spin_trylock(raw_spinlock_t *lp) 86static inline int __raw_spin_trylock(raw_spinlock_t *lp)
79{ 87{
80 unsigned long pc = 1 | (unsigned long) __builtin_return_address(0);
81 int old; 88 int old;
82 89
83 old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id()); 90 old = _raw_compare_and_swap(&lp->owner_cpu, 0, ~smp_processor_id());
84 if (likely(old == 0)) { 91 if (likely(old == 0))
85 lp->owner_pc = pc;
86 return 1; 92 return 1;
87 } 93 return _raw_spin_trylock_retry(lp);
88 return _raw_spin_trylock_retry(lp, pc);
89} 94}
90 95
91static inline void __raw_spin_unlock(raw_spinlock_t *lp) 96static inline void __raw_spin_unlock(raw_spinlock_t *lp)
92{ 97{
93 lp->owner_pc = 0;
94 _raw_compare_and_swap(&lp->owner_cpu, lp->owner_cpu, 0); 98 _raw_compare_and_swap(&lp->owner_cpu, lp->owner_cpu, 0);
95} 99}
96 100
diff --git a/include/asm-s390/spinlock_types.h b/include/asm-s390/spinlock_types.h
index b7ac13f7aa37..654abc40de04 100644
--- a/include/asm-s390/spinlock_types.h
+++ b/include/asm-s390/spinlock_types.h
@@ -7,7 +7,6 @@
7 7
8typedef struct { 8typedef struct {
9 volatile unsigned int owner_cpu; 9 volatile unsigned int owner_cpu;
10 volatile unsigned int owner_pc;
11} __attribute__ ((aligned (4))) raw_spinlock_t; 10} __attribute__ ((aligned (4))) raw_spinlock_t;
12 11
13#define __RAW_SPIN_LOCK_UNLOCKED { 0 } 12#define __RAW_SPIN_LOCK_UNLOCKED { 0 }
diff --git a/include/asm-s390/system.h b/include/asm-s390/system.h
index d866d3385556..44bda786eef7 100644
--- a/include/asm-s390/system.h
+++ b/include/asm-s390/system.h
@@ -388,6 +388,11 @@ extern void (*_machine_power_off)(void);
388 388
389#define arch_align_stack(x) (x) 389#define arch_align_stack(x) (x)
390 390
391#ifdef CONFIG_TRACE_IRQFLAGS
392extern psw_t sysc_restore_trace_psw;
393extern psw_t io_restore_trace_psw;
394#endif
395
391#endif /* __KERNEL__ */ 396#endif /* __KERNEL__ */
392 397
393#endif 398#endif
diff --git a/include/asm-s390/tlbflush.h b/include/asm-s390/tlbflush.h
index a69bd2490d52..70fa5ae58180 100644
--- a/include/asm-s390/tlbflush.h
+++ b/include/asm-s390/tlbflush.h
@@ -42,11 +42,11 @@ static inline void __tlb_flush_global(void)
42/* 42/*
43 * Flush all tlb entries of a page table on all cpus. 43 * Flush all tlb entries of a page table on all cpus.
44 */ 44 */
45static inline void __tlb_flush_idte(pgd_t *pgd) 45static inline void __tlb_flush_idte(unsigned long asce)
46{ 46{
47 asm volatile( 47 asm volatile(
48 " .insn rrf,0xb98e0000,0,%0,%1,0" 48 " .insn rrf,0xb98e0000,0,%0,%1,0"
49 : : "a" (2048), "a" (__pa(pgd) & PAGE_MASK) : "cc" ); 49 : : "a" (2048), "a" (asce) : "cc" );
50} 50}
51 51
52static inline void __tlb_flush_mm(struct mm_struct * mm) 52static inline void __tlb_flush_mm(struct mm_struct * mm)
@@ -61,11 +61,11 @@ static inline void __tlb_flush_mm(struct mm_struct * mm)
61 * only ran on the local cpu. 61 * only ran on the local cpu.
62 */ 62 */
63 if (MACHINE_HAS_IDTE) { 63 if (MACHINE_HAS_IDTE) {
64 pgd_t *shadow_pgd = get_shadow_table(mm->pgd); 64 pgd_t *shadow = get_shadow_table(mm->pgd);
65 65
66 if (shadow_pgd) 66 if (shadow)
67 __tlb_flush_idte(shadow_pgd); 67 __tlb_flush_idte((unsigned long) shadow | mm->context);
68 __tlb_flush_idte(mm->pgd); 68 __tlb_flush_idte((unsigned long) mm->pgd | mm->context);
69 return; 69 return;
70 } 70 }
71 preempt_disable(); 71 preempt_disable();
@@ -106,9 +106,23 @@ static inline void __tlb_flush_mm_cond(struct mm_struct * mm)
106 */ 106 */
107#define flush_tlb() do { } while (0) 107#define flush_tlb() do { } while (0)
108#define flush_tlb_all() do { } while (0) 108#define flush_tlb_all() do { } while (0)
109#define flush_tlb_mm(mm) __tlb_flush_mm_cond(mm)
110#define flush_tlb_page(vma, addr) do { } while (0) 109#define flush_tlb_page(vma, addr) do { } while (0)
111#define flush_tlb_range(vma, start, end) __tlb_flush_mm_cond(mm) 110
112#define flush_tlb_kernel_range(start, end) __tlb_flush_mm(&init_mm) 111static inline void flush_tlb_mm(struct mm_struct *mm)
112{
113 __tlb_flush_mm_cond(mm);
114}
115
116static inline void flush_tlb_range(struct vm_area_struct *vma,
117 unsigned long start, unsigned long end)
118{
119 __tlb_flush_mm_cond(vma->vm_mm);
120}
121
122static inline void flush_tlb_kernel_range(unsigned long start,
123 unsigned long end)
124{
125 __tlb_flush_mm(&init_mm);
126}
113 127
114#endif /* _S390_TLBFLUSH_H */ 128#endif /* _S390_TLBFLUSH_H */
diff --git a/include/asm-s390/zcrypt.h b/include/asm-s390/zcrypt.h
index a5dada617751..f228f1b86877 100644
--- a/include/asm-s390/zcrypt.h
+++ b/include/asm-s390/zcrypt.h
@@ -117,7 +117,7 @@ struct CPRBX {
117 unsigned char padx004[16 - sizeof (char *)]; 117 unsigned char padx004[16 - sizeof (char *)];
118 unsigned char * req_extb; /* request extension block 'addr'*/ 118 unsigned char * req_extb; /* request extension block 'addr'*/
119 unsigned char padx005[16 - sizeof (char *)]; 119 unsigned char padx005[16 - sizeof (char *)];
120 unsigned char * rpl_extb; /* reply extension block 'addres'*/ 120 unsigned char * rpl_extb; /* reply extension block 'address'*/
121 unsigned short ccp_rtcode; /* server return code */ 121 unsigned short ccp_rtcode; /* server return code */
122 unsigned short ccp_rscode; /* server reason code */ 122 unsigned short ccp_rscode; /* server reason code */
123 unsigned int mac_data_len; /* Mac Data Length */ 123 unsigned int mac_data_len; /* Mac Data Length */
diff --git a/include/asm-sh/Kbuild b/include/asm-sh/Kbuild
index 76a8ccf254a5..43910cdf78a5 100644
--- a/include/asm-sh/Kbuild
+++ b/include/asm-sh/Kbuild
@@ -1,3 +1,8 @@
1include include/asm-generic/Kbuild.asm 1include include/asm-generic/Kbuild.asm
2 2
3header-y += cpu-features.h 3header-y += cpu-features.h
4
5unifdef-y += unistd_32.h
6unifdef-y += unistd_64.h
7unifdef-y += posix_types_32.h
8unifdef-y += posix_types_64.h
diff --git a/include/asm-sh/addrspace.h b/include/asm-sh/addrspace.h
index b860218e402e..fa544fc38c23 100644
--- a/include/asm-sh/addrspace.h
+++ b/include/asm-sh/addrspace.h
@@ -9,24 +9,21 @@
9 */ 9 */
10#ifndef __ASM_SH_ADDRSPACE_H 10#ifndef __ASM_SH_ADDRSPACE_H
11#define __ASM_SH_ADDRSPACE_H 11#define __ASM_SH_ADDRSPACE_H
12
12#ifdef __KERNEL__ 13#ifdef __KERNEL__
13 14
14#include <asm/cpu/addrspace.h> 15#include <asm/cpu/addrspace.h>
15 16
16/* Memory segments (32bit Privileged mode addresses) */ 17/* If this CPU supports segmentation, hook up the helpers */
17#ifndef CONFIG_CPU_SH2A 18#ifdef P1SEG
18#define P0SEG 0x00000000 19
19#define P1SEG 0x80000000 20/*
20#define P2SEG 0xa0000000 21 [ P0/U0 (virtual) ] 0x00000000 <------ User space
21#define P3SEG 0xc0000000 22 [ P1 (fixed) cached ] 0x80000000 <------ Kernel space
22#define P4SEG 0xe0000000 23 [ P2 (fixed) non-cachable] 0xA0000000 <------ Physical access
23#else 24 [ P3 (virtual) cached] 0xC0000000 <------ vmalloced area
24#define P0SEG 0x00000000 25 [ P4 control ] 0xE0000000
25#define P1SEG 0x00000000 26 */
26#define P2SEG 0x20000000
27#define P3SEG 0x00000000
28#define P4SEG 0x80000000
29#endif
30 27
31/* Returns the privileged segment base of a given address */ 28/* Returns the privileged segment base of a given address */
32#define PXSEG(a) (((unsigned long)(a)) & 0xe0000000) 29#define PXSEG(a) (((unsigned long)(a)) & 0xe0000000)
@@ -34,13 +31,23 @@
34/* Returns the physical address of a PnSEG (n=1,2) address */ 31/* Returns the physical address of a PnSEG (n=1,2) address */
35#define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff) 32#define PHYSADDR(a) (((unsigned long)(a)) & 0x1fffffff)
36 33
34#ifdef CONFIG_29BIT
37/* 35/*
38 * Map an address to a certain privileged segment 36 * Map an address to a certain privileged segment
39 */ 37 */
40#define P1SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P1SEG)) 38#define P1SEGADDR(a) \
41#define P2SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P2SEG)) 39 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P1SEG))
42#define P3SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG)) 40#define P2SEGADDR(a) \
43#define P4SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG)) 41 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P2SEG))
42#define P3SEGADDR(a) \
43 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG))
44#define P4SEGADDR(a) \
45 ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG))
46#endif /* 29BIT */
47#endif /* P1SEG */
48
49/* Check if an address can be reached in 29 bits */
50#define IS_29BIT(a) (((unsigned long)(a)) < 0x20000000)
44 51
45#endif /* __KERNEL__ */ 52#endif /* __KERNEL__ */
46#endif /* __ASM_SH_ADDRSPACE_H */ 53#endif /* __ASM_SH_ADDRSPACE_H */
diff --git a/include/asm-sh/atomic-grb.h b/include/asm-sh/atomic-grb.h
new file mode 100644
index 000000000000..4c5b7dbfcedb
--- /dev/null
+++ b/include/asm-sh/atomic-grb.h
@@ -0,0 +1,169 @@
1#ifndef __ASM_SH_ATOMIC_GRB_H
2#define __ASM_SH_ATOMIC_GRB_H
3
4static inline void atomic_add(int i, atomic_t *v)
5{
6 int tmp;
7
8 __asm__ __volatile__ (
9 " .align 2 \n\t"
10 " mova 1f, r0 \n\t" /* r0 = end point */
11 " mov r15, r1 \n\t" /* r1 = saved sp */
12 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
13 " mov.l @%1, %0 \n\t" /* load old value */
14 " add %2, %0 \n\t" /* add */
15 " mov.l %0, @%1 \n\t" /* store new value */
16 "1: mov r1, r15 \n\t" /* LOGOUT */
17 : "=&r" (tmp),
18 "+r" (v)
19 : "r" (i)
20 : "memory" , "r0", "r1");
21}
22
23static inline void atomic_sub(int i, atomic_t *v)
24{
25 int tmp;
26
27 __asm__ __volatile__ (
28 " .align 2 \n\t"
29 " mova 1f, r0 \n\t" /* r0 = end point */
30 " mov r15, r1 \n\t" /* r1 = saved sp */
31 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
32 " mov.l @%1, %0 \n\t" /* load old value */
33 " sub %2, %0 \n\t" /* sub */
34 " mov.l %0, @%1 \n\t" /* store new value */
35 "1: mov r1, r15 \n\t" /* LOGOUT */
36 : "=&r" (tmp),
37 "+r" (v)
38 : "r" (i)
39 : "memory" , "r0", "r1");
40}
41
42static inline int atomic_add_return(int i, atomic_t *v)
43{
44 int tmp;
45
46 __asm__ __volatile__ (
47 " .align 2 \n\t"
48 " mova 1f, r0 \n\t" /* r0 = end point */
49 " mov r15, r1 \n\t" /* r1 = saved sp */
50 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
51 " mov.l @%1, %0 \n\t" /* load old value */
52 " add %2, %0 \n\t" /* add */
53 " mov.l %0, @%1 \n\t" /* store new value */
54 "1: mov r1, r15 \n\t" /* LOGOUT */
55 : "=&r" (tmp),
56 "+r" (v)
57 : "r" (i)
58 : "memory" , "r0", "r1");
59
60 return tmp;
61}
62
63static inline int atomic_sub_return(int i, atomic_t *v)
64{
65 int tmp;
66
67 __asm__ __volatile__ (
68 " .align 2 \n\t"
69 " mova 1f, r0 \n\t" /* r0 = end point */
70 " mov r15, r1 \n\t" /* r1 = saved sp */
71 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
72 " mov.l @%1, %0 \n\t" /* load old value */
73 " sub %2, %0 \n\t" /* sub */
74 " mov.l %0, @%1 \n\t" /* store new value */
75 "1: mov r1, r15 \n\t" /* LOGOUT */
76 : "=&r" (tmp),
77 "+r" (v)
78 : "r" (i)
79 : "memory", "r0", "r1");
80
81 return tmp;
82}
83
84static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
85{
86 int tmp;
87 unsigned int _mask = ~mask;
88
89 __asm__ __volatile__ (
90 " .align 2 \n\t"
91 " mova 1f, r0 \n\t" /* r0 = end point */
92 " mov r15, r1 \n\t" /* r1 = saved sp */
93 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
94 " mov.l @%1, %0 \n\t" /* load old value */
95 " and %2, %0 \n\t" /* add */
96 " mov.l %0, @%1 \n\t" /* store new value */
97 "1: mov r1, r15 \n\t" /* LOGOUT */
98 : "=&r" (tmp),
99 "+r" (v)
100 : "r" (_mask)
101 : "memory" , "r0", "r1");
102}
103
104static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
105{
106 int tmp;
107
108 __asm__ __volatile__ (
109 " .align 2 \n\t"
110 " mova 1f, r0 \n\t" /* r0 = end point */
111 " mov r15, r1 \n\t" /* r1 = saved sp */
112 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
113 " mov.l @%1, %0 \n\t" /* load old value */
114 " or %2, %0 \n\t" /* or */
115 " mov.l %0, @%1 \n\t" /* store new value */
116 "1: mov r1, r15 \n\t" /* LOGOUT */
117 : "=&r" (tmp),
118 "+r" (v)
119 : "r" (mask)
120 : "memory" , "r0", "r1");
121}
122
123static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
124{
125 int ret;
126
127 __asm__ __volatile__ (
128 " .align 2 \n\t"
129 " mova 1f, r0 \n\t"
130 " nop \n\t"
131 " mov r15, r1 \n\t"
132 " mov #-8, r15 \n\t"
133 " mov.l @%1, %0 \n\t"
134 " cmp/eq %2, %0 \n\t"
135 " bf 1f \n\t"
136 " mov.l %3, @%1 \n\t"
137 "1: mov r1, r15 \n\t"
138 : "=&r" (ret)
139 : "r" (v), "r" (old), "r" (new)
140 : "memory" , "r0", "r1" , "t");
141
142 return ret;
143}
144
145static inline int atomic_add_unless(atomic_t *v, int a, int u)
146{
147 int ret;
148 unsigned long tmp;
149
150 __asm__ __volatile__ (
151 " .align 2 \n\t"
152 " mova 1f, r0 \n\t"
153 " nop \n\t"
154 " mov r15, r1 \n\t"
155 " mov #-12, r15 \n\t"
156 " mov.l @%2, %1 \n\t"
157 " mov %1, %0 \n\t"
158 " cmp/eq %4, %0 \n\t"
159 " bt/s 1f \n\t"
160 " add %3, %1 \n\t"
161 " mov.l %1, @%2 \n\t"
162 "1: mov r1, r15 \n\t"
163 : "=&r" (ret), "=&r" (tmp)
164 : "r" (v), "r" (a), "r" (u)
165 : "memory" , "r0", "r1" , "t");
166
167 return ret != u;
168}
169#endif /* __ASM_SH_ATOMIC_GRB_H */
diff --git a/include/asm-sh/atomic.h b/include/asm-sh/atomic.h
index e12570b9339d..c043ef003028 100644
--- a/include/asm-sh/atomic.h
+++ b/include/asm-sh/atomic.h
@@ -17,7 +17,9 @@ typedef struct { volatile int counter; } atomic_t;
17#include <linux/compiler.h> 17#include <linux/compiler.h>
18#include <asm/system.h> 18#include <asm/system.h>
19 19
20#ifdef CONFIG_CPU_SH4A 20#if defined(CONFIG_GUSA_RB)
21#include <asm/atomic-grb.h>
22#elif defined(CONFIG_CPU_SH4A)
21#include <asm/atomic-llsc.h> 23#include <asm/atomic-llsc.h>
22#else 24#else
23#include <asm/atomic-irq.h> 25#include <asm/atomic-irq.h>
@@ -44,6 +46,7 @@ typedef struct { volatile int counter; } atomic_t;
44#define atomic_inc(v) atomic_add(1,(v)) 46#define atomic_inc(v) atomic_add(1,(v))
45#define atomic_dec(v) atomic_sub(1,(v)) 47#define atomic_dec(v) atomic_sub(1,(v))
46 48
49#ifndef CONFIG_GUSA_RB
47static inline int atomic_cmpxchg(atomic_t *v, int old, int new) 50static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
48{ 51{
49 int ret; 52 int ret;
@@ -58,8 +61,6 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
58 return ret; 61 return ret;
59} 62}
60 63
61#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
62
63static inline int atomic_add_unless(atomic_t *v, int a, int u) 64static inline int atomic_add_unless(atomic_t *v, int a, int u)
64{ 65{
65 int ret; 66 int ret;
@@ -73,6 +74,9 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
73 74
74 return ret != u; 75 return ret != u;
75} 76}
77#endif
78
79#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
76#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0) 80#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
77 81
78/* Atomic operations are already serializing on SH */ 82/* Atomic operations are already serializing on SH */
diff --git a/include/asm-sh/auxvec.h b/include/asm-sh/auxvec.h
index 1b6916e63e90..a6b9d4f4859e 100644
--- a/include/asm-sh/auxvec.h
+++ b/include/asm-sh/auxvec.h
@@ -6,6 +6,12 @@
6 * for more of them. 6 * for more of them.
7 */ 7 */
8 8
9/*
10 * This entry gives some information about the FPU initialization
11 * performed by the kernel.
12 */
13#define AT_FPUCW 18 /* Used FPU control word. */
14
9#ifdef CONFIG_VSYSCALL 15#ifdef CONFIG_VSYSCALL
10/* 16/*
11 * Only define this in the vsyscall case, the entry point to 17 * Only define this in the vsyscall case, the entry point to
@@ -15,4 +21,16 @@
15#define AT_SYSINFO_EHDR 33 21#define AT_SYSINFO_EHDR 33
16#endif 22#endif
17 23
24/*
25 * More complete cache descriptions than AT_[DIU]CACHEBSIZE. If the
26 * value is -1, then the cache doesn't exist. Otherwise:
27 *
28 * bit 0-3: Cache set-associativity; 0 means fully associative.
29 * bit 4-7: Log2 of cacheline size.
30 * bit 8-31: Size of the entire cache >> 8.
31 */
32#define AT_L1I_CACHESHAPE 34
33#define AT_L1D_CACHESHAPE 35
34#define AT_L2_CACHESHAPE 36
35
18#endif /* __ASM_SH_AUXVEC_H */ 36#endif /* __ASM_SH_AUXVEC_H */
diff --git a/include/asm-sh/bitops-grb.h b/include/asm-sh/bitops-grb.h
new file mode 100644
index 000000000000..a5907b94395b
--- /dev/null
+++ b/include/asm-sh/bitops-grb.h
@@ -0,0 +1,169 @@
1#ifndef __ASM_SH_BITOPS_GRB_H
2#define __ASM_SH_BITOPS_GRB_H
3
4static inline void set_bit(int nr, volatile void * addr)
5{
6 int mask;
7 volatile unsigned int *a = addr;
8 unsigned long tmp;
9
10 a += nr >> 5;
11 mask = 1 << (nr & 0x1f);
12
13 __asm__ __volatile__ (
14 " .align 2 \n\t"
15 " mova 1f, r0 \n\t" /* r0 = end point */
16 " mov r15, r1 \n\t" /* r1 = saved sp */
17 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
18 " mov.l @%1, %0 \n\t" /* load old value */
19 " or %2, %0 \n\t" /* or */
20 " mov.l %0, @%1 \n\t" /* store new value */
21 "1: mov r1, r15 \n\t" /* LOGOUT */
22 : "=&r" (tmp),
23 "+r" (a)
24 : "r" (mask)
25 : "memory" , "r0", "r1");
26}
27
28static inline void clear_bit(int nr, volatile void * addr)
29{
30 int mask;
31 volatile unsigned int *a = addr;
32 unsigned long tmp;
33
34 a += nr >> 5;
35 mask = ~(1 << (nr & 0x1f));
36 __asm__ __volatile__ (
37 " .align 2 \n\t"
38 " mova 1f, r0 \n\t" /* r0 = end point */
39 " mov r15, r1 \n\t" /* r1 = saved sp */
40 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
41 " mov.l @%1, %0 \n\t" /* load old value */
42 " and %2, %0 \n\t" /* and */
43 " mov.l %0, @%1 \n\t" /* store new value */
44 "1: mov r1, r15 \n\t" /* LOGOUT */
45 : "=&r" (tmp),
46 "+r" (a)
47 : "r" (mask)
48 : "memory" , "r0", "r1");
49}
50
51static inline void change_bit(int nr, volatile void * addr)
52{
53 int mask;
54 volatile unsigned int *a = addr;
55 unsigned long tmp;
56
57 a += nr >> 5;
58 mask = 1 << (nr & 0x1f);
59 __asm__ __volatile__ (
60 " .align 2 \n\t"
61 " mova 1f, r0 \n\t" /* r0 = end point */
62 " mov r15, r1 \n\t" /* r1 = saved sp */
63 " mov #-6, r15 \n\t" /* LOGIN: r15 = size */
64 " mov.l @%1, %0 \n\t" /* load old value */
65 " xor %2, %0 \n\t" /* xor */
66 " mov.l %0, @%1 \n\t" /* store new value */
67 "1: mov r1, r15 \n\t" /* LOGOUT */
68 : "=&r" (tmp),
69 "+r" (a)
70 : "r" (mask)
71 : "memory" , "r0", "r1");
72}
73
74static inline int test_and_set_bit(int nr, volatile void * addr)
75{
76 int mask, retval;
77 volatile unsigned int *a = addr;
78 unsigned long tmp;
79
80 a += nr >> 5;
81 mask = 1 << (nr & 0x1f);
82
83 __asm__ __volatile__ (
84 " .align 2 \n\t"
85 " mova 1f, r0 \n\t" /* r0 = end point */
86 " mov r15, r1 \n\t" /* r1 = saved sp */
87 " mov #-14, r15 \n\t" /* LOGIN: r15 = size */
88 " mov.l @%2, %0 \n\t" /* load old value */
89 " mov %0, %1 \n\t"
90 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
91 " mov #-1, %1 \n\t" /* retvat = -1 */
92 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
93 " or %3, %0 \n\t"
94 " mov.l %0, @%2 \n\t" /* store new value */
95 "1: mov r1, r15 \n\t" /* LOGOUT */
96 : "=&r" (tmp),
97 "=&r" (retval),
98 "+r" (a)
99 : "r" (mask)
100 : "memory" , "r0", "r1" ,"t");
101
102 return retval;
103}
104
105static inline int test_and_clear_bit(int nr, volatile void * addr)
106{
107 int mask, retval,not_mask;
108 volatile unsigned int *a = addr;
109 unsigned long tmp;
110
111 a += nr >> 5;
112 mask = 1 << (nr & 0x1f);
113
114 not_mask = ~mask;
115
116 __asm__ __volatile__ (
117 " .align 2 \n\t"
118 " mova 1f, r0 \n\t" /* r0 = end point */
119 " mov r15, r1 \n\t" /* r1 = saved sp */
120 " mov #-14, r15 \n\t" /* LOGIN */
121 " mov.l @%2, %0 \n\t" /* load old value */
122 " mov %0, %1 \n\t" /* %1 = *a */
123 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
124 " mov #-1, %1 \n\t" /* retvat = -1 */
125 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
126 " and %4, %0 \n\t"
127 " mov.l %0, @%2 \n\t" /* store new value */
128 "1: mov r1, r15 \n\t" /* LOGOUT */
129 : "=&r" (tmp),
130 "=&r" (retval),
131 "+r" (a)
132 : "r" (mask),
133 "r" (not_mask)
134 : "memory" , "r0", "r1", "t");
135
136 return retval;
137}
138
139static inline int test_and_change_bit(int nr, volatile void * addr)
140{
141 int mask, retval;
142 volatile unsigned int *a = addr;
143 unsigned long tmp;
144
145 a += nr >> 5;
146 mask = 1 << (nr & 0x1f);
147
148 __asm__ __volatile__ (
149 " .align 2 \n\t"
150 " mova 1f, r0 \n\t" /* r0 = end point */
151 " mov r15, r1 \n\t" /* r1 = saved sp */
152 " mov #-14, r15 \n\t" /* LOGIN */
153 " mov.l @%2, %0 \n\t" /* load old value */
154 " mov %0, %1 \n\t" /* %1 = *a */
155 " tst %1, %3 \n\t" /* T = ((*a & mask) == 0) */
156 " mov #-1, %1 \n\t" /* retvat = -1 */
157 " negc %1, %1 \n\t" /* retval = (mask & *a) != 0 */
158 " xor %3, %0 \n\t"
159 " mov.l %0, @%2 \n\t" /* store new value */
160 "1: mov r1, r15 \n\t" /* LOGOUT */
161 : "=&r" (tmp),
162 "=&r" (retval),
163 "+r" (a)
164 : "r" (mask)
165 : "memory" , "r0", "r1", "t");
166
167 return retval;
168}
169#endif /* __ASM_SH_BITOPS_GRB_H */
diff --git a/include/asm-sh/bitops-irq.h b/include/asm-sh/bitops-irq.h
new file mode 100644
index 000000000000..653a12750584
--- /dev/null
+++ b/include/asm-sh/bitops-irq.h
@@ -0,0 +1,91 @@
1#ifndef __ASM_SH_BITOPS_IRQ_H
2#define __ASM_SH_BITOPS_IRQ_H
3
4static inline void set_bit(int nr, volatile void *addr)
5{
6 int mask;
7 volatile unsigned int *a = addr;
8 unsigned long flags;
9
10 a += nr >> 5;
11 mask = 1 << (nr & 0x1f);
12 local_irq_save(flags);
13 *a |= mask;
14 local_irq_restore(flags);
15}
16
17static inline void clear_bit(int nr, volatile void *addr)
18{
19 int mask;
20 volatile unsigned int *a = addr;
21 unsigned long flags;
22
23 a += nr >> 5;
24 mask = 1 << (nr & 0x1f);
25 local_irq_save(flags);
26 *a &= ~mask;
27 local_irq_restore(flags);
28}
29
30static inline void change_bit(int nr, volatile void *addr)
31{
32 int mask;
33 volatile unsigned int *a = addr;
34 unsigned long flags;
35
36 a += nr >> 5;
37 mask = 1 << (nr & 0x1f);
38 local_irq_save(flags);
39 *a ^= mask;
40 local_irq_restore(flags);
41}
42
43static inline int test_and_set_bit(int nr, volatile void *addr)
44{
45 int mask, retval;
46 volatile unsigned int *a = addr;
47 unsigned long flags;
48
49 a += nr >> 5;
50 mask = 1 << (nr & 0x1f);
51 local_irq_save(flags);
52 retval = (mask & *a) != 0;
53 *a |= mask;
54 local_irq_restore(flags);
55
56 return retval;
57}
58
59static inline int test_and_clear_bit(int nr, volatile void *addr)
60{
61 int mask, retval;
62 volatile unsigned int *a = addr;
63 unsigned long flags;
64
65 a += nr >> 5;
66 mask = 1 << (nr & 0x1f);
67 local_irq_save(flags);
68 retval = (mask & *a) != 0;
69 *a &= ~mask;
70 local_irq_restore(flags);
71
72 return retval;
73}
74
75static inline int test_and_change_bit(int nr, volatile void *addr)
76{
77 int mask, retval;
78 volatile unsigned int *a = addr;
79 unsigned long flags;
80
81 a += nr >> 5;
82 mask = 1 << (nr & 0x1f);
83 local_irq_save(flags);
84 retval = (mask & *a) != 0;
85 *a ^= mask;
86 local_irq_restore(flags);
87
88 return retval;
89}
90
91#endif /* __ASM_SH_BITOPS_IRQ_H */
diff --git a/include/asm-sh/bitops.h b/include/asm-sh/bitops.h
index df805f20b267..b6ba5a60dec2 100644
--- a/include/asm-sh/bitops.h
+++ b/include/asm-sh/bitops.h
@@ -11,100 +11,22 @@
11/* For __swab32 */ 11/* For __swab32 */
12#include <asm/byteorder.h> 12#include <asm/byteorder.h>
13 13
14static inline void set_bit(int nr, volatile void * addr) 14#ifdef CONFIG_GUSA_RB
15{ 15#include <asm/bitops-grb.h>
16 int mask; 16#else
17 volatile unsigned int *a = addr; 17#include <asm/bitops-irq.h>
18 unsigned long flags; 18#endif
19 19
20 a += nr >> 5;
21 mask = 1 << (nr & 0x1f);
22 local_irq_save(flags);
23 *a |= mask;
24 local_irq_restore(flags);
25}
26 20
27/* 21/*
28 * clear_bit() doesn't provide any barrier for the compiler. 22 * clear_bit() doesn't provide any barrier for the compiler.
29 */ 23 */
30#define smp_mb__before_clear_bit() barrier() 24#define smp_mb__before_clear_bit() barrier()
31#define smp_mb__after_clear_bit() barrier() 25#define smp_mb__after_clear_bit() barrier()
32static inline void clear_bit(int nr, volatile void * addr)
33{
34 int mask;
35 volatile unsigned int *a = addr;
36 unsigned long flags;
37
38 a += nr >> 5;
39 mask = 1 << (nr & 0x1f);
40 local_irq_save(flags);
41 *a &= ~mask;
42 local_irq_restore(flags);
43}
44
45static inline void change_bit(int nr, volatile void * addr)
46{
47 int mask;
48 volatile unsigned int *a = addr;
49 unsigned long flags;
50
51 a += nr >> 5;
52 mask = 1 << (nr & 0x1f);
53 local_irq_save(flags);
54 *a ^= mask;
55 local_irq_restore(flags);
56}
57
58static inline int test_and_set_bit(int nr, volatile void * addr)
59{
60 int mask, retval;
61 volatile unsigned int *a = addr;
62 unsigned long flags;
63
64 a += nr >> 5;
65 mask = 1 << (nr & 0x1f);
66 local_irq_save(flags);
67 retval = (mask & *a) != 0;
68 *a |= mask;
69 local_irq_restore(flags);
70
71 return retval;
72}
73
74static inline int test_and_clear_bit(int nr, volatile void * addr)
75{
76 int mask, retval;
77 volatile unsigned int *a = addr;
78 unsigned long flags;
79
80 a += nr >> 5;
81 mask = 1 << (nr & 0x1f);
82 local_irq_save(flags);
83 retval = (mask & *a) != 0;
84 *a &= ~mask;
85 local_irq_restore(flags);
86
87 return retval;
88}
89
90static inline int test_and_change_bit(int nr, volatile void * addr)
91{
92 int mask, retval;
93 volatile unsigned int *a = addr;
94 unsigned long flags;
95
96 a += nr >> 5;
97 mask = 1 << (nr & 0x1f);
98 local_irq_save(flags);
99 retval = (mask & *a) != 0;
100 *a ^= mask;
101 local_irq_restore(flags);
102
103 return retval;
104}
105 26
106#include <asm-generic/bitops/non-atomic.h> 27#include <asm-generic/bitops/non-atomic.h>
107 28
29#ifdef CONFIG_SUPERH32
108static inline unsigned long ffz(unsigned long word) 30static inline unsigned long ffz(unsigned long word)
109{ 31{
110 unsigned long result; 32 unsigned long result;
@@ -138,6 +60,31 @@ static inline unsigned long __ffs(unsigned long word)
138 : "t"); 60 : "t");
139 return result; 61 return result;
140} 62}
63#else
64static inline unsigned long ffz(unsigned long word)
65{
66 unsigned long result, __d2, __d3;
67
68 __asm__("gettr tr0, %2\n\t"
69 "pta $+32, tr0\n\t"
70 "andi %1, 1, %3\n\t"
71 "beq %3, r63, tr0\n\t"
72 "pta $+4, tr0\n"
73 "0:\n\t"
74 "shlri.l %1, 1, %1\n\t"
75 "addi %0, 1, %0\n\t"
76 "andi %1, 1, %3\n\t"
77 "beqi %3, 1, tr0\n"
78 "1:\n\t"
79 "ptabs %2, tr0\n\t"
80 : "=r" (result), "=r" (word), "=r" (__d2), "=r" (__d3)
81 : "0" (0L), "1" (word));
82
83 return result;
84}
85
86#include <asm-generic/bitops/__ffs.h>
87#endif
141 88
142#include <asm-generic/bitops/find.h> 89#include <asm-generic/bitops/find.h>
143#include <asm-generic/bitops/ffs.h> 90#include <asm-generic/bitops/ffs.h>
diff --git a/include/asm-sh/bug.h b/include/asm-sh/bug.h
index a78d482e8b2f..c01718040166 100644
--- a/include/asm-sh/bug.h
+++ b/include/asm-sh/bug.h
@@ -3,7 +3,7 @@
3 3
4#define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */ 4#define TRAPA_BUG_OPCODE 0xc33e /* trapa #0x3e */
5 5
6#ifdef CONFIG_BUG 6#ifdef CONFIG_GENERIC_BUG
7#define HAVE_ARCH_BUG 7#define HAVE_ARCH_BUG
8#define HAVE_ARCH_WARN_ON 8#define HAVE_ARCH_WARN_ON
9 9
@@ -72,12 +72,7 @@ do { \
72 unlikely(__ret_warn_on); \ 72 unlikely(__ret_warn_on); \
73}) 73})
74 74
75struct pt_regs; 75#endif /* CONFIG_GENERIC_BUG */
76
77/* arch/sh/kernel/traps.c */
78void handle_BUG(struct pt_regs *);
79
80#endif /* CONFIG_BUG */
81 76
82#include <asm-generic/bug.h> 77#include <asm-generic/bug.h>
83 78
diff --git a/include/asm-sh/bugs.h b/include/asm-sh/bugs.h
index b66139ff73fc..def8128b8b78 100644
--- a/include/asm-sh/bugs.h
+++ b/include/asm-sh/bugs.h
@@ -25,7 +25,7 @@ static void __init check_bugs(void)
25 case CPU_SH7619: 25 case CPU_SH7619:
26 *p++ = '2'; 26 *p++ = '2';
27 break; 27 break;
28 case CPU_SH7206: 28 case CPU_SH7203 ... CPU_SH7263:
29 *p++ = '2'; 29 *p++ = '2';
30 *p++ = 'a'; 30 *p++ = 'a';
31 break; 31 break;
@@ -35,7 +35,7 @@ static void __init check_bugs(void)
35 case CPU_SH7750 ... CPU_SH4_501: 35 case CPU_SH7750 ... CPU_SH4_501:
36 *p++ = '4'; 36 *p++ = '4';
37 break; 37 break;
38 case CPU_SH7770 ... CPU_SHX3: 38 case CPU_SH7763 ... CPU_SHX3:
39 *p++ = '4'; 39 *p++ = '4';
40 *p++ = 'a'; 40 *p++ = 'a';
41 break; 41 break;
@@ -48,9 +48,16 @@ static void __init check_bugs(void)
48 *p++ = 's'; 48 *p++ = 's';
49 *p++ = 'p'; 49 *p++ = 'p';
50 break; 50 break;
51 default: 51 case CPU_SH5_101 ... CPU_SH5_103:
52 *p++ = '?'; 52 *p++ = '6';
53 *p++ = '!'; 53 *p++ = '4';
54 break;
55 case CPU_SH_NONE:
56 /*
57 * Specifically use CPU_SH_NONE rather than default:,
58 * so we're able to have the compiler whine about
59 * unhandled enumerations.
60 */
54 break; 61 break;
55 } 62 }
56 63
diff --git a/include/asm-sh/byteorder.h b/include/asm-sh/byteorder.h
index bff2b1382e01..0eb9904b6545 100644
--- a/include/asm-sh/byteorder.h
+++ b/include/asm-sh/byteorder.h
@@ -3,40 +3,55 @@
3 3
4/* 4/*
5 * Copyright (C) 1999 Niibe Yutaka 5 * Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2000, 2001 Paolo Alberelli
6 */ 7 */
7
8#include <asm/types.h>
9#include <linux/compiler.h> 8#include <linux/compiler.h>
9#include <linux/types.h>
10 10
11static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) 11static inline __attribute_const__ __u32 ___arch__swab32(__u32 x)
12{ 12{
13 __asm__("swap.b %0, %0\n\t" 13 __asm__(
14 "swap.w %0, %0\n\t" 14#ifdef CONFIG_SUPERH32
15 "swap.b %0, %0" 15 "swap.b %0, %0\n\t"
16 "swap.w %0, %0\n\t"
17 "swap.b %0, %0"
18#else
19 "byterev %0, %0\n\t"
20 "shari %0, 32, %0"
21#endif
16 : "=r" (x) 22 : "=r" (x)
17 : "0" (x)); 23 : "0" (x));
24
18 return x; 25 return x;
19} 26}
20 27
21static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x) 28static inline __attribute_const__ __u16 ___arch__swab16(__u16 x)
22{ 29{
23 __asm__("swap.b %0, %0" 30 __asm__(
31#ifdef CONFIG_SUPERH32
32 "swap.b %0, %0"
33#else
34 "byterev %0, %0\n\t"
35 "shari %0, 32, %0"
36
37#endif
24 : "=r" (x) 38 : "=r" (x)
25 : "0" (x)); 39 : "0" (x));
40
26 return x; 41 return x;
27} 42}
28 43
29static inline __u64 ___arch__swab64(__u64 val) 44static inline __u64 ___arch__swab64(__u64 val)
30{ 45{
31 union { 46 union {
32 struct { __u32 a,b; } s; 47 struct { __u32 a,b; } s;
33 __u64 u; 48 __u64 u;
34 } v, w; 49 } v, w;
35 v.u = val; 50 v.u = val;
36 w.s.b = ___arch__swab32(v.s.a); 51 w.s.b = ___arch__swab32(v.s.a);
37 w.s.a = ___arch__swab32(v.s.b); 52 w.s.a = ___arch__swab32(v.s.b);
38 return w.u; 53 return w.u;
39} 54}
40 55
41#define __arch__swab64(x) ___arch__swab64(x) 56#define __arch__swab64(x) ___arch__swab64(x)
42#define __arch__swab32(x) ___arch__swab32(x) 57#define __arch__swab32(x) ___arch__swab32(x)
diff --git a/include/asm-sh/cache.h b/include/asm-sh/cache.h
index 7a18649d1ccb..083419f47c65 100644
--- a/include/asm-sh/cache.h
+++ b/include/asm-sh/cache.h
@@ -12,15 +12,9 @@
12#include <linux/init.h> 12#include <linux/init.h>
13#include <asm/cpu/cache.h> 13#include <asm/cpu/cache.h>
14 14
15#define SH_CACHE_VALID 1
16#define SH_CACHE_UPDATED 2
17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8
19
20#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 15#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
21#define SMP_CACHE_BYTES L1_CACHE_BYTES
22 16
23#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1)) 17#define __read_mostly __attribute__((__section__(".data.read_mostly")))
24 18
25#ifndef __ASSEMBLY__ 19#ifndef __ASSEMBLY__
26struct cache_info { 20struct cache_info {
diff --git a/include/asm-sh/cacheflush.h b/include/asm-sh/cacheflush.h
index aa558da08471..e034c3604111 100644
--- a/include/asm-sh/cacheflush.h
+++ b/include/asm-sh/cacheflush.h
@@ -43,21 +43,37 @@ extern void __flush_purge_region(void *start, int size);
43extern void __flush_invalidate_region(void *start, int size); 43extern void __flush_invalidate_region(void *start, int size);
44#endif 44#endif
45 45
46#define flush_cache_vmap(start, end) flush_cache_all() 46#define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE
47#define flush_cache_vunmap(start, end) flush_cache_all() 47static inline void flush_kernel_dcache_page(struct page *page)
48{
49 flush_dcache_page(page);
50}
48 51
49#define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 52#if defined(CONFIG_CPU_SH4) && !defined(CONFIG_CACHE_OFF)
53extern void copy_to_user_page(struct vm_area_struct *vma,
54 struct page *page, unsigned long vaddr, void *dst, const void *src,
55 unsigned long len);
56
57extern void copy_from_user_page(struct vm_area_struct *vma,
58 struct page *page, unsigned long vaddr, void *dst, const void *src,
59 unsigned long len);
60#else
61#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
50 do { \ 62 do { \
51 flush_cache_page(vma, vaddr, page_to_pfn(page));\ 63 flush_cache_page(vma, vaddr, page_to_pfn(page));\
52 memcpy(dst, src, len); \ 64 memcpy(dst, src, len); \
53 flush_icache_user_range(vma, page, vaddr, len); \ 65 flush_icache_user_range(vma, page, vaddr, len); \
54 } while (0) 66 } while (0)
55 67
56#define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 68#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
57 do { \ 69 do { \
58 flush_cache_page(vma, vaddr, page_to_pfn(page));\ 70 flush_cache_page(vma, vaddr, page_to_pfn(page));\
59 memcpy(dst, src, len); \ 71 memcpy(dst, src, len); \
60 } while (0) 72 } while (0)
73#endif
74
75#define flush_cache_vmap(start, end) flush_cache_all()
76#define flush_cache_vunmap(start, end) flush_cache_all()
61 77
62#define HAVE_ARCH_UNMAPPED_AREA 78#define HAVE_ARCH_UNMAPPED_AREA
63 79
diff --git a/include/asm-sh/checksum.h b/include/asm-sh/checksum.h
index 4bc8357e8892..67496ab0ef04 100644
--- a/include/asm-sh/checksum.h
+++ b/include/asm-sh/checksum.h
@@ -1,215 +1,5 @@
1#ifndef __ASM_SH_CHECKSUM_H 1#ifdef CONFIG_SUPERH32
2#define __ASM_SH_CHECKSUM_H 2# include "checksum_32.h"
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 1999 by Kaz Kojima & Niibe Yutaka
10 */
11
12#include <linux/in6.h>
13
14/*
15 * computes the checksum of a memory block at buff, length len,
16 * and adds in "sum" (32-bit)
17 *
18 * returns a 32-bit number suitable for feeding into itself
19 * or csum_tcpudp_magic
20 *
21 * this function must be called with even lengths, except
22 * for the last fragment, which may be odd
23 *
24 * it's best to have buff aligned on a 32-bit boundary
25 */
26asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
27
28/*
29 * the same as csum_partial, but copies from src while it
30 * checksums, and handles user-space pointer exceptions correctly, when needed.
31 *
32 * here even more important to align src and dst on a 32-bit (or even
33 * better 64-bit) boundary
34 */
35
36asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
37 int len, __wsum sum,
38 int *src_err_ptr, int *dst_err_ptr);
39
40/*
41 * Note: when you get a NULL pointer exception here this means someone
42 * passed in an incorrect kernel address to one of these functions.
43 *
44 * If you use these functions directly please don't forget the
45 * access_ok().
46 */
47static inline
48__wsum csum_partial_copy_nocheck(const void *src, void *dst,
49 int len, __wsum sum)
50{
51 return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL);
52}
53
54static inline
55__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
56 int len, __wsum sum, int *err_ptr)
57{
58 return csum_partial_copy_generic((__force const void *)src, dst,
59 len, sum, err_ptr, NULL);
60}
61
62/*
63 * Fold a partial checksum
64 */
65
66static inline __sum16 csum_fold(__wsum sum)
67{
68 unsigned int __dummy;
69 __asm__("swap.w %0, %1\n\t"
70 "extu.w %0, %0\n\t"
71 "extu.w %1, %1\n\t"
72 "add %1, %0\n\t"
73 "swap.w %0, %1\n\t"
74 "add %1, %0\n\t"
75 "not %0, %0\n\t"
76 : "=r" (sum), "=&r" (__dummy)
77 : "0" (sum)
78 : "t");
79 return (__force __sum16)sum;
80}
81
82/*
83 * This is a version of ip_compute_csum() optimized for IP headers,
84 * which always checksum on 4 octet boundaries.
85 *
86 * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted
87 * for linux by * Arnt Gulbrandsen.
88 */
89static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
90{
91 unsigned int sum, __dummy0, __dummy1;
92
93 __asm__ __volatile__(
94 "mov.l @%1+, %0\n\t"
95 "mov.l @%1+, %3\n\t"
96 "add #-2, %2\n\t"
97 "clrt\n\t"
98 "1:\t"
99 "addc %3, %0\n\t"
100 "movt %4\n\t"
101 "mov.l @%1+, %3\n\t"
102 "dt %2\n\t"
103 "bf/s 1b\n\t"
104 " cmp/eq #1, %4\n\t"
105 "addc %3, %0\n\t"
106 "addc %2, %0" /* Here %2 is 0, add carry-bit */
107 /* Since the input registers which are loaded with iph and ihl
108 are modified, we must also specify them as outputs, or gcc
109 will assume they contain their original values. */
110 : "=r" (sum), "=r" (iph), "=r" (ihl), "=&r" (__dummy0), "=&z" (__dummy1)
111 : "1" (iph), "2" (ihl)
112 : "t");
113
114 return csum_fold(sum);
115}
116
117static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
118 unsigned short len,
119 unsigned short proto,
120 __wsum sum)
121{
122#ifdef __LITTLE_ENDIAN__
123 unsigned long len_proto = (proto + len) << 8;
124#else 3#else
125 unsigned long len_proto = proto + len; 4# include "checksum_64.h"
126#endif 5#endif
127 __asm__("clrt\n\t"
128 "addc %0, %1\n\t"
129 "addc %2, %1\n\t"
130 "addc %3, %1\n\t"
131 "movt %0\n\t"
132 "add %1, %0"
133 : "=r" (sum), "=r" (len_proto)
134 : "r" (daddr), "r" (saddr), "1" (len_proto), "0" (sum)
135 : "t");
136
137 return sum;
138}
139
140/*
141 * computes the checksum of the TCP/UDP pseudo-header
142 * returns a 16-bit checksum, already complemented
143 */
144static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
145 unsigned short len,
146 unsigned short proto,
147 __wsum sum)
148{
149 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
150}
151
152/*
153 * this routine is used for miscellaneous IP-like checksums, mainly
154 * in icmp.c
155 */
156static inline __sum16 ip_compute_csum(const void *buff, int len)
157{
158 return csum_fold(csum_partial(buff, len, 0));
159}
160
161#define _HAVE_ARCH_IPV6_CSUM
162static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
163 const struct in6_addr *daddr,
164 __u32 len, unsigned short proto,
165 __wsum sum)
166{
167 unsigned int __dummy;
168 __asm__("clrt\n\t"
169 "mov.l @(0,%2), %1\n\t"
170 "addc %1, %0\n\t"
171 "mov.l @(4,%2), %1\n\t"
172 "addc %1, %0\n\t"
173 "mov.l @(8,%2), %1\n\t"
174 "addc %1, %0\n\t"
175 "mov.l @(12,%2), %1\n\t"
176 "addc %1, %0\n\t"
177 "mov.l @(0,%3), %1\n\t"
178 "addc %1, %0\n\t"
179 "mov.l @(4,%3), %1\n\t"
180 "addc %1, %0\n\t"
181 "mov.l @(8,%3), %1\n\t"
182 "addc %1, %0\n\t"
183 "mov.l @(12,%3), %1\n\t"
184 "addc %1, %0\n\t"
185 "addc %4, %0\n\t"
186 "addc %5, %0\n\t"
187 "movt %1\n\t"
188 "add %1, %0\n"
189 : "=r" (sum), "=&r" (__dummy)
190 : "r" (saddr), "r" (daddr),
191 "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
192 : "t");
193
194 return csum_fold(sum);
195}
196
197/*
198 * Copy and checksum to user
199 */
200#define HAVE_CSUM_COPY_USER
201static inline __wsum csum_and_copy_to_user(const void *src,
202 void __user *dst,
203 int len, __wsum sum,
204 int *err_ptr)
205{
206 if (access_ok(VERIFY_WRITE, dst, len))
207 return csum_partial_copy_generic((__force const void *)src,
208 dst, len, sum, NULL, err_ptr);
209
210 if (len)
211 *err_ptr = -EFAULT;
212
213 return (__force __wsum)-1; /* invalid checksum */
214}
215#endif /* __ASM_SH_CHECKSUM_H */
diff --git a/include/asm-sh/checksum_32.h b/include/asm-sh/checksum_32.h
new file mode 100644
index 000000000000..4bc8357e8892
--- /dev/null
+++ b/include/asm-sh/checksum_32.h
@@ -0,0 +1,215 @@
1#ifndef __ASM_SH_CHECKSUM_H
2#define __ASM_SH_CHECKSUM_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * Copyright (C) 1999 by Kaz Kojima & Niibe Yutaka
10 */
11
12#include <linux/in6.h>
13
14/*
15 * computes the checksum of a memory block at buff, length len,
16 * and adds in "sum" (32-bit)
17 *
18 * returns a 32-bit number suitable for feeding into itself
19 * or csum_tcpudp_magic
20 *
21 * this function must be called with even lengths, except
22 * for the last fragment, which may be odd
23 *
24 * it's best to have buff aligned on a 32-bit boundary
25 */
26asmlinkage __wsum csum_partial(const void *buff, int len, __wsum sum);
27
28/*
29 * the same as csum_partial, but copies from src while it
30 * checksums, and handles user-space pointer exceptions correctly, when needed.
31 *
32 * here even more important to align src and dst on a 32-bit (or even
33 * better 64-bit) boundary
34 */
35
36asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
37 int len, __wsum sum,
38 int *src_err_ptr, int *dst_err_ptr);
39
40/*
41 * Note: when you get a NULL pointer exception here this means someone
42 * passed in an incorrect kernel address to one of these functions.
43 *
44 * If you use these functions directly please don't forget the
45 * access_ok().
46 */
47static inline
48__wsum csum_partial_copy_nocheck(const void *src, void *dst,
49 int len, __wsum sum)
50{
51 return csum_partial_copy_generic(src, dst, len, sum, NULL, NULL);
52}
53
54static inline
55__wsum csum_partial_copy_from_user(const void __user *src, void *dst,
56 int len, __wsum sum, int *err_ptr)
57{
58 return csum_partial_copy_generic((__force const void *)src, dst,
59 len, sum, err_ptr, NULL);
60}
61
62/*
63 * Fold a partial checksum
64 */
65
66static inline __sum16 csum_fold(__wsum sum)
67{
68 unsigned int __dummy;
69 __asm__("swap.w %0, %1\n\t"
70 "extu.w %0, %0\n\t"
71 "extu.w %1, %1\n\t"
72 "add %1, %0\n\t"
73 "swap.w %0, %1\n\t"
74 "add %1, %0\n\t"
75 "not %0, %0\n\t"
76 : "=r" (sum), "=&r" (__dummy)
77 : "0" (sum)
78 : "t");
79 return (__force __sum16)sum;
80}
81
82/*
83 * This is a version of ip_compute_csum() optimized for IP headers,
84 * which always checksum on 4 octet boundaries.
85 *
86 * i386 version by Jorge Cwik <jorge@laser.satlink.net>, adapted
87 * for linux by * Arnt Gulbrandsen.
88 */
89static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
90{
91 unsigned int sum, __dummy0, __dummy1;
92
93 __asm__ __volatile__(
94 "mov.l @%1+, %0\n\t"
95 "mov.l @%1+, %3\n\t"
96 "add #-2, %2\n\t"
97 "clrt\n\t"
98 "1:\t"
99 "addc %3, %0\n\t"
100 "movt %4\n\t"
101 "mov.l @%1+, %3\n\t"
102 "dt %2\n\t"
103 "bf/s 1b\n\t"
104 " cmp/eq #1, %4\n\t"
105 "addc %3, %0\n\t"
106 "addc %2, %0" /* Here %2 is 0, add carry-bit */
107 /* Since the input registers which are loaded with iph and ihl
108 are modified, we must also specify them as outputs, or gcc
109 will assume they contain their original values. */
110 : "=r" (sum), "=r" (iph), "=r" (ihl), "=&r" (__dummy0), "=&z" (__dummy1)
111 : "1" (iph), "2" (ihl)
112 : "t");
113
114 return csum_fold(sum);
115}
116
117static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
118 unsigned short len,
119 unsigned short proto,
120 __wsum sum)
121{
122#ifdef __LITTLE_ENDIAN__
123 unsigned long len_proto = (proto + len) << 8;
124#else
125 unsigned long len_proto = proto + len;
126#endif
127 __asm__("clrt\n\t"
128 "addc %0, %1\n\t"
129 "addc %2, %1\n\t"
130 "addc %3, %1\n\t"
131 "movt %0\n\t"
132 "add %1, %0"
133 : "=r" (sum), "=r" (len_proto)
134 : "r" (daddr), "r" (saddr), "1" (len_proto), "0" (sum)
135 : "t");
136
137 return sum;
138}
139
140/*
141 * computes the checksum of the TCP/UDP pseudo-header
142 * returns a 16-bit checksum, already complemented
143 */
144static inline __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr,
145 unsigned short len,
146 unsigned short proto,
147 __wsum sum)
148{
149 return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
150}
151
152/*
153 * this routine is used for miscellaneous IP-like checksums, mainly
154 * in icmp.c
155 */
156static inline __sum16 ip_compute_csum(const void *buff, int len)
157{
158 return csum_fold(csum_partial(buff, len, 0));
159}
160
161#define _HAVE_ARCH_IPV6_CSUM
162static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
163 const struct in6_addr *daddr,
164 __u32 len, unsigned short proto,
165 __wsum sum)
166{
167 unsigned int __dummy;
168 __asm__("clrt\n\t"
169 "mov.l @(0,%2), %1\n\t"
170 "addc %1, %0\n\t"
171 "mov.l @(4,%2), %1\n\t"
172 "addc %1, %0\n\t"
173 "mov.l @(8,%2), %1\n\t"
174 "addc %1, %0\n\t"
175 "mov.l @(12,%2), %1\n\t"
176 "addc %1, %0\n\t"
177 "mov.l @(0,%3), %1\n\t"
178 "addc %1, %0\n\t"
179 "mov.l @(4,%3), %1\n\t"
180 "addc %1, %0\n\t"
181 "mov.l @(8,%3), %1\n\t"
182 "addc %1, %0\n\t"
183 "mov.l @(12,%3), %1\n\t"
184 "addc %1, %0\n\t"
185 "addc %4, %0\n\t"
186 "addc %5, %0\n\t"
187 "movt %1\n\t"
188 "add %1, %0\n"
189 : "=r" (sum), "=&r" (__dummy)
190 : "r" (saddr), "r" (daddr),
191 "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
192 : "t");
193
194 return csum_fold(sum);
195}
196
197/*
198 * Copy and checksum to user
199 */
200#define HAVE_CSUM_COPY_USER
201static inline __wsum csum_and_copy_to_user(const void *src,
202 void __user *dst,
203 int len, __wsum sum,
204 int *err_ptr)
205{
206 if (access_ok(VERIFY_WRITE, dst, len))
207 return csum_partial_copy_generic((__force const void *)src,
208 dst, len, sum, NULL, err_ptr);
209
210 if (len)
211 *err_ptr = -EFAULT;
212
213 return (__force __wsum)-1; /* invalid checksum */
214}
215#endif /* __ASM_SH_CHECKSUM_H */
diff --git a/include/asm-sh64/checksum.h b/include/asm-sh/checksum_64.h
index ba594ccb42e5..9c62a031a8f5 100644
--- a/include/asm-sh64/checksum.h
+++ b/include/asm-sh/checksum_64.h
@@ -1,19 +1,16 @@
1#ifndef __ASM_SH64_CHECKSUM_H 1#ifndef __ASM_SH_CHECKSUM_64_H
2#define __ASM_SH64_CHECKSUM_H 2#define __ASM_SH_CHECKSUM_64_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/checksum_64.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/checksum.h
10 * 6 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 7 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
13 */ 12 */
14 13
15#include <asm/registers.h>
16
17/* 14/*
18 * computes the checksum of a memory block at buff, length len, 15 * computes the checksum of a memory block at buff, length len,
19 * and adds in "sum" (32-bit) 16 * and adds in "sum" (32-bit)
@@ -78,5 +75,4 @@ static inline __sum16 ip_compute_csum(const void *buff, int len)
78 return csum_fold(csum_partial(buff, len, 0)); 75 return csum_fold(csum_partial(buff, len, 0));
79} 76}
80 77
81#endif /* __ASM_SH64_CHECKSUM_H */ 78#endif /* __ASM_SH_CHECKSUM_64_H */
82
diff --git a/include/asm-sh/cmpxchg-grb.h b/include/asm-sh/cmpxchg-grb.h
new file mode 100644
index 000000000000..e2681abe764f
--- /dev/null
+++ b/include/asm-sh/cmpxchg-grb.h
@@ -0,0 +1,70 @@
1#ifndef __ASM_SH_CMPXCHG_GRB_H
2#define __ASM_SH_CMPXCHG_GRB_H
3
4static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
5{
6 unsigned long retval;
7
8 __asm__ __volatile__ (
9 " .align 2 \n\t"
10 " mova 1f, r0 \n\t" /* r0 = end point */
11 " nop \n\t"
12 " mov r15, r1 \n\t" /* r1 = saved sp */
13 " mov #-4, r15 \n\t" /* LOGIN */
14 " mov.l @%1, %0 \n\t" /* load old value */
15 " mov.l %2, @%1 \n\t" /* store new value */
16 "1: mov r1, r15 \n\t" /* LOGOUT */
17 : "=&r" (retval),
18 "+r" (m)
19 : "r" (val)
20 : "memory", "r0", "r1");
21
22 return retval;
23}
24
25static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
26{
27 unsigned long retval;
28
29 __asm__ __volatile__ (
30 " .align 2 \n\t"
31 " mova 1f, r0 \n\t" /* r0 = end point */
32 " mov r15, r1 \n\t" /* r1 = saved sp */
33 " mov #-6, r15 \n\t" /* LOGIN */
34 " mov.b @%1, %0 \n\t" /* load old value */
35 " extu.b %0, %0 \n\t" /* extend as unsigned */
36 " mov.b %2, @%1 \n\t" /* store new value */
37 "1: mov r1, r15 \n\t" /* LOGOUT */
38 : "=&r" (retval),
39 "+r" (m)
40 : "r" (val)
41 : "memory" , "r0", "r1");
42
43 return retval;
44}
45
46static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
47 unsigned long new)
48{
49 unsigned long retval;
50
51 __asm__ __volatile__ (
52 " .align 2 \n\t"
53 " mova 1f, r0 \n\t" /* r0 = end point */
54 " nop \n\t"
55 " mov r15, r1 \n\t" /* r1 = saved sp */
56 " mov #-8, r15 \n\t" /* LOGIN */
57 " mov.l @%1, %0 \n\t" /* load old value */
58 " cmp/eq %0, %2 \n\t"
59 " bf 1f \n\t" /* if not equal */
60 " mov.l %2, @%1 \n\t" /* store new value */
61 "1: mov r1, r15 \n\t" /* LOGOUT */
62 : "=&r" (retval),
63 "+r" (m)
64 : "r" (new)
65 : "memory" , "r0", "r1", "t");
66
67 return retval;
68}
69
70#endif /* __ASM_SH_CMPXCHG_GRB_H */
diff --git a/include/asm-sh/cmpxchg-irq.h b/include/asm-sh/cmpxchg-irq.h
new file mode 100644
index 000000000000..43049ec0554b
--- /dev/null
+++ b/include/asm-sh/cmpxchg-irq.h
@@ -0,0 +1,40 @@
1#ifndef __ASM_SH_CMPXCHG_IRQ_H
2#define __ASM_SH_CMPXCHG_IRQ_H
3
4static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
5{
6 unsigned long flags, retval;
7
8 local_irq_save(flags);
9 retval = *m;
10 *m = val;
11 local_irq_restore(flags);
12 return retval;
13}
14
15static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
16{
17 unsigned long flags, retval;
18
19 local_irq_save(flags);
20 retval = *m;
21 *m = val & 0xff;
22 local_irq_restore(flags);
23 return retval;
24}
25
26static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old,
27 unsigned long new)
28{
29 __u32 retval;
30 unsigned long flags;
31
32 local_irq_save(flags);
33 retval = *m;
34 if (retval == old)
35 *m = new;
36 local_irq_restore(flags); /* implies memory barrier */
37 return retval;
38}
39
40#endif /* __ASM_SH_CMPXCHG_IRQ_H */
diff --git a/include/asm-sh/cpu-sh2/addrspace.h b/include/asm-sh/cpu-sh2/addrspace.h
index 8706c903c5a0..2b9ab93efa4e 100644
--- a/include/asm-sh/cpu-sh2/addrspace.h
+++ b/include/asm-sh/cpu-sh2/addrspace.h
@@ -10,7 +10,10 @@
10#ifndef __ASM_CPU_SH2_ADDRSPACE_H 10#ifndef __ASM_CPU_SH2_ADDRSPACE_H
11#define __ASM_CPU_SH2_ADDRSPACE_H 11#define __ASM_CPU_SH2_ADDRSPACE_H
12 12
13/* Should fill here */ 13#define P0SEG 0x00000000
14#define P1SEG 0x80000000
15#define P2SEG 0xa0000000
16#define P3SEG 0xc0000000
17#define P4SEG 0xe0000000
14 18
15#endif /* __ASM_CPU_SH2_ADDRSPACE_H */ 19#endif /* __ASM_CPU_SH2_ADDRSPACE_H */
16
diff --git a/include/asm-sh/cpu-sh2/cache.h b/include/asm-sh/cpu-sh2/cache.h
index f02ba7a672b2..4e0b16500686 100644
--- a/include/asm-sh/cpu-sh2/cache.h
+++ b/include/asm-sh/cpu-sh2/cache.h
@@ -12,9 +12,13 @@
12 12
13#define L1_CACHE_SHIFT 4 13#define L1_CACHE_SHIFT 4
14 14
15#define SH_CACHE_VALID 1
16#define SH_CACHE_UPDATED 2
17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8
19
15#if defined(CONFIG_CPU_SUBTYPE_SH7619) 20#if defined(CONFIG_CPU_SUBTYPE_SH7619)
16#define CCR1 0xffffffec 21#define CCR 0xffffffec
17#define CCR CCR1
18 22
19#define CCR_CACHE_CE 0x01 /* Cache enable */ 23#define CCR_CACHE_CE 0x01 /* Cache enable */
20#define CCR_CACHE_WT 0x06 /* CCR[bit1=1,bit2=1] */ 24#define CCR_CACHE_WT 0x06 /* CCR[bit1=1,bit2=1] */
diff --git a/include/asm-sh/cpu-sh2/rtc.h b/include/asm-sh/cpu-sh2/rtc.h
new file mode 100644
index 000000000000..39e2d6e94782
--- /dev/null
+++ b/include/asm-sh/cpu-sh2/rtc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_SH_CPU_SH2_RTC_H
2#define __ASM_SH_CPU_SH2_RTC_H
3
4#define rtc_reg_size sizeof(u16)
5#define RTC_BIT_INVERTED 0
6#define RTC_DEF_CAPABILITIES 0UL
7
8#endif /* __ASM_SH_CPU_SH2_RTC_H */
diff --git a/include/asm-sh/cpu-sh2a/addrspace.h b/include/asm-sh/cpu-sh2a/addrspace.h
index 3d2e9aa21522..795ddd6856a3 100644
--- a/include/asm-sh/cpu-sh2a/addrspace.h
+++ b/include/asm-sh/cpu-sh2a/addrspace.h
@@ -1 +1,10 @@
1#include <asm/cpu-sh2/addrspace.h> 1#ifndef __ASM_SH_CPU_SH2A_ADDRSPACE_H
2#define __ASM_SH_CPU_SH2A_ADDRSPACE_H
3
4#define P0SEG 0x00000000
5#define P1SEG 0x00000000
6#define P2SEG 0x20000000
7#define P3SEG 0x00000000
8#define P4SEG 0x80000000
9
10#endif /* __ASM_SH_CPU_SH2A_ADDRSPACE_H */
diff --git a/include/asm-sh/cpu-sh2a/cache.h b/include/asm-sh/cpu-sh2a/cache.h
index 3e4b9e480982..afe228b3f493 100644
--- a/include/asm-sh/cpu-sh2a/cache.h
+++ b/include/asm-sh/cpu-sh2a/cache.h
@@ -12,11 +12,13 @@
12 12
13#define L1_CACHE_SHIFT 4 13#define L1_CACHE_SHIFT 4
14 14
15#define CCR1 0xfffc1000 15#define SH_CACHE_VALID 1
16#define CCR2 0xfffc1004 16#define SH_CACHE_UPDATED 2
17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8
17 19
18/* CCR1 behaves more like the traditional CCR */ 20#define CCR 0xfffc1000 /* CCR1 */
19#define CCR CCR1 21#define CCR2 0xfffc1004
20 22
21/* 23/*
22 * Most of the SH-2A CCR1 definitions resemble the SH-4 ones. All others not 24 * Most of the SH-2A CCR1 definitions resemble the SH-4 ones. All others not
@@ -36,4 +38,3 @@
36#define CCR_CACHE_INVALIDATE (CCR_CACHE_OCI | CCR_CACHE_ICI) 38#define CCR_CACHE_INVALIDATE (CCR_CACHE_OCI | CCR_CACHE_ICI)
37 39
38#endif /* __ASM_CPU_SH2A_CACHE_H */ 40#endif /* __ASM_CPU_SH2A_CACHE_H */
39
diff --git a/include/asm-sh/cpu-sh2a/freq.h b/include/asm-sh/cpu-sh2a/freq.h
index e518fff6d10f..830fd43b6cdc 100644
--- a/include/asm-sh/cpu-sh2a/freq.h
+++ b/include/asm-sh/cpu-sh2a/freq.h
@@ -10,9 +10,7 @@
10#ifndef __ASM_CPU_SH2A_FREQ_H 10#ifndef __ASM_CPU_SH2A_FREQ_H
11#define __ASM_CPU_SH2A_FREQ_H 11#define __ASM_CPU_SH2A_FREQ_H
12 12
13#if defined(CONFIG_CPU_SUBTYPE_SH7206)
14#define FREQCR 0xfffe0010 13#define FREQCR 0xfffe0010
15#endif
16 14
17#endif /* __ASM_CPU_SH2A_FREQ_H */ 15#endif /* __ASM_CPU_SH2A_FREQ_H */
18 16
diff --git a/include/asm-sh/cpu-sh2a/rtc.h b/include/asm-sh/cpu-sh2a/rtc.h
new file mode 100644
index 000000000000..afb511e2bed7
--- /dev/null
+++ b/include/asm-sh/cpu-sh2a/rtc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_SH_CPU_SH2A_RTC_H
2#define __ASM_SH_CPU_SH2A_RTC_H
3
4#define rtc_reg_size sizeof(u16)
5#define RTC_BIT_INVERTED 0
6#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR
7
8#endif /* __ASM_SH_CPU_SH2A_RTC_H */
diff --git a/include/asm-sh/cpu-sh3/addrspace.h b/include/asm-sh/cpu-sh3/addrspace.h
index 872e9e1b548c..0f94726c7d62 100644
--- a/include/asm-sh/cpu-sh3/addrspace.h
+++ b/include/asm-sh/cpu-sh3/addrspace.h
@@ -10,7 +10,10 @@
10#ifndef __ASM_CPU_SH3_ADDRSPACE_H 10#ifndef __ASM_CPU_SH3_ADDRSPACE_H
11#define __ASM_CPU_SH3_ADDRSPACE_H 11#define __ASM_CPU_SH3_ADDRSPACE_H
12 12
13/* Should fill here */ 13#define P0SEG 0x00000000
14#define P1SEG 0x80000000
15#define P2SEG 0xa0000000
16#define P3SEG 0xc0000000
17#define P4SEG 0xe0000000
14 18
15#endif /* __ASM_CPU_SH3_ADDRSPACE_H */ 19#endif /* __ASM_CPU_SH3_ADDRSPACE_H */
16
diff --git a/include/asm-sh/cpu-sh3/cache.h b/include/asm-sh/cpu-sh3/cache.h
index 255016fc91f0..56bd838b7db4 100644
--- a/include/asm-sh/cpu-sh3/cache.h
+++ b/include/asm-sh/cpu-sh3/cache.h
@@ -12,6 +12,11 @@
12 12
13#define L1_CACHE_SHIFT 4 13#define L1_CACHE_SHIFT 4
14 14
15#define SH_CACHE_VALID 1
16#define SH_CACHE_UPDATED 2
17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8
19
15#define CCR 0xffffffec /* Address of Cache Control Register */ 20#define CCR 0xffffffec /* Address of Cache Control Register */
16 21
17#define CCR_CACHE_CE 0x01 /* Cache Enable */ 22#define CCR_CACHE_CE 0x01 /* Cache Enable */
@@ -28,7 +33,8 @@
28 33
29#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \ 34#if defined(CONFIG_CPU_SUBTYPE_SH7705) || \
30 defined(CONFIG_CPU_SUBTYPE_SH7710) || \ 35 defined(CONFIG_CPU_SUBTYPE_SH7710) || \
31 defined(CONFIG_CPU_SUBTYPE_SH7720) 36 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
37 defined(CONFIG_CPU_SUBTYPE_SH7721)
32#define CCR3 0xa40000b4 38#define CCR3 0xa40000b4
33#define CCR_CACHE_16KB 0x00010000 39#define CCR_CACHE_16KB 0x00010000
34#define CCR_CACHE_32KB 0x00020000 40#define CCR_CACHE_32KB 0x00020000
diff --git a/include/asm-sh/cpu-sh3/dma.h b/include/asm-sh/cpu-sh3/dma.h
index 54bfece328c2..092ff9d872c3 100644
--- a/include/asm-sh/cpu-sh3/dma.h
+++ b/include/asm-sh/cpu-sh3/dma.h
@@ -2,7 +2,9 @@
2#define __ASM_CPU_SH3_DMA_H 2#define __ASM_CPU_SH3_DMA_H
3 3
4 4
5#if defined(CONFIG_CPU_SUBTYPE_SH7720) || defined(CONFIG_CPU_SUBTYPE_SH7709) 5#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
6 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
7 defined(CONFIG_CPU_SUBTYPE_SH7709)
6#define SH_DMAC_BASE 0xa4010020 8#define SH_DMAC_BASE 0xa4010020
7 9
8#define DMTE0_IRQ 48 10#define DMTE0_IRQ 48
diff --git a/include/asm-sh/cpu-sh3/freq.h b/include/asm-sh/cpu-sh3/freq.h
index 0a054b53b9de..53c62302b2e3 100644
--- a/include/asm-sh/cpu-sh3/freq.h
+++ b/include/asm-sh/cpu-sh3/freq.h
@@ -10,7 +10,12 @@
10#ifndef __ASM_CPU_SH3_FREQ_H 10#ifndef __ASM_CPU_SH3_FREQ_H
11#define __ASM_CPU_SH3_FREQ_H 11#define __ASM_CPU_SH3_FREQ_H
12 12
13#ifdef CONFIG_CPU_SUBTYPE_SH7712
14#define FRQCR 0xA415FF80
15#else
13#define FRQCR 0xffffff80 16#define FRQCR 0xffffff80
17#endif
18
14#define MIN_DIVISOR_NR 0 19#define MIN_DIVISOR_NR 0
15#define MAX_DIVISOR_NR 4 20#define MAX_DIVISOR_NR 4
16 21
diff --git a/include/asm-sh/cpu-sh3/gpio.h b/include/asm-sh/cpu-sh3/gpio.h
index 48770c1c7bdf..4e53eb314b8f 100644
--- a/include/asm-sh/cpu-sh3/gpio.h
+++ b/include/asm-sh/cpu-sh3/gpio.h
@@ -12,7 +12,8 @@
12#ifndef _CPU_SH3_GPIO_H 12#ifndef _CPU_SH3_GPIO_H
13#define _CPU_SH3_GPIO_H 13#define _CPU_SH3_GPIO_H
14 14
15#if defined(CONFIG_CPU_SUBTYPE_SH7720) 15#if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
16 defined(CONFIG_CPU_SUBTYPE_SH7721)
16 17
17/* Control registers */ 18/* Control registers */
18#define PORT_PACR 0xA4050100UL 19#define PORT_PACR 0xA4050100UL
diff --git a/include/asm-sh/cpu-sh3/mmu_context.h b/include/asm-sh/cpu-sh3/mmu_context.h
index 16c2d63b7e39..ab09da73ce77 100644
--- a/include/asm-sh/cpu-sh3/mmu_context.h
+++ b/include/asm-sh/cpu-sh3/mmu_context.h
@@ -33,7 +33,8 @@
33 defined(CONFIG_CPU_SUBTYPE_SH7709) || \ 33 defined(CONFIG_CPU_SUBTYPE_SH7709) || \
34 defined(CONFIG_CPU_SUBTYPE_SH7710) || \ 34 defined(CONFIG_CPU_SUBTYPE_SH7710) || \
35 defined(CONFIG_CPU_SUBTYPE_SH7712) || \ 35 defined(CONFIG_CPU_SUBTYPE_SH7712) || \
36 defined(CONFIG_CPU_SUBTYPE_SH7720) 36 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
37 defined(CONFIG_CPU_SUBTYPE_SH7721)
37#define INTEVT 0xa4000000 /* INTEVTE2(0xa4000000) */ 38#define INTEVT 0xa4000000 /* INTEVTE2(0xa4000000) */
38#else 39#else
39#define INTEVT 0xffffffd8 40#define INTEVT 0xffffffd8
diff --git a/include/asm-sh/cpu-sh3/rtc.h b/include/asm-sh/cpu-sh3/rtc.h
new file mode 100644
index 000000000000..319404aaee37
--- /dev/null
+++ b/include/asm-sh/cpu-sh3/rtc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_SH_CPU_SH3_RTC_H
2#define __ASM_SH_CPU_SH3_RTC_H
3
4#define rtc_reg_size sizeof(u16)
5#define RTC_BIT_INVERTED 0 /* No bug on SH7708, SH7709A */
6#define RTC_DEF_CAPABILITIES 0UL
7
8#endif /* __ASM_SH_CPU_SH3_RTC_H */
diff --git a/include/asm-sh/cpu-sh3/timer.h b/include/asm-sh/cpu-sh3/timer.h
index 3880ce047fe0..793acf12aa08 100644
--- a/include/asm-sh/cpu-sh3/timer.h
+++ b/include/asm-sh/cpu-sh3/timer.h
@@ -23,13 +23,13 @@
23 * --------------------------------------------------------------------------- 23 * ---------------------------------------------------------------------------
24 */ 24 */
25 25
26#if !defined(CONFIG_CPU_SUBTYPE_SH7720) && \ 26#if !defined(CONFIG_CPU_SUBTYPE_SH7720) && !defined(CONFIG_CPU_SUBTYPE_SH7721)
27 !defined(CONFIG_CPU_SUBTYPE_SH7727)
28#define TMU_TOCR 0xfffffe90 /* Byte access */ 27#define TMU_TOCR 0xfffffe90 /* Byte access */
29#endif 28#endif
30 29
31#if defined(CONFIG_CPU_SUBTYPE_SH7710) || \ 30#if defined(CONFIG_CPU_SUBTYPE_SH7710) || \
32 defined(CONFIG_CPU_SUBTYPE_SH7720) 31 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
32 defined(CONFIG_CPU_SUBTYPE_SH7721)
33#define TMU_012_TSTR 0xa412fe92 /* Byte access */ 33#define TMU_012_TSTR 0xa412fe92 /* Byte access */
34 34
35#define TMU0_TCOR 0xa412fe94 /* Long access */ 35#define TMU0_TCOR 0xa412fe94 /* Long access */
@@ -58,8 +58,7 @@
58#define TMU2_TCOR 0xfffffeac /* Long access */ 58#define TMU2_TCOR 0xfffffeac /* Long access */
59#define TMU2_TCNT 0xfffffeb0 /* Long access */ 59#define TMU2_TCNT 0xfffffeb0 /* Long access */
60#define TMU2_TCR 0xfffffeb4 /* Word access */ 60#define TMU2_TCR 0xfffffeb4 /* Word access */
61#if !defined(CONFIG_CPU_SUBTYPE_SH7720) && \ 61#if !defined(CONFIG_CPU_SUBTYPE_SH7720) && !defined(CONFIG_CPU_SUBTYPE_SH7721)
62 !defined(CONFIG_CPU_SUBTYPE_SH7727)
63#define TMU2_TCPR2 0xfffffeb8 /* Long access */ 62#define TMU2_TCPR2 0xfffffeb8 /* Long access */
64#endif 63#endif
65#endif 64#endif
diff --git a/include/asm-sh/cpu-sh3/ubc.h b/include/asm-sh/cpu-sh3/ubc.h
index 18467c574534..4e6381d5ff7a 100644
--- a/include/asm-sh/cpu-sh3/ubc.h
+++ b/include/asm-sh/cpu-sh3/ubc.h
@@ -12,7 +12,8 @@
12#define __ASM_CPU_SH3_UBC_H 12#define __ASM_CPU_SH3_UBC_H
13 13
14#if defined(CONFIG_CPU_SUBTYPE_SH7710) || \ 14#if defined(CONFIG_CPU_SUBTYPE_SH7710) || \
15 defined(CONFIG_CPU_SUBTYPE_SH7720) 15 defined(CONFIG_CPU_SUBTYPE_SH7720) || \
16 defined(CONFIG_CPU_SUBTYPE_SH7721)
16#define UBC_BARA 0xa4ffffb0 17#define UBC_BARA 0xa4ffffb0
17#define UBC_BAMRA 0xa4ffffb4 18#define UBC_BAMRA 0xa4ffffb4
18#define UBC_BBRA 0xa4ffffb8 19#define UBC_BBRA 0xa4ffffb8
diff --git a/include/asm-sh/cpu-sh4/addrspace.h b/include/asm-sh/cpu-sh4/addrspace.h
index bb2e1b03060c..a3fa733c1c7d 100644
--- a/include/asm-sh/cpu-sh4/addrspace.h
+++ b/include/asm-sh/cpu-sh4/addrspace.h
@@ -10,6 +10,12 @@
10#ifndef __ASM_CPU_SH4_ADDRSPACE_H 10#ifndef __ASM_CPU_SH4_ADDRSPACE_H
11#define __ASM_CPU_SH4_ADDRSPACE_H 11#define __ASM_CPU_SH4_ADDRSPACE_H
12 12
13#define P0SEG 0x00000000
14#define P1SEG 0x80000000
15#define P2SEG 0xa0000000
16#define P3SEG 0xc0000000
17#define P4SEG 0xe0000000
18
13/* Detailed P4SEG */ 19/* Detailed P4SEG */
14#define P4SEG_STORE_QUE (P4SEG) 20#define P4SEG_STORE_QUE (P4SEG)
15#define P4SEG_IC_ADDR 0xf0000000 21#define P4SEG_IC_ADDR 0xf0000000
diff --git a/include/asm-sh/cpu-sh4/cache.h b/include/asm-sh/cpu-sh4/cache.h
index f92b20a0983d..1c61ebf5c8e3 100644
--- a/include/asm-sh/cpu-sh4/cache.h
+++ b/include/asm-sh/cpu-sh4/cache.h
@@ -12,6 +12,11 @@
12 12
13#define L1_CACHE_SHIFT 5 13#define L1_CACHE_SHIFT 5
14 14
15#define SH_CACHE_VALID 1
16#define SH_CACHE_UPDATED 2
17#define SH_CACHE_COMBINED 4
18#define SH_CACHE_ASSOC 8
19
15#define CCR 0xff00001c /* Address of Cache Control Register */ 20#define CCR 0xff00001c /* Address of Cache Control Register */
16#define CCR_CACHE_OCE 0x0001 /* Operand Cache Enable */ 21#define CCR_CACHE_OCE 0x0001 /* Operand Cache Enable */
17#define CCR_CACHE_WT 0x0002 /* Write-Through (for P0,U0,P3) (else writeback)*/ 22#define CCR_CACHE_WT 0x0002 /* Write-Through (for P0,U0,P3) (else writeback)*/
diff --git a/include/asm-sh/cpu-sh4/fpu.h b/include/asm-sh/cpu-sh4/fpu.h
new file mode 100644
index 000000000000..febef7342528
--- /dev/null
+++ b/include/asm-sh/cpu-sh4/fpu.h
@@ -0,0 +1,32 @@
1/*
2 * linux/arch/sh/kernel/cpu/sh4/sh4_fpu.h
3 *
4 * Copyright (C) 2006 STMicroelectronics Limited
5 * Author: Carl Shaw <carl.shaw@st.com>
6 *
7 * May be copied or modified under the terms of the GNU General Public
8 * License Version 2. See linux/COPYING for more information.
9 *
10 * Definitions for SH4 FPU operations
11 */
12
13#ifndef __CPU_SH4_FPU_H
14#define __CPU_SH4_FPU_H
15
16#define FPSCR_ENABLE_MASK 0x00000f80UL
17
18#define FPSCR_FMOV_DOUBLE (1<<1)
19
20#define FPSCR_CAUSE_INEXACT (1<<12)
21#define FPSCR_CAUSE_UNDERFLOW (1<<13)
22#define FPSCR_CAUSE_OVERFLOW (1<<14)
23#define FPSCR_CAUSE_DIVZERO (1<<15)
24#define FPSCR_CAUSE_INVALID (1<<16)
25#define FPSCR_CAUSE_ERROR (1<<17)
26
27#define FPSCR_DBL_PRECISION (1<<19)
28#define FPSCR_ROUNDING_MODE(x) ((x >> 20) & 3)
29#define FPSCR_RM_NEAREST (0)
30#define FPSCR_RM_ZERO (1)
31
32#endif
diff --git a/include/asm-sh/cpu-sh4/freq.h b/include/asm-sh/cpu-sh4/freq.h
index dc1d32a86374..1ac10b9a078f 100644
--- a/include/asm-sh/cpu-sh4/freq.h
+++ b/include/asm-sh/cpu-sh4/freq.h
@@ -16,7 +16,8 @@
16#define SCLKACR 0xa4150008 16#define SCLKACR 0xa4150008
17#define SCLKBCR 0xa415000c 17#define SCLKBCR 0xa415000c
18#define IrDACLKCR 0xa4150010 18#define IrDACLKCR 0xa4150010
19#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 19#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
20 defined(CONFIG_CPU_SUBTYPE_SH7780)
20#define FRQCR 0xffc80000 21#define FRQCR 0xffc80000
21#elif defined(CONFIG_CPU_SUBTYPE_SH7785) 22#elif defined(CONFIG_CPU_SUBTYPE_SH7785)
22#define FRQCR0 0xffc80000 23#define FRQCR0 0xffc80000
diff --git a/include/asm-sh/cpu-sh4/mmu_context.h b/include/asm-sh/cpu-sh4/mmu_context.h
index 979acddc0f8e..9ea8eb27b18e 100644
--- a/include/asm-sh/cpu-sh4/mmu_context.h
+++ b/include/asm-sh/cpu-sh4/mmu_context.h
@@ -22,12 +22,20 @@
22#define MMU_UTLB_ADDRESS_ARRAY 0xF6000000 22#define MMU_UTLB_ADDRESS_ARRAY 0xF6000000
23#define MMU_PAGE_ASSOC_BIT 0x80 23#define MMU_PAGE_ASSOC_BIT 0x80
24 24
25#define MMUCR_TI (1<<2)
26
25#ifdef CONFIG_X2TLB 27#ifdef CONFIG_X2TLB
26#define MMUCR_ME (1 << 7) 28#define MMUCR_ME (1 << 7)
27#else 29#else
28#define MMUCR_ME (0) 30#define MMUCR_ME (0)
29#endif 31#endif
30 32
33#if defined(CONFIG_32BIT) && defined(CONFIG_CPU_SUBTYPE_ST40)
34#define MMUCR_SE (1 << 4)
35#else
36#define MMUCR_SE (0)
37#endif
38
31#ifdef CONFIG_SH_STORE_QUEUES 39#ifdef CONFIG_SH_STORE_QUEUES
32#define MMUCR_SQMD (1 << 9) 40#define MMUCR_SQMD (1 << 9)
33#else 41#else
@@ -35,7 +43,7 @@
35#endif 43#endif
36 44
37#define MMU_NTLB_ENTRIES 64 45#define MMU_NTLB_ENTRIES 64
38#define MMU_CONTROL_INIT (0x05|MMUCR_SQMD|MMUCR_ME) 46#define MMU_CONTROL_INIT (0x05|MMUCR_SQMD|MMUCR_ME|MMUCR_SE)
39 47
40#define MMU_ITLB_DATA_ARRAY 0xF3000000 48#define MMU_ITLB_DATA_ARRAY 0xF3000000
41#define MMU_UTLB_DATA_ARRAY 0xF7000000 49#define MMU_UTLB_DATA_ARRAY 0xF7000000
diff --git a/include/asm-sh/cpu-sh4/rtc.h b/include/asm-sh/cpu-sh4/rtc.h
new file mode 100644
index 000000000000..f3d0f53275e4
--- /dev/null
+++ b/include/asm-sh/cpu-sh4/rtc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_SH_CPU_SH4_RTC_H
2#define __ASM_SH_CPU_SH4_RTC_H
3
4#define rtc_reg_size sizeof(u32)
5#define RTC_BIT_INVERTED 0x40 /* bug on SH7750, SH7750S */
6#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR
7
8#endif /* __ASM_SH_CPU_SH4_RTC_H */
diff --git a/include/asm-sh/cpu-sh5/addrspace.h b/include/asm-sh/cpu-sh5/addrspace.h
new file mode 100644
index 000000000000..dc36b9a03af6
--- /dev/null
+++ b/include/asm-sh/cpu-sh5/addrspace.h
@@ -0,0 +1,11 @@
1#ifndef __ASM_SH_CPU_SH5_ADDRSPACE_H
2#define __ASM_SH_CPU_SH5_ADDRSPACE_H
3
4#define PHYS_PERIPHERAL_BLOCK 0x09000000
5#define PHYS_DMAC_BLOCK 0x0e000000
6#define PHYS_PCI_BLOCK 0x60000000
7#define PHYS_EMI_BLOCK 0xff000000
8
9/* No segmentation.. */
10
11#endif /* __ASM_SH_CPU_SH5_ADDRSPACE_H */
diff --git a/include/asm-sh64/cache.h b/include/asm-sh/cpu-sh5/cache.h
index a4f36f0036e1..ed050ab526f2 100644
--- a/include/asm-sh64/cache.h
+++ b/include/asm-sh/cpu-sh5/cache.h
@@ -1,33 +1,30 @@
1#ifndef __ASM_SH64_CACHE_H 1#ifndef __ASM_SH_CPU_SH5_CACHE_H
2#define __ASM_SH64_CACHE_H 2#define __ASM_SH_CPU_SH5_CACHE_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/cpu-sh5/cache.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/cache.h
10 * 6 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 7 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003, 2004 Paul Mundt 8 * Copyright (C) 2003, 2004 Paul Mundt
13 * 9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
14 */ 13 */
15#include <asm/cacheflush.h>
16 14
17#define L1_CACHE_SHIFT 5 15#define L1_CACHE_SHIFT 5
18/* bytes per L1 cache line */ 16
19#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 17/* Valid and Dirty bits */
20#define L1_CACHE_ALIGN_MASK (~(L1_CACHE_BYTES - 1)) 18#define SH_CACHE_VALID (1LL<<0)
21#define L1_CACHE_ALIGN(x) (((x)+(L1_CACHE_BYTES - 1)) & L1_CACHE_ALIGN_MASK) 19#define SH_CACHE_UPDATED (1LL<<57)
22#define L1_CACHE_SIZE_BYTES (L1_CACHE_BYTES << 10) 20
23 21/* Unimplemented compat bits.. */
24#ifdef MODULE 22#define SH_CACHE_COMBINED 0
25#define __cacheline_aligned __attribute__((__aligned__(L1_CACHE_BYTES))) 23#define SH_CACHE_ASSOC 0
26#else 24
27#define __cacheline_aligned \ 25/* Cache flags */
28 __attribute__((__aligned__(L1_CACHE_BYTES), \ 26#define SH_CACHE_MODE_WT (1LL<<0)
29 __section__(".data.cacheline_aligned"))) 27#define SH_CACHE_MODE_WB (1LL<<1)
30#endif
31 28
32/* 29/*
33 * Control Registers. 30 * Control Registers.
@@ -58,7 +55,6 @@
58 55
59#define OCCR1_NOLOCK 0x0 /* Set No Locking */ 56#define OCCR1_NOLOCK 0x0 /* Set No Locking */
60 57
61
62/* 58/*
63 * SH-5 59 * SH-5
64 * A bit of description here, for neff=32. 60 * A bit of description here, for neff=32.
@@ -77,43 +73,6 @@
77 * 73 *
78 */ 74 */
79 75
80/* Valid and Dirty bits */
81#define SH_CACHE_VALID (1LL<<0)
82#define SH_CACHE_UPDATED (1LL<<57)
83
84/* Cache flags */
85#define SH_CACHE_MODE_WT (1LL<<0)
86#define SH_CACHE_MODE_WB (1LL<<1)
87
88#ifndef __ASSEMBLY__
89
90/*
91 * Cache information structure.
92 *
93 * Defined for both I and D cache, per-processor.
94 */
95struct cache_info {
96 unsigned int ways;
97 unsigned int sets;
98 unsigned int linesz;
99
100 unsigned int way_shift;
101 unsigned int entry_shift;
102 unsigned int set_shift;
103 unsigned int way_step_shift;
104 unsigned int asid_shift;
105
106 unsigned int way_ofs;
107
108 unsigned int asid_mask;
109 unsigned int idx_mask;
110 unsigned int epn_mask;
111
112 unsigned long flags;
113};
114
115#endif /* __ASSEMBLY__ */
116
117/* Instruction cache */ 76/* Instruction cache */
118#define CACHE_IC_ADDRESS_ARRAY 0x01000000 77#define CACHE_IC_ADDRESS_ARRAY 0x01000000
119 78
@@ -130,10 +89,9 @@ struct cache_info {
130/* Mask to select synonym bit(s) */ 89/* Mask to select synonym bit(s) */
131#define CACHE_OC_SYN_MASK (((1UL<<CACHE_OC_N_SYNBITS)-1)<<CACHE_OC_SYN_SHIFT) 90#define CACHE_OC_SYN_MASK (((1UL<<CACHE_OC_N_SYNBITS)-1)<<CACHE_OC_SYN_SHIFT)
132 91
133
134/* 92/*
135 * Instruction cache can't be invalidated based on physical addresses. 93 * Instruction cache can't be invalidated based on physical addresses.
136 * No Instruction Cache defines required, then. 94 * No Instruction Cache defines required, then.
137 */ 95 */
138 96
139#endif /* __ASM_SH64_CACHE_H */ 97#endif /* __ASM_SH_CPU_SH5_CACHE_H */
diff --git a/include/asm-sh64/cacheflush.h b/include/asm-sh/cpu-sh5/cacheflush.h
index 1e53a47bdc97..98edb5b1da32 100644
--- a/include/asm-sh64/cacheflush.h
+++ b/include/asm-sh/cpu-sh5/cacheflush.h
@@ -1,5 +1,5 @@
1#ifndef __ASM_SH64_CACHEFLUSH_H 1#ifndef __ASM_SH_CPU_SH5_CACHEFLUSH_H
2#define __ASM_SH64_CACHEFLUSH_H 2#define __ASM_SH_CPU_SH5_CACHEFLUSH_H
3 3
4#ifndef __ASSEMBLY__ 4#ifndef __ASSEMBLY__
5 5
@@ -26,25 +26,10 @@ extern void flush_icache_user_range(struct vm_area_struct *vma,
26#define flush_dcache_mmap_lock(mapping) do { } while (0) 26#define flush_dcache_mmap_lock(mapping) do { } while (0)
27#define flush_dcache_mmap_unlock(mapping) do { } while (0) 27#define flush_dcache_mmap_unlock(mapping) do { } while (0)
28 28
29#define flush_cache_vmap(start, end) flush_cache_all()
30#define flush_cache_vunmap(start, end) flush_cache_all()
31
32#define flush_icache_page(vma, page) do { } while (0) 29#define flush_icache_page(vma, page) do { } while (0)
33 30#define p3_cache_init() do { } while (0)
34#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
35 do { \
36 flush_cache_page(vma, vaddr, page_to_pfn(page));\
37 memcpy(dst, src, len); \
38 flush_icache_user_range(vma, page, vaddr, len); \
39 } while (0)
40
41#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
42 do { \
43 flush_cache_page(vma, vaddr, page_to_pfn(page));\
44 memcpy(dst, src, len); \
45 } while (0)
46 31
47#endif /* __ASSEMBLY__ */ 32#endif /* __ASSEMBLY__ */
48 33
49#endif /* __ASM_SH64_CACHEFLUSH_H */ 34#endif /* __ASM_SH_CPU_SH5_CACHEFLUSH_H */
50 35
diff --git a/include/asm-sh/cpu-sh5/dma.h b/include/asm-sh/cpu-sh5/dma.h
new file mode 100644
index 000000000000..7bf6bb3d35ed
--- /dev/null
+++ b/include/asm-sh/cpu-sh5/dma.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_SH_CPU_SH5_DMA_H
2#define __ASM_SH_CPU_SH5_DMA_H
3
4/* Nothing yet */
5
6#endif /* __ASM_SH_CPU_SH5_DMA_H */
diff --git a/include/asm-sh64/irq.h b/include/asm-sh/cpu-sh5/irq.h
index 5c9e6a873aeb..f0f0756e6e84 100644
--- a/include/asm-sh64/irq.h
+++ b/include/asm-sh/cpu-sh5/irq.h
@@ -1,15 +1,14 @@
1#ifndef __ASM_SH64_IRQ_H 1#ifndef __ASM_SH_CPU_SH5_IRQ_H
2#define __ASM_SH64_IRQ_H 2#define __ASM_SH_CPU_SH5_IRQ_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/cpu-sh5/irq.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/irq.h
10 * 6 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 7 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * 8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
13 */ 12 */
14 13
15 14
@@ -92,9 +91,6 @@
92#define NR_EXT_IRQS 0 91#define NR_EXT_IRQS 0
93#endif 92#endif
94 93
95#define NR_IRQS (NR_INTC_IRQS+NR_EXT_IRQS)
96
97
98/* Default IRQs, fixed */ 94/* Default IRQs, fixed */
99#define TIMER_IRQ IRQ_TUNI0 95#define TIMER_IRQ IRQ_TUNI0
100#define RTC_IRQ IRQ_CUI 96#define RTC_IRQ IRQ_CUI
@@ -116,29 +112,6 @@
116 112
117extern int intc_evt_to_irq[(0xE20/0x20)+1]; 113extern int intc_evt_to_irq[(0xE20/0x20)+1];
118int intc_irq_describe(char* p, int irq); 114int intc_irq_describe(char* p, int irq);
115extern int platform_int_priority[NR_INTC_IRQS];
119 116
120#define irq_canonicalize(irq) (irq) 117#endif /* __ASM_SH_CPU_SH5_IRQ_H */
121
122#ifdef CONFIG_SH_CAYMAN
123int cayman_irq_demux(int evt);
124int cayman_irq_describe(char* p, int irq);
125#define irq_demux(x) cayman_irq_demux(x)
126#define irq_describe(p, x) cayman_irq_describe(p, x)
127#else
128#define irq_demux(x) (intc_evt_to_irq[x])
129#define irq_describe(p, x) intc_irq_describe(p, x)
130#endif
131
132/*
133 * Function for "on chip support modules".
134 */
135
136/*
137 * SH-5 supports Priority based interrupts only.
138 * Interrupt priorities are defined at platform level.
139 */
140#define set_ipr_data(a, b, c, d)
141#define make_ipr_irq(a)
142#define make_imask_irq(a)
143
144#endif /* __ASM_SH64_IRQ_H */
diff --git a/include/asm-sh/cpu-sh5/mmu_context.h b/include/asm-sh/cpu-sh5/mmu_context.h
new file mode 100644
index 000000000000..df857fc09960
--- /dev/null
+++ b/include/asm-sh/cpu-sh5/mmu_context.h
@@ -0,0 +1,27 @@
1#ifndef __ASM_SH_CPU_SH5_MMU_CONTEXT_H
2#define __ASM_SH_CPU_SH5_MMU_CONTEXT_H
3
4/* Common defines */
5#define TLB_STEP 0x00000010
6#define TLB_PTEH 0x00000000
7#define TLB_PTEL 0x00000008
8
9/* PTEH defines */
10#define PTEH_ASID_SHIFT 2
11#define PTEH_VALID 0x0000000000000001
12#define PTEH_SHARED 0x0000000000000002
13#define PTEH_MATCH_ASID 0x00000000000003ff
14
15#ifndef __ASSEMBLY__
16/* This has to be a common function because the next location to fill
17 * information is shared. */
18extern void __do_tlb_refill(unsigned long address, unsigned long long is_text_not_data, pte_t *pte);
19
20/* Profiling counter. */
21#ifdef CONFIG_SH64_PROC_TLB
22extern unsigned long long calls_to_do_fast_page_fault;
23#endif
24
25#endif /* __ASSEMBLY__ */
26
27#endif /* __ASM_SH_CPU_SH5_MMU_CONTEXT_H */
diff --git a/include/asm-sh64/registers.h b/include/asm-sh/cpu-sh5/registers.h
index 7eec666acf84..6664ea6f1566 100644
--- a/include/asm-sh64/registers.h
+++ b/include/asm-sh/cpu-sh5/registers.h
@@ -1,15 +1,15 @@
1#ifndef __ASM_SH64_REGISTERS_H 1#ifndef __ASM_SH_CPU_SH5_REGISTERS_H
2#define __ASM_SH64_REGISTERS_H 2#define __ASM_SH_CPU_SH5_REGISTERS_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/cpu-sh5/registers.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/registers.h
10 * 6 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 7 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2004 Richard Curnow 8 * Copyright (C) 2004 Richard Curnow
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */ 13 */
14 14
15#ifdef __ASSEMBLY__ 15#ifdef __ASSEMBLY__
@@ -103,4 +103,4 @@
103#define __USR __str(USR) 103#define __USR __str(USR)
104 104
105#endif /* __ASSEMBLY__ */ 105#endif /* __ASSEMBLY__ */
106#endif /* __ASM_SH64_REGISTERS_H */ 106#endif /* __ASM_SH_CPU_SH5_REGISTERS_H */
diff --git a/include/asm-sh/cpu-sh5/rtc.h b/include/asm-sh/cpu-sh5/rtc.h
new file mode 100644
index 000000000000..12ea0ed144e1
--- /dev/null
+++ b/include/asm-sh/cpu-sh5/rtc.h
@@ -0,0 +1,8 @@
1#ifndef __ASM_SH_CPU_SH5_RTC_H
2#define __ASM_SH_CPU_SH5_RTC_H
3
4#define rtc_reg_size sizeof(u32)
5#define RTC_BIT_INVERTED 0 /* The SH-5 RTC is surprisingly sane! */
6#define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR
7
8#endif /* __ASM_SH_CPU_SH5_RTC_H */
diff --git a/include/asm-sh/cpu-sh5/timer.h b/include/asm-sh/cpu-sh5/timer.h
new file mode 100644
index 000000000000..88da9b341a36
--- /dev/null
+++ b/include/asm-sh/cpu-sh5/timer.h
@@ -0,0 +1,4 @@
1#ifndef __ASM_SH_CPU_SH5_TIMER_H
2#define __ASM_SH_CPU_SH5_TIMER_H
3
4#endif /* __ASM_SH_CPU_SH5_TIMER_H */
diff --git a/include/asm-sh/delay.h b/include/asm-sh/delay.h
index db599b2a5a9c..031db84f2aa1 100644
--- a/include/asm-sh/delay.h
+++ b/include/asm-sh/delay.h
@@ -6,7 +6,7 @@
6 * 6 *
7 * Delay routines calling functions in arch/sh/lib/delay.c 7 * Delay routines calling functions in arch/sh/lib/delay.c
8 */ 8 */
9 9
10extern void __bad_udelay(void); 10extern void __bad_udelay(void);
11extern void __bad_ndelay(void); 11extern void __bad_ndelay(void);
12 12
@@ -15,13 +15,17 @@ extern void __ndelay(unsigned long nsecs);
15extern void __const_udelay(unsigned long usecs); 15extern void __const_udelay(unsigned long usecs);
16extern void __delay(unsigned long loops); 16extern void __delay(unsigned long loops);
17 17
18#ifdef CONFIG_SUPERH32
18#define udelay(n) (__builtin_constant_p(n) ? \ 19#define udelay(n) (__builtin_constant_p(n) ? \
19 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \ 20 ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \
20 __udelay(n)) 21 __udelay(n))
21 22
22
23#define ndelay(n) (__builtin_constant_p(n) ? \ 23#define ndelay(n) (__builtin_constant_p(n) ? \
24 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \ 24 ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
25 __ndelay(n)) 25 __ndelay(n))
26#else
27extern void udelay(unsigned long usecs);
28extern void ndelay(unsigned long nsecs);
29#endif
26 30
27#endif /* __ASM_SH_DELAY_H */ 31#endif /* __ASM_SH_DELAY_H */
diff --git a/include/asm-sh/dma-mapping.h b/include/asm-sh/dma-mapping.h
index fcea067f7a9c..22cc419389fe 100644
--- a/include/asm-sh/dma-mapping.h
+++ b/include/asm-sh/dma-mapping.h
@@ -8,11 +8,6 @@
8 8
9extern struct bus_type pci_bus_type; 9extern struct bus_type pci_bus_type;
10 10
11/* arch/sh/mm/consistent.c */
12extern void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *handle);
13extern void consistent_free(void *vaddr, size_t size);
14extern void consistent_sync(void *vaddr, size_t size, int direction);
15
16#define dma_supported(dev, mask) (1) 11#define dma_supported(dev, mask) (1)
17 12
18static inline int dma_set_mask(struct device *dev, u64 mask) 13static inline int dma_set_mask(struct device *dev, u64 mask)
@@ -25,44 +20,19 @@ static inline int dma_set_mask(struct device *dev, u64 mask)
25 return 0; 20 return 0;
26} 21}
27 22
28static inline void *dma_alloc_coherent(struct device *dev, size_t size, 23void *dma_alloc_coherent(struct device *dev, size_t size,
29 dma_addr_t *dma_handle, gfp_t flag) 24 dma_addr_t *dma_handle, gfp_t flag);
30{
31 if (sh_mv.mv_consistent_alloc) {
32 void *ret;
33 25
34 ret = sh_mv.mv_consistent_alloc(dev, size, dma_handle, flag); 26void dma_free_coherent(struct device *dev, size_t size,
35 if (ret != NULL) 27 void *vaddr, dma_addr_t dma_handle);
36 return ret;
37 }
38
39 return consistent_alloc(flag, size, dma_handle);
40}
41
42static inline void dma_free_coherent(struct device *dev, size_t size,
43 void *vaddr, dma_addr_t dma_handle)
44{
45 if (sh_mv.mv_consistent_free) {
46 int ret;
47
48 ret = sh_mv.mv_consistent_free(dev, size, vaddr, dma_handle);
49 if (ret == 0)
50 return;
51 }
52 28
53 consistent_free(vaddr, size); 29void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
54} 30 enum dma_data_direction dir);
55 31
56#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 32#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
57#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 33#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
58#define dma_is_consistent(d, h) (1) 34#define dma_is_consistent(d, h) (1)
59 35
60static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
61 enum dma_data_direction dir)
62{
63 consistent_sync(vaddr, size, (int)dir);
64}
65
66static inline dma_addr_t dma_map_single(struct device *dev, 36static inline dma_addr_t dma_map_single(struct device *dev,
67 void *ptr, size_t size, 37 void *ptr, size_t size,
68 enum dma_data_direction dir) 38 enum dma_data_direction dir)
@@ -205,4 +175,18 @@ static inline int dma_mapping_error(dma_addr_t dma_addr)
205{ 175{
206 return dma_addr == 0; 176 return dma_addr == 0;
207} 177}
178
179#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
180
181extern int
182dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
183 dma_addr_t device_addr, size_t size, int flags);
184
185extern void
186dma_release_declared_memory(struct device *dev);
187
188extern void *
189dma_mark_declared_memory_occupied(struct device *dev,
190 dma_addr_t device_addr, size_t size);
191
208#endif /* __ASM_SH_DMA_MAPPING_H */ 192#endif /* __ASM_SH_DMA_MAPPING_H */
diff --git a/include/asm-sh/elf.h b/include/asm-sh/elf.h
index 12cc4b392bf0..05092da1aa59 100644
--- a/include/asm-sh/elf.h
+++ b/include/asm-sh/elf.h
@@ -5,7 +5,7 @@
5#include <asm/ptrace.h> 5#include <asm/ptrace.h>
6#include <asm/user.h> 6#include <asm/user.h>
7 7
8/* SH relocation types */ 8/* SH (particularly SHcompact) relocation types */
9#define R_SH_NONE 0 9#define R_SH_NONE 0
10#define R_SH_DIR32 1 10#define R_SH_DIR32 1
11#define R_SH_REL32 2 11#define R_SH_REL32 2
@@ -43,6 +43,11 @@
43#define R_SH_RELATIVE 165 43#define R_SH_RELATIVE 165
44#define R_SH_GOTOFF 166 44#define R_SH_GOTOFF 166
45#define R_SH_GOTPC 167 45#define R_SH_GOTPC 167
46/* SHmedia relocs */
47#define R_SH_IMM_LOW16 246
48#define R_SH_IMM_LOW16_PCREL 247
49#define R_SH_IMM_MEDLOW16 248
50#define R_SH_IMM_MEDLOW16_PCREL 249
46/* Keep this the last entry. */ 51/* Keep this the last entry. */
47#define R_SH_NUM 256 52#define R_SH_NUM 256
48 53
@@ -58,11 +63,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG];
58typedef struct user_fpu_struct elf_fpregset_t; 63typedef struct user_fpu_struct elf_fpregset_t;
59 64
60/* 65/*
61 * This is used to ensure we don't load something for the wrong architecture.
62 */
63#define elf_check_arch(x) ( (x)->e_machine == EM_SH )
64
65/*
66 * These are used to set parameters in the core dumps. 66 * These are used to set parameters in the core dumps.
67 */ 67 */
68#define ELF_CLASS ELFCLASS32 68#define ELF_CLASS ELFCLASS32
@@ -73,6 +73,12 @@ typedef struct user_fpu_struct elf_fpregset_t;
73#endif 73#endif
74#define ELF_ARCH EM_SH 74#define ELF_ARCH EM_SH
75 75
76#ifdef __KERNEL__
77/*
78 * This is used to ensure we don't load something for the wrong architecture.
79 */
80#define elf_check_arch(x) ( (x)->e_machine == EM_SH )
81
76#define USE_ELF_CORE_DUMP 82#define USE_ELF_CORE_DUMP
77#define ELF_EXEC_PAGESIZE PAGE_SIZE 83#define ELF_EXEC_PAGESIZE PAGE_SIZE
78 84
@@ -83,7 +89,6 @@ typedef struct user_fpu_struct elf_fpregset_t;
83 89
84#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3) 90#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
85 91
86
87#define ELF_CORE_COPY_REGS(_dest,_regs) \ 92#define ELF_CORE_COPY_REGS(_dest,_regs) \
88 memcpy((char *) &_dest, (char *) _regs, \ 93 memcpy((char *) &_dest, (char *) _regs, \
89 sizeof(struct pt_regs)); 94 sizeof(struct pt_regs));
@@ -101,16 +106,38 @@ typedef struct user_fpu_struct elf_fpregset_t;
101 For the moment, we have only optimizations for the Intel generations, 106 For the moment, we have only optimizations for the Intel generations,
102 but that could change... */ 107 but that could change... */
103 108
104#define ELF_PLATFORM (NULL) 109#define ELF_PLATFORM (utsname()->machine)
105 110
111#ifdef __SH5__
112#define ELF_PLAT_INIT(_r, load_addr) \
113 do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \
114 _r->regs[4]=0; _r->regs[5]=0; _r->regs[6]=0; _r->regs[7]=0; \
115 _r->regs[8]=0; _r->regs[9]=0; _r->regs[10]=0; _r->regs[11]=0; \
116 _r->regs[12]=0; _r->regs[13]=0; _r->regs[14]=0; _r->regs[15]=0; \
117 _r->regs[16]=0; _r->regs[17]=0; _r->regs[18]=0; _r->regs[19]=0; \
118 _r->regs[20]=0; _r->regs[21]=0; _r->regs[22]=0; _r->regs[23]=0; \
119 _r->regs[24]=0; _r->regs[25]=0; _r->regs[26]=0; _r->regs[27]=0; \
120 _r->regs[28]=0; _r->regs[29]=0; _r->regs[30]=0; _r->regs[31]=0; \
121 _r->regs[32]=0; _r->regs[33]=0; _r->regs[34]=0; _r->regs[35]=0; \
122 _r->regs[36]=0; _r->regs[37]=0; _r->regs[38]=0; _r->regs[39]=0; \
123 _r->regs[40]=0; _r->regs[41]=0; _r->regs[42]=0; _r->regs[43]=0; \
124 _r->regs[44]=0; _r->regs[45]=0; _r->regs[46]=0; _r->regs[47]=0; \
125 _r->regs[48]=0; _r->regs[49]=0; _r->regs[50]=0; _r->regs[51]=0; \
126 _r->regs[52]=0; _r->regs[53]=0; _r->regs[54]=0; _r->regs[55]=0; \
127 _r->regs[56]=0; _r->regs[57]=0; _r->regs[58]=0; _r->regs[59]=0; \
128 _r->regs[60]=0; _r->regs[61]=0; _r->regs[62]=0; \
129 _r->tregs[0]=0; _r->tregs[1]=0; _r->tregs[2]=0; _r->tregs[3]=0; \
130 _r->tregs[4]=0; _r->tregs[5]=0; _r->tregs[6]=0; _r->tregs[7]=0; \
131 _r->sr = SR_FD | SR_MMU; } while (0)
132#else
106#define ELF_PLAT_INIT(_r, load_addr) \ 133#define ELF_PLAT_INIT(_r, load_addr) \
107 do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \ 134 do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \
108 _r->regs[4]=0; _r->regs[5]=0; _r->regs[6]=0; _r->regs[7]=0; \ 135 _r->regs[4]=0; _r->regs[5]=0; _r->regs[6]=0; _r->regs[7]=0; \
109 _r->regs[8]=0; _r->regs[9]=0; _r->regs[10]=0; _r->regs[11]=0; \ 136 _r->regs[8]=0; _r->regs[9]=0; _r->regs[10]=0; _r->regs[11]=0; \
110 _r->regs[12]=0; _r->regs[13]=0; _r->regs[14]=0; \ 137 _r->regs[12]=0; _r->regs[13]=0; _r->regs[14]=0; \
111 _r->sr = SR_FD; } while (0) 138 _r->sr = SR_FD; } while (0)
139#endif
112 140
113#ifdef __KERNEL__
114#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT) 141#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT)
115struct task_struct; 142struct task_struct;
116extern int dump_task_regs (struct task_struct *, elf_gregset_t *); 143extern int dump_task_regs (struct task_struct *, elf_gregset_t *);
@@ -118,7 +145,6 @@ extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
118 145
119#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) 146#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
120#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) 147#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
121#endif
122 148
123#ifdef CONFIG_VSYSCALL 149#ifdef CONFIG_VSYSCALL
124/* vDSO has arch_setup_additional_pages */ 150/* vDSO has arch_setup_additional_pages */
@@ -133,12 +159,35 @@ extern void __kernel_vsyscall;
133#define VDSO_BASE ((unsigned long)current->mm->context.vdso) 159#define VDSO_BASE ((unsigned long)current->mm->context.vdso)
134#define VDSO_SYM(x) (VDSO_BASE + (unsigned long)(x)) 160#define VDSO_SYM(x) (VDSO_BASE + (unsigned long)(x))
135 161
162#define VSYSCALL_AUX_ENT \
163 if (vdso_enabled) \
164 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE);
165#else
166#define VSYSCALL_AUX_ENT
167#endif /* CONFIG_VSYSCALL */
168
169#ifdef CONFIG_SH_FPU
170#define FPU_AUX_ENT NEW_AUX_ENT(AT_FPUCW, FPSCR_INIT)
171#else
172#define FPU_AUX_ENT
173#endif
174
175extern int l1i_cache_shape, l1d_cache_shape, l2_cache_shape;
176
136/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ 177/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
137#define ARCH_DLINFO \ 178#define ARCH_DLINFO \
138do { \ 179do { \
139 if (vdso_enabled) \ 180 /* Optional FPU initialization */ \
140 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_BASE); \ 181 FPU_AUX_ENT; \
182 \
183 /* Optional vsyscall entry */ \
184 VSYSCALL_AUX_ENT; \
185 \
186 /* Cache desc */ \
187 NEW_AUX_ENT(AT_L1I_CACHESHAPE, l1i_cache_shape); \
188 NEW_AUX_ENT(AT_L1D_CACHESHAPE, l1d_cache_shape); \
189 NEW_AUX_ENT(AT_L2_CACHESHAPE, l2_cache_shape); \
141} while (0) 190} while (0)
142#endif /* CONFIG_VSYSCALL */
143 191
192#endif /* __KERNEL__ */
144#endif /* __ASM_SH_ELF_H */ 193#endif /* __ASM_SH_ELF_H */
diff --git a/include/asm-sh/fixmap.h b/include/asm-sh/fixmap.h
index 8a566177ad96..721fcc4d5e98 100644
--- a/include/asm-sh/fixmap.h
+++ b/include/asm-sh/fixmap.h
@@ -49,6 +49,7 @@ enum fixed_addresses {
49#define FIX_N_COLOURS 16 49#define FIX_N_COLOURS 16
50 FIX_CMAP_BEGIN, 50 FIX_CMAP_BEGIN,
51 FIX_CMAP_END = FIX_CMAP_BEGIN + FIX_N_COLOURS, 51 FIX_CMAP_END = FIX_CMAP_BEGIN + FIX_N_COLOURS,
52 FIX_UNCACHED,
52#ifdef CONFIG_HIGHMEM 53#ifdef CONFIG_HIGHMEM
53 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 54 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
54 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 55 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
@@ -73,7 +74,11 @@ extern void __set_fixmap(enum fixed_addresses idx,
73 * the start of the fixmap, and leave one page empty 74 * the start of the fixmap, and leave one page empty
74 * at the top of mem.. 75 * at the top of mem..
75 */ 76 */
77#ifdef CONFIG_SUPERH32
76#define FIXADDR_TOP (P4SEG - PAGE_SIZE) 78#define FIXADDR_TOP (P4SEG - PAGE_SIZE)
79#else
80#define FIXADDR_TOP (0xff000000 - PAGE_SIZE)
81#endif
77#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) 82#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
78#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) 83#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
79 84
diff --git a/include/asm-sh/flat.h b/include/asm-sh/flat.h
index dc4f5950dafa..0cc800299e06 100644
--- a/include/asm-sh/flat.h
+++ b/include/asm-sh/flat.h
@@ -19,6 +19,6 @@
19#define flat_get_addr_from_rp(rp, relval, flags, p) get_unaligned(rp) 19#define flat_get_addr_from_rp(rp, relval, flags, p) get_unaligned(rp)
20#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp) 20#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp)
21#define flat_get_relocate_addr(rel) (rel) 21#define flat_get_relocate_addr(rel) (rel)
22#define flat_set_persistent(relval, p) 0 22#define flat_set_persistent(relval, p) ({ (void)p; 0; })
23 23
24#endif /* __ASM_SH_FLAT_H */ 24#endif /* __ASM_SH_FLAT_H */
diff --git a/include/asm-sh/fpu.h b/include/asm-sh/fpu.h
new file mode 100644
index 000000000000..f8429880a270
--- /dev/null
+++ b/include/asm-sh/fpu.h
@@ -0,0 +1,46 @@
1#ifndef __ASM_SH_FPU_H
2#define __ASM_SH_FPU_H
3
4#define SR_FD 0x00008000
5
6#ifndef __ASSEMBLY__
7#include <asm/ptrace.h>
8
9#ifdef CONFIG_SH_FPU
10static inline void release_fpu(struct pt_regs *regs)
11{
12 regs->sr |= SR_FD;
13}
14
15static inline void grab_fpu(struct pt_regs *regs)
16{
17 regs->sr &= ~SR_FD;
18}
19
20struct task_struct;
21
22extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
23#else
24#define release_fpu(regs) do { } while (0)
25#define grab_fpu(regs) do { } while (0)
26#define save_fpu(tsk, regs) do { } while (0)
27#endif
28
29extern int do_fpu_inst(unsigned short, struct pt_regs *);
30
31#define unlazy_fpu(tsk, regs) do { \
32 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
33 save_fpu(tsk, regs); \
34 } \
35} while (0)
36
37#define clear_fpu(tsk, regs) do { \
38 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
39 clear_tsk_thread_flag(tsk, TIF_USEDFPU); \
40 release_fpu(regs); \
41 } \
42} while (0)
43
44#endif /* __ASSEMBLY__ */
45
46#endif /* __ASM_SH_FPU_H */
diff --git a/include/asm-sh/hd64461.h b/include/asm-sh/hd64461.h
index 342ca55a266a..8c1353baf00f 100644
--- a/include/asm-sh/hd64461.h
+++ b/include/asm-sh/hd64461.h
@@ -46,10 +46,10 @@
46/* CPU Data Bus Control Register */ 46/* CPU Data Bus Control Register */
47#define HD64461_SCPUCR (CONFIG_HD64461_IOBASE + 0x04) 47#define HD64461_SCPUCR (CONFIG_HD64461_IOBASE + 0x04)
48 48
49/* Base Adress Register */ 49/* Base Address Register */
50#define HD64461_LCDCBAR (CONFIG_HD64461_IOBASE + 0x1000) 50#define HD64461_LCDCBAR (CONFIG_HD64461_IOBASE + 0x1000)
51 51
52/* Line increment adress */ 52/* Line increment address */
53#define HD64461_LCDCLOR (CONFIG_HD64461_IOBASE + 0x1002) 53#define HD64461_LCDCLOR (CONFIG_HD64461_IOBASE + 0x1002)
54 54
55/* Controls LCD controller */ 55/* Controls LCD controller */
@@ -80,9 +80,9 @@
80#define HD64461_LDR3 (CONFIG_HD64461_IOBASE + 0x101e) 80#define HD64461_LDR3 (CONFIG_HD64461_IOBASE + 0x101e)
81 81
82/* Palette Registers */ 82/* Palette Registers */
83#define HD64461_CPTWAR (CONFIG_HD64461_IOBASE + 0x1030) /* Color Palette Write Adress Register */ 83#define HD64461_CPTWAR (CONFIG_HD64461_IOBASE + 0x1030) /* Color Palette Write Address Register */
84#define HD64461_CPTWDR (CONFIG_HD64461_IOBASE + 0x1032) /* Color Palette Write Data Register */ 84#define HD64461_CPTWDR (CONFIG_HD64461_IOBASE + 0x1032) /* Color Palette Write Data Register */
85#define HD64461_CPTRAR (CONFIG_HD64461_IOBASE + 0x1034) /* Color Palette Read Adress Register */ 85#define HD64461_CPTRAR (CONFIG_HD64461_IOBASE + 0x1034) /* Color Palette Read Address Register */
86#define HD64461_CPTRDR (CONFIG_HD64461_IOBASE + 0x1036) /* Color Palette Read Data Register */ 86#define HD64461_CPTRDR (CONFIG_HD64461_IOBASE + 0x1036) /* Color Palette Read Data Register */
87 87
88#define HD64461_GRDOR (CONFIG_HD64461_IOBASE + 0x1040) /* Display Resolution Offset Register */ 88#define HD64461_GRDOR (CONFIG_HD64461_IOBASE + 0x1040) /* Display Resolution Offset Register */
@@ -97,8 +97,8 @@
97#define HD64461_GRCFGR_COLORDEPTH8 0x01 /* Sets Colordepth 8 for Accelerator */ 97#define HD64461_GRCFGR_COLORDEPTH8 0x01 /* Sets Colordepth 8 for Accelerator */
98 98
99/* Line Drawing Registers */ 99/* Line Drawing Registers */
100#define HD64461_LNSARH (CONFIG_HD64461_IOBASE + 0x1046) /* Line Start Adress Register (H) */ 100#define HD64461_LNSARH (CONFIG_HD64461_IOBASE + 0x1046) /* Line Start Address Register (H) */
101#define HD64461_LNSARL (CONFIG_HD64461_IOBASE + 0x1048) /* Line Start Adress Register (L) */ 101#define HD64461_LNSARL (CONFIG_HD64461_IOBASE + 0x1048) /* Line Start Address Register (L) */
102#define HD64461_LNAXLR (CONFIG_HD64461_IOBASE + 0x104a) /* Axis Pixel Length Register */ 102#define HD64461_LNAXLR (CONFIG_HD64461_IOBASE + 0x104a) /* Axis Pixel Length Register */
103#define HD64461_LNDGR (CONFIG_HD64461_IOBASE + 0x104c) /* Diagonal Register */ 103#define HD64461_LNDGR (CONFIG_HD64461_IOBASE + 0x104c) /* Diagonal Register */
104#define HD64461_LNAXR (CONFIG_HD64461_IOBASE + 0x104e) /* Axial Register */ 104#define HD64461_LNAXR (CONFIG_HD64461_IOBASE + 0x104e) /* Axial Register */
@@ -106,16 +106,16 @@
106#define HD64461_LNMDR (CONFIG_HD64461_IOBASE + 0x1052) /* Line Mode Register */ 106#define HD64461_LNMDR (CONFIG_HD64461_IOBASE + 0x1052) /* Line Mode Register */
107 107
108/* BitBLT Registers */ 108/* BitBLT Registers */
109#define HD64461_BBTSSARH (CONFIG_HD64461_IOBASE + 0x1054) /* Source Start Adress Register (H) */ 109#define HD64461_BBTSSARH (CONFIG_HD64461_IOBASE + 0x1054) /* Source Start Address Register (H) */
110#define HD64461_BBTSSARL (CONFIG_HD64461_IOBASE + 0x1056) /* Source Start Adress Register (L) */ 110#define HD64461_BBTSSARL (CONFIG_HD64461_IOBASE + 0x1056) /* Source Start Address Register (L) */
111#define HD64461_BBTDSARH (CONFIG_HD64461_IOBASE + 0x1058) /* Destination Start Adress Register (H) */ 111#define HD64461_BBTDSARH (CONFIG_HD64461_IOBASE + 0x1058) /* Destination Start Address Register (H) */
112#define HD64461_BBTDSARL (CONFIG_HD64461_IOBASE + 0x105a) /* Destination Start Adress Register (L) */ 112#define HD64461_BBTDSARL (CONFIG_HD64461_IOBASE + 0x105a) /* Destination Start Address Register (L) */
113#define HD64461_BBTDWR (CONFIG_HD64461_IOBASE + 0x105c) /* Destination Block Width Register */ 113#define HD64461_BBTDWR (CONFIG_HD64461_IOBASE + 0x105c) /* Destination Block Width Register */
114#define HD64461_BBTDHR (CONFIG_HD64461_IOBASE + 0x105e) /* Destination Block Height Register */ 114#define HD64461_BBTDHR (CONFIG_HD64461_IOBASE + 0x105e) /* Destination Block Height Register */
115#define HD64461_BBTPARH (CONFIG_HD64461_IOBASE + 0x1060) /* Pattern Start Adress Register (H) */ 115#define HD64461_BBTPARH (CONFIG_HD64461_IOBASE + 0x1060) /* Pattern Start Address Register (H) */
116#define HD64461_BBTPARL (CONFIG_HD64461_IOBASE + 0x1062) /* Pattern Start Adress Register (L) */ 116#define HD64461_BBTPARL (CONFIG_HD64461_IOBASE + 0x1062) /* Pattern Start Address Register (L) */
117#define HD64461_BBTMARH (CONFIG_HD64461_IOBASE + 0x1064) /* Mask Start Adress Register (H) */ 117#define HD64461_BBTMARH (CONFIG_HD64461_IOBASE + 0x1064) /* Mask Start Address Register (H) */
118#define HD64461_BBTMARL (CONFIG_HD64461_IOBASE + 0x1066) /* Mask Start Adress Register (L) */ 118#define HD64461_BBTMARL (CONFIG_HD64461_IOBASE + 0x1066) /* Mask Start Address Register (L) */
119#define HD64461_BBTROPR (CONFIG_HD64461_IOBASE + 0x1068) /* ROP Register */ 119#define HD64461_BBTROPR (CONFIG_HD64461_IOBASE + 0x1068) /* ROP Register */
120#define HD64461_BBTMDR (CONFIG_HD64461_IOBASE + 0x106a) /* BitBLT Mode Register */ 120#define HD64461_BBTMDR (CONFIG_HD64461_IOBASE + 0x106a) /* BitBLT Mode Register */
121 121
diff --git a/include/asm-sh/hs7751rvoip.h b/include/asm-sh/hs7751rvoip.h
deleted file mode 100644
index c4cff9d33927..000000000000
--- a/include/asm-sh/hs7751rvoip.h
+++ /dev/null
@@ -1,54 +0,0 @@
1#ifndef __ASM_SH_RENESAS_HS7751RVOIP_H
2#define __ASM_SH_RENESAS_HS7751RVOIP_H
3
4/*
5 * linux/include/asm-sh/hs7751rvoip/hs7751rvoip.h
6 *
7 * Copyright (C) 2000 Atom Create Engineering Co., Ltd.
8 *
9 * Renesas Technology Sales HS7751RVoIP support
10 */
11
12/* Box specific addresses. */
13
14#define PA_BCR 0xa4000000 /* FPGA */
15#define PA_SLICCNTR1 0xa4000006 /* SLIC PIO Control 1 */
16#define PA_SLICCNTR2 0xa4000008 /* SLIC PIO Control 2 */
17#define PA_DMACNTR 0xa400000a /* USB DMA Control */
18#define PA_INPORTR 0xa400000c /* Input Port Register */
19#define PA_OUTPORTR 0xa400000e /* Output Port Reguster */
20#define PA_VERREG 0xa4000014 /* FPGA Version Register */
21
22#define PA_IDE_OFFSET 0x1f0 /* CF IDE Offset */
23
24#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */
25#define IRLCNTR2 (PA_BCR + 2) /* Interrupt Control Register2 */
26#define IRLCNTR3 (PA_BCR + 4) /* Interrupt Control Register3 */
27#define IRLCNTR4 (PA_BCR + 16) /* Interrupt Control Register4 */
28#define IRLCNTR5 (PA_BCR + 18) /* Interrupt Control Register5 */
29
30#define IRQ_PCIETH 6 /* PCI Ethernet IRQ */
31#define IRQ_PCIHUB 7 /* PCI Ethernet Hub IRQ */
32#define IRQ_USBCOM 8 /* USB Comunication IRQ */
33#define IRQ_USBCON 9 /* USB Connect IRQ */
34#define IRQ_USBDMA 10 /* USB DMA IRQ */
35#define IRQ_CFCARD 11 /* CF Card IRQ */
36#define IRQ_PCMCIA 12 /* PCMCIA IRQ */
37#define IRQ_PCISLOT 13 /* PCI Slot #1 IRQ */
38#define IRQ_ONHOOK1 0 /* ON HOOK1 IRQ */
39#define IRQ_OFFHOOK1 1 /* OFF HOOK1 IRQ */
40#define IRQ_ONHOOK2 2 /* ON HOOK2 IRQ */
41#define IRQ_OFFHOOK2 3 /* OFF HOOK2 IRQ */
42#define IRQ_RINGING 4 /* Ringing IRQ */
43#define IRQ_CODEC 5 /* CODEC IRQ */
44
45#define __IO_PREFIX hs7751rvoip
46#include <asm/io_generic.h>
47
48/* arch/sh/boards/renesas/hs7751rvoip/irq.c */
49void init_hs7751rvoip_IRQ(void);
50
51/* arch/sh/boards/renesas/hs7751rvoip/io.c */
52void *hs7751rvoip_ioremap(unsigned long, unsigned long);
53
54#endif /* __ASM_SH_RENESAS_HS7751RVOIP */
diff --git a/include/asm-sh/hw_irq.h b/include/asm-sh/hw_irq.h
index cb0b6c9f7020..c958fdaa0095 100644
--- a/include/asm-sh/hw_irq.h
+++ b/include/asm-sh/hw_irq.h
@@ -33,13 +33,6 @@ struct intc_vect {
33#define INTC_VECT(enum_id, vect) { enum_id, vect } 33#define INTC_VECT(enum_id, vect) { enum_id, vect }
34#define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq)) 34#define INTC_IRQ(enum_id, irq) INTC_VECT(enum_id, irq2evt(irq))
35 35
36struct intc_prio {
37 intc_enum enum_id;
38 unsigned char priority;
39};
40
41#define INTC_PRIO(enum_id, prio) { enum_id, prio }
42
43struct intc_group { 36struct intc_group {
44 intc_enum enum_id; 37 intc_enum enum_id;
45 intc_enum enum_ids[32]; 38 intc_enum enum_ids[32];
@@ -79,8 +72,6 @@ struct intc_desc {
79 unsigned int nr_vectors; 72 unsigned int nr_vectors;
80 struct intc_group *groups; 73 struct intc_group *groups;
81 unsigned int nr_groups; 74 unsigned int nr_groups;
82 struct intc_prio *priorities;
83 unsigned int nr_priorities;
84 struct intc_mask_reg *mask_regs; 75 struct intc_mask_reg *mask_regs;
85 unsigned int nr_mask_regs; 76 unsigned int nr_mask_regs;
86 struct intc_prio_reg *prio_regs; 77 struct intc_prio_reg *prio_regs;
@@ -92,10 +83,9 @@ struct intc_desc {
92 83
93#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a) 84#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
94#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \ 85#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
95 priorities, mask_regs, prio_regs, sense_regs) \ 86 mask_regs, prio_regs, sense_regs) \
96struct intc_desc symbol __initdata = { \ 87struct intc_desc symbol __initdata = { \
97 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ 88 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
98 _INTC_ARRAY(priorities), \
99 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ 89 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
100 _INTC_ARRAY(sense_regs), \ 90 _INTC_ARRAY(sense_regs), \
101 chipname, \ 91 chipname, \
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index 6ed34d8eac5f..94900c089519 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -191,6 +191,8 @@ __BUILD_MEMORY_STRING(w, u16)
191 191
192#define mmiowb() wmb() /* synco on SH-4A, otherwise a nop */ 192#define mmiowb() wmb() /* synco on SH-4A, otherwise a nop */
193 193
194#define IO_SPACE_LIMIT 0xffffffff
195
194/* 196/*
195 * This function provides a method for the generic case where a board-specific 197 * This function provides a method for the generic case where a board-specific
196 * ioport_map simply needs to return the port + some arbitrary port base. 198 * ioport_map simply needs to return the port + some arbitrary port base.
@@ -226,6 +228,11 @@ static inline unsigned int ctrl_inl(unsigned long addr)
226 return *(volatile unsigned long*)addr; 228 return *(volatile unsigned long*)addr;
227} 229}
228 230
231static inline unsigned long long ctrl_inq(unsigned long addr)
232{
233 return *(volatile unsigned long long*)addr;
234}
235
229static inline void ctrl_outb(unsigned char b, unsigned long addr) 236static inline void ctrl_outb(unsigned char b, unsigned long addr)
230{ 237{
231 *(volatile unsigned char*)addr = b; 238 *(volatile unsigned char*)addr = b;
@@ -241,49 +248,52 @@ static inline void ctrl_outl(unsigned int b, unsigned long addr)
241 *(volatile unsigned long*)addr = b; 248 *(volatile unsigned long*)addr = b;
242} 249}
243 250
251static inline void ctrl_outq(unsigned long long b, unsigned long addr)
252{
253 *(volatile unsigned long long*)addr = b;
254}
255
244static inline void ctrl_delay(void) 256static inline void ctrl_delay(void)
245{ 257{
258#ifdef P2SEG
246 ctrl_inw(P2SEG); 259 ctrl_inw(P2SEG);
260#endif
247} 261}
248 262
249#define IO_SPACE_LIMIT 0xffffffff 263/* Quad-word real-mode I/O, don't ask.. */
264unsigned long long peek_real_address_q(unsigned long long addr);
265unsigned long long poke_real_address_q(unsigned long long addr,
266 unsigned long long val);
250 267
251#ifdef CONFIG_MMU 268/* arch/sh/mm/ioremap_64.c */
252/* 269unsigned long onchip_remap(unsigned long addr, unsigned long size,
253 * Change virtual addresses to physical addresses and vv. 270 const char *name);
254 * These are trivial on the 1:1 Linux/SuperH mapping 271extern void onchip_unmap(unsigned long vaddr);
255 */
256static inline unsigned long virt_to_phys(volatile void *address)
257{
258 return PHYSADDR(address);
259}
260 272
261static inline void *phys_to_virt(unsigned long address) 273#if !defined(CONFIG_MMU)
262{
263 return (void *)P1SEGADDR(address);
264}
265#else
266#define phys_to_virt(address) ((void *)(address))
267#define virt_to_phys(address) ((unsigned long)(address)) 274#define virt_to_phys(address) ((unsigned long)(address))
275#define phys_to_virt(address) ((void *)(address))
276#else
277#define virt_to_phys(address) (__pa(address))
278#define phys_to_virt(address) (__va(address))
268#endif 279#endif
269 280
270/* 281/*
271 * readX/writeX() are used to access memory mapped devices. On some 282 * On 32-bit SH, we traditionally have the whole physical address space
272 * architectures the memory mapped IO stuff needs to be accessed 283 * mapped at all times (as MIPS does), so "ioremap()" and "iounmap()" do
273 * differently. On the x86 architecture, we just read/write the 284 * not need to do anything but place the address in the proper segment.
274 * memory location directly. 285 * This is true for P1 and P2 addresses, as well as some P3 ones.
286 * However, most of the P3 addresses and newer cores using extended
287 * addressing need to map through page tables, so the ioremap()
288 * implementation becomes a bit more complicated.
275 * 289 *
276 * On SH, we traditionally have the whole physical address space mapped 290 * See arch/sh/mm/ioremap.c for additional notes on this.
277 * at all times (as MIPS does), so "ioremap()" and "iounmap()" do not
278 * need to do anything but place the address in the proper segment. This
279 * is true for P1 and P2 addresses, as well as some P3 ones. However,
280 * most of the P3 addresses and newer cores using extended addressing
281 * need to map through page tables, so the ioremap() implementation
282 * becomes a bit more complicated. See arch/sh/mm/ioremap.c for
283 * additional notes on this.
284 * 291 *
285 * We cheat a bit and always return uncachable areas until we've fixed 292 * We cheat a bit and always return uncachable areas until we've fixed
286 * the drivers to handle caching properly. 293 * the drivers to handle caching properly.
294 *
295 * On the SH-5 the concept of segmentation in the 1:1 PXSEG sense simply
296 * doesn't exist, so everything must go through page tables.
287 */ 297 */
288#ifdef CONFIG_MMU 298#ifdef CONFIG_MMU
289void __iomem *__ioremap(unsigned long offset, unsigned long size, 299void __iomem *__ioremap(unsigned long offset, unsigned long size,
@@ -297,6 +307,7 @@ void __iounmap(void __iomem *addr);
297static inline void __iomem * 307static inline void __iomem *
298__ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags) 308__ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
299{ 309{
310#ifdef CONFIG_SUPERH32
300 unsigned long last_addr = offset + size - 1; 311 unsigned long last_addr = offset + size - 1;
301 312
302 /* 313 /*
@@ -311,6 +322,7 @@ __ioremap_mode(unsigned long offset, unsigned long size, unsigned long flags)
311 322
312 return (void __iomem *)P2SEGADDR(offset); 323 return (void __iomem *)P2SEGADDR(offset);
313 } 324 }
325#endif
314 326
315 return __ioremap(offset, size, flags); 327 return __ioremap(offset, size, flags);
316} 328}
diff --git a/include/asm-sh/irq.h b/include/asm-sh/irq.h
index c61d902b8bff..11850f65c922 100644
--- a/include/asm-sh/irq.h
+++ b/include/asm-sh/irq.h
@@ -41,7 +41,7 @@ static inline int generic_irq_demux(int irq)
41#define irq_canonicalize(irq) (irq) 41#define irq_canonicalize(irq) (irq)
42#define irq_demux(irq) sh_mv.mv_irq_demux(irq) 42#define irq_demux(irq) sh_mv.mv_irq_demux(irq)
43 43
44#ifdef CONFIG_4KSTACKS 44#ifdef CONFIG_IRQSTACKS
45extern void irq_ctx_init(int cpu); 45extern void irq_ctx_init(int cpu);
46extern void irq_ctx_exit(int cpu); 46extern void irq_ctx_exit(int cpu);
47# define __ARCH_HAS_DO_SOFTIRQ 47# define __ARCH_HAS_DO_SOFTIRQ
diff --git a/include/asm-sh/irqflags.h b/include/asm-sh/irqflags.h
index 9dedc1b693e3..46e71da5be6b 100644
--- a/include/asm-sh/irqflags.h
+++ b/include/asm-sh/irqflags.h
@@ -1,81 +1,11 @@
1#ifndef __ASM_SH_IRQFLAGS_H 1#ifndef __ASM_SH_IRQFLAGS_H
2#define __ASM_SH_IRQFLAGS_H 2#define __ASM_SH_IRQFLAGS_H
3 3
4static inline void raw_local_irq_enable(void) 4#ifdef CONFIG_SUPERH32
5{ 5#include "irqflags_32.h"
6 unsigned long __dummy0, __dummy1; 6#else
7 7#include "irqflags_64.h"
8 __asm__ __volatile__ (
9 "stc sr, %0\n\t"
10 "and %1, %0\n\t"
11#ifdef CONFIG_CPU_HAS_SR_RB
12 "stc r6_bank, %1\n\t"
13 "or %1, %0\n\t"
14#endif 8#endif
15 "ldc %0, sr\n\t"
16 : "=&r" (__dummy0), "=r" (__dummy1)
17 : "1" (~0x000000f0)
18 : "memory"
19 );
20}
21
22static inline void raw_local_irq_disable(void)
23{
24 unsigned long flags;
25
26 __asm__ __volatile__ (
27 "stc sr, %0\n\t"
28 "or #0xf0, %0\n\t"
29 "ldc %0, sr\n\t"
30 : "=&z" (flags)
31 : /* no inputs */
32 : "memory"
33 );
34}
35
36static inline void set_bl_bit(void)
37{
38 unsigned long __dummy0, __dummy1;
39
40 __asm__ __volatile__ (
41 "stc sr, %0\n\t"
42 "or %2, %0\n\t"
43 "and %3, %0\n\t"
44 "ldc %0, sr\n\t"
45 : "=&r" (__dummy0), "=r" (__dummy1)
46 : "r" (0x10000000), "r" (0xffffff0f)
47 : "memory"
48 );
49}
50
51static inline void clear_bl_bit(void)
52{
53 unsigned long __dummy0, __dummy1;
54
55 __asm__ __volatile__ (
56 "stc sr, %0\n\t"
57 "and %2, %0\n\t"
58 "ldc %0, sr\n\t"
59 : "=&r" (__dummy0), "=r" (__dummy1)
60 : "1" (~0x10000000)
61 : "memory"
62 );
63}
64
65static inline unsigned long __raw_local_save_flags(void)
66{
67 unsigned long flags;
68
69 __asm__ __volatile__ (
70 "stc sr, %0\n\t"
71 "and #0xf0, %0\n\t"
72 : "=&z" (flags)
73 : /* no inputs */
74 : "memory"
75 );
76
77 return flags;
78}
79 9
80#define raw_local_save_flags(flags) \ 10#define raw_local_save_flags(flags) \
81 do { (flags) = __raw_local_save_flags(); } while (0) 11 do { (flags) = __raw_local_save_flags(); } while (0)
@@ -92,25 +22,6 @@ static inline int raw_irqs_disabled(void)
92 return raw_irqs_disabled_flags(flags); 22 return raw_irqs_disabled_flags(flags);
93} 23}
94 24
95static inline unsigned long __raw_local_irq_save(void)
96{
97 unsigned long flags, __dummy;
98
99 __asm__ __volatile__ (
100 "stc sr, %1\n\t"
101 "mov %1, %0\n\t"
102 "or #0xf0, %0\n\t"
103 "ldc %0, sr\n\t"
104 "mov %1, %0\n\t"
105 "and #0xf0, %0\n\t"
106 : "=&z" (flags), "=&r" (__dummy)
107 : /* no inputs */
108 : "memory"
109 );
110
111 return flags;
112}
113
114#define raw_local_irq_save(flags) \ 25#define raw_local_irq_save(flags) \
115 do { (flags) = __raw_local_irq_save(); } while (0) 26 do { (flags) = __raw_local_irq_save(); } while (0)
116 27
diff --git a/include/asm-sh/irqflags_32.h b/include/asm-sh/irqflags_32.h
new file mode 100644
index 000000000000..60218f541340
--- /dev/null
+++ b/include/asm-sh/irqflags_32.h
@@ -0,0 +1,99 @@
1#ifndef __ASM_SH_IRQFLAGS_32_H
2#define __ASM_SH_IRQFLAGS_32_H
3
4static inline void raw_local_irq_enable(void)
5{
6 unsigned long __dummy0, __dummy1;
7
8 __asm__ __volatile__ (
9 "stc sr, %0\n\t"
10 "and %1, %0\n\t"
11#ifdef CONFIG_CPU_HAS_SR_RB
12 "stc r6_bank, %1\n\t"
13 "or %1, %0\n\t"
14#endif
15 "ldc %0, sr\n\t"
16 : "=&r" (__dummy0), "=r" (__dummy1)
17 : "1" (~0x000000f0)
18 : "memory"
19 );
20}
21
22static inline void raw_local_irq_disable(void)
23{
24 unsigned long flags;
25
26 __asm__ __volatile__ (
27 "stc sr, %0\n\t"
28 "or #0xf0, %0\n\t"
29 "ldc %0, sr\n\t"
30 : "=&z" (flags)
31 : /* no inputs */
32 : "memory"
33 );
34}
35
36static inline void set_bl_bit(void)
37{
38 unsigned long __dummy0, __dummy1;
39
40 __asm__ __volatile__ (
41 "stc sr, %0\n\t"
42 "or %2, %0\n\t"
43 "and %3, %0\n\t"
44 "ldc %0, sr\n\t"
45 : "=&r" (__dummy0), "=r" (__dummy1)
46 : "r" (0x10000000), "r" (0xffffff0f)
47 : "memory"
48 );
49}
50
51static inline void clear_bl_bit(void)
52{
53 unsigned long __dummy0, __dummy1;
54
55 __asm__ __volatile__ (
56 "stc sr, %0\n\t"
57 "and %2, %0\n\t"
58 "ldc %0, sr\n\t"
59 : "=&r" (__dummy0), "=r" (__dummy1)
60 : "1" (~0x10000000)
61 : "memory"
62 );
63}
64
65static inline unsigned long __raw_local_save_flags(void)
66{
67 unsigned long flags;
68
69 __asm__ __volatile__ (
70 "stc sr, %0\n\t"
71 "and #0xf0, %0\n\t"
72 : "=&z" (flags)
73 : /* no inputs */
74 : "memory"
75 );
76
77 return flags;
78}
79
80static inline unsigned long __raw_local_irq_save(void)
81{
82 unsigned long flags, __dummy;
83
84 __asm__ __volatile__ (
85 "stc sr, %1\n\t"
86 "mov %1, %0\n\t"
87 "or #0xf0, %0\n\t"
88 "ldc %0, sr\n\t"
89 "mov %1, %0\n\t"
90 "and #0xf0, %0\n\t"
91 : "=&z" (flags), "=&r" (__dummy)
92 : /* no inputs */
93 : "memory"
94 );
95
96 return flags;
97}
98
99#endif /* __ASM_SH_IRQFLAGS_32_H */
diff --git a/include/asm-sh/irqflags_64.h b/include/asm-sh/irqflags_64.h
new file mode 100644
index 000000000000..4f6b8a56e7bd
--- /dev/null
+++ b/include/asm-sh/irqflags_64.h
@@ -0,0 +1,85 @@
1#ifndef __ASM_SH_IRQFLAGS_64_H
2#define __ASM_SH_IRQFLAGS_64_H
3
4#include <asm/cpu/registers.h>
5
6#define SR_MASK_LL 0x00000000000000f0LL
7#define SR_BL_LL 0x0000000010000000LL
8
9static inline void raw_local_irq_enable(void)
10{
11 unsigned long long __dummy0, __dummy1 = ~SR_MASK_LL;
12
13 __asm__ __volatile__("getcon " __SR ", %0\n\t"
14 "and %0, %1, %0\n\t"
15 "putcon %0, " __SR "\n\t"
16 : "=&r" (__dummy0)
17 : "r" (__dummy1));
18}
19
20static inline void raw_local_irq_disable(void)
21{
22 unsigned long long __dummy0, __dummy1 = SR_MASK_LL;
23
24 __asm__ __volatile__("getcon " __SR ", %0\n\t"
25 "or %0, %1, %0\n\t"
26 "putcon %0, " __SR "\n\t"
27 : "=&r" (__dummy0)
28 : "r" (__dummy1));
29}
30
31static inline void set_bl_bit(void)
32{
33 unsigned long long __dummy0, __dummy1 = SR_BL_LL;
34
35 __asm__ __volatile__("getcon " __SR ", %0\n\t"
36 "or %0, %1, %0\n\t"
37 "putcon %0, " __SR "\n\t"
38 : "=&r" (__dummy0)
39 : "r" (__dummy1));
40
41}
42
43static inline void clear_bl_bit(void)
44{
45 unsigned long long __dummy0, __dummy1 = ~SR_BL_LL;
46
47 __asm__ __volatile__("getcon " __SR ", %0\n\t"
48 "and %0, %1, %0\n\t"
49 "putcon %0, " __SR "\n\t"
50 : "=&r" (__dummy0)
51 : "r" (__dummy1));
52}
53
54static inline unsigned long __raw_local_save_flags(void)
55{
56 unsigned long long __dummy = SR_MASK_LL;
57 unsigned long flags;
58
59 __asm__ __volatile__ (
60 "getcon " __SR ", %0\n\t"
61 "and %0, %1, %0"
62 : "=&r" (flags)
63 : "r" (__dummy));
64
65 return flags;
66}
67
68static inline unsigned long __raw_local_irq_save(void)
69{
70 unsigned long long __dummy0, __dummy1 = SR_MASK_LL;
71 unsigned long flags;
72
73 __asm__ __volatile__ (
74 "getcon " __SR ", %1\n\t"
75 "or %1, r63, %0\n\t"
76 "or %1, %2, %1\n\t"
77 "putcon %1, " __SR "\n\t"
78 "and %0, %2, %0"
79 : "=&r" (flags), "=&r" (__dummy0)
80 : "r" (__dummy1));
81
82 return flags;
83}
84
85#endif /* __ASM_SH_IRQFLAGS_64_H */
diff --git a/include/asm-sh/machvec.h b/include/asm-sh/machvec.h
index 088698bacf2f..b2e4124070ae 100644
--- a/include/asm-sh/machvec.h
+++ b/include/asm-sh/machvec.h
@@ -56,9 +56,6 @@ struct sh_machine_vector {
56 56
57 void (*mv_heartbeat)(void); 57 void (*mv_heartbeat)(void);
58 58
59 void *(*mv_consistent_alloc)(struct device *, size_t, dma_addr_t *, gfp_t);
60 int (*mv_consistent_free)(struct device *, size_t, void *, dma_addr_t);
61
62 void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size); 59 void __iomem *(*mv_ioport_map)(unsigned long port, unsigned int size);
63 void (*mv_ioport_unmap)(void __iomem *); 60 void (*mv_ioport_unmap)(void __iomem *);
64}; 61};
@@ -68,6 +65,6 @@ extern struct sh_machine_vector sh_mv;
68#define get_system_type() sh_mv.mv_name 65#define get_system_type() sh_mv.mv_name
69 66
70#define __initmv \ 67#define __initmv \
71 __attribute_used__ __attribute__((__section__ (".machvec.init"))) 68 __used __section(.machvec.init)
72 69
73#endif /* _ASM_SH_MACHVEC_H */ 70#endif /* _ASM_SH_MACHVEC_H */
diff --git a/include/asm-sh/microdev.h b/include/asm-sh/microdev.h
index 018332a9e590..1aed15856e11 100644
--- a/include/asm-sh/microdev.h
+++ b/include/asm-sh/microdev.h
@@ -17,7 +17,7 @@ extern void microdev_print_fpga_intc_status(void);
17/* 17/*
18 * The following are useful macros for manipulating the interrupt 18 * The following are useful macros for manipulating the interrupt
19 * controller (INTC) on the CPU-board FPGA. should be noted that there 19 * controller (INTC) on the CPU-board FPGA. should be noted that there
20 * is an INTC on the FPGA, and a seperate INTC on the SH4-202 core - 20 * is an INTC on the FPGA, and a separate INTC on the SH4-202 core -
21 * these are two different things, both of which need to be prorammed to 21 * these are two different things, both of which need to be prorammed to
22 * correctly route - unfortunately, they have the same name and 22 * correctly route - unfortunately, they have the same name and
23 * abbreviations! 23 * abbreviations!
@@ -25,7 +25,7 @@ extern void microdev_print_fpga_intc_status(void);
25#define MICRODEV_FPGA_INTC_BASE 0xa6110000ul /* INTC base address on CPU-board FPGA */ 25#define MICRODEV_FPGA_INTC_BASE 0xa6110000ul /* INTC base address on CPU-board FPGA */
26#define MICRODEV_FPGA_INTENB_REG (MICRODEV_FPGA_INTC_BASE+0ul) /* Interrupt Enable Register on INTC on CPU-board FPGA */ 26#define MICRODEV_FPGA_INTENB_REG (MICRODEV_FPGA_INTC_BASE+0ul) /* Interrupt Enable Register on INTC on CPU-board FPGA */
27#define MICRODEV_FPGA_INTDSB_REG (MICRODEV_FPGA_INTC_BASE+8ul) /* Interrupt Disable Register on INTC on CPU-board FPGA */ 27#define MICRODEV_FPGA_INTDSB_REG (MICRODEV_FPGA_INTC_BASE+8ul) /* Interrupt Disable Register on INTC on CPU-board FPGA */
28#define MICRODEV_FPGA_INTC_MASK(n) (1ul<<(n)) /* Interupt mask to enable/disable INTC in CPU-board FPGA */ 28#define MICRODEV_FPGA_INTC_MASK(n) (1ul<<(n)) /* Interrupt mask to enable/disable INTC in CPU-board FPGA */
29#define MICRODEV_FPGA_INTPRI_REG(n) (MICRODEV_FPGA_INTC_BASE+0x10+((n)/8)*8)/* Interrupt Priority Register on INTC on CPU-board FPGA */ 29#define MICRODEV_FPGA_INTPRI_REG(n) (MICRODEV_FPGA_INTC_BASE+0x10+((n)/8)*8)/* Interrupt Priority Register on INTC on CPU-board FPGA */
30#define MICRODEV_FPGA_INTPRI_LEVEL(n,x) ((x)<<(((n)%8)*4)) /* MICRODEV_FPGA_INTPRI_LEVEL(int_number, int_level) */ 30#define MICRODEV_FPGA_INTPRI_LEVEL(n,x) ((x)<<(((n)%8)*4)) /* MICRODEV_FPGA_INTPRI_LEVEL(int_number, int_level) */
31#define MICRODEV_FPGA_INTPRI_MASK(n) (MICRODEV_FPGA_INTPRI_LEVEL((n),0xful)) /* Interrupt Priority Mask on INTC on CPU-board FPGA */ 31#define MICRODEV_FPGA_INTPRI_MASK(n) (MICRODEV_FPGA_INTPRI_LEVEL((n),0xful)) /* Interrupt Priority Mask on INTC on CPU-board FPGA */
diff --git a/include/asm-sh/mmu_context.h b/include/asm-sh/mmu_context.h
index 199662bb35c6..fe58d00b250c 100644
--- a/include/asm-sh/mmu_context.h
+++ b/include/asm-sh/mmu_context.h
@@ -1,13 +1,13 @@
1/* 1/*
2 * Copyright (C) 1999 Niibe Yutaka 2 * Copyright (C) 1999 Niibe Yutaka
3 * Copyright (C) 2003 - 2006 Paul Mundt 3 * Copyright (C) 2003 - 2007 Paul Mundt
4 * 4 *
5 * ASID handling idea taken from MIPS implementation. 5 * ASID handling idea taken from MIPS implementation.
6 */ 6 */
7#ifndef __ASM_SH_MMU_CONTEXT_H 7#ifndef __ASM_SH_MMU_CONTEXT_H
8#define __ASM_SH_MMU_CONTEXT_H 8#define __ASM_SH_MMU_CONTEXT_H
9#ifdef __KERNEL__
10 9
10#ifdef __KERNEL__
11#include <asm/cpu/mmu_context.h> 11#include <asm/cpu/mmu_context.h>
12#include <asm/tlbflush.h> 12#include <asm/tlbflush.h>
13#include <asm/uaccess.h> 13#include <asm/uaccess.h>
@@ -19,7 +19,6 @@
19 * (a) TLB cache version (or round, cycle whatever expression you like) 19 * (a) TLB cache version (or round, cycle whatever expression you like)
20 * (b) ASID (Address Space IDentifier) 20 * (b) ASID (Address Space IDentifier)
21 */ 21 */
22
23#define MMU_CONTEXT_ASID_MASK 0x000000ff 22#define MMU_CONTEXT_ASID_MASK 0x000000ff
24#define MMU_CONTEXT_VERSION_MASK 0xffffff00 23#define MMU_CONTEXT_VERSION_MASK 0xffffff00
25#define MMU_CONTEXT_FIRST_VERSION 0x00000100 24#define MMU_CONTEXT_FIRST_VERSION 0x00000100
@@ -28,10 +27,11 @@
28/* ASID is 8-bit value, so it can't be 0x100 */ 27/* ASID is 8-bit value, so it can't be 0x100 */
29#define MMU_NO_ASID 0x100 28#define MMU_NO_ASID 0x100
30 29
31#define cpu_context(cpu, mm) ((mm)->context.id[cpu])
32#define cpu_asid(cpu, mm) (cpu_context((cpu), (mm)) & \
33 MMU_CONTEXT_ASID_MASK)
34#define asid_cache(cpu) (cpu_data[cpu].asid_cache) 30#define asid_cache(cpu) (cpu_data[cpu].asid_cache)
31#define cpu_context(cpu, mm) ((mm)->context.id[cpu])
32
33#define cpu_asid(cpu, mm) \
34 (cpu_context((cpu), (mm)) & MMU_CONTEXT_ASID_MASK)
35 35
36/* 36/*
37 * Virtual Page Number mask 37 * Virtual Page Number mask
@@ -39,6 +39,12 @@
39#define MMU_VPN_MASK 0xfffff000 39#define MMU_VPN_MASK 0xfffff000
40 40
41#ifdef CONFIG_MMU 41#ifdef CONFIG_MMU
42#if defined(CONFIG_SUPERH32)
43#include "mmu_context_32.h"
44#else
45#include "mmu_context_64.h"
46#endif
47
42/* 48/*
43 * Get MMU context if needed. 49 * Get MMU context if needed.
44 */ 50 */
@@ -59,6 +65,14 @@ static inline void get_mmu_context(struct mm_struct *mm, unsigned int cpu)
59 */ 65 */
60 flush_tlb_all(); 66 flush_tlb_all();
61 67
68#ifdef CONFIG_SUPERH64
69 /*
70 * The SH-5 cache uses the ASIDs, requiring both the I and D
71 * cache to be flushed when the ASID is exhausted. Weak.
72 */
73 flush_cache_all();
74#endif
75
62 /* 76 /*
63 * Fix version; Note that we avoid version #0 77 * Fix version; Note that we avoid version #0
64 * to distingush NO_CONTEXT. 78 * to distingush NO_CONTEXT.
@@ -86,39 +100,6 @@ static inline int init_new_context(struct task_struct *tsk,
86} 100}
87 101
88/* 102/*
89 * Destroy context related info for an mm_struct that is about
90 * to be put to rest.
91 */
92static inline void destroy_context(struct mm_struct *mm)
93{
94 /* Do nothing */
95}
96
97static inline void set_asid(unsigned long asid)
98{
99 unsigned long __dummy;
100
101 __asm__ __volatile__ ("mov.l %2, %0\n\t"
102 "and %3, %0\n\t"
103 "or %1, %0\n\t"
104 "mov.l %0, %2"
105 : "=&r" (__dummy)
106 : "r" (asid), "m" (__m(MMU_PTEH)),
107 "r" (0xffffff00));
108}
109
110static inline unsigned long get_asid(void)
111{
112 unsigned long asid;
113
114 __asm__ __volatile__ ("mov.l %1, %0"
115 : "=r" (asid)
116 : "m" (__m(MMU_PTEH)));
117 asid &= MMU_CONTEXT_ASID_MASK;
118 return asid;
119}
120
121/*
122 * After we have set current->mm to a new value, this activates 103 * After we have set current->mm to a new value, this activates
123 * the context for the new mm so we see the new mappings. 104 * the context for the new mm so we see the new mappings.
124 */ 105 */
@@ -128,17 +109,6 @@ static inline void activate_context(struct mm_struct *mm, unsigned int cpu)
128 set_asid(cpu_asid(cpu, mm)); 109 set_asid(cpu_asid(cpu, mm));
129} 110}
130 111
131/* MMU_TTB is used for optimizing the fault handling. */
132static inline void set_TTB(pgd_t *pgd)
133{
134 ctrl_outl((unsigned long)pgd, MMU_TTB);
135}
136
137static inline pgd_t *get_TTB(void)
138{
139 return (pgd_t *)ctrl_inl(MMU_TTB);
140}
141
142static inline void switch_mm(struct mm_struct *prev, 112static inline void switch_mm(struct mm_struct *prev,
143 struct mm_struct *next, 113 struct mm_struct *next,
144 struct task_struct *tsk) 114 struct task_struct *tsk)
@@ -153,17 +123,7 @@ static inline void switch_mm(struct mm_struct *prev,
153 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) 123 if (!cpu_test_and_set(cpu, next->cpu_vm_mask))
154 activate_context(next, cpu); 124 activate_context(next, cpu);
155} 125}
156 126#else
157#define deactivate_mm(tsk,mm) do { } while (0)
158
159#define activate_mm(prev, next) \
160 switch_mm((prev),(next),NULL)
161
162static inline void
163enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
164{
165}
166#else /* !CONFIG_MMU */
167#define get_mmu_context(mm) do { } while (0) 127#define get_mmu_context(mm) do { } while (0)
168#define init_new_context(tsk,mm) (0) 128#define init_new_context(tsk,mm) (0)
169#define destroy_context(mm) do { } while (0) 129#define destroy_context(mm) do { } while (0)
@@ -173,10 +133,11 @@ enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
173#define get_TTB() (0) 133#define get_TTB() (0)
174#define activate_context(mm,cpu) do { } while (0) 134#define activate_context(mm,cpu) do { } while (0)
175#define switch_mm(prev,next,tsk) do { } while (0) 135#define switch_mm(prev,next,tsk) do { } while (0)
136#endif /* CONFIG_MMU */
137
138#define activate_mm(prev, next) switch_mm((prev),(next),NULL)
176#define deactivate_mm(tsk,mm) do { } while (0) 139#define deactivate_mm(tsk,mm) do { } while (0)
177#define activate_mm(prev,next) do { } while (0)
178#define enter_lazy_tlb(mm,tsk) do { } while (0) 140#define enter_lazy_tlb(mm,tsk) do { } while (0)
179#endif /* CONFIG_MMU */
180 141
181#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4) 142#if defined(CONFIG_CPU_SH3) || defined(CONFIG_CPU_SH4)
182/* 143/*
diff --git a/include/asm-sh/mmu_context_32.h b/include/asm-sh/mmu_context_32.h
new file mode 100644
index 000000000000..f4f9aebd68b7
--- /dev/null
+++ b/include/asm-sh/mmu_context_32.h
@@ -0,0 +1,47 @@
1#ifndef __ASM_SH_MMU_CONTEXT_32_H
2#define __ASM_SH_MMU_CONTEXT_32_H
3
4/*
5 * Destroy context related info for an mm_struct that is about
6 * to be put to rest.
7 */
8static inline void destroy_context(struct mm_struct *mm)
9{
10 /* Do nothing */
11}
12
13static inline void set_asid(unsigned long asid)
14{
15 unsigned long __dummy;
16
17 __asm__ __volatile__ ("mov.l %2, %0\n\t"
18 "and %3, %0\n\t"
19 "or %1, %0\n\t"
20 "mov.l %0, %2"
21 : "=&r" (__dummy)
22 : "r" (asid), "m" (__m(MMU_PTEH)),
23 "r" (0xffffff00));
24}
25
26static inline unsigned long get_asid(void)
27{
28 unsigned long asid;
29
30 __asm__ __volatile__ ("mov.l %1, %0"
31 : "=r" (asid)
32 : "m" (__m(MMU_PTEH)));
33 asid &= MMU_CONTEXT_ASID_MASK;
34 return asid;
35}
36
37/* MMU_TTB is used for optimizing the fault handling. */
38static inline void set_TTB(pgd_t *pgd)
39{
40 ctrl_outl((unsigned long)pgd, MMU_TTB);
41}
42
43static inline pgd_t *get_TTB(void)
44{
45 return (pgd_t *)ctrl_inl(MMU_TTB);
46}
47#endif /* __ASM_SH_MMU_CONTEXT_32_H */
diff --git a/include/asm-sh/mmu_context_64.h b/include/asm-sh/mmu_context_64.h
new file mode 100644
index 000000000000..020be744b088
--- /dev/null
+++ b/include/asm-sh/mmu_context_64.h
@@ -0,0 +1,75 @@
1#ifndef __ASM_SH_MMU_CONTEXT_64_H
2#define __ASM_SH_MMU_CONTEXT_64_H
3
4/*
5 * sh64-specific mmu_context interface.
6 *
7 * Copyright (C) 2000, 2001 Paolo Alberelli
8 * Copyright (C) 2003 - 2007 Paul Mundt
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <asm/cpu/registers.h>
15#include <asm/cacheflush.h>
16
17#define SR_ASID_MASK 0xffffffffff00ffffULL
18#define SR_ASID_SHIFT 16
19
20/*
21 * Destroy context related info for an mm_struct that is about
22 * to be put to rest.
23 */
24static inline void destroy_context(struct mm_struct *mm)
25{
26 /* Well, at least free TLB entries */
27 flush_tlb_mm(mm);
28}
29
30static inline unsigned long get_asid(void)
31{
32 unsigned long long sr;
33
34 asm volatile ("getcon " __SR ", %0\n\t"
35 : "=r" (sr));
36
37 sr = (sr >> SR_ASID_SHIFT) & MMU_CONTEXT_ASID_MASK;
38 return (unsigned long) sr;
39}
40
41/* Set ASID into SR */
42static inline void set_asid(unsigned long asid)
43{
44 unsigned long long sr, pc;
45
46 asm volatile ("getcon " __SR ", %0" : "=r" (sr));
47
48 sr = (sr & SR_ASID_MASK) | (asid << SR_ASID_SHIFT);
49
50 /*
51 * It is possible that this function may be inlined and so to avoid
52 * the assembler reporting duplicate symbols we make use of the
53 * gas trick of generating symbols using numerics and forward
54 * reference.
55 */
56 asm volatile ("movi 1, %1\n\t"
57 "shlli %1, 28, %1\n\t"
58 "or %0, %1, %1\n\t"
59 "putcon %1, " __SR "\n\t"
60 "putcon %0, " __SSR "\n\t"
61 "movi 1f, %1\n\t"
62 "ori %1, 1 , %1\n\t"
63 "putcon %1, " __SPC "\n\t"
64 "rte\n"
65 "1:\n\t"
66 : "=r" (sr), "=r" (pc) : "0" (sr));
67}
68
69/* No spare register to twiddle, so use a software cache */
70extern pgd_t *mmu_pdtp_cache;
71
72#define set_TTB(pgd) (mmu_pdtp_cache = (pgd))
73#define get_TTB() (mmu_pdtp_cache)
74
75#endif /* __ASM_SH_MMU_CONTEXT_64_H */
diff --git a/include/asm-sh/module.h b/include/asm-sh/module.h
index 118d5a2b228f..46eccd331660 100644
--- a/include/asm-sh/module.h
+++ b/include/asm-sh/module.h
@@ -20,6 +20,8 @@ struct mod_arch_specific {
20# define MODULE_PROC_FAMILY "SH3LE " 20# define MODULE_PROC_FAMILY "SH3LE "
21# elif defined CONFIG_CPU_SH4 21# elif defined CONFIG_CPU_SH4
22# define MODULE_PROC_FAMILY "SH4LE " 22# define MODULE_PROC_FAMILY "SH4LE "
23# elif defined CONFIG_CPU_SH5
24# define MODULE_PROC_FAMILY "SH5LE "
23# else 25# else
24# error unknown processor family 26# error unknown processor family
25# endif 27# endif
@@ -30,6 +32,8 @@ struct mod_arch_specific {
30# define MODULE_PROC_FAMILY "SH3BE " 32# define MODULE_PROC_FAMILY "SH3BE "
31# elif defined CONFIG_CPU_SH4 33# elif defined CONFIG_CPU_SH4
32# define MODULE_PROC_FAMILY "SH4BE " 34# define MODULE_PROC_FAMILY "SH4BE "
35# elif defined CONFIG_CPU_SH5
36# define MODULE_PROC_FAMILY "SH5BE "
33# else 37# else
34# error unknown processor family 38# error unknown processor family
35# endif 39# endif
diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h
index cb3d46c59eab..002e64a4f049 100644
--- a/include/asm-sh/page.h
+++ b/include/asm-sh/page.h
@@ -5,13 +5,7 @@
5 * Copyright (C) 1999 Niibe Yutaka 5 * Copyright (C) 1999 Niibe Yutaka
6 */ 6 */
7 7
8/* 8#include <linux/const.h>
9 [ P0/U0 (virtual) ] 0x00000000 <------ User space
10 [ P1 (fixed) cached ] 0x80000000 <------ Kernel space
11 [ P2 (fixed) non-cachable] 0xA0000000 <------ Physical access
12 [ P3 (virtual) cached] 0xC0000000 <------ vmalloced area
13 [ P4 control ] 0xE0000000
14 */
15 9
16#ifdef __KERNEL__ 10#ifdef __KERNEL__
17 11
@@ -26,15 +20,13 @@
26# error "Bogus kernel page size?" 20# error "Bogus kernel page size?"
27#endif 21#endif
28 22
29#ifdef __ASSEMBLY__ 23#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
30#define PAGE_SIZE (1 << PAGE_SHIFT)
31#else
32#define PAGE_SIZE (1UL << PAGE_SHIFT)
33#endif
34
35#define PAGE_MASK (~(PAGE_SIZE-1)) 24#define PAGE_MASK (~(PAGE_SIZE-1))
36#define PTE_MASK PAGE_MASK 25#define PTE_MASK PAGE_MASK
37 26
27/* to align the pointer to the (next) page boundary */
28#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
29
38#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 30#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
39#define HPAGE_SHIFT 16 31#define HPAGE_SHIFT 16
40#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K) 32#elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
@@ -45,6 +37,8 @@
45#define HPAGE_SHIFT 22 37#define HPAGE_SHIFT 22
46#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB) 38#elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
47#define HPAGE_SHIFT 26 39#define HPAGE_SHIFT 26
40#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB)
41#define HPAGE_SHIFT 29
48#endif 42#endif
49 43
50#ifdef CONFIG_HUGETLB_PAGE 44#ifdef CONFIG_HUGETLB_PAGE
@@ -55,28 +49,23 @@
55 49
56#ifndef __ASSEMBLY__ 50#ifndef __ASSEMBLY__
57 51
58extern void (*clear_page)(void *to);
59extern void (*copy_page)(void *to, void *from);
60
61extern unsigned long shm_align_mask; 52extern unsigned long shm_align_mask;
62extern unsigned long max_low_pfn, min_low_pfn; 53extern unsigned long max_low_pfn, min_low_pfn;
63extern unsigned long memory_start, memory_end; 54extern unsigned long memory_start, memory_end;
64 55
65#ifdef CONFIG_MMU 56extern void clear_page(void *to);
66extern void clear_page_slow(void *to); 57extern void copy_page(void *to, void *from);
67extern void copy_page_slow(void *to, void *from);
68#else
69extern void clear_page_nommu(void *to);
70extern void copy_page_nommu(void *to, void *from);
71#endif
72 58
73#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \ 59#if !defined(CONFIG_CACHE_OFF) && defined(CONFIG_MMU) && \
74 (defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB)) 60 (defined(CONFIG_CPU_SH4) || defined(CONFIG_SH7705_CACHE_32KB))
75struct page; 61struct page;
76extern void clear_user_page(void *to, unsigned long address, struct page *pg); 62struct vm_area_struct;
77extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg); 63extern void clear_user_page(void *to, unsigned long address, struct page *page);
78extern void __clear_user_page(void *to, void *orig_to); 64#ifdef CONFIG_CPU_SH4
79extern void __copy_user_page(void *to, void *from, void *orig_to); 65extern void copy_user_highpage(struct page *to, struct page *from,
66 unsigned long vaddr, struct vm_area_struct *vma);
67#define __HAVE_ARCH_COPY_USER_HIGHPAGE
68#endif
80#else 69#else
81#define clear_user_page(page, vaddr, pg) clear_page(page) 70#define clear_user_page(page, vaddr, pg) clear_page(page)
82#define copy_user_page(to, from, vaddr, pg) copy_page(to, from) 71#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
@@ -93,12 +82,18 @@ typedef struct { unsigned long long pgd; } pgd_t;
93 ((x).pte_low | ((unsigned long long)(x).pte_high << 32)) 82 ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
94#define __pte(x) \ 83#define __pte(x) \
95 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; }) 84 ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
96#else 85#elif defined(CONFIG_SUPERH32)
97typedef struct { unsigned long pte_low; } pte_t; 86typedef struct { unsigned long pte_low; } pte_t;
98typedef struct { unsigned long pgprot; } pgprot_t; 87typedef struct { unsigned long pgprot; } pgprot_t;
99typedef struct { unsigned long pgd; } pgd_t; 88typedef struct { unsigned long pgd; } pgd_t;
100#define pte_val(x) ((x).pte_low) 89#define pte_val(x) ((x).pte_low)
101#define __pte(x) ((pte_t) { (x) } ) 90#define __pte(x) ((pte_t) { (x) } )
91#else
92typedef struct { unsigned long long pte_low; } pte_t;
93typedef struct { unsigned long pgprot; } pgprot_t;
94typedef struct { unsigned long pgd; } pgd_t;
95#define pte_val(x) ((x).pte_low)
96#define __pte(x) ((pte_t) { (x) } )
102#endif 97#endif
103 98
104#define pgd_val(x) ((x).pgd) 99#define pgd_val(x) ((x).pgd)
@@ -109,29 +104,44 @@ typedef struct { unsigned long pgd; } pgd_t;
109 104
110#endif /* !__ASSEMBLY__ */ 105#endif /* !__ASSEMBLY__ */
111 106
112/* to align the pointer to the (next) page boundary */
113#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
114
115/* 107/*
116 * IF YOU CHANGE THIS, PLEASE ALSO CHANGE 108 * __MEMORY_START and SIZE are the physical addresses and size of RAM.
117 *
118 * arch/sh/kernel/vmlinux.lds.S
119 *
120 * which has the same constant encoded..
121 */ 109 */
122
123#define __MEMORY_START CONFIG_MEMORY_START 110#define __MEMORY_START CONFIG_MEMORY_START
124#define __MEMORY_SIZE CONFIG_MEMORY_SIZE 111#define __MEMORY_SIZE CONFIG_MEMORY_SIZE
125 112
113/*
114 * PAGE_OFFSET is the virtual address of the start of kernel address
115 * space.
116 */
126#define PAGE_OFFSET CONFIG_PAGE_OFFSET 117#define PAGE_OFFSET CONFIG_PAGE_OFFSET
127#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
128#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
129#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
130 118
131#define phys_to_page(phys) (pfn_to_page(phys >> PAGE_SHIFT)) 119/*
120 * Virtual to physical RAM address translation.
121 *
122 * In 29 bit mode, the physical offset of RAM from address 0 is visible in
123 * the kernel virtual address space, and thus we don't have to take
124 * this into account when translating. However in 32 bit mode this offset
125 * is not visible (it is part of the PMB mapping) and so needs to be
126 * added or subtracted as required.
127 */
128#ifdef CONFIG_32BIT
129#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET+__MEMORY_START)
130#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET-__MEMORY_START))
131#else
132#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
133#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
134#endif
135
136#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
132#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) 137#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
133 138
134/* PFN start number, because of __MEMORY_START */ 139/*
140 * PFN = physical frame number (ie PFN 0 == physical address 0)
141 * PFN_START is the PFN of the first page of RAM. By defining this we
142 * don't have struct page entries for the portion of address space
143 * between physical address 0 and the start of RAM.
144 */
135#define PFN_START (__MEMORY_START >> PAGE_SHIFT) 145#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
136#define ARCH_PFN_OFFSET (PFN_START) 146#define ARCH_PFN_OFFSET (PFN_START)
137#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 147#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
@@ -152,11 +162,21 @@ typedef struct { unsigned long pgd; } pgd_t;
152#endif 162#endif
153 163
154/* 164/*
155 * Slub defaults to 8-byte alignment, we're only interested in 4. 165 * Some drivers need to perform DMA into kmalloc'ed buffers
156 * Slab defaults to BYTES_PER_WORD, which ends up being the same anyways. 166 * and so we have to increase the kmalloc minalign for this.
157 */ 167 */
158#define ARCH_KMALLOC_MINALIGN 4 168#define ARCH_KMALLOC_MINALIGN L1_CACHE_BYTES
159#define ARCH_SLAB_MINALIGN 4 169
170#ifdef CONFIG_SUPERH64
171/*
172 * While BYTES_PER_WORD == 4 on the current sh64 ABI, GCC will still
173 * happily generate {ld/st}.q pairs, requiring us to have 8-byte
174 * alignment to avoid traps. The kmalloc alignment is gauranteed by
175 * virtue of L1_CACHE_BYTES, requiring this to only be special cased
176 * for slab caches.
177 */
178#define ARCH_SLAB_MINALIGN 8
179#endif
160 180
161#endif /* __KERNEL__ */ 181#endif /* __KERNEL__ */
162#endif /* __ASM_SH_PAGE_H */ 182#endif /* __ASM_SH_PAGE_H */
diff --git a/include/asm-sh/param.h b/include/asm-sh/param.h
index 1012296e07ab..ae245afdfd6a 100644
--- a/include/asm-sh/param.h
+++ b/include/asm-sh/param.h
@@ -2,11 +2,7 @@
2#define __ASM_SH_PARAM_H 2#define __ASM_SH_PARAM_H
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5# ifdef CONFIG_SH_WDT 5# define HZ CONFIG_HZ
6# define HZ 1000 /* Needed for high-res WOVF */
7# else
8# define HZ CONFIG_HZ
9# endif
10# define USER_HZ 100 /* User interfaces are in "ticks" */ 6# define USER_HZ 100 /* User interfaces are in "ticks" */
11# define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */ 7# define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */
12#endif 8#endif
diff --git a/include/asm-sh/pci.h b/include/asm-sh/pci.h
index 2757ce096ff7..df1d383e18a5 100644
--- a/include/asm-sh/pci.h
+++ b/include/asm-sh/pci.h
@@ -38,9 +38,12 @@ extern struct pci_channel board_pci_channels[];
38#if defined(CONFIG_CPU_SUBTYPE_SH7780) || defined(CONFIG_CPU_SUBTYPE_SH7785) 38#if defined(CONFIG_CPU_SUBTYPE_SH7780) || defined(CONFIG_CPU_SUBTYPE_SH7785)
39#define PCI_IO_AREA 0xFE400000 39#define PCI_IO_AREA 0xFE400000
40#define PCI_IO_SIZE 0x00400000 40#define PCI_IO_SIZE 0x00400000
41#elif defined(CONFIG_CPU_SH5)
42extern unsigned long PCI_IO_AREA;
43#define PCI_IO_SIZE 0x00010000
41#else 44#else
42#define PCI_IO_AREA 0xFE240000 45#define PCI_IO_AREA 0xFE240000
43#define PCI_IO_SIZE 0X00040000 46#define PCI_IO_SIZE 0x00040000
44#endif 47#endif
45 48
46#define PCI_MEM_SIZE 0x01000000 49#define PCI_MEM_SIZE 0x01000000
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h
index cf0dd2b648c2..a4a8f8b93463 100644
--- a/include/asm-sh/pgtable.h
+++ b/include/asm-sh/pgtable.h
@@ -3,7 +3,7 @@
3 * use the SuperH page table tree. 3 * use the SuperH page table tree.
4 * 4 *
5 * Copyright (C) 1999 Niibe Yutaka 5 * Copyright (C) 1999 Niibe Yutaka
6 * Copyright (C) 2002 - 2005 Paul Mundt 6 * Copyright (C) 2002 - 2007 Paul Mundt
7 * 7 *
8 * This file is subject to the terms and conditions of the GNU General 8 * This file is subject to the terms and conditions of the GNU General
9 * Public License. See the file "COPYING" in the main directory of this 9 * Public License. See the file "COPYING" in the main directory of this
@@ -29,10 +29,27 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
29#endif /* !__ASSEMBLY__ */ 29#endif /* !__ASSEMBLY__ */
30 30
31/* 31/*
32 * Effective and physical address definitions, to aid with sign
33 * extension.
34 */
35#define NEFF 32
36#define NEFF_SIGN (1LL << (NEFF - 1))
37#define NEFF_MASK (-1LL << NEFF)
38
39#ifdef CONFIG_29BIT
40#define NPHYS 29
41#else
42#define NPHYS 32
43#endif
44
45#define NPHYS_SIGN (1LL << (NPHYS - 1))
46#define NPHYS_MASK (-1LL << NPHYS)
47
48/*
32 * traditional two-level paging structure 49 * traditional two-level paging structure
33 */ 50 */
34/* PTE bits */ 51/* PTE bits */
35#ifdef CONFIG_X2TLB 52#if defined(CONFIG_X2TLB) || defined(CONFIG_SUPERH64)
36# define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */ 53# define PTE_MAGNITUDE 3 /* 64-bit PTEs on extended mode SH-X2 TLB */
37#else 54#else
38# define PTE_MAGNITUDE 2 /* 32-bit PTEs */ 55# define PTE_MAGNITUDE 2 /* 32-bit PTEs */
@@ -52,281 +69,27 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
52#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE) 69#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
53#define FIRST_USER_ADDRESS 0 70#define FIRST_USER_ADDRESS 0
54 71
55#define PTE_PHYS_MASK (0x20000000 - PAGE_SIZE) 72#ifdef CONFIG_32BIT
56 73#define PHYS_ADDR_MASK 0xffffffff
57#define VMALLOC_START (P3SEG)
58#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
59
60/*
61 * Linux PTEL encoding.
62 *
63 * Hardware and software bit definitions for the PTEL value (see below for
64 * notes on SH-X2 MMUs and 64-bit PTEs):
65 *
66 * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4).
67 *
68 * - Bit 1 is the SH-bit, but is unused on SH-3 due to an MMU bug (the
69 * hardware PTEL value can't have the SH-bit set when MMUCR.IX is set,
70 * which is the default in cpu-sh3/mmu_context.h:MMU_CONTROL_INIT).
71 *
72 * In order to keep this relatively clean, do not use these for defining
73 * SH-3 specific flags until all of the other unused bits have been
74 * exhausted.
75 *
76 * - Bit 9 is reserved by everyone and used by _PAGE_PROTNONE.
77 *
78 * - Bits 10 and 11 are low bits of the PPN that are reserved on >= 4K pages.
79 * Bit 10 is used for _PAGE_ACCESSED, bit 11 remains unused.
80 *
81 * - Bits 31, 30, and 29 remain unused by everyone and can be used for future
82 * software flags, although care must be taken to update _PAGE_CLEAR_FLAGS.
83 *
84 * XXX: Leave the _PAGE_FILE and _PAGE_WT overhaul for a rainy day.
85 *
86 * SH-X2 MMUs and extended PTEs
87 *
88 * SH-X2 supports an extended mode TLB with split data arrays due to the
89 * number of bits needed for PR and SZ (now EPR and ESZ) encodings. The PR and
90 * SZ bit placeholders still exist in data array 1, but are implemented as
91 * reserved bits, with the real logic existing in data array 2.
92 *
93 * The downside to this is that we can no longer fit everything in to a 32-bit
94 * PTE encoding, so a 64-bit pte_t is necessary for these parts. On the plus
95 * side, this gives us quite a few spare bits to play with for future usage.
96 */
97/* Legacy and compat mode bits */
98#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */
99#define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */
100#define _PAGE_DIRTY 0x004 /* D-bit : page changed */
101#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */
102#define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */
103#define _PAGE_RW 0x020 /* PR0-bit : write access allowed */
104#define _PAGE_USER 0x040 /* PR1-bit : user space access allowed*/
105#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */
106#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */
107#define _PAGE_PROTNONE 0x200 /* software: if not present */
108#define _PAGE_ACCESSED 0x400 /* software: page referenced */
109#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */
110
111#define _PAGE_SZ_MASK (_PAGE_SZ0 | _PAGE_SZ1)
112#define _PAGE_PR_MASK (_PAGE_RW | _PAGE_USER)
113
114/* Extended mode bits */
115#define _PAGE_EXT_ESZ0 0x0010 /* ESZ0-bit: Size of page */
116#define _PAGE_EXT_ESZ1 0x0020 /* ESZ1-bit: Size of page */
117#define _PAGE_EXT_ESZ2 0x0040 /* ESZ2-bit: Size of page */
118#define _PAGE_EXT_ESZ3 0x0080 /* ESZ3-bit: Size of page */
119
120#define _PAGE_EXT_USER_EXEC 0x0100 /* EPR0-bit: User space executable */
121#define _PAGE_EXT_USER_WRITE 0x0200 /* EPR1-bit: User space writable */
122#define _PAGE_EXT_USER_READ 0x0400 /* EPR2-bit: User space readable */
123
124#define _PAGE_EXT_KERN_EXEC 0x0800 /* EPR3-bit: Kernel space executable */
125#define _PAGE_EXT_KERN_WRITE 0x1000 /* EPR4-bit: Kernel space writable */
126#define _PAGE_EXT_KERN_READ 0x2000 /* EPR5-bit: Kernel space readable */
127
128/* Wrapper for extended mode pgprot twiddling */
129#define _PAGE_EXT(x) ((unsigned long long)(x) << 32)
130
131/* software: moves to PTEA.TC (Timing Control) */
132#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */
133#define _PAGE_PCC_AREA6 0x80000000 /* use BSC registers for area6 */
134
135/* software: moves to PTEA.SA[2:0] (Space Attributes) */
136#define _PAGE_PCC_IODYN 0x00000001 /* IO space, dynamically sized bus */
137#define _PAGE_PCC_IO8 0x20000000 /* IO space, 8 bit bus */
138#define _PAGE_PCC_IO16 0x20000001 /* IO space, 16 bit bus */
139#define _PAGE_PCC_COM8 0x40000000 /* Common Memory space, 8 bit bus */
140#define _PAGE_PCC_COM16 0x40000001 /* Common Memory space, 16 bit bus */
141#define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */
142#define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */
143
144/* Mask which drops unused bits from the PTEL value */
145#if defined(CONFIG_CPU_SH3)
146#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED| \
147 _PAGE_FILE | _PAGE_SZ1 | \
148 _PAGE_HW_SHARED)
149#elif defined(CONFIG_X2TLB)
150/* Get rid of the legacy PR/SZ bits when using extended mode */
151#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | \
152 _PAGE_FILE | _PAGE_PR_MASK | _PAGE_SZ_MASK)
153#else 74#else
154#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE) 75#define PHYS_ADDR_MASK 0x1fffffff
155#endif 76#endif
156 77
157#define _PAGE_FLAGS_HARDWARE_MASK (0x1fffffff & ~(_PAGE_CLEAR_FLAGS)) 78#define PTE_PHYS_MASK (PHYS_ADDR_MASK & PAGE_MASK)
158 79
159/* Hardware flags, page size encoding */ 80#ifdef CONFIG_SUPERH32
160#if defined(CONFIG_X2TLB) 81#define VMALLOC_START (P3SEG)
161# if defined(CONFIG_PAGE_SIZE_4KB)
162# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ0)
163# elif defined(CONFIG_PAGE_SIZE_8KB)
164# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ1)
165# elif defined(CONFIG_PAGE_SIZE_64KB)
166# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ2)
167# endif
168#else 82#else
169# if defined(CONFIG_PAGE_SIZE_4KB) 83#define VMALLOC_START (0xf0000000)
170# define _PAGE_FLAGS_HARD _PAGE_SZ0
171# elif defined(CONFIG_PAGE_SIZE_64KB)
172# define _PAGE_FLAGS_HARD _PAGE_SZ1
173# endif
174#endif 84#endif
85#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
175 86
176#if defined(CONFIG_X2TLB) 87#if defined(CONFIG_SUPERH32)
177# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 88#include <asm/pgtable_32.h>
178# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2)
179# elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
180# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ2)
181# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
182# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ1 | _PAGE_EXT_ESZ2)
183# elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
184# define _PAGE_SZHUGE (_PAGE_EXT_ESZ3)
185# elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
186# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2 | _PAGE_EXT_ESZ3)
187# endif
188#else 89#else
189# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K) 90#include <asm/pgtable_64.h>
190# define _PAGE_SZHUGE (_PAGE_SZ1)
191# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
192# define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1)
193# endif
194#endif
195
196/*
197 * Stub out _PAGE_SZHUGE if we don't have a good definition for it,
198 * to make pte_mkhuge() happy.
199 */
200#ifndef _PAGE_SZHUGE
201# define _PAGE_SZHUGE (_PAGE_FLAGS_HARD)
202#endif
203
204#define _PAGE_CHG_MASK \
205 (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY)
206
207#ifndef __ASSEMBLY__
208
209#if defined(CONFIG_X2TLB) /* SH-X2 TLB */
210#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
211 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
212
213#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
214 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
215 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
216 _PAGE_EXT_KERN_WRITE | \
217 _PAGE_EXT_USER_READ | \
218 _PAGE_EXT_USER_WRITE))
219
220#define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
221 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
222 _PAGE_EXT(_PAGE_EXT_KERN_EXEC | \
223 _PAGE_EXT_KERN_READ | \
224 _PAGE_EXT_USER_EXEC | \
225 _PAGE_EXT_USER_READ))
226
227#define PAGE_COPY PAGE_EXECREAD
228
229#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
230 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
231 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
232 _PAGE_EXT_USER_READ))
233
234#define PAGE_WRITEONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
235 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
236 _PAGE_EXT(_PAGE_EXT_KERN_WRITE | \
237 _PAGE_EXT_USER_WRITE))
238
239#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
240 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
241 _PAGE_EXT(_PAGE_EXT_KERN_WRITE | \
242 _PAGE_EXT_KERN_READ | \
243 _PAGE_EXT_KERN_EXEC | \
244 _PAGE_EXT_USER_WRITE | \
245 _PAGE_EXT_USER_READ | \
246 _PAGE_EXT_USER_EXEC))
247
248#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
249 _PAGE_DIRTY | _PAGE_ACCESSED | \
250 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
251 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
252 _PAGE_EXT_KERN_WRITE | \
253 _PAGE_EXT_KERN_EXEC))
254
255#define PAGE_KERNEL_NOCACHE \
256 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
257 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
258 _PAGE_FLAGS_HARD | \
259 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
260 _PAGE_EXT_KERN_WRITE | \
261 _PAGE_EXT_KERN_EXEC))
262
263#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
264 _PAGE_DIRTY | _PAGE_ACCESSED | \
265 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
266 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
267 _PAGE_EXT_KERN_EXEC))
268
269#define PAGE_KERNEL_PCC(slot, type) \
270 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
271 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
272 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
273 _PAGE_EXT_KERN_WRITE | \
274 _PAGE_EXT_KERN_EXEC) \
275 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
276 (type))
277
278#elif defined(CONFIG_MMU) /* SH-X TLB */
279#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
280 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
281
282#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
283 _PAGE_CACHABLE | _PAGE_ACCESSED | \
284 _PAGE_FLAGS_HARD)
285
286#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
287 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
288
289#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
290 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
291
292#define PAGE_EXECREAD PAGE_READONLY
293#define PAGE_RWX PAGE_SHARED
294#define PAGE_WRITEONLY PAGE_SHARED
295
296#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | \
297 _PAGE_DIRTY | _PAGE_ACCESSED | \
298 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
299
300#define PAGE_KERNEL_NOCACHE \
301 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
302 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
303 _PAGE_FLAGS_HARD)
304
305#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
306 _PAGE_DIRTY | _PAGE_ACCESSED | \
307 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
308
309#define PAGE_KERNEL_PCC(slot, type) \
310 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
311 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
312 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
313 (type))
314#else /* no mmu */
315#define PAGE_NONE __pgprot(0)
316#define PAGE_SHARED __pgprot(0)
317#define PAGE_COPY __pgprot(0)
318#define PAGE_EXECREAD __pgprot(0)
319#define PAGE_RWX __pgprot(0)
320#define PAGE_READONLY __pgprot(0)
321#define PAGE_WRITEONLY __pgprot(0)
322#define PAGE_KERNEL __pgprot(0)
323#define PAGE_KERNEL_NOCACHE __pgprot(0)
324#define PAGE_KERNEL_RO __pgprot(0)
325#define PAGE_KERNEL_PCC __pgprot(0)
326#endif 91#endif
327 92
328#endif /* __ASSEMBLY__ */
329
330/* 93/*
331 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page 94 * SH-X and lower (legacy) SuperH parts (SH-3, SH-4, some SH-4A) can't do page
332 * protection for execute, and considers it the same as a read. Also, write 95 * protection for execute, and considers it the same as a read. Also, write
@@ -355,208 +118,6 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
355#define __S110 PAGE_RWX 118#define __S110 PAGE_RWX
356#define __S111 PAGE_RWX 119#define __S111 PAGE_RWX
357 120
358#ifndef __ASSEMBLY__
359
360/*
361 * Certain architectures need to do special things when PTEs
362 * within a page table are directly modified. Thus, the following
363 * hook is made available.
364 */
365#ifdef CONFIG_X2TLB
366static inline void set_pte(pte_t *ptep, pte_t pte)
367{
368 ptep->pte_high = pte.pte_high;
369 smp_wmb();
370 ptep->pte_low = pte.pte_low;
371}
372#else
373#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
374#endif
375
376#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
377
378/*
379 * (pmds are folded into pgds so this doesn't get actually called,
380 * but the define is needed for a generic inline function.)
381 */
382#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
383
384#define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
385
386#define pfn_pte(pfn, prot) \
387 __pte(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
388#define pfn_pmd(pfn, prot) \
389 __pmd(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
390
391#define pte_none(x) (!pte_val(x))
392#define pte_present(x) ((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE))
393
394#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
395
396#define pmd_none(x) (!pmd_val(x))
397#define pmd_present(x) (pmd_val(x))
398#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
399#define pmd_bad(x) (pmd_val(x) & ~PAGE_MASK)
400
401#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
402#define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK)
403
404/*
405 * The following only work if pte_present() is true.
406 * Undefined behaviour if not..
407 */
408#define pte_not_present(pte) (!((pte).pte_low & _PAGE_PRESENT))
409#define pte_dirty(pte) ((pte).pte_low & _PAGE_DIRTY)
410#define pte_young(pte) ((pte).pte_low & _PAGE_ACCESSED)
411#define pte_file(pte) ((pte).pte_low & _PAGE_FILE)
412
413#ifdef CONFIG_X2TLB
414#define pte_write(pte) ((pte).pte_high & _PAGE_EXT_USER_WRITE)
415#else
416#define pte_write(pte) ((pte).pte_low & _PAGE_RW)
417#endif
418
419#define PTE_BIT_FUNC(h,fn,op) \
420static inline pte_t pte_##fn(pte_t pte) { pte.pte_##h op; return pte; }
421
422#ifdef CONFIG_X2TLB
423/*
424 * We cheat a bit in the SH-X2 TLB case. As the permission bits are
425 * individually toggled (and user permissions are entirely decoupled from
426 * kernel permissions), we attempt to couple them a bit more sanely here.
427 */
428PTE_BIT_FUNC(high, wrprotect, &= ~_PAGE_EXT_USER_WRITE);
429PTE_BIT_FUNC(high, mkwrite, |= _PAGE_EXT_USER_WRITE | _PAGE_EXT_KERN_WRITE);
430PTE_BIT_FUNC(high, mkhuge, |= _PAGE_SZHUGE);
431#else
432PTE_BIT_FUNC(low, wrprotect, &= ~_PAGE_RW);
433PTE_BIT_FUNC(low, mkwrite, |= _PAGE_RW);
434PTE_BIT_FUNC(low, mkhuge, |= _PAGE_SZHUGE);
435#endif
436
437PTE_BIT_FUNC(low, mkclean, &= ~_PAGE_DIRTY);
438PTE_BIT_FUNC(low, mkdirty, |= _PAGE_DIRTY);
439PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED);
440PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED);
441
442/*
443 * Macro and implementation to make a page protection as uncachable.
444 */
445#define pgprot_writecombine(prot) \
446 __pgprot(pgprot_val(prot) & ~_PAGE_CACHABLE)
447
448#define pgprot_noncached pgprot_writecombine
449
450/*
451 * Conversion functions: convert a page and protection to a page entry,
452 * and a page entry and page directory to the page they refer to.
453 *
454 * extern pte_t mk_pte(struct page *page, pgprot_t pgprot)
455 */
456#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
457
458static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
459{
460 pte.pte_low &= _PAGE_CHG_MASK;
461 pte.pte_low |= pgprot_val(newprot);
462
463#ifdef CONFIG_X2TLB
464 pte.pte_high |= pgprot_val(newprot) >> 32;
465#endif
466
467 return pte;
468}
469
470#define pmd_page_vaddr(pmd) ((unsigned long)pmd_val(pmd))
471#define pmd_page(pmd) (virt_to_page(pmd_val(pmd)))
472
473/* to find an entry in a page-table-directory. */
474#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
475#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
476
477/* to find an entry in a kernel page-table-directory */
478#define pgd_offset_k(address) pgd_offset(&init_mm, address)
479
480/* Find an entry in the third-level page table.. */
481#define pte_index(address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
482#define pte_offset_kernel(dir, address) \
483 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
484#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
485#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
486
487#define pte_unmap(pte) do { } while (0)
488#define pte_unmap_nested(pte) do { } while (0)
489
490#ifdef CONFIG_X2TLB
491#define pte_ERROR(e) \
492 printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, \
493 &(e), (e).pte_high, (e).pte_low)
494#define pgd_ERROR(e) \
495 printk("%s:%d: bad pgd %016llx.\n", __FILE__, __LINE__, pgd_val(e))
496#else
497#define pte_ERROR(e) \
498 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
499#define pgd_ERROR(e) \
500 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
501#endif
502
503struct vm_area_struct;
504extern void update_mmu_cache(struct vm_area_struct * vma,
505 unsigned long address, pte_t pte);
506
507/*
508 * Encode and de-code a swap entry
509 *
510 * Constraints:
511 * _PAGE_FILE at bit 0
512 * _PAGE_PRESENT at bit 8
513 * _PAGE_PROTNONE at bit 9
514 *
515 * For the normal case, we encode the swap type into bits 0:7 and the
516 * swap offset into bits 10:30. For the 64-bit PTE case, we keep the
517 * preserved bits in the low 32-bits and use the upper 32 as the swap
518 * offset (along with a 5-bit type), following the same approach as x86
519 * PAE. This keeps the logic quite simple, and allows for a full 32
520 * PTE_FILE_MAX_BITS, as opposed to the 29-bits we're constrained with
521 * in the pte_low case.
522 *
523 * As is evident by the Alpha code, if we ever get a 64-bit unsigned
524 * long (swp_entry_t) to match up with the 64-bit PTEs, this all becomes
525 * much cleaner..
526 *
527 * NOTE: We should set ZEROs at the position of _PAGE_PRESENT
528 * and _PAGE_PROTNONE bits
529 */
530#ifdef CONFIG_X2TLB
531#define __swp_type(x) ((x).val & 0x1f)
532#define __swp_offset(x) ((x).val >> 5)
533#define __swp_entry(type, offset) ((swp_entry_t){ (type) | (offset) << 5})
534#define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high })
535#define __swp_entry_to_pte(x) ((pte_t){ 0, (x).val })
536
537/*
538 * Encode and decode a nonlinear file mapping entry
539 */
540#define pte_to_pgoff(pte) ((pte).pte_high)
541#define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) })
542
543#define PTE_FILE_MAX_BITS 32
544#else
545#define __swp_type(x) ((x).val & 0xff)
546#define __swp_offset(x) ((x).val >> 10)
547#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) <<10})
548
549#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) >> 1 })
550#define __swp_entry_to_pte(x) ((pte_t) { (x).val << 1 })
551
552/*
553 * Encode and decode a nonlinear file mapping entry
554 */
555#define PTE_FILE_MAX_BITS 29
556#define pte_to_pgoff(pte) (pte_val(pte) >> 1)
557#define pgoff_to_pte(off) ((pte_t) { ((off) << 1) | _PAGE_FILE })
558#endif
559
560typedef pte_t *pte_addr_t; 121typedef pte_t *pte_addr_t;
561 122
562#define kern_addr_valid(addr) (1) 123#define kern_addr_valid(addr) (1)
@@ -564,27 +125,28 @@ typedef pte_t *pte_addr_t;
564#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 125#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
565 remap_pfn_range(vma, vaddr, pfn, size, prot) 126 remap_pfn_range(vma, vaddr, pfn, size, prot)
566 127
567struct mm_struct; 128#define pte_pfn(x) ((unsigned long)(((x).pte_low >> PAGE_SHIFT)))
568 129
569/* 130/*
570 * No page table caches to initialise 131 * No page table caches to initialise
571 */ 132 */
572#define pgtable_cache_init() do { } while (0) 133#define pgtable_cache_init() do { } while (0)
573 134
574#ifndef CONFIG_MMU
575extern unsigned int kobjsize(const void *objp);
576#endif /* !CONFIG_MMU */
577
578#if !defined(CONFIG_CACHE_OFF) && (defined(CONFIG_CPU_SH4) || \ 135#if !defined(CONFIG_CACHE_OFF) && (defined(CONFIG_CPU_SH4) || \
579 defined(CONFIG_SH7705_CACHE_32KB)) 136 defined(CONFIG_SH7705_CACHE_32KB))
137struct mm_struct;
580#define __HAVE_ARCH_PTEP_GET_AND_CLEAR 138#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
581extern pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 139pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
582#endif 140#endif
583 141
142struct vm_area_struct;
143extern void update_mmu_cache(struct vm_area_struct * vma,
144 unsigned long address, pte_t pte);
584extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 145extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
585extern void paging_init(void); 146extern void paging_init(void);
147extern void page_table_range_init(unsigned long start, unsigned long end,
148 pgd_t *pgd);
586 149
587#include <asm-generic/pgtable.h> 150#include <asm-generic/pgtable.h>
588 151
589#endif /* !__ASSEMBLY__ */ 152#endif /* __ASM_SH_PGTABLE_H */
590#endif /* __ASM_SH_PAGE_H */
diff --git a/include/asm-sh/pgtable_32.h b/include/asm-sh/pgtable_32.h
new file mode 100644
index 000000000000..3e3557c53c55
--- /dev/null
+++ b/include/asm-sh/pgtable_32.h
@@ -0,0 +1,474 @@
1#ifndef __ASM_SH_PGTABLE_32_H
2#define __ASM_SH_PGTABLE_32_H
3
4/*
5 * Linux PTEL encoding.
6 *
7 * Hardware and software bit definitions for the PTEL value (see below for
8 * notes on SH-X2 MMUs and 64-bit PTEs):
9 *
10 * - Bits 0 and 7 are reserved on SH-3 (_PAGE_WT and _PAGE_SZ1 on SH-4).
11 *
12 * - Bit 1 is the SH-bit, but is unused on SH-3 due to an MMU bug (the
13 * hardware PTEL value can't have the SH-bit set when MMUCR.IX is set,
14 * which is the default in cpu-sh3/mmu_context.h:MMU_CONTROL_INIT).
15 *
16 * In order to keep this relatively clean, do not use these for defining
17 * SH-3 specific flags until all of the other unused bits have been
18 * exhausted.
19 *
20 * - Bit 9 is reserved by everyone and used by _PAGE_PROTNONE.
21 *
22 * - Bits 10 and 11 are low bits of the PPN that are reserved on >= 4K pages.
23 * Bit 10 is used for _PAGE_ACCESSED, bit 11 remains unused.
24 *
25 * - On 29 bit platforms, bits 31 to 29 are used for the space attributes
26 * and timing control which (together with bit 0) are moved into the
27 * old-style PTEA on the parts that support it.
28 *
29 * XXX: Leave the _PAGE_FILE and _PAGE_WT overhaul for a rainy day.
30 *
31 * SH-X2 MMUs and extended PTEs
32 *
33 * SH-X2 supports an extended mode TLB with split data arrays due to the
34 * number of bits needed for PR and SZ (now EPR and ESZ) encodings. The PR and
35 * SZ bit placeholders still exist in data array 1, but are implemented as
36 * reserved bits, with the real logic existing in data array 2.
37 *
38 * The downside to this is that we can no longer fit everything in to a 32-bit
39 * PTE encoding, so a 64-bit pte_t is necessary for these parts. On the plus
40 * side, this gives us quite a few spare bits to play with for future usage.
41 */
42/* Legacy and compat mode bits */
43#define _PAGE_WT 0x001 /* WT-bit on SH-4, 0 on SH-3 */
44#define _PAGE_HW_SHARED 0x002 /* SH-bit : shared among processes */
45#define _PAGE_DIRTY 0x004 /* D-bit : page changed */
46#define _PAGE_CACHABLE 0x008 /* C-bit : cachable */
47#define _PAGE_SZ0 0x010 /* SZ0-bit : Size of page */
48#define _PAGE_RW 0x020 /* PR0-bit : write access allowed */
49#define _PAGE_USER 0x040 /* PR1-bit : user space access allowed*/
50#define _PAGE_SZ1 0x080 /* SZ1-bit : Size of page (on SH-4) */
51#define _PAGE_PRESENT 0x100 /* V-bit : page is valid */
52#define _PAGE_PROTNONE 0x200 /* software: if not present */
53#define _PAGE_ACCESSED 0x400 /* software: page referenced */
54#define _PAGE_FILE _PAGE_WT /* software: pagecache or swap? */
55
56#define _PAGE_SZ_MASK (_PAGE_SZ0 | _PAGE_SZ1)
57#define _PAGE_PR_MASK (_PAGE_RW | _PAGE_USER)
58
59/* Extended mode bits */
60#define _PAGE_EXT_ESZ0 0x0010 /* ESZ0-bit: Size of page */
61#define _PAGE_EXT_ESZ1 0x0020 /* ESZ1-bit: Size of page */
62#define _PAGE_EXT_ESZ2 0x0040 /* ESZ2-bit: Size of page */
63#define _PAGE_EXT_ESZ3 0x0080 /* ESZ3-bit: Size of page */
64
65#define _PAGE_EXT_USER_EXEC 0x0100 /* EPR0-bit: User space executable */
66#define _PAGE_EXT_USER_WRITE 0x0200 /* EPR1-bit: User space writable */
67#define _PAGE_EXT_USER_READ 0x0400 /* EPR2-bit: User space readable */
68
69#define _PAGE_EXT_KERN_EXEC 0x0800 /* EPR3-bit: Kernel space executable */
70#define _PAGE_EXT_KERN_WRITE 0x1000 /* EPR4-bit: Kernel space writable */
71#define _PAGE_EXT_KERN_READ 0x2000 /* EPR5-bit: Kernel space readable */
72
73/* Wrapper for extended mode pgprot twiddling */
74#define _PAGE_EXT(x) ((unsigned long long)(x) << 32)
75
76/* software: moves to PTEA.TC (Timing Control) */
77#define _PAGE_PCC_AREA5 0x00000000 /* use BSC registers for area5 */
78#define _PAGE_PCC_AREA6 0x80000000 /* use BSC registers for area6 */
79
80/* software: moves to PTEA.SA[2:0] (Space Attributes) */
81#define _PAGE_PCC_IODYN 0x00000001 /* IO space, dynamically sized bus */
82#define _PAGE_PCC_IO8 0x20000000 /* IO space, 8 bit bus */
83#define _PAGE_PCC_IO16 0x20000001 /* IO space, 16 bit bus */
84#define _PAGE_PCC_COM8 0x40000000 /* Common Memory space, 8 bit bus */
85#define _PAGE_PCC_COM16 0x40000001 /* Common Memory space, 16 bit bus */
86#define _PAGE_PCC_ATR8 0x60000000 /* Attribute Memory space, 8 bit bus */
87#define _PAGE_PCC_ATR16 0x60000001 /* Attribute Memory space, 6 bit bus */
88
89/* Mask which drops unused bits from the PTEL value */
90#if defined(CONFIG_CPU_SH3)
91#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED| \
92 _PAGE_FILE | _PAGE_SZ1 | \
93 _PAGE_HW_SHARED)
94#elif defined(CONFIG_X2TLB)
95/* Get rid of the legacy PR/SZ bits when using extended mode */
96#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | \
97 _PAGE_FILE | _PAGE_PR_MASK | _PAGE_SZ_MASK)
98#else
99#define _PAGE_CLEAR_FLAGS (_PAGE_PROTNONE | _PAGE_ACCESSED | _PAGE_FILE)
100#endif
101
102#define _PAGE_FLAGS_HARDWARE_MASK (PHYS_ADDR_MASK & ~(_PAGE_CLEAR_FLAGS))
103
104/* Hardware flags, page size encoding */
105#if defined(CONFIG_X2TLB)
106# if defined(CONFIG_PAGE_SIZE_4KB)
107# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ0)
108# elif defined(CONFIG_PAGE_SIZE_8KB)
109# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ1)
110# elif defined(CONFIG_PAGE_SIZE_64KB)
111# define _PAGE_FLAGS_HARD _PAGE_EXT(_PAGE_EXT_ESZ2)
112# endif
113#else
114# if defined(CONFIG_PAGE_SIZE_4KB)
115# define _PAGE_FLAGS_HARD _PAGE_SZ0
116# elif defined(CONFIG_PAGE_SIZE_64KB)
117# define _PAGE_FLAGS_HARD _PAGE_SZ1
118# endif
119#endif
120
121#if defined(CONFIG_X2TLB)
122# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
123# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2)
124# elif defined(CONFIG_HUGETLB_PAGE_SIZE_256K)
125# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ2)
126# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
127# define _PAGE_SZHUGE (_PAGE_EXT_ESZ0 | _PAGE_EXT_ESZ1 | _PAGE_EXT_ESZ2)
128# elif defined(CONFIG_HUGETLB_PAGE_SIZE_4MB)
129# define _PAGE_SZHUGE (_PAGE_EXT_ESZ3)
130# elif defined(CONFIG_HUGETLB_PAGE_SIZE_64MB)
131# define _PAGE_SZHUGE (_PAGE_EXT_ESZ2 | _PAGE_EXT_ESZ3)
132# endif
133#else
134# if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
135# define _PAGE_SZHUGE (_PAGE_SZ1)
136# elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
137# define _PAGE_SZHUGE (_PAGE_SZ0 | _PAGE_SZ1)
138# endif
139#endif
140
141/*
142 * Stub out _PAGE_SZHUGE if we don't have a good definition for it,
143 * to make pte_mkhuge() happy.
144 */
145#ifndef _PAGE_SZHUGE
146# define _PAGE_SZHUGE (_PAGE_FLAGS_HARD)
147#endif
148
149#define _PAGE_CHG_MASK \
150 (PTE_MASK | _PAGE_ACCESSED | _PAGE_CACHABLE | _PAGE_DIRTY)
151
152#ifndef __ASSEMBLY__
153
154#if defined(CONFIG_X2TLB) /* SH-X2 TLB */
155#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
156 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
157
158#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
159 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
160 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
161 _PAGE_EXT_KERN_WRITE | \
162 _PAGE_EXT_USER_READ | \
163 _PAGE_EXT_USER_WRITE))
164
165#define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
166 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
167 _PAGE_EXT(_PAGE_EXT_KERN_EXEC | \
168 _PAGE_EXT_KERN_READ | \
169 _PAGE_EXT_USER_EXEC | \
170 _PAGE_EXT_USER_READ))
171
172#define PAGE_COPY PAGE_EXECREAD
173
174#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
175 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
176 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
177 _PAGE_EXT_USER_READ))
178
179#define PAGE_WRITEONLY __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
180 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
181 _PAGE_EXT(_PAGE_EXT_KERN_WRITE | \
182 _PAGE_EXT_USER_WRITE))
183
184#define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
185 _PAGE_CACHABLE | _PAGE_FLAGS_HARD | \
186 _PAGE_EXT(_PAGE_EXT_KERN_WRITE | \
187 _PAGE_EXT_KERN_READ | \
188 _PAGE_EXT_KERN_EXEC | \
189 _PAGE_EXT_USER_WRITE | \
190 _PAGE_EXT_USER_READ | \
191 _PAGE_EXT_USER_EXEC))
192
193#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
194 _PAGE_DIRTY | _PAGE_ACCESSED | \
195 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
196 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
197 _PAGE_EXT_KERN_WRITE | \
198 _PAGE_EXT_KERN_EXEC))
199
200#define PAGE_KERNEL_NOCACHE \
201 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
202 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
203 _PAGE_FLAGS_HARD | \
204 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
205 _PAGE_EXT_KERN_WRITE | \
206 _PAGE_EXT_KERN_EXEC))
207
208#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
209 _PAGE_DIRTY | _PAGE_ACCESSED | \
210 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD | \
211 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
212 _PAGE_EXT_KERN_EXEC))
213
214#define PAGE_KERNEL_PCC(slot, type) \
215 __pgprot(_PAGE_PRESENT | _PAGE_DIRTY | \
216 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
217 _PAGE_EXT(_PAGE_EXT_KERN_READ | \
218 _PAGE_EXT_KERN_WRITE | \
219 _PAGE_EXT_KERN_EXEC) \
220 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
221 (type))
222
223#elif defined(CONFIG_MMU) /* SH-X TLB */
224#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_CACHABLE | \
225 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
226
227#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | \
228 _PAGE_CACHABLE | _PAGE_ACCESSED | \
229 _PAGE_FLAGS_HARD)
230
231#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
232 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
233
234#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | \
235 _PAGE_ACCESSED | _PAGE_FLAGS_HARD)
236
237#define PAGE_EXECREAD PAGE_READONLY
238#define PAGE_RWX PAGE_SHARED
239#define PAGE_WRITEONLY PAGE_SHARED
240
241#define PAGE_KERNEL __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_CACHABLE | \
242 _PAGE_DIRTY | _PAGE_ACCESSED | \
243 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
244
245#define PAGE_KERNEL_NOCACHE \
246 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
247 _PAGE_ACCESSED | _PAGE_HW_SHARED | \
248 _PAGE_FLAGS_HARD)
249
250#define PAGE_KERNEL_RO __pgprot(_PAGE_PRESENT | _PAGE_CACHABLE | \
251 _PAGE_DIRTY | _PAGE_ACCESSED | \
252 _PAGE_HW_SHARED | _PAGE_FLAGS_HARD)
253
254#define PAGE_KERNEL_PCC(slot, type) \
255 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | \
256 _PAGE_ACCESSED | _PAGE_FLAGS_HARD | \
257 (slot ? _PAGE_PCC_AREA5 : _PAGE_PCC_AREA6) | \
258 (type))
259#else /* no mmu */
260#define PAGE_NONE __pgprot(0)
261#define PAGE_SHARED __pgprot(0)
262#define PAGE_COPY __pgprot(0)
263#define PAGE_EXECREAD __pgprot(0)
264#define PAGE_RWX __pgprot(0)
265#define PAGE_READONLY __pgprot(0)
266#define PAGE_WRITEONLY __pgprot(0)
267#define PAGE_KERNEL __pgprot(0)
268#define PAGE_KERNEL_NOCACHE __pgprot(0)
269#define PAGE_KERNEL_RO __pgprot(0)
270
271#define PAGE_KERNEL_PCC(slot, type) \
272 __pgprot(0)
273#endif
274
275#endif /* __ASSEMBLY__ */
276
277#ifndef __ASSEMBLY__
278
279/*
280 * Certain architectures need to do special things when PTEs
281 * within a page table are directly modified. Thus, the following
282 * hook is made available.
283 */
284#ifdef CONFIG_X2TLB
285static inline void set_pte(pte_t *ptep, pte_t pte)
286{
287 ptep->pte_high = pte.pte_high;
288 smp_wmb();
289 ptep->pte_low = pte.pte_low;
290}
291#else
292#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
293#endif
294
295#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
296
297/*
298 * (pmds are folded into pgds so this doesn't get actually called,
299 * but the define is needed for a generic inline function.)
300 */
301#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
302
303#define pfn_pte(pfn, prot) \
304 __pte(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
305#define pfn_pmd(pfn, prot) \
306 __pmd(((unsigned long long)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
307
308#define pte_none(x) (!pte_val(x))
309#define pte_present(x) ((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE))
310
311#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
312
313#define pmd_none(x) (!pmd_val(x))
314#define pmd_present(x) (pmd_val(x))
315#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
316#define pmd_bad(x) (pmd_val(x) & ~PAGE_MASK)
317
318#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
319#define pte_page(x) pfn_to_page(pte_pfn(x))
320
321/*
322 * The following only work if pte_present() is true.
323 * Undefined behaviour if not..
324 */
325#define pte_not_present(pte) (!((pte).pte_low & _PAGE_PRESENT))
326#define pte_dirty(pte) ((pte).pte_low & _PAGE_DIRTY)
327#define pte_young(pte) ((pte).pte_low & _PAGE_ACCESSED)
328#define pte_file(pte) ((pte).pte_low & _PAGE_FILE)
329
330#ifdef CONFIG_X2TLB
331#define pte_write(pte) ((pte).pte_high & _PAGE_EXT_USER_WRITE)
332#else
333#define pte_write(pte) ((pte).pte_low & _PAGE_RW)
334#endif
335
336#define PTE_BIT_FUNC(h,fn,op) \
337static inline pte_t pte_##fn(pte_t pte) { pte.pte_##h op; return pte; }
338
339#ifdef CONFIG_X2TLB
340/*
341 * We cheat a bit in the SH-X2 TLB case. As the permission bits are
342 * individually toggled (and user permissions are entirely decoupled from
343 * kernel permissions), we attempt to couple them a bit more sanely here.
344 */
345PTE_BIT_FUNC(high, wrprotect, &= ~_PAGE_EXT_USER_WRITE);
346PTE_BIT_FUNC(high, mkwrite, |= _PAGE_EXT_USER_WRITE | _PAGE_EXT_KERN_WRITE);
347PTE_BIT_FUNC(high, mkhuge, |= _PAGE_SZHUGE);
348#else
349PTE_BIT_FUNC(low, wrprotect, &= ~_PAGE_RW);
350PTE_BIT_FUNC(low, mkwrite, |= _PAGE_RW);
351PTE_BIT_FUNC(low, mkhuge, |= _PAGE_SZHUGE);
352#endif
353
354PTE_BIT_FUNC(low, mkclean, &= ~_PAGE_DIRTY);
355PTE_BIT_FUNC(low, mkdirty, |= _PAGE_DIRTY);
356PTE_BIT_FUNC(low, mkold, &= ~_PAGE_ACCESSED);
357PTE_BIT_FUNC(low, mkyoung, |= _PAGE_ACCESSED);
358
359/*
360 * Macro and implementation to make a page protection as uncachable.
361 */
362#define pgprot_writecombine(prot) \
363 __pgprot(pgprot_val(prot) & ~_PAGE_CACHABLE)
364
365#define pgprot_noncached pgprot_writecombine
366
367/*
368 * Conversion functions: convert a page and protection to a page entry,
369 * and a page entry and page directory to the page they refer to.
370 *
371 * extern pte_t mk_pte(struct page *page, pgprot_t pgprot)
372 */
373#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
374
375static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
376{
377 pte.pte_low &= _PAGE_CHG_MASK;
378 pte.pte_low |= pgprot_val(newprot);
379
380#ifdef CONFIG_X2TLB
381 pte.pte_high |= pgprot_val(newprot) >> 32;
382#endif
383
384 return pte;
385}
386
387#define pmd_page_vaddr(pmd) ((unsigned long)pmd_val(pmd))
388#define pmd_page(pmd) (virt_to_page(pmd_val(pmd)))
389
390/* to find an entry in a page-table-directory. */
391#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
392#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
393
394/* to find an entry in a kernel page-table-directory */
395#define pgd_offset_k(address) pgd_offset(&init_mm, address)
396
397/* Find an entry in the third-level page table.. */
398#define pte_index(address) ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
399#define pte_offset_kernel(dir, address) \
400 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
401#define pte_offset_map(dir, address) pte_offset_kernel(dir, address)
402#define pte_offset_map_nested(dir, address) pte_offset_kernel(dir, address)
403
404#define pte_unmap(pte) do { } while (0)
405#define pte_unmap_nested(pte) do { } while (0)
406
407#ifdef CONFIG_X2TLB
408#define pte_ERROR(e) \
409 printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, \
410 &(e), (e).pte_high, (e).pte_low)
411#define pgd_ERROR(e) \
412 printk("%s:%d: bad pgd %016llx.\n", __FILE__, __LINE__, pgd_val(e))
413#else
414#define pte_ERROR(e) \
415 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
416#define pgd_ERROR(e) \
417 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
418#endif
419
420/*
421 * Encode and de-code a swap entry
422 *
423 * Constraints:
424 * _PAGE_FILE at bit 0
425 * _PAGE_PRESENT at bit 8
426 * _PAGE_PROTNONE at bit 9
427 *
428 * For the normal case, we encode the swap type into bits 0:7 and the
429 * swap offset into bits 10:30. For the 64-bit PTE case, we keep the
430 * preserved bits in the low 32-bits and use the upper 32 as the swap
431 * offset (along with a 5-bit type), following the same approach as x86
432 * PAE. This keeps the logic quite simple, and allows for a full 32
433 * PTE_FILE_MAX_BITS, as opposed to the 29-bits we're constrained with
434 * in the pte_low case.
435 *
436 * As is evident by the Alpha code, if we ever get a 64-bit unsigned
437 * long (swp_entry_t) to match up with the 64-bit PTEs, this all becomes
438 * much cleaner..
439 *
440 * NOTE: We should set ZEROs at the position of _PAGE_PRESENT
441 * and _PAGE_PROTNONE bits
442 */
443#ifdef CONFIG_X2TLB
444#define __swp_type(x) ((x).val & 0x1f)
445#define __swp_offset(x) ((x).val >> 5)
446#define __swp_entry(type, offset) ((swp_entry_t){ (type) | (offset) << 5})
447#define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high })
448#define __swp_entry_to_pte(x) ((pte_t){ 0, (x).val })
449
450/*
451 * Encode and decode a nonlinear file mapping entry
452 */
453#define pte_to_pgoff(pte) ((pte).pte_high)
454#define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) })
455
456#define PTE_FILE_MAX_BITS 32
457#else
458#define __swp_type(x) ((x).val & 0xff)
459#define __swp_offset(x) ((x).val >> 10)
460#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) <<10})
461
462#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) >> 1 })
463#define __swp_entry_to_pte(x) ((pte_t) { (x).val << 1 })
464
465/*
466 * Encode and decode a nonlinear file mapping entry
467 */
468#define PTE_FILE_MAX_BITS 29
469#define pte_to_pgoff(pte) (pte_val(pte) >> 1)
470#define pgoff_to_pte(off) ((pte_t) { ((off) << 1) | _PAGE_FILE })
471#endif
472
473#endif /* __ASSEMBLY__ */
474#endif /* __ASM_SH_PGTABLE_32_H */
diff --git a/include/asm-sh64/pgtable.h b/include/asm-sh/pgtable_64.h
index 3488fe32e436..972211671c9a 100644
--- a/include/asm-sh64/pgtable.h
+++ b/include/asm-sh/pgtable_64.h
@@ -1,136 +1,40 @@
1#ifndef __ASM_SH64_PGTABLE_H 1#ifndef __ASM_SH_PGTABLE_64_H
2#define __ASM_SH64_PGTABLE_H 2#define __ASM_SH_PGTABLE_64_H
3
4#include <asm-generic/4level-fixup.h>
5 3
6/* 4/*
7 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/pgtable_64.h
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 * 6 *
11 * include/asm-sh64/pgtable.h 7 * This file contains the functions and defines necessary to modify and use
8 * the SuperH page table tree.
12 * 9 *
13 * Copyright (C) 2000, 2001 Paolo Alberelli 10 * Copyright (C) 2000, 2001 Paolo Alberelli
14 * Copyright (C) 2003, 2004 Paul Mundt 11 * Copyright (C) 2003, 2004 Paul Mundt
15 * Copyright (C) 2003, 2004 Richard Curnow 12 * Copyright (C) 2003, 2004 Richard Curnow
16 * 13 *
17 * This file contains the functions and defines necessary to modify and use 14 * This file is subject to the terms and conditions of the GNU General Public
18 * the SuperH page table tree. 15 * License. See the file "COPYING" in the main directory of this archive
16 * for more details.
19 */ 17 */
20 18#include <linux/threads.h>
21#ifndef __ASSEMBLY__
22#include <asm/processor.h> 19#include <asm/processor.h>
23#include <asm/page.h> 20#include <asm/page.h>
24#include <linux/threads.h>
25
26struct vm_area_struct;
27
28extern void paging_init(void);
29
30/* We provide our own get_unmapped_area to avoid cache synonym issue */
31#define HAVE_ARCH_UNMAPPED_AREA
32
33/*
34 * Basically we have the same two-level (which is the logical three level
35 * Linux page table layout folded) page tables as the i386.
36 */
37
38/*
39 * ZERO_PAGE is a global shared page that is always zero: used
40 * for zero-mapped memory areas etc..
41 */
42extern unsigned char empty_zero_page[PAGE_SIZE];
43#define ZERO_PAGE(vaddr) (mem_map + MAP_NR(empty_zero_page))
44
45#endif /* !__ASSEMBLY__ */
46
47/*
48 * NEFF and NPHYS related defines.
49 * FIXME : These need to be model-dependent. For now this is OK, SH5-101 and SH5-103
50 * implement 32 bits effective and 32 bits physical. But future implementations may
51 * extend beyond this.
52 */
53#define NEFF 32
54#define NEFF_SIGN (1LL << (NEFF - 1))
55#define NEFF_MASK (-1LL << NEFF)
56
57#define NPHYS 32
58#define NPHYS_SIGN (1LL << (NPHYS - 1))
59#define NPHYS_MASK (-1LL << NPHYS)
60
61/* Typically 2-level is sufficient up to 32 bits of virtual address space, beyond
62 that 3-level would be appropriate. */
63#if defined(CONFIG_SH64_PGTABLE_2_LEVEL)
64/* For 4k pages, this contains 512 entries, i.e. 9 bits worth of address. */
65#define PTRS_PER_PTE ((1<<PAGE_SHIFT)/sizeof(unsigned long long))
66#define PTE_MAGNITUDE 3 /* sizeof(unsigned long long) magnit. */
67#define PTE_SHIFT PAGE_SHIFT
68#define PTE_BITS (PAGE_SHIFT - PTE_MAGNITUDE)
69
70/* top level: PMD. */
71#define PGDIR_SHIFT (PTE_SHIFT + PTE_BITS)
72#define PGD_BITS (NEFF - PGDIR_SHIFT)
73#define PTRS_PER_PGD (1<<PGD_BITS)
74
75/* middle level: PMD. This doesn't do anything for the 2-level case. */
76#define PTRS_PER_PMD (1)
77
78#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
79#define PGDIR_MASK (~(PGDIR_SIZE-1))
80#define PMD_SHIFT PGDIR_SHIFT
81#define PMD_SIZE PGDIR_SIZE
82#define PMD_MASK PGDIR_MASK
83
84#elif defined(CONFIG_SH64_PGTABLE_3_LEVEL)
85/*
86 * three-level asymmetric paging structure: PGD is top level.
87 * The asymmetry comes from 32-bit pointers and 64-bit PTEs.
88 */
89/* bottom level: PTE. It's 9 bits = 512 pointers */
90#define PTRS_PER_PTE ((1<<PAGE_SHIFT)/sizeof(unsigned long long))
91#define PTE_MAGNITUDE 3 /* sizeof(unsigned long long) magnit. */
92#define PTE_SHIFT PAGE_SHIFT
93#define PTE_BITS (PAGE_SHIFT - PTE_MAGNITUDE)
94
95/* middle level: PMD. It's 10 bits = 1024 pointers */
96#define PTRS_PER_PMD ((1<<PAGE_SHIFT)/sizeof(unsigned long long *))
97#define PMD_MAGNITUDE 2 /* sizeof(unsigned long long *) magnit. */
98#define PMD_SHIFT (PTE_SHIFT + PTE_BITS)
99#define PMD_BITS (PAGE_SHIFT - PMD_MAGNITUDE)
100
101/* top level: PMD. It's 1 bit = 2 pointers */
102#define PGDIR_SHIFT (PMD_SHIFT + PMD_BITS)
103#define PGD_BITS (NEFF - PGDIR_SHIFT)
104#define PTRS_PER_PGD (1<<PGD_BITS)
105
106#define PMD_SIZE (1UL << PMD_SHIFT)
107#define PMD_MASK (~(PMD_SIZE-1))
108#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
109#define PGDIR_MASK (~(PGDIR_SIZE-1))
110
111#else
112#error "No defined number of page table levels"
113#endif
114 21
115/* 22/*
116 * Error outputs. 23 * Error outputs.
117 */ 24 */
118#define pte_ERROR(e) \ 25#define pte_ERROR(e) \
119 printk("%s:%d: bad pte %016Lx.\n", __FILE__, __LINE__, pte_val(e)) 26 printk("%s:%d: bad pte %016Lx.\n", __FILE__, __LINE__, pte_val(e))
120#define pmd_ERROR(e) \
121 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
122#define pgd_ERROR(e) \ 27#define pgd_ERROR(e) \
123 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) 28 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
124 29
125/* 30/*
126 * Table setting routines. Used within arch/mm only. 31 * Table setting routines. Used within arch/mm only.
127 */ 32 */
128#define set_pgd(pgdptr, pgdval) (*(pgdptr) = pgdval)
129#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval) 33#define set_pmd(pmdptr, pmdval) (*(pmdptr) = pmdval)
130 34
131static __inline__ void set_pte(pte_t *pteptr, pte_t pteval) 35static __inline__ void set_pte(pte_t *pteptr, pte_t pteval)
132{ 36{
133 unsigned long long x = ((unsigned long long) pteval.pte); 37 unsigned long long x = ((unsigned long long) pteval.pte_low);
134 unsigned long long *xp = (unsigned long long *) pteptr; 38 unsigned long long *xp = (unsigned long long *) pteptr;
135 /* 39 /*
136 * Sign-extend based on NPHYS. 40 * Sign-extend based on NPHYS.
@@ -157,61 +61,6 @@ static __inline__ void pmd_set(pmd_t *pmdp,pte_t *ptep)
157#define pgd_offset_k(address) pgd_offset(&init_mm, address) 61#define pgd_offset_k(address) pgd_offset(&init_mm, address)
158 62
159/* 63/*
160 * PGD level access routines.
161 *
162 * Note1:
163 * There's no need to use physical addresses since the tree walk is all
164 * in performed in software, until the PTE translation.
165 *
166 * Note 2:
167 * A PGD entry can be uninitialized (_PGD_UNUSED), generically bad,
168 * clear (_PGD_EMPTY), present. When present, lower 3 nibbles contain
169 * _KERNPG_TABLE. Being a kernel virtual pointer also bit 31 must
170 * be 1. Assuming an arbitrary clear value of bit 31 set to 0 and
171 * lower 3 nibbles set to 0xFFF (_PGD_EMPTY) any other value is a
172 * bad pgd that must be notified via printk().
173 *
174 */
175#define _PGD_EMPTY 0x0
176
177#if defined(CONFIG_SH64_PGTABLE_2_LEVEL)
178static inline int pgd_none(pgd_t pgd) { return 0; }
179static inline int pgd_bad(pgd_t pgd) { return 0; }
180#define pgd_present(pgd) ((pgd_val(pgd) & _PAGE_PRESENT) ? 1 : 0)
181#define pgd_clear(xx) do { } while(0)
182
183#elif defined(CONFIG_SH64_PGTABLE_3_LEVEL)
184#define pgd_present(pgd_entry) (1)
185#define pgd_none(pgd_entry) (pgd_val((pgd_entry)) == _PGD_EMPTY)
186/* TODO: Think later about what a useful definition of 'bad' would be now. */
187#define pgd_bad(pgd_entry) (0)
188#define pgd_clear(pgd_entry_p) (set_pgd((pgd_entry_p), __pgd(_PGD_EMPTY)))
189
190#endif
191
192
193#define pgd_page_vaddr(pgd_entry) ((unsigned long) (pgd_val(pgd_entry) & PAGE_MASK))
194#define pgd_page(pgd) (virt_to_page(pgd_val(pgd)))
195
196
197/*
198 * PMD defines. Middle level.
199 */
200
201/* PGD to PMD dereferencing */
202#if defined(CONFIG_SH64_PGTABLE_2_LEVEL)
203static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
204{
205 return (pmd_t *) dir;
206}
207#elif defined(CONFIG_SH64_PGTABLE_3_LEVEL)
208#define __pmd_offset(address) \
209 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
210#define pmd_offset(dir, addr) \
211 ((pmd_t *) ((pgd_val(*(dir))) & PAGE_MASK) + __pmd_offset((addr)))
212#endif
213
214/*
215 * PMD level access routines. Same notes as above. 64 * PMD level access routines. Same notes as above.
216 */ 65 */
217#define _PMD_EMPTY 0x0 66#define _PMD_EMPTY 0x0
@@ -239,15 +88,7 @@ static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
239#define pte_unmap(pte) do { } while (0) 88#define pte_unmap(pte) do { } while (0)
240#define pte_unmap_nested(pte) do { } while (0) 89#define pte_unmap_nested(pte) do { } while (0)
241 90
242/* Round it up ! */
243#define USER_PTRS_PER_PGD ((TASK_SIZE+PGDIR_SIZE-1)/PGDIR_SIZE)
244#define FIRST_USER_ADDRESS 0
245
246#ifndef __ASSEMBLY__ 91#ifndef __ASSEMBLY__
247#define VMALLOC_END 0xff000000
248#define VMALLOC_START 0xf0000000
249#define VMALLOC_VMADDR(x) ((unsigned long)(x))
250
251#define IOBASE_VADDR 0xff000000 92#define IOBASE_VADDR 0xff000000
252#define IOBASE_END 0xffffffff 93#define IOBASE_END 0xffffffff
253 94
@@ -315,43 +156,28 @@ static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
315 156
316#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY) 157#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
317 158
159/*
160 * We have full permissions (Read/Write/Execute/Shared).
161 */
162#define _PAGE_COMMON (_PAGE_PRESENT | _PAGE_USER | \
163 _PAGE_CACHABLE | _PAGE_ACCESSED)
164
318#define PAGE_NONE __pgprot(_PAGE_CACHABLE | _PAGE_ACCESSED) 165#define PAGE_NONE __pgprot(_PAGE_CACHABLE | _PAGE_ACCESSED)
319#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | \ 166#define PAGE_SHARED __pgprot(_PAGE_COMMON | _PAGE_READ | _PAGE_WRITE | \
320 _PAGE_CACHABLE | _PAGE_ACCESSED | _PAGE_USER | \
321 _PAGE_SHARED) 167 _PAGE_SHARED)
322/* We need to include PAGE_EXECUTE in PAGE_COPY because it is the default 168#define PAGE_EXECREAD __pgprot(_PAGE_COMMON | _PAGE_READ | _PAGE_EXECUTE)
323 * protection mode for the stack. */
324#define PAGE_COPY __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHABLE | \
325 _PAGE_ACCESSED | _PAGE_USER | _PAGE_EXECUTE)
326#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_READ | _PAGE_CACHABLE | \
327 _PAGE_ACCESSED | _PAGE_USER)
328#define PAGE_KERNEL __pgprot(_KERNPG_TABLE)
329
330 169
331/* 170/*
332 * In ST50 we have full permissions (Read/Write/Execute/Shared). 171 * We need to include PAGE_EXECUTE in PAGE_COPY because it is the default
333 * Just match'em all. These are for mmap(), therefore all at least 172 * protection mode for the stack.
334 * User/Cachable/Present/Accessed. No point in making Fault on Write.
335 */ 173 */
336#define __MMAP_COMMON (_PAGE_PRESENT | _PAGE_USER | _PAGE_CACHABLE | _PAGE_ACCESSED) 174#define PAGE_COPY PAGE_EXECREAD
337 /* sxwr */ 175
338#define __P000 __pgprot(__MMAP_COMMON) 176#define PAGE_READONLY __pgprot(_PAGE_COMMON | _PAGE_READ)
339#define __P001 __pgprot(__MMAP_COMMON | _PAGE_READ) 177#define PAGE_WRITEONLY __pgprot(_PAGE_COMMON | _PAGE_WRITE)
340#define __P010 __pgprot(__MMAP_COMMON) 178#define PAGE_RWX __pgprot(_PAGE_COMMON | _PAGE_READ | \
341#define __P011 __pgprot(__MMAP_COMMON | _PAGE_READ) 179 _PAGE_WRITE | _PAGE_EXECUTE)
342#define __P100 __pgprot(__MMAP_COMMON | _PAGE_EXECUTE) 180#define PAGE_KERNEL __pgprot(_KERNPG_TABLE)
343#define __P101 __pgprot(__MMAP_COMMON | _PAGE_EXECUTE | _PAGE_READ)
344#define __P110 __pgprot(__MMAP_COMMON | _PAGE_EXECUTE)
345#define __P111 __pgprot(__MMAP_COMMON | _PAGE_EXECUTE | _PAGE_READ)
346
347#define __S000 __pgprot(__MMAP_COMMON | _PAGE_SHARED)
348#define __S001 __pgprot(__MMAP_COMMON | _PAGE_SHARED | _PAGE_READ)
349#define __S010 __pgprot(__MMAP_COMMON | _PAGE_SHARED | _PAGE_WRITE)
350#define __S011 __pgprot(__MMAP_COMMON | _PAGE_SHARED | _PAGE_READ | _PAGE_WRITE)
351#define __S100 __pgprot(__MMAP_COMMON | _PAGE_SHARED | _PAGE_EXECUTE)
352#define __S101 __pgprot(__MMAP_COMMON | _PAGE_SHARED | _PAGE_EXECUTE | _PAGE_READ)
353#define __S110 __pgprot(__MMAP_COMMON | _PAGE_SHARED | _PAGE_EXECUTE | _PAGE_WRITE)
354#define __S111 __pgprot(__MMAP_COMMON | _PAGE_SHARED | _PAGE_EXECUTE | _PAGE_READ | _PAGE_WRITE)
355 181
356/* Make it a device mapping for maximum safety (e.g. for mapping device 182/* Make it a device mapping for maximum safety (e.g. for mapping device
357 registers into user-space via /dev/map). */ 183 registers into user-space via /dev/map). */
@@ -453,12 +279,6 @@ static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _
453static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 279static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
454{ set_pte(&pte, __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot))); return pte; } 280{ set_pte(&pte, __pte((pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot))); return pte; }
455 281
456typedef pte_t *pte_addr_t;
457#define pgtable_cache_init() do { } while (0)
458
459extern void update_mmu_cache(struct vm_area_struct * vma,
460 unsigned long address, pte_t pte);
461
462/* Encode and decode a swap entry */ 282/* Encode and decode a swap entry */
463#define __swp_type(x) (((x).val & 3) + (((x).val >> 1) & 0x3c)) 283#define __swp_type(x) (((x).val & 3) + (((x).val >> 1) & 0x3c))
464#define __swp_offset(x) ((x).val >> 8) 284#define __swp_offset(x) ((x).val >> 8)
@@ -471,26 +291,9 @@ extern void update_mmu_cache(struct vm_area_struct * vma,
471#define pte_to_pgoff(pte) (pte_val(pte)) 291#define pte_to_pgoff(pte) (pte_val(pte))
472#define pgoff_to_pte(off) ((pte_t) { (off) | _PAGE_FILE }) 292#define pgoff_to_pte(off) ((pte_t) { (off) | _PAGE_FILE })
473 293
474/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
475#define PageSkip(page) (0)
476#define kern_addr_valid(addr) (1)
477
478#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
479 remap_pfn_range(vma, vaddr, pfn, size, prot)
480
481#endif /* !__ASSEMBLY__ */ 294#endif /* !__ASSEMBLY__ */
482 295
483/*
484 * No page table caches to initialise
485 */
486#define pgtable_cache_init() do { } while (0)
487
488#define pte_pfn(x) (((unsigned long)((x).pte)) >> PAGE_SHIFT)
489#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 296#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
490#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 297#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
491 298
492extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; 299#endif /* __ASM_SH_PGTABLE_64_H */
493
494#include <asm-generic/pgtable.h>
495
496#endif /* __ASM_SH64_PGTABLE_H */
diff --git a/include/asm-sh/posix_types.h b/include/asm-sh/posix_types.h
index 0a3d2f54ab27..4b9d11c9fc77 100644
--- a/include/asm-sh/posix_types.h
+++ b/include/asm-sh/posix_types.h
@@ -1,122 +1,7 @@
1#ifndef __ASM_SH_POSIX_TYPES_H 1#ifdef __KERNEL__
2#define __ASM_SH_POSIX_TYPES_H 2# ifdef CONFIG_SUPERH32
3 3# include "posix_types_32.h"
4/* 4# else
5 * This file is generally used by user-level software, so you need to 5# include "posix_types_64.h"
6 * be a little careful about namespace pollution etc. Also, we cannot 6# endif
7 * assume GCC is being used. 7#endif /* __KERNEL__ */
8 */
9
10typedef unsigned long __kernel_ino_t;
11typedef unsigned short __kernel_mode_t;
12typedef unsigned short __kernel_nlink_t;
13typedef long __kernel_off_t;
14typedef int __kernel_pid_t;
15typedef unsigned short __kernel_ipc_pid_t;
16typedef unsigned short __kernel_uid_t;
17typedef unsigned short __kernel_gid_t;
18typedef unsigned int __kernel_size_t;
19typedef int __kernel_ssize_t;
20typedef int __kernel_ptrdiff_t;
21typedef long __kernel_time_t;
22typedef long __kernel_suseconds_t;
23typedef long __kernel_clock_t;
24typedef int __kernel_timer_t;
25typedef int __kernel_clockid_t;
26typedef int __kernel_daddr_t;
27typedef char * __kernel_caddr_t;
28typedef unsigned short __kernel_uid16_t;
29typedef unsigned short __kernel_gid16_t;
30typedef unsigned int __kernel_uid32_t;
31typedef unsigned int __kernel_gid32_t;
32
33typedef unsigned short __kernel_old_uid_t;
34typedef unsigned short __kernel_old_gid_t;
35typedef unsigned short __kernel_old_dev_t;
36
37#ifdef __GNUC__
38typedef long long __kernel_loff_t;
39#endif
40
41typedef struct {
42#if defined(__KERNEL__) || defined(__USE_ALL)
43 int val[2];
44#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
45 int __val[2];
46#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
47} __kernel_fsid_t;
48
49#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
50
51#undef __FD_SET
52static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
53{
54 unsigned long __tmp = __fd / __NFDBITS;
55 unsigned long __rem = __fd % __NFDBITS;
56 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
57}
58
59#undef __FD_CLR
60static __inline__ void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
61{
62 unsigned long __tmp = __fd / __NFDBITS;
63 unsigned long __rem = __fd % __NFDBITS;
64 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
65}
66
67
68#undef __FD_ISSET
69static __inline__ int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
70{
71 unsigned long __tmp = __fd / __NFDBITS;
72 unsigned long __rem = __fd % __NFDBITS;
73 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
74}
75
76/*
77 * This will unroll the loop for the normal constant case (8 ints,
78 * for a 256-bit fd_set)
79 */
80#undef __FD_ZERO
81static __inline__ void __FD_ZERO(__kernel_fd_set *__p)
82{
83 unsigned long *__tmp = __p->fds_bits;
84 int __i;
85
86 if (__builtin_constant_p(__FDSET_LONGS)) {
87 switch (__FDSET_LONGS) {
88 case 16:
89 __tmp[ 0] = 0; __tmp[ 1] = 0;
90 __tmp[ 2] = 0; __tmp[ 3] = 0;
91 __tmp[ 4] = 0; __tmp[ 5] = 0;
92 __tmp[ 6] = 0; __tmp[ 7] = 0;
93 __tmp[ 8] = 0; __tmp[ 9] = 0;
94 __tmp[10] = 0; __tmp[11] = 0;
95 __tmp[12] = 0; __tmp[13] = 0;
96 __tmp[14] = 0; __tmp[15] = 0;
97 return;
98
99 case 8:
100 __tmp[ 0] = 0; __tmp[ 1] = 0;
101 __tmp[ 2] = 0; __tmp[ 3] = 0;
102 __tmp[ 4] = 0; __tmp[ 5] = 0;
103 __tmp[ 6] = 0; __tmp[ 7] = 0;
104 return;
105
106 case 4:
107 __tmp[ 0] = 0; __tmp[ 1] = 0;
108 __tmp[ 2] = 0; __tmp[ 3] = 0;
109 return;
110 }
111 }
112 __i = __FDSET_LONGS;
113 while (__i) {
114 __i--;
115 *__tmp = 0;
116 __tmp++;
117 }
118}
119
120#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
121
122#endif /* __ASM_SH_POSIX_TYPES_H */
diff --git a/include/asm-sh/posix_types_32.h b/include/asm-sh/posix_types_32.h
new file mode 100644
index 000000000000..0a3d2f54ab27
--- /dev/null
+++ b/include/asm-sh/posix_types_32.h
@@ -0,0 +1,122 @@
1#ifndef __ASM_SH_POSIX_TYPES_H
2#define __ASM_SH_POSIX_TYPES_H
3
4/*
5 * This file is generally used by user-level software, so you need to
6 * be a little careful about namespace pollution etc. Also, we cannot
7 * assume GCC is being used.
8 */
9
10typedef unsigned long __kernel_ino_t;
11typedef unsigned short __kernel_mode_t;
12typedef unsigned short __kernel_nlink_t;
13typedef long __kernel_off_t;
14typedef int __kernel_pid_t;
15typedef unsigned short __kernel_ipc_pid_t;
16typedef unsigned short __kernel_uid_t;
17typedef unsigned short __kernel_gid_t;
18typedef unsigned int __kernel_size_t;
19typedef int __kernel_ssize_t;
20typedef int __kernel_ptrdiff_t;
21typedef long __kernel_time_t;
22typedef long __kernel_suseconds_t;
23typedef long __kernel_clock_t;
24typedef int __kernel_timer_t;
25typedef int __kernel_clockid_t;
26typedef int __kernel_daddr_t;
27typedef char * __kernel_caddr_t;
28typedef unsigned short __kernel_uid16_t;
29typedef unsigned short __kernel_gid16_t;
30typedef unsigned int __kernel_uid32_t;
31typedef unsigned int __kernel_gid32_t;
32
33typedef unsigned short __kernel_old_uid_t;
34typedef unsigned short __kernel_old_gid_t;
35typedef unsigned short __kernel_old_dev_t;
36
37#ifdef __GNUC__
38typedef long long __kernel_loff_t;
39#endif
40
41typedef struct {
42#if defined(__KERNEL__) || defined(__USE_ALL)
43 int val[2];
44#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */
45 int __val[2];
46#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */
47} __kernel_fsid_t;
48
49#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
50
51#undef __FD_SET
52static __inline__ void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp)
53{
54 unsigned long __tmp = __fd / __NFDBITS;
55 unsigned long __rem = __fd % __NFDBITS;
56 __fdsetp->fds_bits[__tmp] |= (1UL<<__rem);
57}
58
59#undef __FD_CLR
60static __inline__ void __FD_CLR(unsigned long __fd, __kernel_fd_set *__fdsetp)
61{
62 unsigned long __tmp = __fd / __NFDBITS;
63 unsigned long __rem = __fd % __NFDBITS;
64 __fdsetp->fds_bits[__tmp] &= ~(1UL<<__rem);
65}
66
67
68#undef __FD_ISSET
69static __inline__ int __FD_ISSET(unsigned long __fd, const __kernel_fd_set *__p)
70{
71 unsigned long __tmp = __fd / __NFDBITS;
72 unsigned long __rem = __fd % __NFDBITS;
73 return (__p->fds_bits[__tmp] & (1UL<<__rem)) != 0;
74}
75
76/*
77 * This will unroll the loop for the normal constant case (8 ints,
78 * for a 256-bit fd_set)
79 */
80#undef __FD_ZERO
81static __inline__ void __FD_ZERO(__kernel_fd_set *__p)
82{
83 unsigned long *__tmp = __p->fds_bits;
84 int __i;
85
86 if (__builtin_constant_p(__FDSET_LONGS)) {
87 switch (__FDSET_LONGS) {
88 case 16:
89 __tmp[ 0] = 0; __tmp[ 1] = 0;
90 __tmp[ 2] = 0; __tmp[ 3] = 0;
91 __tmp[ 4] = 0; __tmp[ 5] = 0;
92 __tmp[ 6] = 0; __tmp[ 7] = 0;
93 __tmp[ 8] = 0; __tmp[ 9] = 0;
94 __tmp[10] = 0; __tmp[11] = 0;
95 __tmp[12] = 0; __tmp[13] = 0;
96 __tmp[14] = 0; __tmp[15] = 0;
97 return;
98
99 case 8:
100 __tmp[ 0] = 0; __tmp[ 1] = 0;
101 __tmp[ 2] = 0; __tmp[ 3] = 0;
102 __tmp[ 4] = 0; __tmp[ 5] = 0;
103 __tmp[ 6] = 0; __tmp[ 7] = 0;
104 return;
105
106 case 4:
107 __tmp[ 0] = 0; __tmp[ 1] = 0;
108 __tmp[ 2] = 0; __tmp[ 3] = 0;
109 return;
110 }
111 }
112 __i = __FDSET_LONGS;
113 while (__i) {
114 __i--;
115 *__tmp = 0;
116 __tmp++;
117 }
118}
119
120#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
121
122#endif /* __ASM_SH_POSIX_TYPES_H */
diff --git a/include/asm-sh64/posix_types.h b/include/asm-sh/posix_types_64.h
index 0620317a6f0f..0620317a6f0f 100644
--- a/include/asm-sh64/posix_types.h
+++ b/include/asm-sh/posix_types_64.h
diff --git a/include/asm-sh/processor.h b/include/asm-sh/processor.h
index 4f2922a1979c..c9b14161f73d 100644
--- a/include/asm-sh/processor.h
+++ b/include/asm-sh/processor.h
@@ -1,32 +1,10 @@
1/*
2 * include/asm-sh/processor.h
3 *
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002, 2003 Paul Mundt
6 */
7
8#ifndef __ASM_SH_PROCESSOR_H 1#ifndef __ASM_SH_PROCESSOR_H
9#define __ASM_SH_PROCESSOR_H 2#define __ASM_SH_PROCESSOR_H
10#ifdef __KERNEL__
11 3
12#include <linux/compiler.h>
13#include <asm/page.h>
14#include <asm/types.h>
15#include <asm/cache.h>
16#include <asm/ptrace.h>
17#include <asm/cpu-features.h> 4#include <asm/cpu-features.h>
5#include <asm/fpu.h>
18 6
19/* 7#ifndef __ASSEMBLY__
20 * Default implementation of macro that returns current
21 * instruction pointer ("program counter").
22 */
23#define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n1:":"=z" (pc)); pc; })
24
25/* Core Processor Version Register */
26#define CCN_PVR 0xff000030
27#define CCN_CVR 0xff000040
28#define CCN_PRR 0xff000044
29
30/* 8/*
31 * CPU type and hardware bug flags. Kept separately for each CPU. 9 * CPU type and hardware bug flags. Kept separately for each CPU.
32 * 10 *
@@ -39,247 +17,49 @@ enum cpu_type {
39 CPU_SH7619, 17 CPU_SH7619,
40 18
41 /* SH-2A types */ 19 /* SH-2A types */
42 CPU_SH7206, 20 CPU_SH7203, CPU_SH7206, CPU_SH7263,
43 21
44 /* SH-3 types */ 22 /* SH-3 types */
45 CPU_SH7705, CPU_SH7706, CPU_SH7707, 23 CPU_SH7705, CPU_SH7706, CPU_SH7707,
46 CPU_SH7708, CPU_SH7708S, CPU_SH7708R, 24 CPU_SH7708, CPU_SH7708S, CPU_SH7708R,
47 CPU_SH7709, CPU_SH7709A, CPU_SH7710, CPU_SH7712, 25 CPU_SH7709, CPU_SH7709A, CPU_SH7710, CPU_SH7712,
48 CPU_SH7720, CPU_SH7729, 26 CPU_SH7720, CPU_SH7721, CPU_SH7729,
49 27
50 /* SH-4 types */ 28 /* SH-4 types */
51 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R, 29 CPU_SH7750, CPU_SH7750S, CPU_SH7750R, CPU_SH7751, CPU_SH7751R,
52 CPU_SH7760, CPU_ST40RA, CPU_ST40GX1, CPU_SH4_202, CPU_SH4_501, 30 CPU_SH7760, CPU_SH4_202, CPU_SH4_501,
53 31
54 /* SH-4A types */ 32 /* SH-4A types */
55 CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SHX3, 33 CPU_SH7763, CPU_SH7770, CPU_SH7780, CPU_SH7781, CPU_SH7785, CPU_SHX3,
56 34
57 /* SH4AL-DSP types */ 35 /* SH4AL-DSP types */
58 CPU_SH7343, CPU_SH7722, 36 CPU_SH7343, CPU_SH7722,
59 37
38 /* SH-5 types */
39 CPU_SH5_101, CPU_SH5_103,
40
60 /* Unknown subtype */ 41 /* Unknown subtype */
61 CPU_SH_NONE 42 CPU_SH_NONE
62}; 43};
63 44
64struct sh_cpuinfo { 45/* Forward decl */
65 unsigned int type; 46struct sh_cpuinfo;
66 unsigned long loops_per_jiffy;
67 unsigned long asid_cache;
68
69 struct cache_info icache; /* Primary I-cache */
70 struct cache_info dcache; /* Primary D-cache */
71 struct cache_info scache; /* Secondary cache */
72
73 unsigned long flags;
74} __attribute__ ((aligned(SMP_CACHE_BYTES)));
75
76extern struct sh_cpuinfo cpu_data[];
77#define boot_cpu_data cpu_data[0]
78#define current_cpu_data cpu_data[smp_processor_id()]
79#define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
80
81/*
82 * User space process size: 2GB.
83 *
84 * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff
85 */
86#define TASK_SIZE 0x7c000000UL
87
88/* This decides where the kernel will search for a free chunk of vm
89 * space during mmap's.
90 */
91#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
92
93/*
94 * Bit of SR register
95 *
96 * FD-bit:
97 * When it's set, it means the processor doesn't have right to use FPU,
98 * and it results exception when the floating operation is executed.
99 *
100 * IMASK-bit:
101 * Interrupt level mask
102 */
103#define SR_FD 0x00008000
104#define SR_DSP 0x00001000
105#define SR_IMASK 0x000000f0
106
107/*
108 * FPU structure and data
109 */
110
111struct sh_fpu_hard_struct {
112 unsigned long fp_regs[16];
113 unsigned long xfp_regs[16];
114 unsigned long fpscr;
115 unsigned long fpul;
116
117 long status; /* software status information */
118};
119
120/* Dummy fpu emulator */
121struct sh_fpu_soft_struct {
122 unsigned long fp_regs[16];
123 unsigned long xfp_regs[16];
124 unsigned long fpscr;
125 unsigned long fpul;
126
127 unsigned char lookahead;
128 unsigned long entry_pc;
129};
130
131union sh_fpu_union {
132 struct sh_fpu_hard_struct hard;
133 struct sh_fpu_soft_struct soft;
134};
135
136struct thread_struct {
137 /* Saved registers when thread is descheduled */
138 unsigned long sp;
139 unsigned long pc;
140
141 /* Hardware debugging registers */
142 unsigned long ubc_pc;
143
144 /* floating point info */
145 union sh_fpu_union fpu;
146};
147
148typedef struct {
149 unsigned long seg;
150} mm_segment_t;
151
152/* Count of active tasks with UBC settings */
153extern int ubc_usercnt;
154 47
155#define INIT_THREAD { \ 48/* arch/sh/kernel/setup.c */
156 .sp = sizeof(init_stack) + (long) &init_stack, \ 49const char *get_cpu_subtype(struct sh_cpuinfo *c);
157}
158
159/*
160 * Do necessary setup to start up a newly executed thread.
161 */
162#define start_thread(regs, new_pc, new_sp) \
163 set_fs(USER_DS); \
164 regs->pr = 0; \
165 regs->sr = SR_FD; /* User mode. */ \
166 regs->pc = new_pc; \
167 regs->regs[15] = new_sp
168
169/* Forward declaration, a strange C thing */
170struct task_struct;
171struct mm_struct;
172
173/* Free all resources held by a thread. */
174extern void release_thread(struct task_struct *);
175
176/* Prepare to copy thread state - unlazy all lazy status */
177#define prepare_to_copy(tsk) do { } while (0)
178
179/*
180 * create a kernel thread without removing it from tasklists
181 */
182extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
183
184/* Copy and release all segment info associated with a VM */
185#define copy_segments(p, mm) do { } while(0)
186#define release_segments(mm) do { } while(0)
187
188/*
189 * FPU lazy state save handling.
190 */
191
192static __inline__ void disable_fpu(void)
193{
194 unsigned long __dummy;
195
196 /* Set FD flag in SR */
197 __asm__ __volatile__("stc sr, %0\n\t"
198 "or %1, %0\n\t"
199 "ldc %0, sr"
200 : "=&r" (__dummy)
201 : "r" (SR_FD));
202}
203
204static __inline__ void enable_fpu(void)
205{
206 unsigned long __dummy;
207
208 /* Clear out FD flag in SR */
209 __asm__ __volatile__("stc sr, %0\n\t"
210 "and %1, %0\n\t"
211 "ldc %0, sr"
212 : "=&r" (__dummy)
213 : "r" (~SR_FD));
214}
215
216static __inline__ void release_fpu(struct pt_regs *regs)
217{
218 regs->sr |= SR_FD;
219}
220
221static __inline__ void grab_fpu(struct pt_regs *regs)
222{
223 regs->sr &= ~SR_FD;
224}
225
226extern void save_fpu(struct task_struct *__tsk, struct pt_regs *regs);
227
228#define unlazy_fpu(tsk, regs) do { \
229 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
230 save_fpu(tsk, regs); \
231 } \
232} while (0)
233
234#define clear_fpu(tsk, regs) do { \
235 if (test_tsk_thread_flag(tsk, TIF_USEDFPU)) { \
236 clear_tsk_thread_flag(tsk, TIF_USEDFPU); \
237 release_fpu(regs); \
238 } \
239} while (0)
240
241/* Double presision, NANS as NANS, rounding to nearest, no exceptions */
242#define FPSCR_INIT 0x00080000
243
244#define FPSCR_CAUSE_MASK 0x0001f000 /* Cause bits */
245#define FPSCR_FLAG_MASK 0x0000007c /* Flag bits */
246
247/*
248 * Return saved PC of a blocked thread.
249 */
250#define thread_saved_pc(tsk) (tsk->thread.pc)
251
252void show_trace(struct task_struct *tsk, unsigned long *sp,
253 struct pt_regs *regs);
254extern unsigned long get_wchan(struct task_struct *p);
255
256#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
257#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
258
259#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory")
260#define cpu_relax() barrier()
261
262#if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH3) || \
263 defined(CONFIG_CPU_SH4)
264#define PREFETCH_STRIDE L1_CACHE_BYTES
265#define ARCH_HAS_PREFETCH
266#define ARCH_HAS_PREFETCHW
267static inline void prefetch(void *x)
268{
269 __asm__ __volatile__ ("pref @%0\n\t" : : "r" (x) : "memory");
270}
271
272#define prefetchw(x) prefetch(x)
273#endif
274 50
275#ifdef CONFIG_VSYSCALL 51#ifdef CONFIG_VSYSCALL
276extern int vsyscall_init(void); 52int vsyscall_init(void);
277#else 53#else
278#define vsyscall_init() do { } while (0) 54#define vsyscall_init() do { } while (0)
279#endif 55#endif
280 56
281/* arch/sh/kernel/setup.c */ 57#endif /* __ASSEMBLY__ */
282const char *get_cpu_subtype(struct sh_cpuinfo *c); 58
59#ifdef CONFIG_SUPERH32
60# include "processor_32.h"
61#else
62# include "processor_64.h"
63#endif
283 64
284#endif /* __KERNEL__ */
285#endif /* __ASM_SH_PROCESSOR_H */ 65#endif /* __ASM_SH_PROCESSOR_H */
diff --git a/include/asm-sh/processor_32.h b/include/asm-sh/processor_32.h
new file mode 100644
index 000000000000..a7edaa1a870c
--- /dev/null
+++ b/include/asm-sh/processor_32.h
@@ -0,0 +1,215 @@
1/*
2 * include/asm-sh/processor.h
3 *
4 * Copyright (C) 1999, 2000 Niibe Yutaka
5 * Copyright (C) 2002, 2003 Paul Mundt
6 */
7
8#ifndef __ASM_SH_PROCESSOR_32_H
9#define __ASM_SH_PROCESSOR_32_H
10#ifdef __KERNEL__
11
12#include <linux/compiler.h>
13#include <asm/page.h>
14#include <asm/types.h>
15#include <asm/cache.h>
16#include <asm/ptrace.h>
17
18/*
19 * Default implementation of macro that returns current
20 * instruction pointer ("program counter").
21 */
22#define current_text_addr() ({ void *pc; __asm__("mova 1f, %0\n1:":"=z" (pc)); pc; })
23
24/* Core Processor Version Register */
25#define CCN_PVR 0xff000030
26#define CCN_CVR 0xff000040
27#define CCN_PRR 0xff000044
28
29struct sh_cpuinfo {
30 unsigned int type;
31 unsigned long loops_per_jiffy;
32 unsigned long asid_cache;
33
34 struct cache_info icache; /* Primary I-cache */
35 struct cache_info dcache; /* Primary D-cache */
36 struct cache_info scache; /* Secondary cache */
37
38 unsigned long flags;
39} __attribute__ ((aligned(L1_CACHE_BYTES)));
40
41extern struct sh_cpuinfo cpu_data[];
42#define boot_cpu_data cpu_data[0]
43#define current_cpu_data cpu_data[smp_processor_id()]
44#define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
45
46/*
47 * User space process size: 2GB.
48 *
49 * Since SH7709 and SH7750 have "area 7", we can't use 0x7c000000--0x7fffffff
50 */
51#define TASK_SIZE 0x7c000000UL
52
53/* This decides where the kernel will search for a free chunk of vm
54 * space during mmap's.
55 */
56#define TASK_UNMAPPED_BASE (TASK_SIZE / 3)
57
58/*
59 * Bit of SR register
60 *
61 * FD-bit:
62 * When it's set, it means the processor doesn't have right to use FPU,
63 * and it results exception when the floating operation is executed.
64 *
65 * IMASK-bit:
66 * Interrupt level mask
67 */
68#define SR_DSP 0x00001000
69#define SR_IMASK 0x000000f0
70
71/*
72 * FPU structure and data
73 */
74
75struct sh_fpu_hard_struct {
76 unsigned long fp_regs[16];
77 unsigned long xfp_regs[16];
78 unsigned long fpscr;
79 unsigned long fpul;
80
81 long status; /* software status information */
82};
83
84/* Dummy fpu emulator */
85struct sh_fpu_soft_struct {
86 unsigned long fp_regs[16];
87 unsigned long xfp_regs[16];
88 unsigned long fpscr;
89 unsigned long fpul;
90
91 unsigned char lookahead;
92 unsigned long entry_pc;
93};
94
95union sh_fpu_union {
96 struct sh_fpu_hard_struct hard;
97 struct sh_fpu_soft_struct soft;
98};
99
100struct thread_struct {
101 /* Saved registers when thread is descheduled */
102 unsigned long sp;
103 unsigned long pc;
104
105 /* Hardware debugging registers */
106 unsigned long ubc_pc;
107
108 /* floating point info */
109 union sh_fpu_union fpu;
110};
111
112typedef struct {
113 unsigned long seg;
114} mm_segment_t;
115
116/* Count of active tasks with UBC settings */
117extern int ubc_usercnt;
118
119#define INIT_THREAD { \
120 .sp = sizeof(init_stack) + (long) &init_stack, \
121}
122
123/*
124 * Do necessary setup to start up a newly executed thread.
125 */
126#define start_thread(regs, new_pc, new_sp) \
127 set_fs(USER_DS); \
128 regs->pr = 0; \
129 regs->sr = SR_FD; /* User mode. */ \
130 regs->pc = new_pc; \
131 regs->regs[15] = new_sp
132
133/* Forward declaration, a strange C thing */
134struct task_struct;
135struct mm_struct;
136
137/* Free all resources held by a thread. */
138extern void release_thread(struct task_struct *);
139
140/* Prepare to copy thread state - unlazy all lazy status */
141#define prepare_to_copy(tsk) do { } while (0)
142
143/*
144 * create a kernel thread without removing it from tasklists
145 */
146extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
147
148/* Copy and release all segment info associated with a VM */
149#define copy_segments(p, mm) do { } while(0)
150#define release_segments(mm) do { } while(0)
151
152/*
153 * FPU lazy state save handling.
154 */
155
156static __inline__ void disable_fpu(void)
157{
158 unsigned long __dummy;
159
160 /* Set FD flag in SR */
161 __asm__ __volatile__("stc sr, %0\n\t"
162 "or %1, %0\n\t"
163 "ldc %0, sr"
164 : "=&r" (__dummy)
165 : "r" (SR_FD));
166}
167
168static __inline__ void enable_fpu(void)
169{
170 unsigned long __dummy;
171
172 /* Clear out FD flag in SR */
173 __asm__ __volatile__("stc sr, %0\n\t"
174 "and %1, %0\n\t"
175 "ldc %0, sr"
176 : "=&r" (__dummy)
177 : "r" (~SR_FD));
178}
179
180/* Double presision, NANS as NANS, rounding to nearest, no exceptions */
181#define FPSCR_INIT 0x00080000
182
183#define FPSCR_CAUSE_MASK 0x0001f000 /* Cause bits */
184#define FPSCR_FLAG_MASK 0x0000007c /* Flag bits */
185
186/*
187 * Return saved PC of a blocked thread.
188 */
189#define thread_saved_pc(tsk) (tsk->thread.pc)
190
191void show_trace(struct task_struct *tsk, unsigned long *sp,
192 struct pt_regs *regs);
193extern unsigned long get_wchan(struct task_struct *p);
194
195#define KSTK_EIP(tsk) (task_pt_regs(tsk)->pc)
196#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[15])
197
198#define cpu_sleep() __asm__ __volatile__ ("sleep" : : : "memory")
199#define cpu_relax() barrier()
200
201#if defined(CONFIG_CPU_SH2A) || defined(CONFIG_CPU_SH3) || \
202 defined(CONFIG_CPU_SH4)
203#define PREFETCH_STRIDE L1_CACHE_BYTES
204#define ARCH_HAS_PREFETCH
205#define ARCH_HAS_PREFETCHW
206static inline void prefetch(void *x)
207{
208 __asm__ __volatile__ ("pref @%0\n\t" : : "r" (x) : "memory");
209}
210
211#define prefetchw(x) prefetch(x)
212#endif
213
214#endif /* __KERNEL__ */
215#endif /* __ASM_SH_PROCESSOR_32_H */
diff --git a/include/asm-sh64/processor.h b/include/asm-sh/processor_64.h
index eb2bee4b47b9..99c22b14a85b 100644
--- a/include/asm-sh64/processor.h
+++ b/include/asm-sh/processor_64.h
@@ -1,28 +1,25 @@
1#ifndef __ASM_SH64_PROCESSOR_H 1#ifndef __ASM_SH_PROCESSOR_64_H
2#define __ASM_SH64_PROCESSOR_H 2#define __ASM_SH_PROCESSOR_64_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/processor_64.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/processor.h
10 * 6 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 7 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt 8 * Copyright (C) 2003 Paul Mundt
13 * Copyright (C) 2004 Richard Curnow 9 * Copyright (C) 2004 Richard Curnow
14 * 10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
15 */ 14 */
16
17#include <asm/page.h>
18
19#ifndef __ASSEMBLY__ 15#ifndef __ASSEMBLY__
20 16
17#include <linux/compiler.h>
18#include <asm/page.h>
21#include <asm/types.h> 19#include <asm/types.h>
22#include <asm/cache.h> 20#include <asm/cache.h>
23#include <asm/registers.h> 21#include <asm/ptrace.h>
24#include <linux/threads.h> 22#include <asm/cpu/registers.h>
25#include <linux/compiler.h>
26 23
27/* 24/*
28 * Default implementation of macro that returns current 25 * Default implementation of macro that returns current
@@ -40,15 +37,6 @@ __asm__("gettr tr0, %1\n\t" \
40pc; }) 37pc; })
41 38
42/* 39/*
43 * CPU type and hardware bug flags. Kept separately for each CPU.
44 */
45enum cpu_type {
46 CPU_SH5_101,
47 CPU_SH5_103,
48 CPU_SH_NONE
49};
50
51/*
52 * TLB information structure 40 * TLB information structure
53 * 41 *
54 * Defined for both I and D tlb, per-processor. 42 * Defined for both I and D tlb, per-processor.
@@ -67,28 +55,26 @@ struct tlb_info {
67struct sh_cpuinfo { 55struct sh_cpuinfo {
68 enum cpu_type type; 56 enum cpu_type type;
69 unsigned long loops_per_jiffy; 57 unsigned long loops_per_jiffy;
58 unsigned long asid_cache;
70 59
71 char hard_math;
72
73 unsigned long *pgd_quick;
74 unsigned long *pmd_quick;
75 unsigned long *pte_quick;
76 unsigned long pgtable_cache_sz;
77 unsigned int cpu_clock, master_clock, bus_clock, module_clock; 60 unsigned int cpu_clock, master_clock, bus_clock, module_clock;
78 61
79 /* Cache info */ 62 /* Cache info */
80 struct cache_info icache; 63 struct cache_info icache;
81 struct cache_info dcache; 64 struct cache_info dcache;
65 struct cache_info scache;
82 66
83 /* TLB info */ 67 /* TLB info */
84 struct tlb_info itlb; 68 struct tlb_info itlb;
85 struct tlb_info dtlb; 69 struct tlb_info dtlb;
86};
87 70
88extern struct sh_cpuinfo boot_cpu_data; 71 unsigned long flags;
72};
89 73
90#define cpu_data (&boot_cpu_data) 74extern struct sh_cpuinfo cpu_data[];
91#define current_cpu_data boot_cpu_data 75#define boot_cpu_data cpu_data[0]
76#define current_cpu_data cpu_data[smp_processor_id()]
77#define raw_current_cpu_data cpu_data[raw_smp_processor_id()]
92 78
93#endif 79#endif
94 80
@@ -116,8 +102,6 @@ extern struct sh_cpuinfo boot_cpu_data;
116 * Single step bit 102 * Single step bit
117 * 103 *
118 */ 104 */
119#define SR_FD 0x00008000
120
121#if defined(CONFIG_SH64_SR_WATCH) 105#if defined(CONFIG_SH64_SR_WATCH)
122#define SR_MMU 0x84000000 106#define SR_MMU 0x84000000
123#else 107#else
@@ -178,6 +162,10 @@ struct thread_struct {
178 union sh_fpu_union fpu; 162 union sh_fpu_union fpu;
179}; 163};
180 164
165typedef struct {
166 unsigned long seg;
167} mm_segment_t;
168
181#define INIT_MMAP \ 169#define INIT_MMAP \
182{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL } 170{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
183 171
@@ -200,12 +188,12 @@ extern struct pt_regs fake_swapper_regs;
200 */ 188 */
201#define SR_USER (SR_MMU | SR_FD) 189#define SR_USER (SR_MMU | SR_FD)
202 190
203#define start_thread(regs, new_pc, new_sp) \ 191#define start_thread(regs, new_pc, new_sp) \
204 set_fs(USER_DS); \ 192 set_fs(USER_DS); \
205 regs->sr = SR_USER; /* User mode. */ \ 193 regs->sr = SR_USER; /* User mode. */ \
206 regs->pc = new_pc - 4; /* Compensate syscall exit */ \ 194 regs->pc = new_pc - 4; /* Compensate syscall exit */ \
207 regs->pc |= 1; /* Set SHmedia ! */ \ 195 regs->pc |= 1; /* Set SHmedia ! */ \
208 regs->regs[18] = 0; \ 196 regs->regs[18] = 0; \
209 regs->regs[15] = new_sp 197 regs->regs[15] = new_sp
210 198
211/* Forward declaration, a strange C thing */ 199/* Forward declaration, a strange C thing */
@@ -229,7 +217,7 @@ extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
229 * FPU lazy state save handling. 217 * FPU lazy state save handling.
230 */ 218 */
231 219
232static inline void release_fpu(void) 220static inline void disable_fpu(void)
233{ 221{
234 unsigned long long __dummy; 222 unsigned long long __dummy;
235 223
@@ -241,7 +229,7 @@ static inline void release_fpu(void)
241 : "r" (SR_FD)); 229 : "r" (SR_FD));
242} 230}
243 231
244static inline void grab_fpu(void) 232static inline void enable_fpu(void)
245{ 233{
246 unsigned long long __dummy; 234 unsigned long long __dummy;
247 235
@@ -262,11 +250,12 @@ static inline void grab_fpu(void)
262#define FPSCR_INIT 0x00000000 250#define FPSCR_INIT 0x00000000
263#endif 251#endif
264 252
265/* Save the current FP regs */ 253#ifdef CONFIG_SH_FPU
266void fpsave(struct sh_fpu_hard_struct *fpregs);
267
268/* Initialise the FP state of a task */ 254/* Initialise the FP state of a task */
269void fpinit(struct sh_fpu_hard_struct *fpregs); 255void fpinit(struct sh_fpu_hard_struct *fpregs);
256#else
257#define fpinit(fpregs) do { } while (0)
258#endif
270 259
271extern struct task_struct *last_task_used_math; 260extern struct task_struct *last_task_used_math;
272 261
@@ -283,5 +272,4 @@ extern unsigned long get_wchan(struct task_struct *p);
283#define cpu_relax() barrier() 272#define cpu_relax() barrier()
284 273
285#endif /* __ASSEMBLY__ */ 274#endif /* __ASSEMBLY__ */
286#endif /* __ASM_SH64_PROCESSOR_H */ 275#endif /* __ASM_SH_PROCESSOR_64_H */
287
diff --git a/include/asm-sh/ptrace.h b/include/asm-sh/ptrace.h
index ed358a376e6e..8d6c92b3e770 100644
--- a/include/asm-sh/ptrace.h
+++ b/include/asm-sh/ptrace.h
@@ -5,7 +5,16 @@
5 * Copyright (C) 1999, 2000 Niibe Yutaka 5 * Copyright (C) 1999, 2000 Niibe Yutaka
6 * 6 *
7 */ 7 */
8 8#if defined(__SH5__) || defined(CONFIG_SUPERH64)
9struct pt_regs {
10 unsigned long long pc;
11 unsigned long long sr;
12 unsigned long long syscall_nr;
13 unsigned long long regs[63];
14 unsigned long long tregs[8];
15 unsigned long long pad[2];
16};
17#else
9/* 18/*
10 * GCC defines register number like this: 19 * GCC defines register number like this:
11 * ----------------------------- 20 * -----------------------------
@@ -28,7 +37,7 @@
28 37
29#define REG_PR 17 38#define REG_PR 17
30#define REG_SR 18 39#define REG_SR 18
31#define REG_GBR 19 40#define REG_GBR 19
32#define REG_MACH 20 41#define REG_MACH 20
33#define REG_MACL 21 42#define REG_MACL 21
34 43
@@ -42,9 +51,6 @@
42#define REG_FPSCR 55 51#define REG_FPSCR 55
43#define REG_FPUL 56 52#define REG_FPUL 56
44 53
45/* options set using PTRACE_SETOPTIONS */
46#define PTRACE_O_TRACESYSGOOD 0x00000001
47
48/* 54/*
49 * This struct defines the way the registers are stored on the 55 * This struct defines the way the registers are stored on the
50 * kernel stack during a system call or other kernel entry. 56 * kernel stack during a system call or other kernel entry.
@@ -83,10 +89,14 @@ struct pt_dspregs {
83 89
84#define PTRACE_GETDSPREGS 55 90#define PTRACE_GETDSPREGS 55
85#define PTRACE_SETDSPREGS 56 91#define PTRACE_SETDSPREGS 56
92#endif
86 93
87#ifdef __KERNEL__ 94#ifdef __KERNEL__
88#define user_mode(regs) (((regs)->sr & 0x40000000)==0) 95#include <asm/addrspace.h>
89#define instruction_pointer(regs) ((regs)->pc) 96
97#define user_mode(regs) (((regs)->sr & 0x40000000)==0)
98#define instruction_pointer(regs) ((unsigned long)(regs)->pc)
99
90extern void show_regs(struct pt_regs *); 100extern void show_regs(struct pt_regs *);
91 101
92#ifdef CONFIG_SH_DSP 102#ifdef CONFIG_SH_DSP
@@ -103,10 +113,13 @@ static inline unsigned long profile_pc(struct pt_regs *regs)
103{ 113{
104 unsigned long pc = instruction_pointer(regs); 114 unsigned long pc = instruction_pointer(regs);
105 115
106 if (pc >= 0xa0000000UL && pc < 0xc0000000UL) 116#ifdef P2SEG
117 if (pc >= P2SEG && pc < P3SEG)
107 pc -= 0x20000000; 118 pc -= 0x20000000;
119#endif
120
108 return pc; 121 return pc;
109} 122}
110#endif 123#endif /* __KERNEL__ */
111 124
112#endif /* __ASM_SH_PTRACE_H */ 125#endif /* __ASM_SH_PTRACE_H */
diff --git a/include/asm-sh/r7780rp.h b/include/asm-sh/r7780rp.h
index de37f933aa42..bdecea0840a0 100644
--- a/include/asm-sh/r7780rp.h
+++ b/include/asm-sh/r7780rp.h
@@ -121,21 +121,6 @@
121 121
122#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */ 122#define IRLCNTR1 (PA_BCR + 0) /* Interrupt Control Register1 */
123 123
124#define IRQ_PCISLOT1 0 /* PCI Slot #1 IRQ */
125#define IRQ_PCISLOT2 1 /* PCI Slot #2 IRQ */
126#define IRQ_PCISLOT3 2 /* PCI Slot #3 IRQ */
127#define IRQ_PCISLOT4 3 /* PCI Slot #4 IRQ */
128#define IRQ_CFINST 5 /* CF Card Insert IRQ */
129#define IRQ_M66596 6 /* M66596 IRQ */
130#define IRQ_SDCARD 7 /* SD Card IRQ */
131#define IRQ_TUCHPANEL 8 /* Touch Panel IRQ */
132#define IRQ_SCI 9 /* SCI IRQ */
133#define IRQ_2SERIAL 10 /* Serial IRQ */
134#define IRQ_EXTENTION 11 /* EXTn IRQ */
135#define IRQ_ONETH 12 /* On board Ethernet IRQ */
136#define IRQ_PSW 13 /* Push Switch IRQ */
137#define IRQ_ZIGBEE 14 /* Ziggbee IO IRQ */
138
139#define IVDR_CK_ON 8 /* iVDR Clock ON */ 124#define IVDR_CK_ON 8 /* iVDR Clock ON */
140 125
141#elif defined(CONFIG_SH_R7785RP) 126#elif defined(CONFIG_SH_R7785RP)
@@ -192,13 +177,19 @@
192 177
193#define IRQ_AX88796 (HL_FPGA_IRQ_BASE + 0) 178#define IRQ_AX88796 (HL_FPGA_IRQ_BASE + 0)
194#define IRQ_CF (HL_FPGA_IRQ_BASE + 1) 179#define IRQ_CF (HL_FPGA_IRQ_BASE + 1)
195#ifndef IRQ_PSW
196#define IRQ_PSW (HL_FPGA_IRQ_BASE + 2) 180#define IRQ_PSW (HL_FPGA_IRQ_BASE + 2)
197#endif 181#define IRQ_EXT0 (HL_FPGA_IRQ_BASE + 3)
198#define IRQ_EXT1 (HL_FPGA_IRQ_BASE + 3) 182#define IRQ_EXT1 (HL_FPGA_IRQ_BASE + 4)
199#define IRQ_EXT4 (HL_FPGA_IRQ_BASE + 4) 183#define IRQ_EXT2 (HL_FPGA_IRQ_BASE + 5)
200 184#define IRQ_EXT3 (HL_FPGA_IRQ_BASE + 6)
201void make_r7780rp_irq(unsigned int irq); 185#define IRQ_EXT4 (HL_FPGA_IRQ_BASE + 7)
186#define IRQ_EXT5 (HL_FPGA_IRQ_BASE + 8)
187#define IRQ_EXT6 (HL_FPGA_IRQ_BASE + 9)
188#define IRQ_EXT7 (HL_FPGA_IRQ_BASE + 10)
189#define IRQ_SMBUS (HL_FPGA_IRQ_BASE + 11)
190#define IRQ_TP (HL_FPGA_IRQ_BASE + 12)
191#define IRQ_RTC (HL_FPGA_IRQ_BASE + 13)
192#define IRQ_TH_ALERT (HL_FPGA_IRQ_BASE + 14)
202 193
203unsigned char *highlander_init_irq_r7780mp(void); 194unsigned char *highlander_init_irq_r7780mp(void);
204unsigned char *highlander_init_irq_r7780rp(void); 195unsigned char *highlander_init_irq_r7780rp(void);
diff --git a/include/asm-sh/rtc.h b/include/asm-sh/rtc.h
index 858da99d37e0..ec45ba8e11d9 100644
--- a/include/asm-sh/rtc.h
+++ b/include/asm-sh/rtc.h
@@ -11,4 +11,6 @@ struct sh_rtc_platform_info {
11 unsigned long capabilities; 11 unsigned long capabilities;
12}; 12};
13 13
14#include <asm/cpu/rtc.h>
15
14#endif /* _ASM_RTC_H */ 16#endif /* _ASM_RTC_H */
diff --git a/include/asm-sh/scatterlist.h b/include/asm-sh/scatterlist.h
index a7d0d1856a99..2084d0373693 100644
--- a/include/asm-sh/scatterlist.h
+++ b/include/asm-sh/scatterlist.h
@@ -13,7 +13,7 @@ struct scatterlist {
13 unsigned int length; 13 unsigned int length;
14}; 14};
15 15
16#define ISA_DMA_THRESHOLD (0x1fffffff) 16#define ISA_DMA_THRESHOLD PHYS_ADDR_MASK
17 17
18/* These macros should be used after a pci_map_sg call has been done 18/* These macros should be used after a pci_map_sg call has been done
19 * to get bus addresses of each of the SG entries and their lengths. 19 * to get bus addresses of each of the SG entries and their lengths.
diff --git a/include/asm-sh/sdk7780.h b/include/asm-sh/sdk7780.h
new file mode 100644
index 000000000000..697dc865f21b
--- /dev/null
+++ b/include/asm-sh/sdk7780.h
@@ -0,0 +1,81 @@
1#ifndef __ASM_SH_RENESAS_SDK7780_H
2#define __ASM_SH_RENESAS_SDK7780_H
3
4/*
5 * linux/include/asm-sh/sdk7780.h
6 *
7 * Renesas Solutions SH7780 SDK Support
8 * Copyright (C) 2008 Nicholas Beck <nbeck@mpc-data.co.uk>
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <asm/addrspace.h>
15
16/* Box specific addresses. */
17#define SE_AREA0_WIDTH 4 /* Area0: 32bit */
18#define PA_ROM 0xa0000000 /* EPROM */
19#define PA_ROM_SIZE 0x00400000 /* EPROM size 4M byte */
20#define PA_FROM 0xa0800000 /* Flash-ROM */
21#define PA_FROM_SIZE 0x00400000 /* Flash-ROM size 4M byte */
22#define PA_EXT1 0xa4000000
23#define PA_EXT1_SIZE 0x04000000
24#define PA_SDRAM 0xa8000000 /* DDR-SDRAM(Area2/3) 128MB */
25#define PA_SDRAM_SIZE 0x08000000
26
27#define PA_EXT4 0xb0000000
28#define PA_EXT4_SIZE 0x04000000
29#define PA_EXT_USER PA_EXT4 /* User Expansion Space */
30
31#define PA_PERIPHERAL PA_AREA5_IO
32
33/* SRAM/Reserved */
34#define PA_RESERVED (PA_PERIPHERAL + 0)
35/* FPGA base address */
36#define PA_FPGA (PA_PERIPHERAL + 0x01000000)
37/* SMC LAN91C111 */
38#define PA_LAN (PA_PERIPHERAL + 0x01800000)
39
40
41#define FPGA_SRSTR (PA_FPGA + 0x000) /* System reset */
42#define FPGA_IRQ0SR (PA_FPGA + 0x010) /* IRQ0 status */
43#define FPGA_IRQ0MR (PA_FPGA + 0x020) /* IRQ0 mask */
44#define FPGA_BDMR (PA_FPGA + 0x030) /* Board operating mode */
45#define FPGA_INTT0PRTR (PA_FPGA + 0x040) /* Interrupt test mode0 port */
46#define FPGA_INTT0SELR (PA_FPGA + 0x050) /* Int. test mode0 select */
47#define FPGA_INTT1POLR (PA_FPGA + 0x060) /* Int. test mode0 polarity */
48#define FPGA_NMIR (PA_FPGA + 0x070) /* NMI source */
49#define FPGA_NMIMR (PA_FPGA + 0x080) /* NMI mask */
50#define FPGA_IRQR (PA_FPGA + 0x090) /* IRQX source */
51#define FPGA_IRQMR (PA_FPGA + 0x0A0) /* IRQX mask */
52#define FPGA_SLEDR (PA_FPGA + 0x0B0) /* LED control */
53#define PA_LED FPGA_SLEDR
54#define FPGA_MAPSWR (PA_FPGA + 0x0C0) /* Map switch */
55#define FPGA_FPVERR (PA_FPGA + 0x0D0) /* FPGA version */
56#define FPGA_FPDATER (PA_FPGA + 0x0E0) /* FPGA date */
57#define FPGA_RSE (PA_FPGA + 0x100) /* Reset source */
58#define FPGA_EASR (PA_FPGA + 0x110) /* External area select */
59#define FPGA_SPER (PA_FPGA + 0x120) /* Serial port enable */
60#define FPGA_IMSR (PA_FPGA + 0x130) /* Interrupt mode select */
61#define FPGA_PCIMR (PA_FPGA + 0x140) /* PCI Mode */
62#define FPGA_DIPSWMR (PA_FPGA + 0x150) /* DIPSW monitor */
63#define FPGA_FPODR (PA_FPGA + 0x160) /* Output port data */
64#define FPGA_ATAESR (PA_FPGA + 0x170) /* ATA extended bus status */
65#define FPGA_IRQPOLR (PA_FPGA + 0x180) /* IRQx polarity */
66
67
68#define SDK7780_NR_IRL 15
69/* IDE/ATA interrupt */
70#define IRQ_CFCARD 14
71/* SMC interrupt */
72#define IRQ_ETHERNET 6
73
74
75/* arch/sh/boards/renesas/sdk7780/irq.c */
76void init_sdk7780_IRQ(void);
77
78#define __IO_PREFIX sdk7780
79#include <asm/io_generic.h>
80
81#endif /* __ASM_SH_RENESAS_SDK7780_H */
diff --git a/include/asm-sh/sections.h b/include/asm-sh/sections.h
index bd9cbc967c2a..8f8f4ad400df 100644
--- a/include/asm-sh/sections.h
+++ b/include/asm-sh/sections.h
@@ -4,6 +4,7 @@
4#include <asm-generic/sections.h> 4#include <asm-generic/sections.h>
5 5
6extern long __machvec_start, __machvec_end; 6extern long __machvec_start, __machvec_end;
7extern char __uncached_start, __uncached_end;
7extern char _ebss[]; 8extern char _ebss[];
8 9
9#endif /* __ASM_SH_SECTIONS_H */ 10#endif /* __ASM_SH_SECTIONS_H */
diff --git a/include/asm-sh/setup.h b/include/asm-sh/setup.h
index 586a9711a75d..55a2bd328d99 100644
--- a/include/asm-sh/setup.h
+++ b/include/asm-sh/setup.h
@@ -5,6 +5,20 @@
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7 7
8/*
9 * This is set up by the setup-routine at boot-time
10 */
11#define PARAM ((unsigned char *)empty_zero_page)
12
13#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
14#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
15#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008))
16#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
17#define INITRD_START (*(unsigned long *) (PARAM+0x010))
18#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
19/* ... */
20#define COMMAND_LINE ((char *) (PARAM+0x100))
21
8int setup_early_printk(char *); 22int setup_early_printk(char *);
9void sh_mv_setup(void); 23void sh_mv_setup(void);
10 24
diff --git a/include/asm-sh/sigcontext.h b/include/asm-sh/sigcontext.h
index eb8effba2e80..8ce1435bc0bf 100644
--- a/include/asm-sh/sigcontext.h
+++ b/include/asm-sh/sigcontext.h
@@ -4,6 +4,18 @@
4struct sigcontext { 4struct sigcontext {
5 unsigned long oldmask; 5 unsigned long oldmask;
6 6
7#if defined(__SH5__) || defined(CONFIG_CPU_SH5)
8 /* CPU registers */
9 unsigned long long sc_regs[63];
10 unsigned long long sc_tregs[8];
11 unsigned long long sc_pc;
12 unsigned long long sc_sr;
13
14 /* FPU registers */
15 unsigned long long sc_fpregs[32];
16 unsigned int sc_fpscr;
17 unsigned int sc_fpvalid;
18#else
7 /* CPU registers */ 19 /* CPU registers */
8 unsigned long sc_regs[16]; 20 unsigned long sc_regs[16];
9 unsigned long sc_pc; 21 unsigned long sc_pc;
@@ -13,7 +25,8 @@ struct sigcontext {
13 unsigned long sc_mach; 25 unsigned long sc_mach;
14 unsigned long sc_macl; 26 unsigned long sc_macl;
15 27
16#if defined(__SH4__) || defined(CONFIG_CPU_SH4) 28#if defined(__SH4__) || defined(CONFIG_CPU_SH4) || \
29 defined(__SH2A__) || defined(CONFIG_CPU_SH2A)
17 /* FPU registers */ 30 /* FPU registers */
18 unsigned long sc_fpregs[16]; 31 unsigned long sc_fpregs[16];
19 unsigned long sc_xfpregs[16]; 32 unsigned long sc_xfpregs[16];
@@ -21,6 +34,7 @@ struct sigcontext {
21 unsigned int sc_fpul; 34 unsigned int sc_fpul;
22 unsigned int sc_ownedfp; 35 unsigned int sc_ownedfp;
23#endif 36#endif
37#endif
24}; 38};
25 39
26#endif /* __ASM_SH_SIGCONTEXT_H */ 40#endif /* __ASM_SH_SIGCONTEXT_H */
diff --git a/include/asm-sh/socket.h b/include/asm-sh/socket.h
index c48d6fc9da38..6d4bf6512959 100644
--- a/include/asm-sh/socket.h
+++ b/include/asm-sh/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* __ASM_SH_SOCKET_H */ 57#endif /* __ASM_SH_SOCKET_H */
diff --git a/include/asm-sh/spi.h b/include/asm-sh/spi.h
new file mode 100644
index 000000000000..e96f5b0953c8
--- /dev/null
+++ b/include/asm-sh/spi.h
@@ -0,0 +1,13 @@
1#ifndef __ASM_SPI_H__
2#define __ASM_SPI_H__
3
4struct sh_spi_info;
5
6struct sh_spi_info {
7 int bus_num;
8 int num_chipselect;
9
10 void (*chip_select)(struct sh_spi_info *spi, int cs, int state);
11};
12
13#endif /* __ASM_SPI_H__ */
diff --git a/include/asm-sh/stat.h b/include/asm-sh/stat.h
index 6d6ad26e3a2a..e1810cc6e3da 100644
--- a/include/asm-sh/stat.h
+++ b/include/asm-sh/stat.h
@@ -15,6 +15,66 @@ struct __old_kernel_stat {
15 unsigned long st_ctime; 15 unsigned long st_ctime;
16}; 16};
17 17
18#if defined(__SH5__) || defined(CONFIG_CPU_SH5)
19struct stat {
20 unsigned short st_dev;
21 unsigned short __pad1;
22 unsigned long st_ino;
23 unsigned short st_mode;
24 unsigned short st_nlink;
25 unsigned short st_uid;
26 unsigned short st_gid;
27 unsigned short st_rdev;
28 unsigned short __pad2;
29 unsigned long st_size;
30 unsigned long st_blksize;
31 unsigned long st_blocks;
32 unsigned long st_atime;
33 unsigned long st_atime_nsec;
34 unsigned long st_mtime;
35 unsigned long st_mtime_nsec;
36 unsigned long st_ctime;
37 unsigned long st_ctime_nsec;
38 unsigned long __unused4;
39 unsigned long __unused5;
40};
41
42/* This matches struct stat64 in glibc2.1, hence the absolutely
43 * insane amounts of padding around dev_t's.
44 */
45struct stat64 {
46 unsigned short st_dev;
47 unsigned char __pad0[10];
48
49 unsigned long st_ino;
50 unsigned int st_mode;
51 unsigned int st_nlink;
52
53 unsigned long st_uid;
54 unsigned long st_gid;
55
56 unsigned short st_rdev;
57 unsigned char __pad3[10];
58
59 long long st_size;
60 unsigned long st_blksize;
61
62 unsigned long st_blocks; /* Number 512-byte blocks allocated. */
63 unsigned long __pad4; /* future possible st_blocks high bits */
64
65 unsigned long st_atime;
66 unsigned long st_atime_nsec;
67
68 unsigned long st_mtime;
69 unsigned long st_mtime_nsec;
70
71 unsigned long st_ctime;
72 unsigned long st_ctime_nsec; /* will be high 32 bits of ctime someday */
73
74 unsigned long __unused1;
75 unsigned long __unused2;
76};
77#else
18struct stat { 78struct stat {
19 unsigned long st_dev; 79 unsigned long st_dev;
20 unsigned long st_ino; 80 unsigned long st_ino;
@@ -67,11 +127,12 @@ struct stat64 {
67 unsigned long st_mtime_nsec; 127 unsigned long st_mtime_nsec;
68 128
69 unsigned long st_ctime; 129 unsigned long st_ctime;
70 unsigned long st_ctime_nsec; 130 unsigned long st_ctime_nsec;
71 131
72 unsigned long long st_ino; 132 unsigned long long st_ino;
73}; 133};
74 134
75#define STAT_HAVE_NSEC 1 135#define STAT_HAVE_NSEC 1
136#endif
76 137
77#endif /* __ASM_SH_STAT_H */ 138#endif /* __ASM_SH_STAT_H */
diff --git a/include/asm-sh/string.h b/include/asm-sh/string.h
index 55f8db6bc1d7..8c1ea21dc0ae 100644
--- a/include/asm-sh/string.h
+++ b/include/asm-sh/string.h
@@ -1,131 +1,5 @@
1#ifndef __ASM_SH_STRING_H 1#ifdef CONFIG_SUPERH32
2#define __ASM_SH_STRING_H 2# include "string_32.h"
3 3#else
4#ifdef __KERNEL__ 4# include "string_64.h"
5 5#endif
6/*
7 * Copyright (C) 1999 Niibe Yutaka
8 * But consider these trivial functions to be public domain.
9 */
10
11#define __HAVE_ARCH_STRCPY
12static inline char *strcpy(char *__dest, const char *__src)
13{
14 register char *__xdest = __dest;
15 unsigned long __dummy;
16
17 __asm__ __volatile__("1:\n\t"
18 "mov.b @%1+, %2\n\t"
19 "mov.b %2, @%0\n\t"
20 "cmp/eq #0, %2\n\t"
21 "bf/s 1b\n\t"
22 " add #1, %0\n\t"
23 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
24 : "0" (__dest), "1" (__src)
25 : "memory", "t");
26
27 return __xdest;
28}
29
30#define __HAVE_ARCH_STRNCPY
31static inline char *strncpy(char *__dest, const char *__src, size_t __n)
32{
33 register char *__xdest = __dest;
34 unsigned long __dummy;
35
36 if (__n == 0)
37 return __xdest;
38
39 __asm__ __volatile__(
40 "1:\n"
41 "mov.b @%1+, %2\n\t"
42 "mov.b %2, @%0\n\t"
43 "cmp/eq #0, %2\n\t"
44 "bt/s 2f\n\t"
45 " cmp/eq %5,%1\n\t"
46 "bf/s 1b\n\t"
47 " add #1, %0\n"
48 "2:"
49 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
50 : "0" (__dest), "1" (__src), "r" (__src+__n)
51 : "memory", "t");
52
53 return __xdest;
54}
55
56#define __HAVE_ARCH_STRCMP
57static inline int strcmp(const char *__cs, const char *__ct)
58{
59 register int __res;
60 unsigned long __dummy;
61
62 __asm__ __volatile__(
63 "mov.b @%1+, %3\n"
64 "1:\n\t"
65 "mov.b @%0+, %2\n\t"
66 "cmp/eq #0, %3\n\t"
67 "bt 2f\n\t"
68 "cmp/eq %2, %3\n\t"
69 "bt/s 1b\n\t"
70 " mov.b @%1+, %3\n\t"
71 "add #-2, %1\n\t"
72 "mov.b @%1, %3\n\t"
73 "sub %3, %2\n"
74 "2:"
75 : "=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
76 : "0" (__cs), "1" (__ct)
77 : "t");
78
79 return __res;
80}
81
82#define __HAVE_ARCH_STRNCMP
83static inline int strncmp(const char *__cs, const char *__ct, size_t __n)
84{
85 register int __res;
86 unsigned long __dummy;
87
88 if (__n == 0)
89 return 0;
90
91 __asm__ __volatile__(
92 "mov.b @%1+, %3\n"
93 "1:\n\t"
94 "mov.b @%0+, %2\n\t"
95 "cmp/eq %6, %0\n\t"
96 "bt/s 2f\n\t"
97 " cmp/eq #0, %3\n\t"
98 "bt/s 3f\n\t"
99 " cmp/eq %3, %2\n\t"
100 "bt/s 1b\n\t"
101 " mov.b @%1+, %3\n\t"
102 "add #-2, %1\n\t"
103 "mov.b @%1, %3\n"
104 "2:\n\t"
105 "sub %3, %2\n"
106 "3:"
107 :"=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
108 : "0" (__cs), "1" (__ct), "r" (__cs+__n)
109 : "t");
110
111 return __res;
112}
113
114#define __HAVE_ARCH_MEMSET
115extern void *memset(void *__s, int __c, size_t __count);
116
117#define __HAVE_ARCH_MEMCPY
118extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
119
120#define __HAVE_ARCH_MEMMOVE
121extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
122
123#define __HAVE_ARCH_MEMCHR
124extern void *memchr(const void *__s, int __c, size_t __n);
125
126#define __HAVE_ARCH_STRLEN
127extern size_t strlen(const char *);
128
129#endif /* __KERNEL__ */
130
131#endif /* __ASM_SH_STRING_H */
diff --git a/include/asm-sh/string_32.h b/include/asm-sh/string_32.h
new file mode 100644
index 000000000000..55f8db6bc1d7
--- /dev/null
+++ b/include/asm-sh/string_32.h
@@ -0,0 +1,131 @@
1#ifndef __ASM_SH_STRING_H
2#define __ASM_SH_STRING_H
3
4#ifdef __KERNEL__
5
6/*
7 * Copyright (C) 1999 Niibe Yutaka
8 * But consider these trivial functions to be public domain.
9 */
10
11#define __HAVE_ARCH_STRCPY
12static inline char *strcpy(char *__dest, const char *__src)
13{
14 register char *__xdest = __dest;
15 unsigned long __dummy;
16
17 __asm__ __volatile__("1:\n\t"
18 "mov.b @%1+, %2\n\t"
19 "mov.b %2, @%0\n\t"
20 "cmp/eq #0, %2\n\t"
21 "bf/s 1b\n\t"
22 " add #1, %0\n\t"
23 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
24 : "0" (__dest), "1" (__src)
25 : "memory", "t");
26
27 return __xdest;
28}
29
30#define __HAVE_ARCH_STRNCPY
31static inline char *strncpy(char *__dest, const char *__src, size_t __n)
32{
33 register char *__xdest = __dest;
34 unsigned long __dummy;
35
36 if (__n == 0)
37 return __xdest;
38
39 __asm__ __volatile__(
40 "1:\n"
41 "mov.b @%1+, %2\n\t"
42 "mov.b %2, @%0\n\t"
43 "cmp/eq #0, %2\n\t"
44 "bt/s 2f\n\t"
45 " cmp/eq %5,%1\n\t"
46 "bf/s 1b\n\t"
47 " add #1, %0\n"
48 "2:"
49 : "=r" (__dest), "=r" (__src), "=&z" (__dummy)
50 : "0" (__dest), "1" (__src), "r" (__src+__n)
51 : "memory", "t");
52
53 return __xdest;
54}
55
56#define __HAVE_ARCH_STRCMP
57static inline int strcmp(const char *__cs, const char *__ct)
58{
59 register int __res;
60 unsigned long __dummy;
61
62 __asm__ __volatile__(
63 "mov.b @%1+, %3\n"
64 "1:\n\t"
65 "mov.b @%0+, %2\n\t"
66 "cmp/eq #0, %3\n\t"
67 "bt 2f\n\t"
68 "cmp/eq %2, %3\n\t"
69 "bt/s 1b\n\t"
70 " mov.b @%1+, %3\n\t"
71 "add #-2, %1\n\t"
72 "mov.b @%1, %3\n\t"
73 "sub %3, %2\n"
74 "2:"
75 : "=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
76 : "0" (__cs), "1" (__ct)
77 : "t");
78
79 return __res;
80}
81
82#define __HAVE_ARCH_STRNCMP
83static inline int strncmp(const char *__cs, const char *__ct, size_t __n)
84{
85 register int __res;
86 unsigned long __dummy;
87
88 if (__n == 0)
89 return 0;
90
91 __asm__ __volatile__(
92 "mov.b @%1+, %3\n"
93 "1:\n\t"
94 "mov.b @%0+, %2\n\t"
95 "cmp/eq %6, %0\n\t"
96 "bt/s 2f\n\t"
97 " cmp/eq #0, %3\n\t"
98 "bt/s 3f\n\t"
99 " cmp/eq %3, %2\n\t"
100 "bt/s 1b\n\t"
101 " mov.b @%1+, %3\n\t"
102 "add #-2, %1\n\t"
103 "mov.b @%1, %3\n"
104 "2:\n\t"
105 "sub %3, %2\n"
106 "3:"
107 :"=r" (__cs), "=r" (__ct), "=&r" (__res), "=&z" (__dummy)
108 : "0" (__cs), "1" (__ct), "r" (__cs+__n)
109 : "t");
110
111 return __res;
112}
113
114#define __HAVE_ARCH_MEMSET
115extern void *memset(void *__s, int __c, size_t __count);
116
117#define __HAVE_ARCH_MEMCPY
118extern void *memcpy(void *__to, __const__ void *__from, size_t __n);
119
120#define __HAVE_ARCH_MEMMOVE
121extern void *memmove(void *__dest, __const__ void *__src, size_t __n);
122
123#define __HAVE_ARCH_MEMCHR
124extern void *memchr(const void *__s, int __c, size_t __n);
125
126#define __HAVE_ARCH_STRLEN
127extern size_t strlen(const char *);
128
129#endif /* __KERNEL__ */
130
131#endif /* __ASM_SH_STRING_H */
diff --git a/include/asm-sh64/string.h b/include/asm-sh/string_64.h
index 8a7357366ce8..aa1fef229c78 100644
--- a/include/asm-sh64/string.h
+++ b/include/asm-sh/string_64.h
@@ -1,21 +1,17 @@
1#ifndef __ASM_SH64_STRING_H 1#ifndef __ASM_SH_STRING_64_H
2#define __ASM_SH64_STRING_H 2#define __ASM_SH_STRING_64_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/string_64.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/string.h
10 * 6 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 7 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * 8 *
13 * Empty on purpose. ARCH SH64 ASM libs are out of the current project scope. 9 * This file is subject to the terms and conditions of the GNU General Public
14 * 10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
15 */ 12 */
16 13
17#define __HAVE_ARCH_MEMCPY 14#define __HAVE_ARCH_MEMCPY
18
19extern void *memcpy(void *dest, const void *src, size_t count); 15extern void *memcpy(void *dest, const void *src, size_t count);
20 16
21#endif 17#endif /* __ASM_SH_STRING_64_H */
diff --git a/include/asm-sh/system.h b/include/asm-sh/system.h
index 4faa2fb88616..772cd1a0a674 100644
--- a/include/asm-sh/system.h
+++ b/include/asm-sh/system.h
@@ -12,60 +12,9 @@
12#include <asm/types.h> 12#include <asm/types.h>
13#include <asm/ptrace.h> 13#include <asm/ptrace.h>
14 14
15struct task_struct *__switch_to(struct task_struct *prev, 15#define AT_VECTOR_SIZE_ARCH 5 /* entries in ARCH_DLINFO */
16 struct task_struct *next);
17 16
18#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */ 17#if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5)
19/*
20 * switch_to() should switch tasks to task nr n, first
21 */
22
23#define switch_to(prev, next, last) do { \
24 struct task_struct *__last; \
25 register unsigned long *__ts1 __asm__ ("r1") = &prev->thread.sp; \
26 register unsigned long *__ts2 __asm__ ("r2") = &prev->thread.pc; \
27 register unsigned long *__ts4 __asm__ ("r4") = (unsigned long *)prev; \
28 register unsigned long *__ts5 __asm__ ("r5") = (unsigned long *)next; \
29 register unsigned long *__ts6 __asm__ ("r6") = &next->thread.sp; \
30 register unsigned long __ts7 __asm__ ("r7") = next->thread.pc; \
31 __asm__ __volatile__ (".balign 4\n\t" \
32 "stc.l gbr, @-r15\n\t" \
33 "sts.l pr, @-r15\n\t" \
34 "mov.l r8, @-r15\n\t" \
35 "mov.l r9, @-r15\n\t" \
36 "mov.l r10, @-r15\n\t" \
37 "mov.l r11, @-r15\n\t" \
38 "mov.l r12, @-r15\n\t" \
39 "mov.l r13, @-r15\n\t" \
40 "mov.l r14, @-r15\n\t" \
41 "mov.l r15, @r1 ! save SP\n\t" \
42 "mov.l @r6, r15 ! change to new stack\n\t" \
43 "mova 1f, %0\n\t" \
44 "mov.l %0, @r2 ! save PC\n\t" \
45 "mov.l 2f, %0\n\t" \
46 "jmp @%0 ! call __switch_to\n\t" \
47 " lds r7, pr ! with return to new PC\n\t" \
48 ".balign 4\n" \
49 "2:\n\t" \
50 ".long __switch_to\n" \
51 "1:\n\t" \
52 "mov.l @r15+, r14\n\t" \
53 "mov.l @r15+, r13\n\t" \
54 "mov.l @r15+, r12\n\t" \
55 "mov.l @r15+, r11\n\t" \
56 "mov.l @r15+, r10\n\t" \
57 "mov.l @r15+, r9\n\t" \
58 "mov.l @r15+, r8\n\t" \
59 "lds.l @r15+, pr\n\t" \
60 "ldc.l @r15+, gbr\n\t" \
61 : "=z" (__last) \
62 : "r" (__ts1), "r" (__ts2), "r" (__ts4), \
63 "r" (__ts5), "r" (__ts6), "r" (__ts7) \
64 : "r3", "t"); \
65 last = __last; \
66} while (0)
67
68#ifdef CONFIG_CPU_SH4A
69#define __icbi() \ 18#define __icbi() \
70{ \ 19{ \
71 unsigned long __addr; \ 20 unsigned long __addr; \
@@ -91,7 +40,7 @@ struct task_struct *__switch_to(struct task_struct *prev,
91 * Historically we have only done this type of barrier for the MMUCR, but 40 * Historically we have only done this type of barrier for the MMUCR, but
92 * it's also necessary for the CCR, so we make it generic here instead. 41 * it's also necessary for the CCR, so we make it generic here instead.
93 */ 42 */
94#ifdef CONFIG_CPU_SH4A 43#if defined(CONFIG_CPU_SH4A) || defined(CONFIG_CPU_SH5)
95#define mb() __asm__ __volatile__ ("synco": : :"memory") 44#define mb() __asm__ __volatile__ ("synco": : :"memory")
96#define rmb() mb() 45#define rmb() mb()
97#define wmb() __asm__ __volatile__ ("synco": : :"memory") 46#define wmb() __asm__ __volatile__ ("synco": : :"memory")
@@ -119,63 +68,11 @@ struct task_struct *__switch_to(struct task_struct *prev,
119 68
120#define set_mb(var, value) do { (void)xchg(&var, value); } while (0) 69#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
121 70
122/* 71#ifdef CONFIG_GUSA_RB
123 * Jump to P2 area. 72#include <asm/cmpxchg-grb.h>
124 * When handling TLB or caches, we need to do it from P2 area. 73#else
125 */ 74#include <asm/cmpxchg-irq.h>
126#define jump_to_P2() \ 75#endif
127do { \
128 unsigned long __dummy; \
129 __asm__ __volatile__( \
130 "mov.l 1f, %0\n\t" \
131 "or %1, %0\n\t" \
132 "jmp @%0\n\t" \
133 " nop\n\t" \
134 ".balign 4\n" \
135 "1: .long 2f\n" \
136 "2:" \
137 : "=&r" (__dummy) \
138 : "r" (0x20000000)); \
139} while (0)
140
141/*
142 * Back to P1 area.
143 */
144#define back_to_P1() \
145do { \
146 unsigned long __dummy; \
147 ctrl_barrier(); \
148 __asm__ __volatile__( \
149 "mov.l 1f, %0\n\t" \
150 "jmp @%0\n\t" \
151 " nop\n\t" \
152 ".balign 4\n" \
153 "1: .long 2f\n" \
154 "2:" \
155 : "=&r" (__dummy)); \
156} while (0)
157
158static inline unsigned long xchg_u32(volatile u32 *m, unsigned long val)
159{
160 unsigned long flags, retval;
161
162 local_irq_save(flags);
163 retval = *m;
164 *m = val;
165 local_irq_restore(flags);
166 return retval;
167}
168
169static inline unsigned long xchg_u8(volatile u8 *m, unsigned long val)
170{
171 unsigned long flags, retval;
172
173 local_irq_save(flags);
174 retval = *m;
175 *m = val & 0xff;
176 local_irq_restore(flags);
177 return retval;
178}
179 76
180extern void __xchg_called_with_bad_pointer(void); 77extern void __xchg_called_with_bad_pointer(void);
181 78
@@ -202,20 +99,6 @@ extern void __xchg_called_with_bad_pointer(void);
202#define xchg(ptr,x) \ 99#define xchg(ptr,x) \
203 ((__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr)))) 100 ((__typeof__(*(ptr)))__xchg((ptr),(unsigned long)(x), sizeof(*(ptr))))
204 101
205static inline unsigned long __cmpxchg_u32(volatile int * m, unsigned long old,
206 unsigned long new)
207{
208 __u32 retval;
209 unsigned long flags;
210
211 local_irq_save(flags);
212 retval = *m;
213 if (retval == old)
214 *m = new;
215 local_irq_restore(flags); /* implies memory barrier */
216 return retval;
217}
218
219/* This function doesn't exist, so you'll get a linker error 102/* This function doesn't exist, so you'll get a linker error
220 * if something tries to do an invalid cmpxchg(). */ 103 * if something tries to do an invalid cmpxchg(). */
221extern void __cmpxchg_called_with_bad_pointer(void); 104extern void __cmpxchg_called_with_bad_pointer(void);
@@ -255,10 +138,14 @@ static inline void *set_exception_table_evt(unsigned int evt, void *handler)
255 */ 138 */
256#ifdef CONFIG_CPU_SH2A 139#ifdef CONFIG_CPU_SH2A
257extern unsigned int instruction_size(unsigned int insn); 140extern unsigned int instruction_size(unsigned int insn);
258#else 141#elif defined(CONFIG_SUPERH32)
259#define instruction_size(insn) (2) 142#define instruction_size(insn) (2)
143#else
144#define instruction_size(insn) (4)
260#endif 145#endif
261 146
147extern unsigned long cached_to_uncached;
148
262/* XXX 149/* XXX
263 * disable hlt during certain critical i/o operations 150 * disable hlt during certain critical i/o operations
264 */ 151 */
@@ -270,13 +157,35 @@ void default_idle(void);
270void per_cpu_trap_init(void); 157void per_cpu_trap_init(void);
271 158
272asmlinkage void break_point_trap(void); 159asmlinkage void break_point_trap(void);
273asmlinkage void debug_trap_handler(unsigned long r4, unsigned long r5, 160
274 unsigned long r6, unsigned long r7, 161#ifdef CONFIG_SUPERH32
275 struct pt_regs __regs); 162#define BUILD_TRAP_HANDLER(name) \
276asmlinkage void bug_trap_handler(unsigned long r4, unsigned long r5, 163asmlinkage void name##_trap_handler(unsigned long r4, unsigned long r5, \
277 unsigned long r6, unsigned long r7, 164 unsigned long r6, unsigned long r7, \
278 struct pt_regs __regs); 165 struct pt_regs __regs)
166
167#define TRAP_HANDLER_DECL \
168 struct pt_regs *regs = RELOC_HIDE(&__regs, 0); \
169 unsigned int vec = regs->tra; \
170 (void)vec;
171#else
172#define BUILD_TRAP_HANDLER(name) \
173asmlinkage void name##_trap_handler(unsigned int vec, struct pt_regs *regs)
174#define TRAP_HANDLER_DECL
175#endif
176
177BUILD_TRAP_HANDLER(address_error);
178BUILD_TRAP_HANDLER(debug);
179BUILD_TRAP_HANDLER(bug);
180BUILD_TRAP_HANDLER(fpu_error);
181BUILD_TRAP_HANDLER(fpu_state_restore);
279 182
280#define arch_align_stack(x) (x) 183#define arch_align_stack(x) (x)
281 184
185#ifdef CONFIG_SUPERH32
186# include "system_32.h"
187#else
188# include "system_64.h"
189#endif
190
282#endif 191#endif
diff --git a/include/asm-sh/system_32.h b/include/asm-sh/system_32.h
new file mode 100644
index 000000000000..7ff08d956ba8
--- /dev/null
+++ b/include/asm-sh/system_32.h
@@ -0,0 +1,99 @@
1#ifndef __ASM_SH_SYSTEM_32_H
2#define __ASM_SH_SYSTEM_32_H
3
4#include <linux/types.h>
5
6struct task_struct *__switch_to(struct task_struct *prev,
7 struct task_struct *next);
8
9/*
10 * switch_to() should switch tasks to task nr n, first
11 */
12#define switch_to(prev, next, last) \
13do { \
14 register u32 *__ts1 __asm__ ("r1") = (u32 *)&prev->thread.sp; \
15 register u32 *__ts2 __asm__ ("r2") = (u32 *)&prev->thread.pc; \
16 register u32 *__ts4 __asm__ ("r4") = (u32 *)prev; \
17 register u32 *__ts5 __asm__ ("r5") = (u32 *)next; \
18 register u32 *__ts6 __asm__ ("r6") = (u32 *)&next->thread.sp; \
19 register u32 __ts7 __asm__ ("r7") = next->thread.pc; \
20 struct task_struct *__last; \
21 \
22 __asm__ __volatile__ ( \
23 ".balign 4\n\t" \
24 "stc.l gbr, @-r15\n\t" \
25 "sts.l pr, @-r15\n\t" \
26 "mov.l r8, @-r15\n\t" \
27 "mov.l r9, @-r15\n\t" \
28 "mov.l r10, @-r15\n\t" \
29 "mov.l r11, @-r15\n\t" \
30 "mov.l r12, @-r15\n\t" \
31 "mov.l r13, @-r15\n\t" \
32 "mov.l r14, @-r15\n\t" \
33 "mov.l r15, @r1\t! save SP\n\t" \
34 "mov.l @r6, r15\t! change to new stack\n\t" \
35 "mova 1f, %0\n\t" \
36 "mov.l %0, @r2\t! save PC\n\t" \
37 "mov.l 2f, %0\n\t" \
38 "jmp @%0\t! call __switch_to\n\t" \
39 " lds r7, pr\t! with return to new PC\n\t" \
40 ".balign 4\n" \
41 "2:\n\t" \
42 ".long __switch_to\n" \
43 "1:\n\t" \
44 "mov.l @r15+, r14\n\t" \
45 "mov.l @r15+, r13\n\t" \
46 "mov.l @r15+, r12\n\t" \
47 "mov.l @r15+, r11\n\t" \
48 "mov.l @r15+, r10\n\t" \
49 "mov.l @r15+, r9\n\t" \
50 "mov.l @r15+, r8\n\t" \
51 "lds.l @r15+, pr\n\t" \
52 "ldc.l @r15+, gbr\n\t" \
53 : "=z" (__last) \
54 : "r" (__ts1), "r" (__ts2), "r" (__ts4), \
55 "r" (__ts5), "r" (__ts6), "r" (__ts7) \
56 : "r3", "t"); \
57 \
58 last = __last; \
59} while (0)
60
61#define __uses_jump_to_uncached __attribute__ ((__section__ (".uncached.text")))
62
63/*
64 * Jump to uncached area.
65 * When handling TLB or caches, we need to do it from an uncached area.
66 */
67#define jump_to_uncached() \
68do { \
69 unsigned long __dummy; \
70 \
71 __asm__ __volatile__( \
72 "mova 1f, %0\n\t" \
73 "add %1, %0\n\t" \
74 "jmp @%0\n\t" \
75 " nop\n\t" \
76 ".balign 4\n" \
77 "1:" \
78 : "=&z" (__dummy) \
79 : "r" (cached_to_uncached)); \
80} while (0)
81
82/*
83 * Back to cached area.
84 */
85#define back_to_cached() \
86do { \
87 unsigned long __dummy; \
88 ctrl_barrier(); \
89 __asm__ __volatile__( \
90 "mov.l 1f, %0\n\t" \
91 "jmp @%0\n\t" \
92 " nop\n\t" \
93 ".balign 4\n" \
94 "1: .long 2f\n" \
95 "2:" \
96 : "=&r" (__dummy)); \
97} while (0)
98
99#endif /* __ASM_SH_SYSTEM_32_H */
diff --git a/include/asm-sh/system_64.h b/include/asm-sh/system_64.h
new file mode 100644
index 000000000000..943acf5ea07c
--- /dev/null
+++ b/include/asm-sh/system_64.h
@@ -0,0 +1,40 @@
1#ifndef __ASM_SH_SYSTEM_64_H
2#define __ASM_SH_SYSTEM_64_H
3
4/*
5 * include/asm-sh/system_64.h
6 *
7 * Copyright (C) 2000, 2001 Paolo Alberelli
8 * Copyright (C) 2003 Paul Mundt
9 * Copyright (C) 2004 Richard Curnow
10 *
11 * This file is subject to the terms and conditions of the GNU General Public
12 * License. See the file "COPYING" in the main directory of this archive
13 * for more details.
14 */
15#include <asm/processor.h>
16
17/*
18 * switch_to() should switch tasks to task nr n, first
19 */
20struct task_struct *sh64_switch_to(struct task_struct *prev,
21 struct thread_struct *prev_thread,
22 struct task_struct *next,
23 struct thread_struct *next_thread);
24
25#define switch_to(prev,next,last) \
26do { \
27 if (last_task_used_math != next) { \
28 struct pt_regs *regs = next->thread.uregs; \
29 if (regs) regs->sr |= SR_FD; \
30 } \
31 last = sh64_switch_to(prev, &prev->thread, next, \
32 &next->thread); \
33} while (0)
34
35#define __uses_jump_to_uncached
36
37#define jump_to_uncached() do { } while (0)
38#define back_to_cached() do { } while (0)
39
40#endif /* __ASM_SH_SYSTEM_64_H */
diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h
index 1f7e1deb8d92..c50e5d35fe84 100644
--- a/include/asm-sh/thread_info.h
+++ b/include/asm-sh/thread_info.h
@@ -68,14 +68,16 @@ struct thread_info {
68#define init_stack (init_thread_union.stack) 68#define init_stack (init_thread_union.stack)
69 69
70/* how to get the current stack pointer from C */ 70/* how to get the current stack pointer from C */
71register unsigned long current_stack_pointer asm("r15") __attribute_used__; 71register unsigned long current_stack_pointer asm("r15") __used;
72 72
73/* how to get the thread information struct from C */ 73/* how to get the thread information struct from C */
74static inline struct thread_info *current_thread_info(void) 74static inline struct thread_info *current_thread_info(void)
75{ 75{
76 struct thread_info *ti; 76 struct thread_info *ti;
77#ifdef CONFIG_CPU_HAS_SR_RB 77#if defined(CONFIG_SUPERH64)
78 __asm__("stc r7_bank, %0" : "=r" (ti)); 78 __asm__ __volatile__ ("getcon cr17, %0" : "=r" (ti));
79#elif defined(CONFIG_CPU_HAS_SR_RB)
80 __asm__ __volatile__ ("stc r7_bank, %0" : "=r" (ti));
79#else 81#else
80 unsigned long __dummy; 82 unsigned long __dummy;
81 83
@@ -111,6 +113,7 @@ static inline struct thread_info *current_thread_info(void)
111#define TIF_NEED_RESCHED 2 /* rescheduling necessary */ 113#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
112#define TIF_RESTORE_SIGMASK 3 /* restore signal mask in do_signal() */ 114#define TIF_RESTORE_SIGMASK 3 /* restore signal mask in do_signal() */
113#define TIF_SINGLESTEP 4 /* singlestepping active */ 115#define TIF_SINGLESTEP 4 /* singlestepping active */
116#define TIF_SYSCALL_AUDIT 5
114#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */ 117#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
115#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */ 118#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
116#define TIF_MEMDIE 18 119#define TIF_MEMDIE 18
@@ -121,6 +124,7 @@ static inline struct thread_info *current_thread_info(void)
121#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 124#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
122#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 125#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
123#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) 126#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
127#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
124#define _TIF_USEDFPU (1<<TIF_USEDFPU) 128#define _TIF_USEDFPU (1<<TIF_USEDFPU)
125#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 129#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
126#define _TIF_FREEZE (1<<TIF_FREEZE) 130#define _TIF_FREEZE (1<<TIF_FREEZE)
diff --git a/include/asm-sh/tlb.h b/include/asm-sh/tlb.h
index 53d185bcf872..56ad1fb888a2 100644
--- a/include/asm-sh/tlb.h
+++ b/include/asm-sh/tlb.h
@@ -1,6 +1,12 @@
1#ifndef __ASM_SH_TLB_H 1#ifndef __ASM_SH_TLB_H
2#define __ASM_SH_TLB_H 2#define __ASM_SH_TLB_H
3 3
4#ifdef CONFIG_SUPERH64
5# include "tlb_64.h"
6#endif
7
8#ifndef __ASSEMBLY__
9
4#define tlb_start_vma(tlb, vma) \ 10#define tlb_start_vma(tlb, vma) \
5 flush_cache_range(vma, vma->vm_start, vma->vm_end) 11 flush_cache_range(vma, vma->vm_start, vma->vm_end)
6 12
@@ -15,4 +21,6 @@
15#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm) 21#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
16 22
17#include <asm-generic/tlb.h> 23#include <asm-generic/tlb.h>
18#endif 24
25#endif /* __ASSEMBLY__ */
26#endif /* __ASM_SH_TLB_H */
diff --git a/include/asm-sh64/tlb.h b/include/asm-sh/tlb_64.h
index 4979408bd88c..0308e05fc57b 100644
--- a/include/asm-sh64/tlb.h
+++ b/include/asm-sh/tlb_64.h
@@ -1,20 +1,14 @@
1/* 1/*
2 * include/asm-sh64/tlb.h 2 * include/asm-sh/tlb_64.h
3 * 3 *
4 * Copyright (C) 2003 Paul Mundt 4 * Copyright (C) 2003 Paul Mundt
5 * 5 *
6 * This file is subject to the terms and conditions of the GNU General Public 6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive 7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details. 8 * for more details.
9 *
10 */
11#ifndef __ASM_SH64_TLB_H
12#define __ASM_SH64_TLB_H
13
14/*
15 * Note! These are mostly unused, we just need the xTLB_LAST_VAR_UNRESTRICTED
16 * for head.S! Once this limitation is gone, we can clean the rest of this up.
17 */ 9 */
10#ifndef __ASM_SH_TLB_64_H
11#define __ASM_SH_TLB_64_H
18 12
19/* ITLB defines */ 13/* ITLB defines */
20#define ITLB_FIXED 0x00000000 /* First fixed ITLB, see head.S */ 14#define ITLB_FIXED 0x00000000 /* First fixed ITLB, see head.S */
@@ -63,30 +57,13 @@ static inline void __flush_tlb_slot(unsigned long long slot)
63} 57}
64 58
65/* arch/sh64/mm/tlb.c */ 59/* arch/sh64/mm/tlb.c */
66extern int sh64_tlb_init(void); 60int sh64_tlb_init(void);
67extern unsigned long long sh64_next_free_dtlb_entry(void); 61unsigned long long sh64_next_free_dtlb_entry(void);
68extern unsigned long long sh64_get_wired_dtlb_entry(void); 62unsigned long long sh64_get_wired_dtlb_entry(void);
69extern int sh64_put_wired_dtlb_entry(unsigned long long entry); 63int sh64_put_wired_dtlb_entry(unsigned long long entry);
70 64void sh64_setup_tlb_slot(unsigned long long config_addr, unsigned long eaddr,
71extern void sh64_setup_tlb_slot(unsigned long long config_addr, unsigned long eaddr, unsigned long asid, unsigned long paddr); 65 unsigned long asid, unsigned long paddr);
72extern void sh64_teardown_tlb_slot(unsigned long long config_addr); 66void sh64_teardown_tlb_slot(unsigned long long config_addr);
73
74#define tlb_start_vma(tlb, vma) \
75 flush_cache_range(vma, vma->vm_start, vma->vm_end)
76
77#define tlb_end_vma(tlb, vma) \
78 flush_tlb_range(vma, vma->vm_start, vma->vm_end)
79
80#define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
81
82/*
83 * Flush whole TLBs for MM
84 */
85#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
86
87#include <asm-generic/tlb.h>
88 67
89#endif /* __ASSEMBLY__ */ 68#endif /* __ASSEMBLY__ */
90 69#endif /* __ASM_SH_TLB_64_H */
91#endif /* __ASM_SH64_TLB_H */
92
diff --git a/include/asm-sh/types.h b/include/asm-sh/types.h
index 7ba69d9707ef..a6e1d4126e67 100644
--- a/include/asm-sh/types.h
+++ b/include/asm-sh/types.h
@@ -52,6 +52,12 @@ typedef unsigned long long u64;
52 52
53typedef u32 dma_addr_t; 53typedef u32 dma_addr_t;
54 54
55#ifdef CONFIG_SUPERH32
56typedef u16 opcode_t;
57#else
58typedef u32 opcode_t;
59#endif
60
55#endif /* __ASSEMBLY__ */ 61#endif /* __ASSEMBLY__ */
56 62
57#endif /* __KERNEL__ */ 63#endif /* __KERNEL__ */
diff --git a/include/asm-sh/uaccess.h b/include/asm-sh/uaccess.h
index f18a1a5c95c0..ff24ce95b238 100644
--- a/include/asm-sh/uaccess.h
+++ b/include/asm-sh/uaccess.h
@@ -1,575 +1,5 @@
1/* $Id: uaccess.h,v 1.11 2003/10/13 07:21:20 lethal Exp $ 1#ifdef CONFIG_SUPERH32
2 * 2# include "uaccess_32.h"
3 * User space memory access functions
4 *
5 * Copyright (C) 1999, 2002 Niibe Yutaka
6 * Copyright (C) 2003 Paul Mundt
7 *
8 * Based on:
9 * MIPS implementation version 1.15 by
10 * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
11 * and i386 version.
12 */
13#ifndef __ASM_SH_UACCESS_H
14#define __ASM_SH_UACCESS_H
15
16#include <linux/errno.h>
17#include <linux/sched.h>
18
19#define VERIFY_READ 0
20#define VERIFY_WRITE 1
21
22/*
23 * The fs value determines whether argument validity checking should be
24 * performed or not. If get_fs() == USER_DS, checking is performed, with
25 * get_fs() == KERNEL_DS, checking is bypassed.
26 *
27 * For historical reasons (Data Segment Register?), these macros are misnamed.
28 */
29
30#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
31
32#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL)
33#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
34
35#define segment_eq(a,b) ((a).seg == (b).seg)
36
37#define get_ds() (KERNEL_DS)
38
39#if !defined(CONFIG_MMU)
40/* NOMMU is always true */
41#define __addr_ok(addr) (1)
42
43static inline mm_segment_t get_fs(void)
44{
45 return USER_DS;
46}
47
48static inline void set_fs(mm_segment_t s)
49{
50}
51
52/*
53 * __access_ok: Check if address with size is OK or not.
54 *
55 * If we don't have an MMU (or if its disabled) the only thing we really have
56 * to look out for is if the address resides somewhere outside of what
57 * available RAM we have.
58 *
59 * TODO: This check could probably also stand to be restricted somewhat more..
60 * though it still does the Right Thing(tm) for the time being.
61 */
62static inline int __access_ok(unsigned long addr, unsigned long size)
63{
64 return ((addr >= memory_start) && ((addr + size) < memory_end));
65}
66#else /* CONFIG_MMU */
67#define __addr_ok(addr) \
68 ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
69
70#define get_fs() (current_thread_info()->addr_limit)
71#define set_fs(x) (current_thread_info()->addr_limit = (x))
72
73/*
74 * __access_ok: Check if address with size is OK or not.
75 *
76 * We do three checks:
77 * (1) is it user space?
78 * (2) addr + size --> carry?
79 * (3) addr + size >= 0x80000000 (PAGE_OFFSET)
80 *
81 * (1) (2) (3) | RESULT
82 * 0 0 0 | ok
83 * 0 0 1 | ok
84 * 0 1 0 | bad
85 * 0 1 1 | bad
86 * 1 0 0 | ok
87 * 1 0 1 | bad
88 * 1 1 0 | bad
89 * 1 1 1 | bad
90 */
91static inline int __access_ok(unsigned long addr, unsigned long size)
92{
93 unsigned long flag, tmp;
94
95 __asm__("stc r7_bank, %0\n\t"
96 "mov.l @(8,%0), %0\n\t"
97 "clrt\n\t"
98 "addc %2, %1\n\t"
99 "and %1, %0\n\t"
100 "rotcl %0\n\t"
101 "rotcl %0\n\t"
102 "and #3, %0"
103 : "=&z" (flag), "=r" (tmp)
104 : "r" (addr), "1" (size)
105 : "t");
106
107 return flag == 0;
108}
109#endif /* CONFIG_MMU */
110
111static inline int access_ok(int type, const void __user *p, unsigned long size)
112{
113 unsigned long addr = (unsigned long)p;
114 return __access_ok(addr, size);
115}
116
117/*
118 * Uh, these should become the main single-value transfer routines ...
119 * They automatically use the right size if we just have the right
120 * pointer type ...
121 *
122 * As SuperH uses the same address space for kernel and user data, we
123 * can just do these as direct assignments.
124 *
125 * Careful to not
126 * (a) re-use the arguments for side effects (sizeof is ok)
127 * (b) require any knowledge of processes at this stage
128 */
129#define put_user(x,ptr) __put_user_check((x),(ptr),sizeof(*(ptr)))
130#define get_user(x,ptr) __get_user_check((x),(ptr),sizeof(*(ptr)))
131
132/*
133 * The "__xxx" versions do not do address space checking, useful when
134 * doing multiple accesses to the same area (the user has to do the
135 * checks by hand with "access_ok()")
136 */
137#define __put_user(x,ptr) \
138 __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
139#define __get_user(x,ptr) \
140 __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
141
142struct __large_struct { unsigned long buf[100]; };
143#define __m(x) (*(struct __large_struct __user *)(x))
144
145#define __get_user_size(x,ptr,size,retval) \
146do { \
147 retval = 0; \
148 __chk_user_ptr(ptr); \
149 switch (size) { \
150 case 1: \
151 __get_user_asm(x, ptr, retval, "b"); \
152 break; \
153 case 2: \
154 __get_user_asm(x, ptr, retval, "w"); \
155 break; \
156 case 4: \
157 __get_user_asm(x, ptr, retval, "l"); \
158 break; \
159 default: \
160 __get_user_unknown(); \
161 break; \
162 } \
163} while (0)
164
165#define __get_user_nocheck(x,ptr,size) \
166({ \
167 long __gu_err, __gu_val; \
168 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
169 (x) = (__typeof__(*(ptr)))__gu_val; \
170 __gu_err; \
171})
172
173#ifdef CONFIG_MMU
174#define __get_user_check(x,ptr,size) \
175({ \
176 long __gu_err, __gu_val; \
177 __chk_user_ptr(ptr); \
178 switch (size) { \
179 case 1: \
180 __get_user_1(__gu_val, (ptr), __gu_err); \
181 break; \
182 case 2: \
183 __get_user_2(__gu_val, (ptr), __gu_err); \
184 break; \
185 case 4: \
186 __get_user_4(__gu_val, (ptr), __gu_err); \
187 break; \
188 default: \
189 __get_user_unknown(); \
190 break; \
191 } \
192 \
193 (x) = (__typeof__(*(ptr)))__gu_val; \
194 __gu_err; \
195})
196
197#define __get_user_1(x,addr,err) ({ \
198__asm__("stc r7_bank, %1\n\t" \
199 "mov.l @(8,%1), %1\n\t" \
200 "and %2, %1\n\t" \
201 "cmp/pz %1\n\t" \
202 "bt/s 1f\n\t" \
203 " mov #0, %0\n\t" \
204 "0:\n" \
205 "mov #-14, %0\n\t" \
206 "bra 2f\n\t" \
207 " mov #0, %1\n" \
208 "1:\n\t" \
209 "mov.b @%2, %1\n\t" \
210 "extu.b %1, %1\n" \
211 "2:\n" \
212 ".section __ex_table,\"a\"\n\t" \
213 ".long 1b, 0b\n\t" \
214 ".previous" \
215 : "=&r" (err), "=&r" (x) \
216 : "r" (addr) \
217 : "t"); \
218})
219
220#define __get_user_2(x,addr,err) ({ \
221__asm__("stc r7_bank, %1\n\t" \
222 "mov.l @(8,%1), %1\n\t" \
223 "and %2, %1\n\t" \
224 "cmp/pz %1\n\t" \
225 "bt/s 1f\n\t" \
226 " mov #0, %0\n\t" \
227 "0:\n" \
228 "mov #-14, %0\n\t" \
229 "bra 2f\n\t" \
230 " mov #0, %1\n" \
231 "1:\n\t" \
232 "mov.w @%2, %1\n\t" \
233 "extu.w %1, %1\n" \
234 "2:\n" \
235 ".section __ex_table,\"a\"\n\t" \
236 ".long 1b, 0b\n\t" \
237 ".previous" \
238 : "=&r" (err), "=&r" (x) \
239 : "r" (addr) \
240 : "t"); \
241})
242
243#define __get_user_4(x,addr,err) ({ \
244__asm__("stc r7_bank, %1\n\t" \
245 "mov.l @(8,%1), %1\n\t" \
246 "and %2, %1\n\t" \
247 "cmp/pz %1\n\t" \
248 "bt/s 1f\n\t" \
249 " mov #0, %0\n\t" \
250 "0:\n" \
251 "mov #-14, %0\n\t" \
252 "bra 2f\n\t" \
253 " mov #0, %1\n" \
254 "1:\n\t" \
255 "mov.l @%2, %1\n\t" \
256 "2:\n" \
257 ".section __ex_table,\"a\"\n\t" \
258 ".long 1b, 0b\n\t" \
259 ".previous" \
260 : "=&r" (err), "=&r" (x) \
261 : "r" (addr) \
262 : "t"); \
263})
264#else /* CONFIG_MMU */
265#define __get_user_check(x,ptr,size) \
266({ \
267 long __gu_err, __gu_val; \
268 if (__access_ok((unsigned long)(ptr), (size))) { \
269 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
270 (x) = (__typeof__(*(ptr)))__gu_val; \
271 } else \
272 __gu_err = -EFAULT; \
273 __gu_err; \
274})
275#endif
276
277#define __get_user_asm(x, addr, err, insn) \
278({ \
279__asm__ __volatile__( \
280 "1:\n\t" \
281 "mov." insn " %2, %1\n\t" \
282 "mov #0, %0\n" \
283 "2:\n" \
284 ".section .fixup,\"ax\"\n" \
285 "3:\n\t" \
286 "mov #0, %1\n\t" \
287 "mov.l 4f, %0\n\t" \
288 "jmp @%0\n\t" \
289 " mov %3, %0\n" \
290 "4: .long 2b\n\t" \
291 ".previous\n" \
292 ".section __ex_table,\"a\"\n\t" \
293 ".long 1b, 3b\n\t" \
294 ".previous" \
295 :"=&r" (err), "=&r" (x) \
296 :"m" (__m(addr)), "i" (-EFAULT)); })
297
298extern void __get_user_unknown(void);
299
300#define __put_user_size(x,ptr,size,retval) \
301do { \
302 retval = 0; \
303 __chk_user_ptr(ptr); \
304 switch (size) { \
305 case 1: \
306 __put_user_asm(x, ptr, retval, "b"); \
307 break; \
308 case 2: \
309 __put_user_asm(x, ptr, retval, "w"); \
310 break; \
311 case 4: \
312 __put_user_asm(x, ptr, retval, "l"); \
313 break; \
314 case 8: \
315 __put_user_u64(x, ptr, retval); \
316 break; \
317 default: \
318 __put_user_unknown(); \
319 } \
320} while (0)
321
322#define __put_user_nocheck(x,ptr,size) \
323({ \
324 long __pu_err; \
325 __put_user_size((x),(ptr),(size),__pu_err); \
326 __pu_err; \
327})
328
329#define __put_user_check(x,ptr,size) \
330({ \
331 long __pu_err = -EFAULT; \
332 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
333 \
334 if (__access_ok((unsigned long)__pu_addr,size)) \
335 __put_user_size((x),__pu_addr,(size),__pu_err); \
336 __pu_err; \
337})
338
339#define __put_user_asm(x, addr, err, insn) \
340({ \
341__asm__ __volatile__( \
342 "1:\n\t" \
343 "mov." insn " %1, %2\n\t" \
344 "mov #0, %0\n" \
345 "2:\n" \
346 ".section .fixup,\"ax\"\n" \
347 "3:\n\t" \
348 "nop\n\t" \
349 "mov.l 4f, %0\n\t" \
350 "jmp @%0\n\t" \
351 "mov %3, %0\n" \
352 "4: .long 2b\n\t" \
353 ".previous\n" \
354 ".section __ex_table,\"a\"\n\t" \
355 ".long 1b, 3b\n\t" \
356 ".previous" \
357 :"=&r" (err) \
358 :"r" (x), "m" (__m(addr)), "i" (-EFAULT) \
359 :"memory"); })
360
361#if defined(__LITTLE_ENDIAN__)
362#define __put_user_u64(val,addr,retval) \
363({ \
364__asm__ __volatile__( \
365 "1:\n\t" \
366 "mov.l %R1,%2\n\t" \
367 "mov.l %S1,%T2\n\t" \
368 "mov #0,%0\n" \
369 "2:\n" \
370 ".section .fixup,\"ax\"\n" \
371 "3:\n\t" \
372 "nop\n\t" \
373 "mov.l 4f,%0\n\t" \
374 "jmp @%0\n\t" \
375 " mov %3,%0\n" \
376 "4: .long 2b\n\t" \
377 ".previous\n" \
378 ".section __ex_table,\"a\"\n\t" \
379 ".long 1b, 3b\n\t" \
380 ".previous" \
381 : "=r" (retval) \
382 : "r" (val), "m" (__m(addr)), "i" (-EFAULT) \
383 : "memory"); })
384#else 3#else
385#define __put_user_u64(val,addr,retval) \ 4# include "uaccess_64.h"
386({ \
387__asm__ __volatile__( \
388 "1:\n\t" \
389 "mov.l %S1,%2\n\t" \
390 "mov.l %R1,%T2\n\t" \
391 "mov #0,%0\n" \
392 "2:\n" \
393 ".section .fixup,\"ax\"\n" \
394 "3:\n\t" \
395 "nop\n\t" \
396 "mov.l 4f,%0\n\t" \
397 "jmp @%0\n\t" \
398 " mov %3,%0\n" \
399 "4: .long 2b\n\t" \
400 ".previous\n" \
401 ".section __ex_table,\"a\"\n\t" \
402 ".long 1b, 3b\n\t" \
403 ".previous" \
404 : "=r" (retval) \
405 : "r" (val), "m" (__m(addr)), "i" (-EFAULT) \
406 : "memory"); })
407#endif 5#endif
408
409extern void __put_user_unknown(void);
410
411/* Generic arbitrary sized copy. */
412/* Return the number of bytes NOT copied */
413__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
414
415#define copy_to_user(to,from,n) ({ \
416void *__copy_to = (void *) (to); \
417__kernel_size_t __copy_size = (__kernel_size_t) (n); \
418__kernel_size_t __copy_res; \
419if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \
420__copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \
421} else __copy_res = __copy_size; \
422__copy_res; })
423
424#define copy_from_user(to,from,n) ({ \
425void *__copy_to = (void *) (to); \
426void *__copy_from = (void *) (from); \
427__kernel_size_t __copy_size = (__kernel_size_t) (n); \
428__kernel_size_t __copy_res; \
429if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \
430__copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \
431} else __copy_res = __copy_size; \
432__copy_res; })
433
434static __always_inline unsigned long
435__copy_from_user(void *to, const void __user *from, unsigned long n)
436{
437 return __copy_user(to, (__force void *)from, n);
438}
439
440static __always_inline unsigned long __must_check
441__copy_to_user(void __user *to, const void *from, unsigned long n)
442{
443 return __copy_user((__force void *)to, from, n);
444}
445
446#define __copy_to_user_inatomic __copy_to_user
447#define __copy_from_user_inatomic __copy_from_user
448
449/*
450 * Clear the area and return remaining number of bytes
451 * (on failure. Usually it's 0.)
452 */
453extern __kernel_size_t __clear_user(void *addr, __kernel_size_t size);
454
455#define clear_user(addr,n) ({ \
456void * __cl_addr = (addr); \
457unsigned long __cl_size = (n); \
458if (__cl_size && __access_ok(((unsigned long)(__cl_addr)), __cl_size)) \
459__cl_size = __clear_user(__cl_addr, __cl_size); \
460__cl_size; })
461
462static __inline__ int
463__strncpy_from_user(unsigned long __dest, unsigned long __user __src, int __count)
464{
465 __kernel_size_t res;
466 unsigned long __dummy, _d, _s;
467
468 __asm__ __volatile__(
469 "9:\n"
470 "mov.b @%2+, %1\n\t"
471 "cmp/eq #0, %1\n\t"
472 "bt/s 2f\n"
473 "1:\n"
474 "mov.b %1, @%3\n\t"
475 "dt %7\n\t"
476 "bf/s 9b\n\t"
477 " add #1, %3\n\t"
478 "2:\n\t"
479 "sub %7, %0\n"
480 "3:\n"
481 ".section .fixup,\"ax\"\n"
482 "4:\n\t"
483 "mov.l 5f, %1\n\t"
484 "jmp @%1\n\t"
485 " mov %8, %0\n\t"
486 ".balign 4\n"
487 "5: .long 3b\n"
488 ".previous\n"
489 ".section __ex_table,\"a\"\n"
490 " .balign 4\n"
491 " .long 9b,4b\n"
492 ".previous"
493 : "=r" (res), "=&z" (__dummy), "=r" (_s), "=r" (_d)
494 : "0" (__count), "2" (__src), "3" (__dest), "r" (__count),
495 "i" (-EFAULT)
496 : "memory", "t");
497
498 return res;
499}
500
501#define strncpy_from_user(dest,src,count) ({ \
502unsigned long __sfu_src = (unsigned long) (src); \
503int __sfu_count = (int) (count); \
504long __sfu_res = -EFAULT; \
505if(__access_ok(__sfu_src, __sfu_count)) { \
506__sfu_res = __strncpy_from_user((unsigned long) (dest), __sfu_src, __sfu_count); \
507} __sfu_res; })
508
509/*
510 * Return the size of a string (including the ending 0!)
511 */
512static __inline__ long __strnlen_user(const char __user *__s, long __n)
513{
514 unsigned long res;
515 unsigned long __dummy;
516
517 __asm__ __volatile__(
518 "9:\n"
519 "cmp/eq %4, %0\n\t"
520 "bt 2f\n"
521 "1:\t"
522 "mov.b @(%0,%3), %1\n\t"
523 "tst %1, %1\n\t"
524 "bf/s 9b\n\t"
525 " add #1, %0\n"
526 "2:\n"
527 ".section .fixup,\"ax\"\n"
528 "3:\n\t"
529 "mov.l 4f, %1\n\t"
530 "jmp @%1\n\t"
531 " mov #0, %0\n"
532 ".balign 4\n"
533 "4: .long 2b\n"
534 ".previous\n"
535 ".section __ex_table,\"a\"\n"
536 " .balign 4\n"
537 " .long 1b,3b\n"
538 ".previous"
539 : "=z" (res), "=&r" (__dummy)
540 : "0" (0), "r" (__s), "r" (__n)
541 : "t");
542 return res;
543}
544
545static __inline__ long strnlen_user(const char __user *s, long n)
546{
547 if (!__addr_ok(s))
548 return 0;
549 else
550 return __strnlen_user(s, n);
551}
552
553#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
554
555/*
556 * The exception table consists of pairs of addresses: the first is the
557 * address of an instruction that is allowed to fault, and the second is
558 * the address at which the program should continue. No registers are
559 * modified, so it is entirely up to the continuation code to figure out
560 * what to do.
561 *
562 * All the routines below use bits of fixup code that are out of line
563 * with the main instruction path. This means when everything is well,
564 * we don't even have to jump over them. Further, they do not intrude
565 * on our cache or tlb entries.
566 */
567
568struct exception_table_entry
569{
570 unsigned long insn, fixup;
571};
572
573extern int fixup_exception(struct pt_regs *regs);
574
575#endif /* __ASM_SH_UACCESS_H */
diff --git a/include/asm-sh/uaccess_32.h b/include/asm-sh/uaccess_32.h
new file mode 100644
index 000000000000..b6082f3c1dc4
--- /dev/null
+++ b/include/asm-sh/uaccess_32.h
@@ -0,0 +1,510 @@
1/* $Id: uaccess.h,v 1.11 2003/10/13 07:21:20 lethal Exp $
2 *
3 * User space memory access functions
4 *
5 * Copyright (C) 1999, 2002 Niibe Yutaka
6 * Copyright (C) 2003 Paul Mundt
7 *
8 * Based on:
9 * MIPS implementation version 1.15 by
10 * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
11 * and i386 version.
12 */
13#ifndef __ASM_SH_UACCESS_H
14#define __ASM_SH_UACCESS_H
15
16#include <linux/errno.h>
17#include <linux/sched.h>
18
19#define VERIFY_READ 0
20#define VERIFY_WRITE 1
21
22/*
23 * The fs value determines whether argument validity checking should be
24 * performed or not. If get_fs() == USER_DS, checking is performed, with
25 * get_fs() == KERNEL_DS, checking is bypassed.
26 *
27 * For historical reasons (Data Segment Register?), these macros are misnamed.
28 */
29
30#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
31
32#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL)
33#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
34
35#define segment_eq(a,b) ((a).seg == (b).seg)
36
37#define get_ds() (KERNEL_DS)
38
39#if !defined(CONFIG_MMU)
40/* NOMMU is always true */
41#define __addr_ok(addr) (1)
42
43static inline mm_segment_t get_fs(void)
44{
45 return USER_DS;
46}
47
48static inline void set_fs(mm_segment_t s)
49{
50}
51
52/*
53 * __access_ok: Check if address with size is OK or not.
54 *
55 * If we don't have an MMU (or if its disabled) the only thing we really have
56 * to look out for is if the address resides somewhere outside of what
57 * available RAM we have.
58 *
59 * TODO: This check could probably also stand to be restricted somewhat more..
60 * though it still does the Right Thing(tm) for the time being.
61 */
62static inline int __access_ok(unsigned long addr, unsigned long size)
63{
64 return ((addr >= memory_start) && ((addr + size) < memory_end));
65}
66#else /* CONFIG_MMU */
67#define __addr_ok(addr) \
68 ((unsigned long)(addr) < (current_thread_info()->addr_limit.seg))
69
70#define get_fs() (current_thread_info()->addr_limit)
71#define set_fs(x) (current_thread_info()->addr_limit = (x))
72
73/*
74 * __access_ok: Check if address with size is OK or not.
75 *
76 * Uhhuh, this needs 33-bit arithmetic. We have a carry..
77 *
78 * sum := addr + size; carry? --> flag = true;
79 * if (sum >= addr_limit) flag = true;
80 */
81static inline int __access_ok(unsigned long addr, unsigned long size)
82{
83 unsigned long flag, sum;
84
85 __asm__("clrt\n\t"
86 "addc %3, %1\n\t"
87 "movt %0\n\t"
88 "cmp/hi %4, %1\n\t"
89 "rotcl %0"
90 :"=&r" (flag), "=r" (sum)
91 :"1" (addr), "r" (size),
92 "r" (current_thread_info()->addr_limit.seg)
93 :"t");
94 return flag == 0;
95}
96#endif /* CONFIG_MMU */
97
98#define access_ok(type, addr, size) \
99 (__chk_user_ptr(addr), \
100 __access_ok((unsigned long __force)(addr), (size)))
101
102/*
103 * Uh, these should become the main single-value transfer routines ...
104 * They automatically use the right size if we just have the right
105 * pointer type ...
106 *
107 * As SuperH uses the same address space for kernel and user data, we
108 * can just do these as direct assignments.
109 *
110 * Careful to not
111 * (a) re-use the arguments for side effects (sizeof is ok)
112 * (b) require any knowledge of processes at this stage
113 */
114#define put_user(x,ptr) __put_user_check((x), (ptr), sizeof(*(ptr)))
115#define get_user(x,ptr) __get_user_check((x), (ptr), sizeof(*(ptr)))
116
117/*
118 * The "__xxx" versions do not do address space checking, useful when
119 * doing multiple accesses to the same area (the user has to do the
120 * checks by hand with "access_ok()")
121 */
122#define __put_user(x,ptr) __put_user_nocheck((x), (ptr), sizeof(*(ptr)))
123#define __get_user(x,ptr) __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
124
125struct __large_struct { unsigned long buf[100]; };
126#define __m(x) (*(struct __large_struct __user *)(x))
127
128#define __get_user_size(x,ptr,size,retval) \
129do { \
130 retval = 0; \
131 switch (size) { \
132 case 1: \
133 __get_user_asm(x, ptr, retval, "b"); \
134 break; \
135 case 2: \
136 __get_user_asm(x, ptr, retval, "w"); \
137 break; \
138 case 4: \
139 __get_user_asm(x, ptr, retval, "l"); \
140 break; \
141 default: \
142 __get_user_unknown(); \
143 break; \
144 } \
145} while (0)
146
147#define __get_user_nocheck(x,ptr,size) \
148({ \
149 long __gu_err; \
150 unsigned long __gu_val; \
151 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
152 __chk_user_ptr(ptr); \
153 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
154 (x) = (__typeof__(*(ptr)))__gu_val; \
155 __gu_err; \
156})
157
158#define __get_user_check(x,ptr,size) \
159({ \
160 long __gu_err = -EFAULT; \
161 unsigned long __gu_val = 0; \
162 const __typeof__(*(ptr)) *__gu_addr = (ptr); \
163 if (likely(access_ok(VERIFY_READ, __gu_addr, (size)))) \
164 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
165 (x) = (__typeof__(*(ptr)))__gu_val; \
166 __gu_err; \
167})
168
169#define __get_user_asm(x, addr, err, insn) \
170({ \
171__asm__ __volatile__( \
172 "1:\n\t" \
173 "mov." insn " %2, %1\n\t" \
174 "2:\n" \
175 ".section .fixup,\"ax\"\n" \
176 "3:\n\t" \
177 "mov #0, %1\n\t" \
178 "mov.l 4f, %0\n\t" \
179 "jmp @%0\n\t" \
180 " mov %3, %0\n\t" \
181 ".balign 4\n" \
182 "4: .long 2b\n\t" \
183 ".previous\n" \
184 ".section __ex_table,\"a\"\n\t" \
185 ".long 1b, 3b\n\t" \
186 ".previous" \
187 :"=&r" (err), "=&r" (x) \
188 :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); })
189
190extern void __get_user_unknown(void);
191
192#define __put_user_size(x,ptr,size,retval) \
193do { \
194 retval = 0; \
195 switch (size) { \
196 case 1: \
197 __put_user_asm(x, ptr, retval, "b"); \
198 break; \
199 case 2: \
200 __put_user_asm(x, ptr, retval, "w"); \
201 break; \
202 case 4: \
203 __put_user_asm(x, ptr, retval, "l"); \
204 break; \
205 case 8: \
206 __put_user_u64(x, ptr, retval); \
207 break; \
208 default: \
209 __put_user_unknown(); \
210 } \
211} while (0)
212
213#define __put_user_nocheck(x,ptr,size) \
214({ \
215 long __pu_err; \
216 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
217 __chk_user_ptr(ptr); \
218 __put_user_size((x), __pu_addr, (size), __pu_err); \
219 __pu_err; \
220})
221
222#define __put_user_check(x,ptr,size) \
223({ \
224 long __pu_err = -EFAULT; \
225 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
226 if (likely(access_ok(VERIFY_WRITE, __pu_addr, size))) \
227 __put_user_size((x), __pu_addr, (size), \
228 __pu_err); \
229 __pu_err; \
230})
231
232#define __put_user_asm(x, addr, err, insn) \
233({ \
234__asm__ __volatile__( \
235 "1:\n\t" \
236 "mov." insn " %1, %2\n\t" \
237 "2:\n" \
238 ".section .fixup,\"ax\"\n" \
239 "3:\n\t" \
240 "mov.l 4f, %0\n\t" \
241 "jmp @%0\n\t" \
242 " mov %3, %0\n\t" \
243 ".balign 4\n" \
244 "4: .long 2b\n\t" \
245 ".previous\n" \
246 ".section __ex_table,\"a\"\n\t" \
247 ".long 1b, 3b\n\t" \
248 ".previous" \
249 :"=&r" (err) \
250 :"r" (x), "m" (__m(addr)), "i" (-EFAULT), "0" (err) \
251 :"memory"); })
252
253#if defined(CONFIG_CPU_LITTLE_ENDIAN)
254#define __put_user_u64(val,addr,retval) \
255({ \
256__asm__ __volatile__( \
257 "1:\n\t" \
258 "mov.l %R1,%2\n\t" \
259 "mov.l %S1,%T2\n\t" \
260 "2:\n" \
261 ".section .fixup,\"ax\"\n" \
262 "3:\n\t" \
263 "mov.l 4f,%0\n\t" \
264 "jmp @%0\n\t" \
265 " mov %3,%0\n\t" \
266 ".balign 4\n" \
267 "4: .long 2b\n\t" \
268 ".previous\n" \
269 ".section __ex_table,\"a\"\n\t" \
270 ".long 1b, 3b\n\t" \
271 ".previous" \
272 : "=r" (retval) \
273 : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \
274 : "memory"); })
275#else
276#define __put_user_u64(val,addr,retval) \
277({ \
278__asm__ __volatile__( \
279 "1:\n\t" \
280 "mov.l %S1,%2\n\t" \
281 "mov.l %R1,%T2\n\t" \
282 "2:\n" \
283 ".section .fixup,\"ax\"\n" \
284 "3:\n\t" \
285 "mov.l 4f,%0\n\t" \
286 "jmp @%0\n\t" \
287 " mov %3,%0\n\t" \
288 ".balign 4\n" \
289 "4: .long 2b\n\t" \
290 ".previous\n" \
291 ".section __ex_table,\"a\"\n\t" \
292 ".long 1b, 3b\n\t" \
293 ".previous" \
294 : "=r" (retval) \
295 : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \
296 : "memory"); })
297#endif
298
299extern void __put_user_unknown(void);
300
301/* Generic arbitrary sized copy. */
302/* Return the number of bytes NOT copied */
303__kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n);
304
305#define copy_to_user(to,from,n) ({ \
306void *__copy_to = (void *) (to); \
307__kernel_size_t __copy_size = (__kernel_size_t) (n); \
308__kernel_size_t __copy_res; \
309if(__copy_size && __access_ok((unsigned long)__copy_to, __copy_size)) { \
310__copy_res = __copy_user(__copy_to, (void *) (from), __copy_size); \
311} else __copy_res = __copy_size; \
312__copy_res; })
313
314#define copy_from_user(to,from,n) ({ \
315void *__copy_to = (void *) (to); \
316void *__copy_from = (void *) (from); \
317__kernel_size_t __copy_size = (__kernel_size_t) (n); \
318__kernel_size_t __copy_res; \
319if(__copy_size && __access_ok((unsigned long)__copy_from, __copy_size)) { \
320__copy_res = __copy_user(__copy_to, __copy_from, __copy_size); \
321} else __copy_res = __copy_size; \
322__copy_res; })
323
324static __always_inline unsigned long
325__copy_from_user(void *to, const void __user *from, unsigned long n)
326{
327 return __copy_user(to, (__force void *)from, n);
328}
329
330static __always_inline unsigned long __must_check
331__copy_to_user(void __user *to, const void *from, unsigned long n)
332{
333 return __copy_user((__force void *)to, from, n);
334}
335
336#define __copy_to_user_inatomic __copy_to_user
337#define __copy_from_user_inatomic __copy_from_user
338
339/*
340 * Clear the area and return remaining number of bytes
341 * (on failure. Usually it's 0.)
342 */
343extern __kernel_size_t __clear_user(void *addr, __kernel_size_t size);
344
345#define clear_user(addr,n) ({ \
346void * __cl_addr = (addr); \
347unsigned long __cl_size = (n); \
348if (__cl_size && __access_ok(((unsigned long)(__cl_addr)), __cl_size)) \
349__cl_size = __clear_user(__cl_addr, __cl_size); \
350__cl_size; })
351
352static __inline__ int
353__strncpy_from_user(unsigned long __dest, unsigned long __user __src, int __count)
354{
355 __kernel_size_t res;
356 unsigned long __dummy, _d, _s, _c;
357
358 __asm__ __volatile__(
359 "9:\n"
360 "mov.b @%2+, %1\n\t"
361 "cmp/eq #0, %1\n\t"
362 "bt/s 2f\n"
363 "1:\n"
364 "mov.b %1, @%3\n\t"
365 "dt %4\n\t"
366 "bf/s 9b\n\t"
367 " add #1, %3\n\t"
368 "2:\n\t"
369 "sub %4, %0\n"
370 "3:\n"
371 ".section .fixup,\"ax\"\n"
372 "4:\n\t"
373 "mov.l 5f, %1\n\t"
374 "jmp @%1\n\t"
375 " mov %9, %0\n\t"
376 ".balign 4\n"
377 "5: .long 3b\n"
378 ".previous\n"
379 ".section __ex_table,\"a\"\n"
380 " .balign 4\n"
381 " .long 9b,4b\n"
382 ".previous"
383 : "=r" (res), "=&z" (__dummy), "=r" (_s), "=r" (_d), "=r"(_c)
384 : "0" (__count), "2" (__src), "3" (__dest), "4" (__count),
385 "i" (-EFAULT)
386 : "memory", "t");
387
388 return res;
389}
390
391/**
392 * strncpy_from_user: - Copy a NUL terminated string from userspace.
393 * @dst: Destination address, in kernel space. This buffer must be at
394 * least @count bytes long.
395 * @src: Source address, in user space.
396 * @count: Maximum number of bytes to copy, including the trailing NUL.
397 *
398 * Copies a NUL-terminated string from userspace to kernel space.
399 *
400 * On success, returns the length of the string (not including the trailing
401 * NUL).
402 *
403 * If access to userspace fails, returns -EFAULT (some data may have been
404 * copied).
405 *
406 * If @count is smaller than the length of the string, copies @count bytes
407 * and returns @count.
408 */
409#define strncpy_from_user(dest,src,count) ({ \
410unsigned long __sfu_src = (unsigned long) (src); \
411int __sfu_count = (int) (count); \
412long __sfu_res = -EFAULT; \
413if(__access_ok(__sfu_src, __sfu_count)) { \
414__sfu_res = __strncpy_from_user((unsigned long) (dest), __sfu_src, __sfu_count); \
415} __sfu_res; })
416
417/*
418 * Return the size of a string (including the ending 0 even when we have
419 * exceeded the maximum string length).
420 */
421static __inline__ long __strnlen_user(const char __user *__s, long __n)
422{
423 unsigned long res;
424 unsigned long __dummy;
425
426 __asm__ __volatile__(
427 "1:\t"
428 "mov.b @(%0,%3), %1\n\t"
429 "cmp/eq %4, %0\n\t"
430 "bt/s 2f\n\t"
431 " add #1, %0\n\t"
432 "tst %1, %1\n\t"
433 "bf 1b\n\t"
434 "2:\n"
435 ".section .fixup,\"ax\"\n"
436 "3:\n\t"
437 "mov.l 4f, %1\n\t"
438 "jmp @%1\n\t"
439 " mov #0, %0\n"
440 ".balign 4\n"
441 "4: .long 2b\n"
442 ".previous\n"
443 ".section __ex_table,\"a\"\n"
444 " .balign 4\n"
445 " .long 1b,3b\n"
446 ".previous"
447 : "=z" (res), "=&r" (__dummy)
448 : "0" (0), "r" (__s), "r" (__n)
449 : "t");
450 return res;
451}
452
453/**
454 * strnlen_user: - Get the size of a string in user space.
455 * @s: The string to measure.
456 * @n: The maximum valid length
457 *
458 * Context: User context only. This function may sleep.
459 *
460 * Get the size of a NUL-terminated string in user space.
461 *
462 * Returns the size of the string INCLUDING the terminating NUL.
463 * On exception, returns 0.
464 * If the string is too long, returns a value greater than @n.
465 */
466static __inline__ long strnlen_user(const char __user *s, long n)
467{
468 if (!__addr_ok(s))
469 return 0;
470 else
471 return __strnlen_user(s, n);
472}
473
474/**
475 * strlen_user: - Get the size of a string in user space.
476 * @str: The string to measure.
477 *
478 * Context: User context only. This function may sleep.
479 *
480 * Get the size of a NUL-terminated string in user space.
481 *
482 * Returns the size of the string INCLUDING the terminating NUL.
483 * On exception, returns 0.
484 *
485 * If there is a limit on the length of a valid string, you may wish to
486 * consider using strnlen_user() instead.
487 */
488#define strlen_user(str) strnlen_user(str, ~0UL >> 1)
489
490/*
491 * The exception table consists of pairs of addresses: the first is the
492 * address of an instruction that is allowed to fault, and the second is
493 * the address at which the program should continue. No registers are
494 * modified, so it is entirely up to the continuation code to figure out
495 * what to do.
496 *
497 * All the routines below use bits of fixup code that are out of line
498 * with the main instruction path. This means when everything is well,
499 * we don't even have to jump over them. Further, they do not intrude
500 * on our cache or tlb entries.
501 */
502
503struct exception_table_entry
504{
505 unsigned long insn, fixup;
506};
507
508extern int fixup_exception(struct pt_regs *regs);
509
510#endif /* __ASM_SH_UACCESS_H */
diff --git a/include/asm-sh64/uaccess.h b/include/asm-sh/uaccess_64.h
index 644c67b65f94..d54ec082d25a 100644
--- a/include/asm-sh64/uaccess.h
+++ b/include/asm-sh/uaccess_64.h
@@ -1,12 +1,8 @@
1#ifndef __ASM_SH64_UACCESS_H 1#ifndef __ASM_SH_UACCESS_64_H
2#define __ASM_SH64_UACCESS_H 2#define __ASM_SH_UACCESS_64_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/uaccess_64.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/uaccess.h
10 * 6 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 7 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003, 2004 Paul Mundt 8 * Copyright (C) 2003, 2004 Paul Mundt
@@ -20,8 +16,10 @@
20 * Copyright (C) 1996, 1997, 1998 by Ralf Baechle 16 * Copyright (C) 1996, 1997, 1998 by Ralf Baechle
21 * and i386 version. 17 * and i386 version.
22 * 18 *
19 * This file is subject to the terms and conditions of the GNU General Public
20 * License. See the file "COPYING" in the main directory of this archive
21 * for more details.
23 */ 22 */
24
25#include <linux/errno.h> 23#include <linux/errno.h>
26#include <linux/sched.h> 24#include <linux/sched.h>
27 25
@@ -297,20 +295,8 @@ struct exception_table_entry
297 295
298#define ARCH_HAS_SEARCH_EXTABLE 296#define ARCH_HAS_SEARCH_EXTABLE
299 297
300/* If gcc inlines memset, it will use st.q instructions. Therefore, we need
301 kmalloc allocations to be 8-byte aligned. Without this, the alignment
302 becomes BYTE_PER_WORD i.e. only 4 (since sizeof(long)==sizeof(void*)==4 on
303 sh64 at the moment). */
304#define ARCH_KMALLOC_MINALIGN 8
305
306/*
307 * We want 8-byte alignment for the slab caches as well, otherwise we have
308 * the same BYTES_PER_WORD (sizeof(void *)) min align in kmem_cache_create().
309 */
310#define ARCH_SLAB_MINALIGN 8
311
312/* Returns 0 if exception not found and fixup.unit otherwise. */ 298/* Returns 0 if exception not found and fixup.unit otherwise. */
313extern unsigned long search_exception_table(unsigned long addr); 299extern unsigned long search_exception_table(unsigned long addr);
314extern const struct exception_table_entry *search_exception_tables (unsigned long addr); 300extern const struct exception_table_entry *search_exception_tables (unsigned long addr);
315 301
316#endif /* __ASM_SH64_UACCESS_H */ 302#endif /* __ASM_SH_UACCESS_64_H */
diff --git a/include/asm-sh/unistd.h b/include/asm-sh/unistd.h
index b182b1cb05fd..4b21f369c28c 100644
--- a/include/asm-sh/unistd.h
+++ b/include/asm-sh/unistd.h
@@ -1,376 +1,5 @@
1#ifndef __ASM_SH_UNISTD_H 1#ifdef CONFIG_SUPERH32
2#define __ASM_SH_UNISTD_H 2# include "unistd_32.h"
3 3#else
4/* 4# include "unistd_64.h"
5 * Copyright (C) 1999 Niibe Yutaka
6 */
7
8/*
9 * This file contains the system call numbers.
10 */
11
12#define __NR_restart_syscall 0
13#define __NR_exit 1
14#define __NR_fork 2
15#define __NR_read 3
16#define __NR_write 4
17#define __NR_open 5
18#define __NR_close 6
19#define __NR_waitpid 7
20#define __NR_creat 8
21#define __NR_link 9
22#define __NR_unlink 10
23#define __NR_execve 11
24#define __NR_chdir 12
25#define __NR_time 13
26#define __NR_mknod 14
27#define __NR_chmod 15
28#define __NR_lchown 16
29#define __NR_break 17
30#define __NR_oldstat 18
31#define __NR_lseek 19
32#define __NR_getpid 20
33#define __NR_mount 21
34#define __NR_umount 22
35#define __NR_setuid 23
36#define __NR_getuid 24
37#define __NR_stime 25
38#define __NR_ptrace 26
39#define __NR_alarm 27
40#define __NR_oldfstat 28
41#define __NR_pause 29
42#define __NR_utime 30
43#define __NR_stty 31
44#define __NR_gtty 32
45#define __NR_access 33
46#define __NR_nice 34
47#define __NR_ftime 35
48#define __NR_sync 36
49#define __NR_kill 37
50#define __NR_rename 38
51#define __NR_mkdir 39
52#define __NR_rmdir 40
53#define __NR_dup 41
54#define __NR_pipe 42
55#define __NR_times 43
56#define __NR_prof 44
57#define __NR_brk 45
58#define __NR_setgid 46
59#define __NR_getgid 47
60#define __NR_signal 48
61#define __NR_geteuid 49
62#define __NR_getegid 50
63#define __NR_acct 51
64#define __NR_umount2 52
65#define __NR_lock 53
66#define __NR_ioctl 54
67#define __NR_fcntl 55
68#define __NR_mpx 56
69#define __NR_setpgid 57
70#define __NR_ulimit 58
71#define __NR_oldolduname 59
72#define __NR_umask 60
73#define __NR_chroot 61
74#define __NR_ustat 62
75#define __NR_dup2 63
76#define __NR_getppid 64
77#define __NR_getpgrp 65
78#define __NR_setsid 66
79#define __NR_sigaction 67
80#define __NR_sgetmask 68
81#define __NR_ssetmask 69
82#define __NR_setreuid 70
83#define __NR_setregid 71
84#define __NR_sigsuspend 72
85#define __NR_sigpending 73
86#define __NR_sethostname 74
87#define __NR_setrlimit 75
88#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
89#define __NR_getrusage 77
90#define __NR_gettimeofday 78
91#define __NR_settimeofday 79
92#define __NR_getgroups 80
93#define __NR_setgroups 81
94#define __NR_select 82
95#define __NR_symlink 83
96#define __NR_oldlstat 84
97#define __NR_readlink 85
98#define __NR_uselib 86
99#define __NR_swapon 87
100#define __NR_reboot 88
101#define __NR_readdir 89
102#define __NR_mmap 90
103#define __NR_munmap 91
104#define __NR_truncate 92
105#define __NR_ftruncate 93
106#define __NR_fchmod 94
107#define __NR_fchown 95
108#define __NR_getpriority 96
109#define __NR_setpriority 97
110#define __NR_profil 98
111#define __NR_statfs 99
112#define __NR_fstatfs 100
113#define __NR_ioperm 101
114#define __NR_socketcall 102
115#define __NR_syslog 103
116#define __NR_setitimer 104
117#define __NR_getitimer 105
118#define __NR_stat 106
119#define __NR_lstat 107
120#define __NR_fstat 108
121#define __NR_olduname 109
122#define __NR_iopl 110
123#define __NR_vhangup 111
124#define __NR_idle 112
125#define __NR_vm86old 113
126#define __NR_wait4 114
127#define __NR_swapoff 115
128#define __NR_sysinfo 116
129#define __NR_ipc 117
130#define __NR_fsync 118
131#define __NR_sigreturn 119
132#define __NR_clone 120
133#define __NR_setdomainname 121
134#define __NR_uname 122
135#define __NR_modify_ldt 123
136#define __NR_adjtimex 124
137#define __NR_mprotect 125
138#define __NR_sigprocmask 126
139#define __NR_create_module 127
140#define __NR_init_module 128
141#define __NR_delete_module 129
142#define __NR_get_kernel_syms 130
143#define __NR_quotactl 131
144#define __NR_getpgid 132
145#define __NR_fchdir 133
146#define __NR_bdflush 134
147#define __NR_sysfs 135
148#define __NR_personality 136
149#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
150#define __NR_setfsuid 138
151#define __NR_setfsgid 139
152#define __NR__llseek 140
153#define __NR_getdents 141
154#define __NR__newselect 142
155#define __NR_flock 143
156#define __NR_msync 144
157#define __NR_readv 145
158#define __NR_writev 146
159#define __NR_getsid 147
160#define __NR_fdatasync 148
161#define __NR__sysctl 149
162#define __NR_mlock 150
163#define __NR_munlock 151
164#define __NR_mlockall 152
165#define __NR_munlockall 153
166#define __NR_sched_setparam 154
167#define __NR_sched_getparam 155
168#define __NR_sched_setscheduler 156
169#define __NR_sched_getscheduler 157
170#define __NR_sched_yield 158
171#define __NR_sched_get_priority_max 159
172#define __NR_sched_get_priority_min 160
173#define __NR_sched_rr_get_interval 161
174#define __NR_nanosleep 162
175#define __NR_mremap 163
176#define __NR_setresuid 164
177#define __NR_getresuid 165
178#define __NR_vm86 166
179#define __NR_query_module 167
180#define __NR_poll 168
181#define __NR_nfsservctl 169
182#define __NR_setresgid 170
183#define __NR_getresgid 171
184#define __NR_prctl 172
185#define __NR_rt_sigreturn 173
186#define __NR_rt_sigaction 174
187#define __NR_rt_sigprocmask 175
188#define __NR_rt_sigpending 176
189#define __NR_rt_sigtimedwait 177
190#define __NR_rt_sigqueueinfo 178
191#define __NR_rt_sigsuspend 179
192#define __NR_pread64 180
193#define __NR_pwrite64 181
194#define __NR_chown 182
195#define __NR_getcwd 183
196#define __NR_capget 184
197#define __NR_capset 185
198#define __NR_sigaltstack 186
199#define __NR_sendfile 187
200#define __NR_streams1 188 /* some people actually want it */
201#define __NR_streams2 189 /* some people actually want it */
202#define __NR_vfork 190
203#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
204#define __NR_mmap2 192
205#define __NR_truncate64 193
206#define __NR_ftruncate64 194
207#define __NR_stat64 195
208#define __NR_lstat64 196
209#define __NR_fstat64 197
210#define __NR_lchown32 198
211#define __NR_getuid32 199
212#define __NR_getgid32 200
213#define __NR_geteuid32 201
214#define __NR_getegid32 202
215#define __NR_setreuid32 203
216#define __NR_setregid32 204
217#define __NR_getgroups32 205
218#define __NR_setgroups32 206
219#define __NR_fchown32 207
220#define __NR_setresuid32 208
221#define __NR_getresuid32 209
222#define __NR_setresgid32 210
223#define __NR_getresgid32 211
224#define __NR_chown32 212
225#define __NR_setuid32 213
226#define __NR_setgid32 214
227#define __NR_setfsuid32 215
228#define __NR_setfsgid32 216
229#define __NR_pivot_root 217
230#define __NR_mincore 218
231#define __NR_madvise 219
232#define __NR_getdents64 220
233#define __NR_fcntl64 221
234/* 223 is unused */
235#define __NR_gettid 224
236#define __NR_readahead 225
237#define __NR_setxattr 226
238#define __NR_lsetxattr 227
239#define __NR_fsetxattr 228
240#define __NR_getxattr 229
241#define __NR_lgetxattr 230
242#define __NR_fgetxattr 231
243#define __NR_listxattr 232
244#define __NR_llistxattr 233
245#define __NR_flistxattr 234
246#define __NR_removexattr 235
247#define __NR_lremovexattr 236
248#define __NR_fremovexattr 237
249#define __NR_tkill 238
250#define __NR_sendfile64 239
251#define __NR_futex 240
252#define __NR_sched_setaffinity 241
253#define __NR_sched_getaffinity 242
254#define __NR_set_thread_area 243
255#define __NR_get_thread_area 244
256#define __NR_io_setup 245
257#define __NR_io_destroy 246
258#define __NR_io_getevents 247
259#define __NR_io_submit 248
260#define __NR_io_cancel 249
261#define __NR_fadvise64 250
262
263#define __NR_exit_group 252
264#define __NR_lookup_dcookie 253
265#define __NR_epoll_create 254
266#define __NR_epoll_ctl 255
267#define __NR_epoll_wait 256
268#define __NR_remap_file_pages 257
269#define __NR_set_tid_address 258
270#define __NR_timer_create 259
271#define __NR_timer_settime (__NR_timer_create+1)
272#define __NR_timer_gettime (__NR_timer_create+2)
273#define __NR_timer_getoverrun (__NR_timer_create+3)
274#define __NR_timer_delete (__NR_timer_create+4)
275#define __NR_clock_settime (__NR_timer_create+5)
276#define __NR_clock_gettime (__NR_timer_create+6)
277#define __NR_clock_getres (__NR_timer_create+7)
278#define __NR_clock_nanosleep (__NR_timer_create+8)
279#define __NR_statfs64 268
280#define __NR_fstatfs64 269
281#define __NR_tgkill 270
282#define __NR_utimes 271
283#define __NR_fadvise64_64 272
284#define __NR_vserver 273
285#define __NR_mbind 274
286#define __NR_get_mempolicy 275
287#define __NR_set_mempolicy 276
288#define __NR_mq_open 277
289#define __NR_mq_unlink (__NR_mq_open+1)
290#define __NR_mq_timedsend (__NR_mq_open+2)
291#define __NR_mq_timedreceive (__NR_mq_open+3)
292#define __NR_mq_notify (__NR_mq_open+4)
293#define __NR_mq_getsetattr (__NR_mq_open+5)
294#define __NR_kexec_load 283
295#define __NR_waitid 284
296#define __NR_add_key 285
297#define __NR_request_key 286
298#define __NR_keyctl 287
299#define __NR_ioprio_set 288
300#define __NR_ioprio_get 289
301#define __NR_inotify_init 290
302#define __NR_inotify_add_watch 291
303#define __NR_inotify_rm_watch 292
304/* 293 is unused */
305#define __NR_migrate_pages 294
306#define __NR_openat 295
307#define __NR_mkdirat 296
308#define __NR_mknodat 297
309#define __NR_fchownat 298
310#define __NR_futimesat 299
311#define __NR_fstatat64 300
312#define __NR_unlinkat 301
313#define __NR_renameat 302
314#define __NR_linkat 303
315#define __NR_symlinkat 304
316#define __NR_readlinkat 305
317#define __NR_fchmodat 306
318#define __NR_faccessat 307
319#define __NR_pselect6 308
320#define __NR_ppoll 309
321#define __NR_unshare 310
322#define __NR_set_robust_list 311
323#define __NR_get_robust_list 312
324#define __NR_splice 313
325#define __NR_sync_file_range 314
326#define __NR_tee 315
327#define __NR_vmsplice 316
328#define __NR_move_pages 317
329#define __NR_getcpu 318
330#define __NR_epoll_pwait 319
331#define __NR_utimensat 320
332#define __NR_signalfd 321
333#define __NR_timerfd 322
334#define __NR_eventfd 323
335#define __NR_fallocate 324
336
337#define NR_syscalls 325
338
339#ifdef __KERNEL__
340
341#define __ARCH_WANT_IPC_PARSE_VERSION
342#define __ARCH_WANT_OLD_READDIR
343#define __ARCH_WANT_OLD_STAT
344#define __ARCH_WANT_STAT64
345#define __ARCH_WANT_SYS_ALARM
346#define __ARCH_WANT_SYS_GETHOSTNAME
347#define __ARCH_WANT_SYS_PAUSE
348#define __ARCH_WANT_SYS_SGETMASK
349#define __ARCH_WANT_SYS_SIGNAL
350#define __ARCH_WANT_SYS_TIME
351#define __ARCH_WANT_SYS_UTIME
352#define __ARCH_WANT_SYS_WAITPID
353#define __ARCH_WANT_SYS_SOCKETCALL
354#define __ARCH_WANT_SYS_FADVISE64
355#define __ARCH_WANT_SYS_GETPGRP
356#define __ARCH_WANT_SYS_LLSEEK
357#define __ARCH_WANT_SYS_NICE
358#define __ARCH_WANT_SYS_OLD_GETRLIMIT
359#define __ARCH_WANT_SYS_OLDUMOUNT
360#define __ARCH_WANT_SYS_SIGPENDING
361#define __ARCH_WANT_SYS_SIGPROCMASK
362#define __ARCH_WANT_SYS_RT_SIGACTION
363#define __ARCH_WANT_SYS_RT_SIGSUSPEND
364
365/*
366 * "Conditional" syscalls
367 *
368 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
369 * but it doesn't work on all toolchains, so we just do it by hand
370 */
371#ifndef cond_syscall
372#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
373#endif 5#endif
374
375#endif /* __KERNEL__ */
376#endif /* __ASM_SH_UNISTD_H */
diff --git a/include/asm-sh/unistd_32.h b/include/asm-sh/unistd_32.h
new file mode 100644
index 000000000000..b182b1cb05fd
--- /dev/null
+++ b/include/asm-sh/unistd_32.h
@@ -0,0 +1,376 @@
1#ifndef __ASM_SH_UNISTD_H
2#define __ASM_SH_UNISTD_H
3
4/*
5 * Copyright (C) 1999 Niibe Yutaka
6 */
7
8/*
9 * This file contains the system call numbers.
10 */
11
12#define __NR_restart_syscall 0
13#define __NR_exit 1
14#define __NR_fork 2
15#define __NR_read 3
16#define __NR_write 4
17#define __NR_open 5
18#define __NR_close 6
19#define __NR_waitpid 7
20#define __NR_creat 8
21#define __NR_link 9
22#define __NR_unlink 10
23#define __NR_execve 11
24#define __NR_chdir 12
25#define __NR_time 13
26#define __NR_mknod 14
27#define __NR_chmod 15
28#define __NR_lchown 16
29#define __NR_break 17
30#define __NR_oldstat 18
31#define __NR_lseek 19
32#define __NR_getpid 20
33#define __NR_mount 21
34#define __NR_umount 22
35#define __NR_setuid 23
36#define __NR_getuid 24
37#define __NR_stime 25
38#define __NR_ptrace 26
39#define __NR_alarm 27
40#define __NR_oldfstat 28
41#define __NR_pause 29
42#define __NR_utime 30
43#define __NR_stty 31
44#define __NR_gtty 32
45#define __NR_access 33
46#define __NR_nice 34
47#define __NR_ftime 35
48#define __NR_sync 36
49#define __NR_kill 37
50#define __NR_rename 38
51#define __NR_mkdir 39
52#define __NR_rmdir 40
53#define __NR_dup 41
54#define __NR_pipe 42
55#define __NR_times 43
56#define __NR_prof 44
57#define __NR_brk 45
58#define __NR_setgid 46
59#define __NR_getgid 47
60#define __NR_signal 48
61#define __NR_geteuid 49
62#define __NR_getegid 50
63#define __NR_acct 51
64#define __NR_umount2 52
65#define __NR_lock 53
66#define __NR_ioctl 54
67#define __NR_fcntl 55
68#define __NR_mpx 56
69#define __NR_setpgid 57
70#define __NR_ulimit 58
71#define __NR_oldolduname 59
72#define __NR_umask 60
73#define __NR_chroot 61
74#define __NR_ustat 62
75#define __NR_dup2 63
76#define __NR_getppid 64
77#define __NR_getpgrp 65
78#define __NR_setsid 66
79#define __NR_sigaction 67
80#define __NR_sgetmask 68
81#define __NR_ssetmask 69
82#define __NR_setreuid 70
83#define __NR_setregid 71
84#define __NR_sigsuspend 72
85#define __NR_sigpending 73
86#define __NR_sethostname 74
87#define __NR_setrlimit 75
88#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
89#define __NR_getrusage 77
90#define __NR_gettimeofday 78
91#define __NR_settimeofday 79
92#define __NR_getgroups 80
93#define __NR_setgroups 81
94#define __NR_select 82
95#define __NR_symlink 83
96#define __NR_oldlstat 84
97#define __NR_readlink 85
98#define __NR_uselib 86
99#define __NR_swapon 87
100#define __NR_reboot 88
101#define __NR_readdir 89
102#define __NR_mmap 90
103#define __NR_munmap 91
104#define __NR_truncate 92
105#define __NR_ftruncate 93
106#define __NR_fchmod 94
107#define __NR_fchown 95
108#define __NR_getpriority 96
109#define __NR_setpriority 97
110#define __NR_profil 98
111#define __NR_statfs 99
112#define __NR_fstatfs 100
113#define __NR_ioperm 101
114#define __NR_socketcall 102
115#define __NR_syslog 103
116#define __NR_setitimer 104
117#define __NR_getitimer 105
118#define __NR_stat 106
119#define __NR_lstat 107
120#define __NR_fstat 108
121#define __NR_olduname 109
122#define __NR_iopl 110
123#define __NR_vhangup 111
124#define __NR_idle 112
125#define __NR_vm86old 113
126#define __NR_wait4 114
127#define __NR_swapoff 115
128#define __NR_sysinfo 116
129#define __NR_ipc 117
130#define __NR_fsync 118
131#define __NR_sigreturn 119
132#define __NR_clone 120
133#define __NR_setdomainname 121
134#define __NR_uname 122
135#define __NR_modify_ldt 123
136#define __NR_adjtimex 124
137#define __NR_mprotect 125
138#define __NR_sigprocmask 126
139#define __NR_create_module 127
140#define __NR_init_module 128
141#define __NR_delete_module 129
142#define __NR_get_kernel_syms 130
143#define __NR_quotactl 131
144#define __NR_getpgid 132
145#define __NR_fchdir 133
146#define __NR_bdflush 134
147#define __NR_sysfs 135
148#define __NR_personality 136
149#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
150#define __NR_setfsuid 138
151#define __NR_setfsgid 139
152#define __NR__llseek 140
153#define __NR_getdents 141
154#define __NR__newselect 142
155#define __NR_flock 143
156#define __NR_msync 144
157#define __NR_readv 145
158#define __NR_writev 146
159#define __NR_getsid 147
160#define __NR_fdatasync 148
161#define __NR__sysctl 149
162#define __NR_mlock 150
163#define __NR_munlock 151
164#define __NR_mlockall 152
165#define __NR_munlockall 153
166#define __NR_sched_setparam 154
167#define __NR_sched_getparam 155
168#define __NR_sched_setscheduler 156
169#define __NR_sched_getscheduler 157
170#define __NR_sched_yield 158
171#define __NR_sched_get_priority_max 159
172#define __NR_sched_get_priority_min 160
173#define __NR_sched_rr_get_interval 161
174#define __NR_nanosleep 162
175#define __NR_mremap 163
176#define __NR_setresuid 164
177#define __NR_getresuid 165
178#define __NR_vm86 166
179#define __NR_query_module 167
180#define __NR_poll 168
181#define __NR_nfsservctl 169
182#define __NR_setresgid 170
183#define __NR_getresgid 171
184#define __NR_prctl 172
185#define __NR_rt_sigreturn 173
186#define __NR_rt_sigaction 174
187#define __NR_rt_sigprocmask 175
188#define __NR_rt_sigpending 176
189#define __NR_rt_sigtimedwait 177
190#define __NR_rt_sigqueueinfo 178
191#define __NR_rt_sigsuspend 179
192#define __NR_pread64 180
193#define __NR_pwrite64 181
194#define __NR_chown 182
195#define __NR_getcwd 183
196#define __NR_capget 184
197#define __NR_capset 185
198#define __NR_sigaltstack 186
199#define __NR_sendfile 187
200#define __NR_streams1 188 /* some people actually want it */
201#define __NR_streams2 189 /* some people actually want it */
202#define __NR_vfork 190
203#define __NR_ugetrlimit 191 /* SuS compliant getrlimit */
204#define __NR_mmap2 192
205#define __NR_truncate64 193
206#define __NR_ftruncate64 194
207#define __NR_stat64 195
208#define __NR_lstat64 196
209#define __NR_fstat64 197
210#define __NR_lchown32 198
211#define __NR_getuid32 199
212#define __NR_getgid32 200
213#define __NR_geteuid32 201
214#define __NR_getegid32 202
215#define __NR_setreuid32 203
216#define __NR_setregid32 204
217#define __NR_getgroups32 205
218#define __NR_setgroups32 206
219#define __NR_fchown32 207
220#define __NR_setresuid32 208
221#define __NR_getresuid32 209
222#define __NR_setresgid32 210
223#define __NR_getresgid32 211
224#define __NR_chown32 212
225#define __NR_setuid32 213
226#define __NR_setgid32 214
227#define __NR_setfsuid32 215
228#define __NR_setfsgid32 216
229#define __NR_pivot_root 217
230#define __NR_mincore 218
231#define __NR_madvise 219
232#define __NR_getdents64 220
233#define __NR_fcntl64 221
234/* 223 is unused */
235#define __NR_gettid 224
236#define __NR_readahead 225
237#define __NR_setxattr 226
238#define __NR_lsetxattr 227
239#define __NR_fsetxattr 228
240#define __NR_getxattr 229
241#define __NR_lgetxattr 230
242#define __NR_fgetxattr 231
243#define __NR_listxattr 232
244#define __NR_llistxattr 233
245#define __NR_flistxattr 234
246#define __NR_removexattr 235
247#define __NR_lremovexattr 236
248#define __NR_fremovexattr 237
249#define __NR_tkill 238
250#define __NR_sendfile64 239
251#define __NR_futex 240
252#define __NR_sched_setaffinity 241
253#define __NR_sched_getaffinity 242
254#define __NR_set_thread_area 243
255#define __NR_get_thread_area 244
256#define __NR_io_setup 245
257#define __NR_io_destroy 246
258#define __NR_io_getevents 247
259#define __NR_io_submit 248
260#define __NR_io_cancel 249
261#define __NR_fadvise64 250
262
263#define __NR_exit_group 252
264#define __NR_lookup_dcookie 253
265#define __NR_epoll_create 254
266#define __NR_epoll_ctl 255
267#define __NR_epoll_wait 256
268#define __NR_remap_file_pages 257
269#define __NR_set_tid_address 258
270#define __NR_timer_create 259
271#define __NR_timer_settime (__NR_timer_create+1)
272#define __NR_timer_gettime (__NR_timer_create+2)
273#define __NR_timer_getoverrun (__NR_timer_create+3)
274#define __NR_timer_delete (__NR_timer_create+4)
275#define __NR_clock_settime (__NR_timer_create+5)
276#define __NR_clock_gettime (__NR_timer_create+6)
277#define __NR_clock_getres (__NR_timer_create+7)
278#define __NR_clock_nanosleep (__NR_timer_create+8)
279#define __NR_statfs64 268
280#define __NR_fstatfs64 269
281#define __NR_tgkill 270
282#define __NR_utimes 271
283#define __NR_fadvise64_64 272
284#define __NR_vserver 273
285#define __NR_mbind 274
286#define __NR_get_mempolicy 275
287#define __NR_set_mempolicy 276
288#define __NR_mq_open 277
289#define __NR_mq_unlink (__NR_mq_open+1)
290#define __NR_mq_timedsend (__NR_mq_open+2)
291#define __NR_mq_timedreceive (__NR_mq_open+3)
292#define __NR_mq_notify (__NR_mq_open+4)
293#define __NR_mq_getsetattr (__NR_mq_open+5)
294#define __NR_kexec_load 283
295#define __NR_waitid 284
296#define __NR_add_key 285
297#define __NR_request_key 286
298#define __NR_keyctl 287
299#define __NR_ioprio_set 288
300#define __NR_ioprio_get 289
301#define __NR_inotify_init 290
302#define __NR_inotify_add_watch 291
303#define __NR_inotify_rm_watch 292
304/* 293 is unused */
305#define __NR_migrate_pages 294
306#define __NR_openat 295
307#define __NR_mkdirat 296
308#define __NR_mknodat 297
309#define __NR_fchownat 298
310#define __NR_futimesat 299
311#define __NR_fstatat64 300
312#define __NR_unlinkat 301
313#define __NR_renameat 302
314#define __NR_linkat 303
315#define __NR_symlinkat 304
316#define __NR_readlinkat 305
317#define __NR_fchmodat 306
318#define __NR_faccessat 307
319#define __NR_pselect6 308
320#define __NR_ppoll 309
321#define __NR_unshare 310
322#define __NR_set_robust_list 311
323#define __NR_get_robust_list 312
324#define __NR_splice 313
325#define __NR_sync_file_range 314
326#define __NR_tee 315
327#define __NR_vmsplice 316
328#define __NR_move_pages 317
329#define __NR_getcpu 318
330#define __NR_epoll_pwait 319
331#define __NR_utimensat 320
332#define __NR_signalfd 321
333#define __NR_timerfd 322
334#define __NR_eventfd 323
335#define __NR_fallocate 324
336
337#define NR_syscalls 325
338
339#ifdef __KERNEL__
340
341#define __ARCH_WANT_IPC_PARSE_VERSION
342#define __ARCH_WANT_OLD_READDIR
343#define __ARCH_WANT_OLD_STAT
344#define __ARCH_WANT_STAT64
345#define __ARCH_WANT_SYS_ALARM
346#define __ARCH_WANT_SYS_GETHOSTNAME
347#define __ARCH_WANT_SYS_PAUSE
348#define __ARCH_WANT_SYS_SGETMASK
349#define __ARCH_WANT_SYS_SIGNAL
350#define __ARCH_WANT_SYS_TIME
351#define __ARCH_WANT_SYS_UTIME
352#define __ARCH_WANT_SYS_WAITPID
353#define __ARCH_WANT_SYS_SOCKETCALL
354#define __ARCH_WANT_SYS_FADVISE64
355#define __ARCH_WANT_SYS_GETPGRP
356#define __ARCH_WANT_SYS_LLSEEK
357#define __ARCH_WANT_SYS_NICE
358#define __ARCH_WANT_SYS_OLD_GETRLIMIT
359#define __ARCH_WANT_SYS_OLDUMOUNT
360#define __ARCH_WANT_SYS_SIGPENDING
361#define __ARCH_WANT_SYS_SIGPROCMASK
362#define __ARCH_WANT_SYS_RT_SIGACTION
363#define __ARCH_WANT_SYS_RT_SIGSUSPEND
364
365/*
366 * "Conditional" syscalls
367 *
368 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
369 * but it doesn't work on all toolchains, so we just do it by hand
370 */
371#ifndef cond_syscall
372#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
373#endif
374
375#endif /* __KERNEL__ */
376#endif /* __ASM_SH_UNISTD_H */
diff --git a/include/asm-sh64/unistd.h b/include/asm-sh/unistd_64.h
index 1a5197f369b2..944511882cac 100644
--- a/include/asm-sh64/unistd.h
+++ b/include/asm-sh/unistd_64.h
@@ -1,21 +1,19 @@
1#ifndef __ASM_SH64_UNISTD_H 1#ifndef __ASM_SH_UNISTD_64_H
2#define __ASM_SH64_UNISTD_H 2#define __ASM_SH_UNISTD_64_H
3 3
4/* 4/*
5 * This file is subject to the terms and conditions of the GNU General Public 5 * include/asm-sh/unistd_64.h
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 * 6 *
9 * include/asm-sh64/unistd.h 7 * This file contains the system call numbers.
10 * 8 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli 9 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 - 2007 Paul Mundt 10 * Copyright (C) 2003 - 2007 Paul Mundt
13 * Copyright (C) 2004 Sean McGoogan 11 * Copyright (C) 2004 Sean McGoogan
14 * 12 *
15 * This file contains the system call numbers. 13 * This file is subject to the terms and conditions of the GNU General Public
16 * 14 * License. See the file "COPYING" in the main directory of this archive
15 * for more details.
17 */ 16 */
18
19#define __NR_restart_syscall 0 17#define __NR_restart_syscall 0
20#define __NR_exit 1 18#define __NR_exit 1
21#define __NR_fork 2 19#define __NR_fork 2
@@ -414,4 +412,4 @@
414#endif 412#endif
415 413
416#endif /* __KERNEL__ */ 414#endif /* __KERNEL__ */
417#endif /* __ASM_SH64_UNISTD_H */ 415#endif /* __ASM_SH_UNISTD_64_H */
diff --git a/include/asm-sh/user.h b/include/asm-sh/user.h
index d1b8511d9d9f..1a4f43c75126 100644
--- a/include/asm-sh/user.h
+++ b/include/asm-sh/user.h
@@ -27,12 +27,19 @@
27 * to write an integer number of pages. 27 * to write an integer number of pages.
28 */ 28 */
29 29
30#if defined(__SH5__) || defined(CONFIG_CPU_SH5)
31struct user_fpu_struct {
32 unsigned long fp_regs[32];
33 unsigned int fpscr;
34};
35#else
30struct user_fpu_struct { 36struct user_fpu_struct {
31 unsigned long fp_regs[16]; 37 unsigned long fp_regs[16];
32 unsigned long xfp_regs[16]; 38 unsigned long xfp_regs[16];
33 unsigned long fpscr; 39 unsigned long fpscr;
34 unsigned long fpul; 40 unsigned long fpul;
35}; 41};
42#endif
36 43
37struct user { 44struct user {
38 struct pt_regs regs; /* entire machine state */ 45 struct pt_regs regs; /* entire machine state */
diff --git a/include/asm-sh/vga.h b/include/asm-sh/vga.h
new file mode 100644
index 000000000000..06a5de8ace1a
--- /dev/null
+++ b/include/asm-sh/vga.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_SH_VGA_H
2#define __ASM_SH_VGA_H
3
4/* Stupid drivers. */
5
6#endif /* __ASM_SH_VGA_H */
diff --git a/include/asm-sh/voyagergx.h b/include/asm-sh/voyagergx.h
deleted file mode 100644
index d825596562df..000000000000
--- a/include/asm-sh/voyagergx.h
+++ /dev/null
@@ -1,341 +0,0 @@
1/* -------------------------------------------------------------------- */
2/* voyagergx.h */
3/* -------------------------------------------------------------------- */
4/* This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 Copyright 2003 (c) Lineo uSolutions,Inc.
19*/
20/* -------------------------------------------------------------------- */
21
22#ifndef _VOYAGER_GX_REG_H
23#define _VOYAGER_GX_REG_H
24
25#define VOYAGER_BASE 0xb3e00000
26#define VOYAGER_USBH_BASE (0x40000 + VOYAGER_BASE)
27#define VOYAGER_UART_BASE (0x30000 + VOYAGER_BASE)
28#define VOYAGER_AC97_BASE (0xa0000 + VOYAGER_BASE)
29
30#define VOYAGER_IRQ_NUM 26
31#define VOYAGER_IRQ_BASE 200
32
33#define IRQ_SM501_UP (VOYAGER_IRQ_BASE + 0)
34#define IRQ_SM501_G54 (VOYAGER_IRQ_BASE + 1)
35#define IRQ_SM501_G53 (VOYAGER_IRQ_BASE + 2)
36#define IRQ_SM501_G52 (VOYAGER_IRQ_BASE + 3)
37#define IRQ_SM501_G51 (VOYAGER_IRQ_BASE + 4)
38#define IRQ_SM501_G50 (VOYAGER_IRQ_BASE + 5)
39#define IRQ_SM501_G49 (VOYAGER_IRQ_BASE + 6)
40#define IRQ_SM501_G48 (VOYAGER_IRQ_BASE + 7)
41#define IRQ_SM501_I2C (VOYAGER_IRQ_BASE + 8)
42#define IRQ_SM501_PW (VOYAGER_IRQ_BASE + 9)
43#define IRQ_SM501_DMA (VOYAGER_IRQ_BASE + 10)
44#define IRQ_SM501_PCI (VOYAGER_IRQ_BASE + 11)
45#define IRQ_SM501_I2S (VOYAGER_IRQ_BASE + 12)
46#define IRQ_SM501_AC (VOYAGER_IRQ_BASE + 13)
47#define IRQ_SM501_US (VOYAGER_IRQ_BASE + 14)
48#define IRQ_SM501_U1 (VOYAGER_IRQ_BASE + 15)
49#define IRQ_SM501_U0 (VOYAGER_IRQ_BASE + 16)
50#define IRQ_SM501_CV (VOYAGER_IRQ_BASE + 17)
51#define IRQ_SM501_MC (VOYAGER_IRQ_BASE + 18)
52#define IRQ_SM501_S1 (VOYAGER_IRQ_BASE + 19)
53#define IRQ_SM501_S0 (VOYAGER_IRQ_BASE + 20)
54#define IRQ_SM501_UH (VOYAGER_IRQ_BASE + 21)
55#define IRQ_SM501_2D (VOYAGER_IRQ_BASE + 22)
56#define IRQ_SM501_ZD (VOYAGER_IRQ_BASE + 23)
57#define IRQ_SM501_PV (VOYAGER_IRQ_BASE + 24)
58#define IRQ_SM501_CI (VOYAGER_IRQ_BASE + 25)
59
60/* ----- MISC controle register ------------------------------ */
61#define MISC_CTRL (0x000004 + VOYAGER_BASE)
62#define MISC_CTRL_USBCLK_48 (3 << 28)
63#define MISC_CTRL_USBCLK_96 (2 << 28)
64#define MISC_CTRL_USBCLK_CRYSTAL (1 << 28)
65
66/* ----- GPIO[31:0] register --------------------------------- */
67#define GPIO_MUX_LOW (0x000008 + VOYAGER_BASE)
68#define GPIO_MUX_LOW_AC97 0x1F000000
69#define GPIO_MUX_LOW_8051 0x0000ffff
70#define GPIO_MUX_LOW_PWM (1 << 29)
71
72/* ----- GPIO[63:32] register --------------------------------- */
73#define GPIO_MUX_HIGH (0x00000C + VOYAGER_BASE)
74
75/* ----- DRAM controle register ------------------------------- */
76#define DRAM_CTRL (0x000010 + VOYAGER_BASE)
77#define DRAM_CTRL_EMBEDDED (1 << 31)
78#define DRAM_CTRL_CPU_BURST_1 (0 << 28)
79#define DRAM_CTRL_CPU_BURST_2 (1 << 28)
80#define DRAM_CTRL_CPU_BURST_4 (2 << 28)
81#define DRAM_CTRL_CPU_BURST_8 (3 << 28)
82#define DRAM_CTRL_CPU_CAS_LATENCY (1 << 27)
83#define DRAM_CTRL_CPU_SIZE_2 (0 << 24)
84#define DRAM_CTRL_CPU_SIZE_4 (1 << 24)
85#define DRAM_CTRL_CPU_SIZE_64 (4 << 24)
86#define DRAM_CTRL_CPU_SIZE_32 (5 << 24)
87#define DRAM_CTRL_CPU_SIZE_16 (6 << 24)
88#define DRAM_CTRL_CPU_SIZE_8 (7 << 24)
89#define DRAM_CTRL_CPU_COLUMN_SIZE_1024 (0 << 22)
90#define DRAM_CTRL_CPU_COLUMN_SIZE_512 (2 << 22)
91#define DRAM_CTRL_CPU_COLUMN_SIZE_256 (3 << 22)
92#define DRAM_CTRL_CPU_ACTIVE_PRECHARGE (1 << 21)
93#define DRAM_CTRL_CPU_RESET (1 << 20)
94#define DRAM_CTRL_CPU_BANKS (1 << 19)
95#define DRAM_CTRL_CPU_WRITE_PRECHARGE (1 << 18)
96#define DRAM_CTRL_BLOCK_WRITE (1 << 17)
97#define DRAM_CTRL_REFRESH_COMMAND (1 << 16)
98#define DRAM_CTRL_SIZE_4 (0 << 13)
99#define DRAM_CTRL_SIZE_8 (1 << 13)
100#define DRAM_CTRL_SIZE_16 (2 << 13)
101#define DRAM_CTRL_SIZE_32 (3 << 13)
102#define DRAM_CTRL_SIZE_64 (4 << 13)
103#define DRAM_CTRL_SIZE_2 (5 << 13)
104#define DRAM_CTRL_COLUMN_SIZE_256 (0 << 11)
105#define DRAM_CTRL_COLUMN_SIZE_512 (2 << 11)
106#define DRAM_CTRL_COLUMN_SIZE_1024 (3 << 11)
107#define DRAM_CTRL_BLOCK_WRITE_TIME (1 << 10)
108#define DRAM_CTRL_BLOCK_WRITE_PRECHARGE (1 << 9)
109#define DRAM_CTRL_ACTIVE_PRECHARGE (1 << 8)
110#define DRAM_CTRL_RESET (1 << 7)
111#define DRAM_CTRL_REMAIN_ACTIVE (1 << 6)
112#define DRAM_CTRL_BANKS (1 << 1)
113#define DRAM_CTRL_WRITE_PRECHARGE (1 << 0)
114
115/* ----- Arvitration control register -------------------------- */
116#define ARBITRATION_CTRL (0x000014 + VOYAGER_BASE)
117#define ARBITRATION_CTRL_CPUMEM (1 << 29)
118#define ARBITRATION_CTRL_INTMEM (1 << 28)
119#define ARBITRATION_CTRL_USB_OFF (0 << 24)
120#define ARBITRATION_CTRL_USB_PRIORITY_1 (1 << 24)
121#define ARBITRATION_CTRL_USB_PRIORITY_2 (2 << 24)
122#define ARBITRATION_CTRL_USB_PRIORITY_3 (3 << 24)
123#define ARBITRATION_CTRL_USB_PRIORITY_4 (4 << 24)
124#define ARBITRATION_CTRL_USB_PRIORITY_5 (5 << 24)
125#define ARBITRATION_CTRL_USB_PRIORITY_6 (6 << 24)
126#define ARBITRATION_CTRL_USB_PRIORITY_7 (7 << 24)
127#define ARBITRATION_CTRL_PANEL_OFF (0 << 20)
128#define ARBITRATION_CTRL_PANEL_PRIORITY_1 (1 << 20)
129#define ARBITRATION_CTRL_PANEL_PRIORITY_2 (2 << 20)
130#define ARBITRATION_CTRL_PANEL_PRIORITY_3 (3 << 20)
131#define ARBITRATION_CTRL_PANEL_PRIORITY_4 (4 << 20)
132#define ARBITRATION_CTRL_PANEL_PRIORITY_5 (5 << 20)
133#define ARBITRATION_CTRL_PANEL_PRIORITY_6 (6 << 20)
134#define ARBITRATION_CTRL_PANEL_PRIORITY_7 (7 << 20)
135#define ARBITRATION_CTRL_ZVPORT_OFF (0 << 16)
136#define ARBITRATION_CTRL_ZVPORTL_PRIORITY_1 (1 << 16)
137#define ARBITRATION_CTRL_ZVPORTL_PRIORITY_2 (2 << 16)
138#define ARBITRATION_CTRL_ZVPORTL_PRIORITY_3 (3 << 16)
139#define ARBITRATION_CTRL_ZVPORTL_PRIORITY_4 (4 << 16)
140#define ARBITRATION_CTRL_ZVPORTL_PRIORITY_5 (5 << 16)
141#define ARBITRATION_CTRL_ZVPORTL_PRIORITY_6 (6 << 16)
142#define ARBITRATION_CTRL_ZVPORTL_PRIORITY_7 (7 << 16)
143#define ARBITRATION_CTRL_CMD_INTPR_OFF (0 << 12)
144#define ARBITRATION_CTRL_CMD_INTPR_PRIORITY_1 (1 << 12)
145#define ARBITRATION_CTRL_CMD_INTPR_PRIORITY_2 (2 << 12)
146#define ARBITRATION_CTRL_CMD_INTPR_PRIORITY_3 (3 << 12)
147#define ARBITRATION_CTRL_CMD_INTPR_PRIORITY_4 (4 << 12)
148#define ARBITRATION_CTRL_CMD_INTPR_PRIORITY_5 (5 << 12)
149#define ARBITRATION_CTRL_CMD_INTPR_PRIORITY_6 (6 << 12)
150#define ARBITRATION_CTRL_CMD_INTPR_PRIORITY_7 (7 << 12)
151#define ARBITRATION_CTRL_DMA_OFF (0 << 8)
152#define ARBITRATION_CTRL_DMA_PRIORITY_1 (1 << 8)
153#define ARBITRATION_CTRL_DMA_PRIORITY_2 (2 << 8)
154#define ARBITRATION_CTRL_DMA_PRIORITY_3 (3 << 8)
155#define ARBITRATION_CTRL_DMA_PRIORITY_4 (4 << 8)
156#define ARBITRATION_CTRL_DMA_PRIORITY_5 (5 << 8)
157#define ARBITRATION_CTRL_DMA_PRIORITY_6 (6 << 8)
158#define ARBITRATION_CTRL_DMA_PRIORITY_7 (7 << 8)
159#define ARBITRATION_CTRL_VIDEO_OFF (0 << 4)
160#define ARBITRATION_CTRL_VIDEO_PRIORITY_1 (1 << 4)
161#define ARBITRATION_CTRL_VIDEO_PRIORITY_2 (2 << 4)
162#define ARBITRATION_CTRL_VIDEO_PRIORITY_3 (3 << 4)
163#define ARBITRATION_CTRL_VIDEO_PRIORITY_4 (4 << 4)
164#define ARBITRATION_CTRL_VIDEO_PRIORITY_5 (5 << 4)
165#define ARBITRATION_CTRL_VIDEO_PRIORITY_6 (6 << 4)
166#define ARBITRATION_CTRL_VIDEO_PRIORITY_7 (7 << 4)
167#define ARBITRATION_CTRL_CRT_OFF (0 << 0)
168#define ARBITRATION_CTRL_CRT_PRIORITY_1 (1 << 0)
169#define ARBITRATION_CTRL_CRT_PRIORITY_2 (2 << 0)
170#define ARBITRATION_CTRL_CRT_PRIORITY_3 (3 << 0)
171#define ARBITRATION_CTRL_CRT_PRIORITY_4 (4 << 0)
172#define ARBITRATION_CTRL_CRT_PRIORITY_5 (5 << 0)
173#define ARBITRATION_CTRL_CRT_PRIORITY_6 (6 << 0)
174#define ARBITRATION_CTRL_CRT_PRIORITY_7 (7 << 0)
175
176/* ----- Command list status register -------------------------- */
177#define CMD_INTPR_STATUS (0x000024 + VOYAGER_BASE)
178
179/* ----- Interrupt status register ----------------------------- */
180#define INT_STATUS (0x00002c + VOYAGER_BASE)
181#define INT_STATUS_UH (1 << 6)
182#define INT_STATUS_MC (1 << 10)
183#define INT_STATUS_U0 (1 << 12)
184#define INT_STATUS_U1 (1 << 13)
185#define INT_STATUS_AC (1 << 17)
186
187/* ----- Interrupt mask register ------------------------------ */
188#define VOYAGER_INT_MASK (0x000030 + VOYAGER_BASE)
189#define VOYAGER_INT_MASK_AC (1 << 17)
190
191/* ----- Current Gate register ---------------------------------*/
192#define CURRENT_GATE (0x000038 + VOYAGER_BASE)
193
194/* ----- Power mode 0 gate register --------------------------- */
195#define POWER_MODE0_GATE (0x000040 + VOYAGER_BASE)
196#define POWER_MODE0_GATE_G (1 << 6)
197#define POWER_MODE0_GATE_U0 (1 << 7)
198#define POWER_MODE0_GATE_U1 (1 << 8)
199#define POWER_MODE0_GATE_UH (1 << 11)
200#define POWER_MODE0_GATE_AC (1 << 18)
201
202/* ----- Power mode 1 gate register --------------------------- */
203#define POWER_MODE1_GATE (0x000048 + VOYAGER_BASE)
204#define POWER_MODE1_GATE_G (1 << 6)
205#define POWER_MODE1_GATE_U0 (1 << 7)
206#define POWER_MODE1_GATE_U1 (1 << 8)
207#define POWER_MODE1_GATE_UH (1 << 11)
208#define POWER_MODE1_GATE_AC (1 << 18)
209
210/* ----- Power mode 0 clock register -------------------------- */
211#define POWER_MODE0_CLOCK (0x000044 + VOYAGER_BASE)
212
213/* ----- Power mode 1 clock register -------------------------- */
214#define POWER_MODE1_CLOCK (0x00004C + VOYAGER_BASE)
215
216/* ----- Power mode controll register ------------------------- */
217#define POWER_MODE_CTRL (0x000054 + VOYAGER_BASE)
218
219/* ----- Miscellaneous Timing register ------------------------ */
220#define SYSTEM_DRAM_CTRL (0x000068 + VOYAGER_BASE)
221
222/* ----- PWM register ------------------------------------------*/
223#define PWM_0 (0x010020 + VOYAGER_BASE)
224#define PWM_0_HC(x) (((x)&0x0fff)<<20)
225#define PWM_0_LC(x) (((x)&0x0fff)<<8 )
226#define PWM_0_CLK_DEV(x) (((x)&0x000f)<<4 )
227#define PWM_0_EN (1<<0)
228
229/* ----- I2C register ----------------------------------------- */
230#define I2C_BYTECOUNT (0x010040 + VOYAGER_BASE)
231#define I2C_CONTROL (0x010041 + VOYAGER_BASE)
232#define I2C_STATUS (0x010042 + VOYAGER_BASE)
233#define I2C_RESET (0x010042 + VOYAGER_BASE)
234#define I2C_SADDRESS (0x010043 + VOYAGER_BASE)
235#define I2C_DATA (0x010044 + VOYAGER_BASE)
236
237/* ----- Controle register bits ----------------------------------------- */
238#define I2C_CONTROL_E (1 << 0)
239#define I2C_CONTROL_MODE (1 << 1)
240#define I2C_CONTROL_STATUS (1 << 2)
241#define I2C_CONTROL_INT (1 << 4)
242#define I2C_CONTROL_INTACK (1 << 5)
243#define I2C_CONTROL_REPEAT (1 << 6)
244
245/* ----- Status register bits ----------------------------------------- */
246#define I2C_STATUS_BUSY (1 << 0)
247#define I2C_STATUS_ACK (1 << 1)
248#define I2C_STATUS_ERROR (1 << 2)
249#define I2C_STATUS_COMPLETE (1 << 3)
250
251/* ----- Reset register ---------------------------------------------- */
252#define I2C_RESET_ERROR (1 << 2)
253
254/* ----- transmission frequencies ------------------------------------- */
255#define I2C_SADDRESS_SELECT (1 << 0)
256
257/* ----- Display Controll register ----------------------------------------- */
258#define PANEL_DISPLAY_CTRL (0x080000 + VOYAGER_BASE)
259#define PANEL_DISPLAY_CTRL_BIAS (1<<26)
260#define PANEL_PAN_CTRL (0x080004 + VOYAGER_BASE)
261#define PANEL_COLOR_KEY (0x080008 + VOYAGER_BASE)
262#define PANEL_FB_ADDRESS (0x08000C + VOYAGER_BASE)
263#define PANEL_FB_WIDTH (0x080010 + VOYAGER_BASE)
264#define PANEL_WINDOW_WIDTH (0x080014 + VOYAGER_BASE)
265#define PANEL_WINDOW_HEIGHT (0x080018 + VOYAGER_BASE)
266#define PANEL_PLANE_TL (0x08001C + VOYAGER_BASE)
267#define PANEL_PLANE_BR (0x080020 + VOYAGER_BASE)
268#define PANEL_HORIZONTAL_TOTAL (0x080024 + VOYAGER_BASE)
269#define PANEL_HORIZONTAL_SYNC (0x080028 + VOYAGER_BASE)
270#define PANEL_VERTICAL_TOTAL (0x08002C + VOYAGER_BASE)
271#define PANEL_VERTICAL_SYNC (0x080030 + VOYAGER_BASE)
272#define PANEL_CURRENT_LINE (0x080034 + VOYAGER_BASE)
273#define VIDEO_DISPLAY_CTRL (0x080040 + VOYAGER_BASE)
274#define VIDEO_FB_0_ADDRESS (0x080044 + VOYAGER_BASE)
275#define VIDEO_FB_WIDTH (0x080048 + VOYAGER_BASE)
276#define VIDEO_FB_0_LAST_ADDRESS (0x08004C + VOYAGER_BASE)
277#define VIDEO_PLANE_TL (0x080050 + VOYAGER_BASE)
278#define VIDEO_PLANE_BR (0x080054 + VOYAGER_BASE)
279#define VIDEO_SCALE (0x080058 + VOYAGER_BASE)
280#define VIDEO_INITIAL_SCALE (0x08005C + VOYAGER_BASE)
281#define VIDEO_YUV_CONSTANTS (0x080060 + VOYAGER_BASE)
282#define VIDEO_FB_1_ADDRESS (0x080064 + VOYAGER_BASE)
283#define VIDEO_FB_1_LAST_ADDRESS (0x080068 + VOYAGER_BASE)
284#define VIDEO_ALPHA_DISPLAY_CTRL (0x080080 + VOYAGER_BASE)
285#define VIDEO_ALPHA_FB_ADDRESS (0x080084 + VOYAGER_BASE)
286#define VIDEO_ALPHA_FB_WIDTH (0x080088 + VOYAGER_BASE)
287#define VIDEO_ALPHA_FB_LAST_ADDRESS (0x08008C + VOYAGER_BASE)
288#define VIDEO_ALPHA_PLANE_TL (0x080090 + VOYAGER_BASE)
289#define VIDEO_ALPHA_PLANE_BR (0x080094 + VOYAGER_BASE)
290#define VIDEO_ALPHA_SCALE (0x080098 + VOYAGER_BASE)
291#define VIDEO_ALPHA_INITIAL_SCALE (0x08009C + VOYAGER_BASE)
292#define VIDEO_ALPHA_CHROMA_KEY (0x0800A0 + VOYAGER_BASE)
293#define PANEL_HWC_ADDRESS (0x0800F0 + VOYAGER_BASE)
294#define PANEL_HWC_LOCATION (0x0800F4 + VOYAGER_BASE)
295#define PANEL_HWC_COLOR_12 (0x0800F8 + VOYAGER_BASE)
296#define PANEL_HWC_COLOR_3 (0x0800FC + VOYAGER_BASE)
297#define ALPHA_DISPLAY_CTRL (0x080100 + VOYAGER_BASE)
298#define ALPHA_FB_ADDRESS (0x080104 + VOYAGER_BASE)
299#define ALPHA_FB_WIDTH (0x080108 + VOYAGER_BASE)
300#define ALPHA_PLANE_TL (0x08010C + VOYAGER_BASE)
301#define ALPHA_PLANE_BR (0x080110 + VOYAGER_BASE)
302#define ALPHA_CHROMA_KEY (0x080114 + VOYAGER_BASE)
303#define CRT_DISPLAY_CTRL (0x080200 + VOYAGER_BASE)
304#define CRT_FB_ADDRESS (0x080204 + VOYAGER_BASE)
305#define CRT_FB_WIDTH (0x080208 + VOYAGER_BASE)
306#define CRT_HORIZONTAL_TOTAL (0x08020C + VOYAGER_BASE)
307#define CRT_HORIZONTAL_SYNC (0x080210 + VOYAGER_BASE)
308#define CRT_VERTICAL_TOTAL (0x080214 + VOYAGER_BASE)
309#define CRT_VERTICAL_SYNC (0x080218 + VOYAGER_BASE)
310#define CRT_SIGNATURE_ANALYZER (0x08021C + VOYAGER_BASE)
311#define CRT_CURRENT_LINE (0x080220 + VOYAGER_BASE)
312#define CRT_MONITOR_DETECT (0x080224 + VOYAGER_BASE)
313#define CRT_HWC_ADDRESS (0x080230 + VOYAGER_BASE)
314#define CRT_HWC_LOCATION (0x080234 + VOYAGER_BASE)
315#define CRT_HWC_COLOR_12 (0x080238 + VOYAGER_BASE)
316#define CRT_HWC_COLOR_3 (0x08023C + VOYAGER_BASE)
317#define CRT_PALETTE_RAM (0x080400 + VOYAGER_BASE)
318#define PANEL_PALETTE_RAM (0x080800 + VOYAGER_BASE)
319#define VIDEO_PALETTE_RAM (0x080C00 + VOYAGER_BASE)
320
321/* ----- 8051 Controle register ----------------------------------------- */
322#define VOYAGER_8051_BASE (0x000c0000 + VOYAGER_BASE)
323#define VOYAGER_8051_RESET (0x000b0000 + VOYAGER_BASE)
324#define VOYAGER_8051_SELECT (0x000b0004 + VOYAGER_BASE)
325#define VOYAGER_8051_CPU_INT (0x000b000c + VOYAGER_BASE)
326
327/* ----- AC97 Controle register ----------------------------------------- */
328#define AC97_TX_SLOT0 (0x00000000 + VOYAGER_AC97_BASE)
329#define AC97_CONTROL_STATUS (0x00000080 + VOYAGER_AC97_BASE)
330#define AC97C_READ (1 << 19)
331#define AC97C_WD_BIT (1 << 2)
332#define AC97C_INDEX_MASK 0x7f
333
334/* arch/sh/cchips/voyagergx/consistent.c */
335void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t);
336int voyagergx_consistent_free(struct device *, size_t, void *, dma_addr_t);
337
338/* arch/sh/cchips/voyagergx/irq.c */
339void setup_voyagergx_irq(void);
340
341#endif /* _VOYAGER_GX_REG_H */
diff --git a/include/asm-sh64/Kbuild b/include/asm-sh64/Kbuild
deleted file mode 100644
index c68e1680da01..000000000000
--- a/include/asm-sh64/Kbuild
+++ /dev/null
@@ -1 +0,0 @@
1include include/asm-generic/Kbuild.asm
diff --git a/include/asm-sh64/a.out.h b/include/asm-sh64/a.out.h
deleted file mode 100644
index 237ee4e5b72a..000000000000
--- a/include/asm-sh64/a.out.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef __ASM_SH64_A_OUT_H
2#define __ASM_SH64_A_OUT_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/a.out.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15struct exec
16{
17 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
18 unsigned a_text; /* length of text, in bytes */
19 unsigned a_data; /* length of data, in bytes */
20 unsigned a_bss; /* length of uninitialized data area for file, in bytes */
21 unsigned a_syms; /* length of symbol table data in file, in bytes */
22 unsigned a_entry; /* start address */
23 unsigned a_trsize; /* length of relocation info for text, in bytes */
24 unsigned a_drsize; /* length of relocation info for data, in bytes */
25};
26
27#define N_TRSIZE(a) ((a).a_trsize)
28#define N_DRSIZE(a) ((a).a_drsize)
29#define N_SYMSIZE(a) ((a).a_syms)
30
31#ifdef __KERNEL__
32
33#define STACK_TOP TASK_SIZE
34#define STACK_TOP_MAX STACK_TOP
35
36#endif
37
38#endif /* __ASM_SH64_A_OUT_H */
diff --git a/include/asm-sh64/atomic.h b/include/asm-sh64/atomic.h
deleted file mode 100644
index 28f2ea9b567b..000000000000
--- a/include/asm-sh64/atomic.h
+++ /dev/null
@@ -1,158 +0,0 @@
1#ifndef __ASM_SH64_ATOMIC_H
2#define __ASM_SH64_ATOMIC_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/atomic.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 *
14 */
15
16/*
17 * Atomic operations that C can't guarantee us. Useful for
18 * resource counting etc..
19 *
20 */
21
22typedef struct { volatile int counter; } atomic_t;
23
24#define ATOMIC_INIT(i) ( (atomic_t) { (i) } )
25
26#define atomic_read(v) ((v)->counter)
27#define atomic_set(v,i) ((v)->counter = (i))
28
29#include <asm/system.h>
30
31/*
32 * To get proper branch prediction for the main line, we must branch
33 * forward to code at the end of this object's .text section, then
34 * branch back to restart the operation.
35 */
36
37static __inline__ void atomic_add(int i, atomic_t * v)
38{
39 unsigned long flags;
40
41 local_irq_save(flags);
42 *(long *)v += i;
43 local_irq_restore(flags);
44}
45
46static __inline__ void atomic_sub(int i, atomic_t *v)
47{
48 unsigned long flags;
49
50 local_irq_save(flags);
51 *(long *)v -= i;
52 local_irq_restore(flags);
53}
54
55static __inline__ int atomic_add_return(int i, atomic_t * v)
56{
57 unsigned long temp, flags;
58
59 local_irq_save(flags);
60 temp = *(long *)v;
61 temp += i;
62 *(long *)v = temp;
63 local_irq_restore(flags);
64
65 return temp;
66}
67
68#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
69
70static __inline__ int atomic_sub_return(int i, atomic_t * v)
71{
72 unsigned long temp, flags;
73
74 local_irq_save(flags);
75 temp = *(long *)v;
76 temp -= i;
77 *(long *)v = temp;
78 local_irq_restore(flags);
79
80 return temp;
81}
82
83#define atomic_dec_return(v) atomic_sub_return(1,(v))
84#define atomic_inc_return(v) atomic_add_return(1,(v))
85
86/*
87 * atomic_inc_and_test - increment and test
88 * @v: pointer of type atomic_t
89 *
90 * Atomically increments @v by 1
91 * and returns true if the result is zero, or false for all
92 * other cases.
93 */
94#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
95
96#define atomic_sub_and_test(i,v) (atomic_sub_return((i), (v)) == 0)
97#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
98
99#define atomic_inc(v) atomic_add(1,(v))
100#define atomic_dec(v) atomic_sub(1,(v))
101
102static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
103{
104 int ret;
105 unsigned long flags;
106
107 local_irq_save(flags);
108 ret = v->counter;
109 if (likely(ret == old))
110 v->counter = new;
111 local_irq_restore(flags);
112
113 return ret;
114}
115
116#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
117
118static inline int atomic_add_unless(atomic_t *v, int a, int u)
119{
120 int ret;
121 unsigned long flags;
122
123 local_irq_save(flags);
124 ret = v->counter;
125 if (ret != u)
126 v->counter += a;
127 local_irq_restore(flags);
128
129 return ret != u;
130}
131#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
132
133static __inline__ void atomic_clear_mask(unsigned int mask, atomic_t *v)
134{
135 unsigned long flags;
136
137 local_irq_save(flags);
138 *(long *)v &= ~mask;
139 local_irq_restore(flags);
140}
141
142static __inline__ void atomic_set_mask(unsigned int mask, atomic_t *v)
143{
144 unsigned long flags;
145
146 local_irq_save(flags);
147 *(long *)v |= mask;
148 local_irq_restore(flags);
149}
150
151/* Atomic operations are already serializing on SH */
152#define smp_mb__before_atomic_dec() barrier()
153#define smp_mb__after_atomic_dec() barrier()
154#define smp_mb__before_atomic_inc() barrier()
155#define smp_mb__after_atomic_inc() barrier()
156
157#include <asm-generic/atomic.h>
158#endif /* __ASM_SH64_ATOMIC_H */
diff --git a/include/asm-sh64/auxvec.h b/include/asm-sh64/auxvec.h
deleted file mode 100644
index 1ad5a44bdc76..000000000000
--- a/include/asm-sh64/auxvec.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#ifndef __ASM_SH64_AUXVEC_H
2#define __ASM_SH64_AUXVEC_H
3
4#endif /* __ASM_SH64_AUXVEC_H */
diff --git a/include/asm-sh64/bitops.h b/include/asm-sh64/bitops.h
deleted file mode 100644
index 600c59efb4c2..000000000000
--- a/include/asm-sh64/bitops.h
+++ /dev/null
@@ -1,155 +0,0 @@
1#ifndef __ASM_SH64_BITOPS_H
2#define __ASM_SH64_BITOPS_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/bitops.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 */
14
15#ifdef __KERNEL__
16
17#ifndef _LINUX_BITOPS_H
18#error only <linux/bitops.h> can be included directly
19#endif
20
21#include <linux/compiler.h>
22#include <asm/system.h>
23/* For __swab32 */
24#include <asm/byteorder.h>
25
26static __inline__ void set_bit(int nr, volatile void * addr)
27{
28 int mask;
29 volatile unsigned int *a = addr;
30 unsigned long flags;
31
32 a += nr >> 5;
33 mask = 1 << (nr & 0x1f);
34 local_irq_save(flags);
35 *a |= mask;
36 local_irq_restore(flags);
37}
38
39/*
40 * clear_bit() doesn't provide any barrier for the compiler.
41 */
42#define smp_mb__before_clear_bit() barrier()
43#define smp_mb__after_clear_bit() barrier()
44static inline void clear_bit(int nr, volatile unsigned long *a)
45{
46 int mask;
47 unsigned long flags;
48
49 a += nr >> 5;
50 mask = 1 << (nr & 0x1f);
51 local_irq_save(flags);
52 *a &= ~mask;
53 local_irq_restore(flags);
54}
55
56static __inline__ void change_bit(int nr, volatile void * addr)
57{
58 int mask;
59 volatile unsigned int *a = addr;
60 unsigned long flags;
61
62 a += nr >> 5;
63 mask = 1 << (nr & 0x1f);
64 local_irq_save(flags);
65 *a ^= mask;
66 local_irq_restore(flags);
67}
68
69static __inline__ int test_and_set_bit(int nr, volatile void * addr)
70{
71 int mask, retval;
72 volatile unsigned int *a = addr;
73 unsigned long flags;
74
75 a += nr >> 5;
76 mask = 1 << (nr & 0x1f);
77 local_irq_save(flags);
78 retval = (mask & *a) != 0;
79 *a |= mask;
80 local_irq_restore(flags);
81
82 return retval;
83}
84
85static __inline__ int test_and_clear_bit(int nr, volatile void * addr)
86{
87 int mask, retval;
88 volatile unsigned int *a = addr;
89 unsigned long flags;
90
91 a += nr >> 5;
92 mask = 1 << (nr & 0x1f);
93 local_irq_save(flags);
94 retval = (mask & *a) != 0;
95 *a &= ~mask;
96 local_irq_restore(flags);
97
98 return retval;
99}
100
101static __inline__ int test_and_change_bit(int nr, volatile void * addr)
102{
103 int mask, retval;
104 volatile unsigned int *a = addr;
105 unsigned long flags;
106
107 a += nr >> 5;
108 mask = 1 << (nr & 0x1f);
109 local_irq_save(flags);
110 retval = (mask & *a) != 0;
111 *a ^= mask;
112 local_irq_restore(flags);
113
114 return retval;
115}
116
117#include <asm-generic/bitops/non-atomic.h>
118
119static __inline__ unsigned long ffz(unsigned long word)
120{
121 unsigned long result, __d2, __d3;
122
123 __asm__("gettr tr0, %2\n\t"
124 "pta $+32, tr0\n\t"
125 "andi %1, 1, %3\n\t"
126 "beq %3, r63, tr0\n\t"
127 "pta $+4, tr0\n"
128 "0:\n\t"
129 "shlri.l %1, 1, %1\n\t"
130 "addi %0, 1, %0\n\t"
131 "andi %1, 1, %3\n\t"
132 "beqi %3, 1, tr0\n"
133 "1:\n\t"
134 "ptabs %2, tr0\n\t"
135 : "=r" (result), "=r" (word), "=r" (__d2), "=r" (__d3)
136 : "0" (0L), "1" (word));
137
138 return result;
139}
140
141#include <asm-generic/bitops/__ffs.h>
142#include <asm-generic/bitops/find.h>
143#include <asm-generic/bitops/hweight.h>
144#include <asm-generic/bitops/lock.h>
145#include <asm-generic/bitops/sched.h>
146#include <asm-generic/bitops/ffs.h>
147#include <asm-generic/bitops/ext2-non-atomic.h>
148#include <asm-generic/bitops/ext2-atomic.h>
149#include <asm-generic/bitops/minix.h>
150#include <asm-generic/bitops/fls.h>
151#include <asm-generic/bitops/fls64.h>
152
153#endif /* __KERNEL__ */
154
155#endif /* __ASM_SH64_BITOPS_H */
diff --git a/include/asm-sh64/bug.h b/include/asm-sh64/bug.h
deleted file mode 100644
index f3a9c9248ef4..000000000000
--- a/include/asm-sh64/bug.h
+++ /dev/null
@@ -1,19 +0,0 @@
1#ifndef __ASM_SH64_BUG_H
2#define __ASM_SH64_BUG_H
3
4#ifdef CONFIG_BUG
5/*
6 * Tell the user there is some problem, then force a segfault (in process
7 * context) or a panic (interrupt context).
8 */
9#define BUG() do { \
10 printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
11 *(volatile int *)0 = 0; \
12} while (0)
13
14#define HAVE_ARCH_BUG
15#endif
16
17#include <asm-generic/bug.h>
18
19#endif /* __ASM_SH64_BUG_H */
diff --git a/include/asm-sh64/bugs.h b/include/asm-sh64/bugs.h
deleted file mode 100644
index 05554aaea672..000000000000
--- a/include/asm-sh64/bugs.h
+++ /dev/null
@@ -1,38 +0,0 @@
1#ifndef __ASM_SH64_BUGS_H
2#define __ASM_SH64_BUGS_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/bugs.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 *
14 */
15
16/*
17 * This is included by init/main.c to check for architecture-dependent bugs.
18 *
19 * Needs:
20 * void check_bugs(void);
21 */
22
23/*
24 * I don't know of any Super-H bugs yet.
25 */
26
27#include <asm/processor.h>
28
29static void __init check_bugs(void)
30{
31 extern char *get_cpu_subtype(void);
32 extern unsigned long loops_per_jiffy;
33
34 cpu_data->loops_per_jiffy = loops_per_jiffy;
35
36 printk("CPU: %s\n", get_cpu_subtype());
37}
38#endif /* __ASM_SH64_BUGS_H */
diff --git a/include/asm-sh64/byteorder.h b/include/asm-sh64/byteorder.h
deleted file mode 100644
index 7419d78820ee..000000000000
--- a/include/asm-sh64/byteorder.h
+++ /dev/null
@@ -1,49 +0,0 @@
1#ifndef __ASM_SH64_BYTEORDER_H
2#define __ASM_SH64_BYTEORDER_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/byteorder.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#include <asm/types.h>
16
17static inline __attribute_const__ __u32 ___arch__swab32(__u32 x)
18{
19 __asm__("byterev %0, %0\n\t"
20 "shari %0, 32, %0"
21 : "=r" (x)
22 : "0" (x));
23 return x;
24}
25
26static inline __attribute_const__ __u16 ___arch__swab16(__u16 x)
27{
28 __asm__("byterev %0, %0\n\t"
29 "shari %0, 48, %0"
30 : "=r" (x)
31 : "0" (x));
32 return x;
33}
34
35#define __arch__swab32(x) ___arch__swab32(x)
36#define __arch__swab16(x) ___arch__swab16(x)
37
38#if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
39# define __BYTEORDER_HAS_U64__
40# define __SWAB_64_THRU_32__
41#endif
42
43#ifdef __LITTLE_ENDIAN__
44#include <linux/byteorder/little_endian.h>
45#else
46#include <linux/byteorder/big_endian.h>
47#endif
48
49#endif /* __ASM_SH64_BYTEORDER_H */
diff --git a/include/asm-sh64/cayman.h b/include/asm-sh64/cayman.h
deleted file mode 100644
index 7b6b96844842..000000000000
--- a/include/asm-sh64/cayman.h
+++ /dev/null
@@ -1,20 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * include/asm-sh64/cayman.h
7 *
8 * Cayman definitions
9 *
10 * Global defintions for the SH5 Cayman board
11 *
12 * Copyright (C) 2002 Stuart Menefy
13 */
14
15
16/* Setup for the SMSC FDC37C935 / LAN91C100FD */
17#define SMSC_IRQ IRQ_IRL1
18
19/* Setup for PCI Bus 2, which transmits interrupts via the EPLD */
20#define PCI2_IRQ IRQ_IRL3
diff --git a/include/asm-sh64/cpumask.h b/include/asm-sh64/cpumask.h
deleted file mode 100644
index b7b105dbedaf..000000000000
--- a/include/asm-sh64/cpumask.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_CPUMASK_H
2#define __ASM_SH64_CPUMASK_H
3
4#include <asm-generic/cpumask.h>
5
6#endif /* __ASM_SH64_CPUMASK_H */
diff --git a/include/asm-sh64/cputime.h b/include/asm-sh64/cputime.h
deleted file mode 100644
index 0fd89da2aa86..000000000000
--- a/include/asm-sh64/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __SH64_CPUTIME_H
2#define __SH64_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __SH64_CPUTIME_H */
diff --git a/include/asm-sh64/current.h b/include/asm-sh64/current.h
deleted file mode 100644
index 261224339d6f..000000000000
--- a/include/asm-sh64/current.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#ifndef __ASM_SH64_CURRENT_H
2#define __ASM_SH64_CURRENT_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/current.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 *
14 */
15
16#include <linux/thread_info.h>
17
18struct task_struct;
19
20static __inline__ struct task_struct * get_current(void)
21{
22 return current_thread_info()->task;
23}
24
25#define current get_current()
26
27#endif /* __ASM_SH64_CURRENT_H */
28
diff --git a/include/asm-sh64/delay.h b/include/asm-sh64/delay.h
deleted file mode 100644
index 6ae31301a16a..000000000000
--- a/include/asm-sh64/delay.h
+++ /dev/null
@@ -1,11 +0,0 @@
1#ifndef __ASM_SH64_DELAY_H
2#define __ASM_SH64_DELAY_H
3
4extern void __delay(int loops);
5extern void __udelay(unsigned long long usecs, unsigned long lpj);
6extern void __ndelay(unsigned long long nsecs, unsigned long lpj);
7extern void udelay(unsigned long usecs);
8extern void ndelay(unsigned long nsecs);
9
10#endif /* __ASM_SH64_DELAY_H */
11
diff --git a/include/asm-sh64/device.h b/include/asm-sh64/device.h
deleted file mode 100644
index d8f9872b0e2d..000000000000
--- a/include/asm-sh64/device.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/include/asm-sh64/div64.h b/include/asm-sh64/div64.h
deleted file mode 100644
index f75869565e2e..000000000000
--- a/include/asm-sh64/div64.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_DIV64_H
2#define __ASM_SH64_DIV64_H
3
4#include <asm-generic/div64.h>
5
6#endif /* __ASM_SH64_DIV64_H */
diff --git a/include/asm-sh64/dma-mapping.h b/include/asm-sh64/dma-mapping.h
deleted file mode 100644
index 1438b763a5ea..000000000000
--- a/include/asm-sh64/dma-mapping.h
+++ /dev/null
@@ -1,193 +0,0 @@
1#ifndef __ASM_SH_DMA_MAPPING_H
2#define __ASM_SH_DMA_MAPPING_H
3
4#include <linux/mm.h>
5#include <linux/scatterlist.h>
6#include <asm/io.h>
7
8struct pci_dev;
9extern void *consistent_alloc(struct pci_dev *hwdev, size_t size,
10 dma_addr_t *dma_handle);
11extern void consistent_free(struct pci_dev *hwdev, size_t size,
12 void *vaddr, dma_addr_t dma_handle);
13
14#define dma_supported(dev, mask) (1)
15
16static inline int dma_set_mask(struct device *dev, u64 mask)
17{
18 if (!dev->dma_mask || !dma_supported(dev, mask))
19 return -EIO;
20
21 *dev->dma_mask = mask;
22
23 return 0;
24}
25
26static inline void *dma_alloc_coherent(struct device *dev, size_t size,
27 dma_addr_t *dma_handle, gfp_t flag)
28{
29 return consistent_alloc(NULL, size, dma_handle);
30}
31
32static inline void dma_free_coherent(struct device *dev, size_t size,
33 void *vaddr, dma_addr_t dma_handle)
34{
35 consistent_free(NULL, size, vaddr, dma_handle);
36}
37
38#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
39#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
40#define dma_is_consistent(d, h) (1)
41
42static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
43 enum dma_data_direction dir)
44{
45 unsigned long s = (unsigned long) vaddr & L1_CACHE_ALIGN_MASK;
46 unsigned long e = (vaddr + size) & L1_CACHE_ALIGN_MASK;
47
48 for (; s <= e; s += L1_CACHE_BYTES)
49 asm volatile ("ocbp %0, 0" : : "r" (s));
50}
51
52static inline dma_addr_t dma_map_single(struct device *dev,
53 void *ptr, size_t size,
54 enum dma_data_direction dir)
55{
56#if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT)
57 if (dev->bus == &pci_bus_type)
58 return virt_to_phys(ptr);
59#endif
60 dma_cache_sync(dev, ptr, size, dir);
61
62 return virt_to_phys(ptr);
63}
64
65#define dma_unmap_single(dev, addr, size, dir) do { } while (0)
66
67static inline int dma_map_sg(struct device *dev, struct scatterlist *sg,
68 int nents, enum dma_data_direction dir)
69{
70 int i;
71
72 for (i = 0; i < nents; i++) {
73#if !defined(CONFIG_PCI) || defined(CONFIG_SH_PCIDMA_NONCOHERENT)
74 dma_cache_sync(dev, sg_virt(&sg[i]), sg[i].length, dir);
75#endif
76 sg[i].dma_address = sg_phys(&sg[i]);
77 }
78
79 return nents;
80}
81
82#define dma_unmap_sg(dev, sg, nents, dir) do { } while (0)
83
84static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
85 unsigned long offset, size_t size,
86 enum dma_data_direction dir)
87{
88 return dma_map_single(dev, page_address(page) + offset, size, dir);
89}
90
91static inline void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
92 size_t size, enum dma_data_direction dir)
93{
94 dma_unmap_single(dev, dma_address, size, dir);
95}
96
97static inline void dma_sync_single(struct device *dev, dma_addr_t dma_handle,
98 size_t size, enum dma_data_direction dir)
99{
100#if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT)
101 if (dev->bus == &pci_bus_type)
102 return;
103#endif
104 dma_cache_sync(dev, phys_to_virt(dma_handle), size, dir);
105}
106
107static inline void dma_sync_single_range(struct device *dev,
108 dma_addr_t dma_handle,
109 unsigned long offset, size_t size,
110 enum dma_data_direction dir)
111{
112#if defined(CONFIG_PCI) && !defined(CONFIG_SH_PCIDMA_NONCOHERENT)
113 if (dev->bus == &pci_bus_type)
114 return;
115#endif
116 dma_cache_sync(dev, phys_to_virt(dma_handle) + offset, size, dir);
117}
118
119static inline void dma_sync_sg(struct device *dev, struct scatterlist *sg,
120 int nelems, enum dma_data_direction dir)
121{
122 int i;
123
124 for (i = 0; i < nelems; i++) {
125#if !defined(CONFIG_PCI) || defined(CONFIG_SH_PCIDMA_NONCOHERENT)
126 dma_cache_sync(dev, sg_virt(&sg[i]), sg[i].length, dir);
127#endif
128 sg[i].dma_address = sg_phys(&sg[i]);
129 }
130}
131
132static inline void dma_sync_single_for_cpu(struct device *dev,
133 dma_addr_t dma_handle, size_t size,
134 enum dma_data_direction dir)
135{
136 dma_sync_single(dev, dma_handle, size, dir);
137}
138
139static inline void dma_sync_single_for_device(struct device *dev,
140 dma_addr_t dma_handle, size_t size,
141 enum dma_data_direction dir)
142{
143 dma_sync_single(dev, dma_handle, size, dir);
144}
145
146static inline void dma_sync_single_range_for_cpu(struct device *dev,
147 dma_addr_t dma_handle,
148 unsigned long offset,
149 size_t size,
150 enum dma_data_direction direction)
151{
152 dma_sync_single_for_cpu(dev, dma_handle+offset, size, direction);
153}
154
155static inline void dma_sync_single_range_for_device(struct device *dev,
156 dma_addr_t dma_handle,
157 unsigned long offset,
158 size_t size,
159 enum dma_data_direction direction)
160{
161 dma_sync_single_for_device(dev, dma_handle+offset, size, direction);
162}
163
164static inline void dma_sync_sg_for_cpu(struct device *dev,
165 struct scatterlist *sg, int nelems,
166 enum dma_data_direction dir)
167{
168 dma_sync_sg(dev, sg, nelems, dir);
169}
170
171static inline void dma_sync_sg_for_device(struct device *dev,
172 struct scatterlist *sg, int nelems,
173 enum dma_data_direction dir)
174{
175 dma_sync_sg(dev, sg, nelems, dir);
176}
177
178static inline int dma_get_cache_alignment(void)
179{
180 /*
181 * Each processor family will define its own L1_CACHE_SHIFT,
182 * L1_CACHE_BYTES wraps to this, so this is always safe.
183 */
184 return L1_CACHE_BYTES;
185}
186
187static inline int dma_mapping_error(dma_addr_t dma_addr)
188{
189 return dma_addr == 0;
190}
191
192#endif /* __ASM_SH_DMA_MAPPING_H */
193
diff --git a/include/asm-sh64/dma.h b/include/asm-sh64/dma.h
deleted file mode 100644
index e701f39470a2..000000000000
--- a/include/asm-sh64/dma.h
+++ /dev/null
@@ -1,41 +0,0 @@
1#ifndef __ASM_SH64_DMA_H
2#define __ASM_SH64_DMA_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/dma.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 *
14 */
15
16#include <linux/mm.h>
17#include <asm/io.h>
18#include <asm/pgtable.h>
19
20#define MAX_DMA_CHANNELS 4
21
22/*
23 * SH5 can DMA in any memory area.
24 *
25 * The static definition is dodgy because it should limit
26 * the highest DMA-able address based on the actual
27 * Physical memory available. This is actually performed
28 * at run time in defining the memory allowed to DMA_ZONE.
29 */
30#define MAX_DMA_ADDRESS ~(NPHYS_MASK)
31
32#define DMA_MODE_READ 0
33#define DMA_MODE_WRITE 1
34
35#ifdef CONFIG_PCI
36extern int isa_dma_bridge_buggy;
37#else
38#define isa_dma_bridge_buggy (0)
39#endif
40
41#endif /* __ASM_SH64_DMA_H */
diff --git a/include/asm-sh64/elf.h b/include/asm-sh64/elf.h
deleted file mode 100644
index f994286e1998..000000000000
--- a/include/asm-sh64/elf.h
+++ /dev/null
@@ -1,107 +0,0 @@
1#ifndef __ASM_SH64_ELF_H
2#define __ASM_SH64_ELF_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/elf.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/*
16 * ELF register definitions..
17 */
18
19#include <asm/ptrace.h>
20#include <asm/user.h>
21#include <asm/byteorder.h>
22
23typedef unsigned long elf_greg_t;
24
25#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
26typedef elf_greg_t elf_gregset_t[ELF_NGREG];
27
28typedef struct user_fpu_struct elf_fpregset_t;
29
30/*
31 * This is used to ensure we don't load something for the wrong architecture.
32 */
33#define elf_check_arch(x) ( (x)->e_machine == EM_SH )
34
35/*
36 * These are used to set parameters in the core dumps.
37 */
38#define ELF_CLASS ELFCLASS32
39#ifdef __LITTLE_ENDIAN__
40#define ELF_DATA ELFDATA2LSB
41#else
42#define ELF_DATA ELFDATA2MSB
43#endif
44#define ELF_ARCH EM_SH
45
46#define USE_ELF_CORE_DUMP
47#define ELF_EXEC_PAGESIZE 4096
48
49/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
50 use of this is to invoke "./ld.so someprog" to test out a new version of
51 the loader. We need to make sure that it is out of the way of the program
52 that it will "exec", and that there is sufficient room for the brk. */
53
54#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
55
56#define R_SH_DIR32 1
57#define R_SH_REL32 2
58#define R_SH_IMM_LOW16 246
59#define R_SH_IMM_LOW16_PCREL 247
60#define R_SH_IMM_MEDLOW16 248
61#define R_SH_IMM_MEDLOW16_PCREL 249
62
63#define ELF_CORE_COPY_REGS(_dest,_regs) \
64 memcpy((char *) &_dest, (char *) _regs, \
65 sizeof(struct pt_regs));
66
67/* This yields a mask that user programs can use to figure out what
68 instruction set this CPU supports. This could be done in user space,
69 but it's not easy, and we've already done it here. */
70
71#define ELF_HWCAP (0)
72
73/* This yields a string that ld.so will use to load implementation
74 specific libraries for optimization. This is more specific in
75 intent than poking at uname or /proc/cpuinfo.
76
77 For the moment, we have only optimizations for the Intel generations,
78 but that could change... */
79
80#define ELF_PLATFORM (NULL)
81
82#define ELF_PLAT_INIT(_r, load_addr) \
83 do { _r->regs[0]=0; _r->regs[1]=0; _r->regs[2]=0; _r->regs[3]=0; \
84 _r->regs[4]=0; _r->regs[5]=0; _r->regs[6]=0; _r->regs[7]=0; \
85 _r->regs[8]=0; _r->regs[9]=0; _r->regs[10]=0; _r->regs[11]=0; \
86 _r->regs[12]=0; _r->regs[13]=0; _r->regs[14]=0; _r->regs[15]=0; \
87 _r->regs[16]=0; _r->regs[17]=0; _r->regs[18]=0; _r->regs[19]=0; \
88 _r->regs[20]=0; _r->regs[21]=0; _r->regs[22]=0; _r->regs[23]=0; \
89 _r->regs[24]=0; _r->regs[25]=0; _r->regs[26]=0; _r->regs[27]=0; \
90 _r->regs[28]=0; _r->regs[29]=0; _r->regs[30]=0; _r->regs[31]=0; \
91 _r->regs[32]=0; _r->regs[33]=0; _r->regs[34]=0; _r->regs[35]=0; \
92 _r->regs[36]=0; _r->regs[37]=0; _r->regs[38]=0; _r->regs[39]=0; \
93 _r->regs[40]=0; _r->regs[41]=0; _r->regs[42]=0; _r->regs[43]=0; \
94 _r->regs[44]=0; _r->regs[45]=0; _r->regs[46]=0; _r->regs[47]=0; \
95 _r->regs[48]=0; _r->regs[49]=0; _r->regs[50]=0; _r->regs[51]=0; \
96 _r->regs[52]=0; _r->regs[53]=0; _r->regs[54]=0; _r->regs[55]=0; \
97 _r->regs[56]=0; _r->regs[57]=0; _r->regs[58]=0; _r->regs[59]=0; \
98 _r->regs[60]=0; _r->regs[61]=0; _r->regs[62]=0; \
99 _r->tregs[0]=0; _r->tregs[1]=0; _r->tregs[2]=0; _r->tregs[3]=0; \
100 _r->tregs[4]=0; _r->tregs[5]=0; _r->tregs[6]=0; _r->tregs[7]=0; \
101 _r->sr = SR_FD | SR_MMU; } while (0)
102
103#ifdef __KERNEL__
104#define SET_PERSONALITY(ex, ibcs2) set_personality(PER_LINUX_32BIT)
105#endif
106
107#endif /* __ASM_SH64_ELF_H */
diff --git a/include/asm-sh64/emergency-restart.h b/include/asm-sh64/emergency-restart.h
deleted file mode 100644
index 108d8c48e42e..000000000000
--- a/include/asm-sh64/emergency-restart.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_EMERGENCY_RESTART_H
2#define _ASM_EMERGENCY_RESTART_H
3
4#include <asm-generic/emergency-restart.h>
5
6#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/include/asm-sh64/errno.h b/include/asm-sh64/errno.h
deleted file mode 100644
index 57b46d4bdd41..000000000000
--- a/include/asm-sh64/errno.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_ERRNO_H
2#define __ASM_SH64_ERRNO_H
3
4#include <asm-generic/errno.h>
5
6#endif /* __ASM_SH64_ERRNO_H */
diff --git a/include/asm-sh64/fb.h b/include/asm-sh64/fb.h
deleted file mode 100644
index d92e99cd8c8a..000000000000
--- a/include/asm-sh64/fb.h
+++ /dev/null
@@ -1,19 +0,0 @@
1#ifndef _ASM_FB_H_
2#define _ASM_FB_H_
3
4#include <linux/fb.h>
5#include <linux/fs.h>
6#include <asm/page.h>
7
8static inline void fb_pgprotect(struct file *file, struct vm_area_struct *vma,
9 unsigned long off)
10{
11 vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
12}
13
14static inline int fb_is_primary_device(struct fb_info *info)
15{
16 return 0;
17}
18
19#endif /* _ASM_FB_H_ */
diff --git a/include/asm-sh64/fcntl.h b/include/asm-sh64/fcntl.h
deleted file mode 100644
index 744dd79b9d5d..000000000000
--- a/include/asm-sh64/fcntl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sh/fcntl.h>
diff --git a/include/asm-sh64/futex.h b/include/asm-sh64/futex.h
deleted file mode 100644
index 6a332a9f099c..000000000000
--- a/include/asm-sh64/futex.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_FUTEX_H
2#define _ASM_FUTEX_H
3
4#include <asm-generic/futex.h>
5
6#endif
diff --git a/include/asm-sh64/gpio.h b/include/asm-sh64/gpio.h
deleted file mode 100644
index 6bc5a13d8415..000000000000
--- a/include/asm-sh64/gpio.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_SH64_GPIO_H
2#define __ASM_SH64_GPIO_H
3
4/*
5 * This is just a stub, so that every arch using sh-sci has a gpio.h
6 */
7
8#endif /* __ASM_SH64_GPIO_H */
diff --git a/include/asm-sh64/hardirq.h b/include/asm-sh64/hardirq.h
deleted file mode 100644
index 555fd7a35108..000000000000
--- a/include/asm-sh64/hardirq.h
+++ /dev/null
@@ -1,18 +0,0 @@
1#ifndef __ASM_SH64_HARDIRQ_H
2#define __ASM_SH64_HARDIRQ_H
3
4#include <linux/threads.h>
5#include <linux/irq.h>
6
7/* entry.S is sensitive to the offsets of these fields */
8typedef struct {
9 unsigned int __softirq_pending;
10} ____cacheline_aligned irq_cpustat_t;
11
12#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
13
14/* arch/sh64/kernel/irq.c */
15extern void ack_bad_irq(unsigned int irq);
16
17#endif /* __ASM_SH64_HARDIRQ_H */
18
diff --git a/include/asm-sh64/hardware.h b/include/asm-sh64/hardware.h
deleted file mode 100644
index 931c1ad80847..000000000000
--- a/include/asm-sh64/hardware.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef __ASM_SH64_HARDWARE_H
2#define __ASM_SH64_HARDWARE_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/hardware.h
10 *
11 * Copyright (C) 2002 Stuart Menefy
12 * Copyright (C) 2003 Paul Mundt
13 *
14 * Defitions of the locations of registers in the physical address space.
15 */
16
17#define PHYS_PERIPHERAL_BLOCK 0x09000000
18#define PHYS_DMAC_BLOCK 0x0e000000
19#define PHYS_PCI_BLOCK 0x60000000
20#define PHYS_EMI_BLOCK 0xff000000
21
22#endif /* __ASM_SH64_HARDWARE_H */
diff --git a/include/asm-sh64/hw_irq.h b/include/asm-sh64/hw_irq.h
deleted file mode 100644
index ebb39089b0ac..000000000000
--- a/include/asm-sh64/hw_irq.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef __ASM_SH64_HW_IRQ_H
2#define __ASM_SH64_HW_IRQ_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/hw_irq.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#endif /* __ASM_SH64_HW_IRQ_H */
diff --git a/include/asm-sh64/ide.h b/include/asm-sh64/ide.h
deleted file mode 100644
index b6e31e8b9410..000000000000
--- a/include/asm-sh64/ide.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * linux/include/asm-sh64/ide.h
3 *
4 * Copyright (C) 1994-1996 Linus Torvalds & authors
5 *
6 * sh64 version by Richard Curnow & Paul Mundt
7 */
8
9/*
10 * This file contains the sh64 architecture specific IDE code.
11 */
12
13#ifndef __ASM_SH64_IDE_H
14#define __ASM_SH64_IDE_H
15
16#ifdef __KERNEL__
17
18
19/* Without this, the initialisation of PCI IDE cards end up calling
20 * ide_init_hwif_ports, which won't work. */
21#ifdef CONFIG_BLK_DEV_IDEPCI
22#define ide_default_io_ctl(base) (0)
23#endif
24
25#include <asm-generic/ide_iops.h>
26
27#endif /* __KERNEL__ */
28
29#endif /* __ASM_SH64_IDE_H */
diff --git a/include/asm-sh64/io.h b/include/asm-sh64/io.h
deleted file mode 100644
index 7bd7314d38c2..000000000000
--- a/include/asm-sh64/io.h
+++ /dev/null
@@ -1,196 +0,0 @@
1#ifndef __ASM_SH64_IO_H
2#define __ASM_SH64_IO_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/io.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 *
14 */
15
16/*
17 * Convention:
18 * read{b,w,l}/write{b,w,l} are for PCI,
19 * while in{b,w,l}/out{b,w,l} are for ISA
20 * These may (will) be platform specific function.
21 *
22 * In addition, we have
23 * ctrl_in{b,w,l}/ctrl_out{b,w,l} for SuperH specific I/O.
24 * which are processor specific. Address should be the result of
25 * onchip_remap();
26 */
27
28#include <linux/compiler.h>
29#include <asm/cache.h>
30#include <asm/system.h>
31#include <asm/page.h>
32#include <asm-generic/iomap.h>
33
34/*
35 * Nothing overly special here.. instead of doing the same thing
36 * over and over again, we just define a set of sh64_in/out functions
37 * with an implicit size. The traditional read{b,w,l}/write{b,w,l}
38 * mess is wrapped to this, as are the SH-specific ctrl_in/out routines.
39 */
40static inline unsigned char sh64_in8(const volatile void __iomem *addr)
41{
42 return *(volatile unsigned char __force *)addr;
43}
44
45static inline unsigned short sh64_in16(const volatile void __iomem *addr)
46{
47 return *(volatile unsigned short __force *)addr;
48}
49
50static inline unsigned int sh64_in32(const volatile void __iomem *addr)
51{
52 return *(volatile unsigned int __force *)addr;
53}
54
55static inline unsigned long long sh64_in64(const volatile void __iomem *addr)
56{
57 return *(volatile unsigned long long __force *)addr;
58}
59
60static inline void sh64_out8(unsigned char b, volatile void __iomem *addr)
61{
62 *(volatile unsigned char __force *)addr = b;
63 wmb();
64}
65
66static inline void sh64_out16(unsigned short b, volatile void __iomem *addr)
67{
68 *(volatile unsigned short __force *)addr = b;
69 wmb();
70}
71
72static inline void sh64_out32(unsigned int b, volatile void __iomem *addr)
73{
74 *(volatile unsigned int __force *)addr = b;
75 wmb();
76}
77
78static inline void sh64_out64(unsigned long long b, volatile void __iomem *addr)
79{
80 *(volatile unsigned long long __force *)addr = b;
81 wmb();
82}
83
84#define readb(addr) sh64_in8(addr)
85#define readw(addr) sh64_in16(addr)
86#define readl(addr) sh64_in32(addr)
87#define readb_relaxed(addr) sh64_in8(addr)
88#define readw_relaxed(addr) sh64_in16(addr)
89#define readl_relaxed(addr) sh64_in32(addr)
90
91#define writeb(b, addr) sh64_out8(b, addr)
92#define writew(b, addr) sh64_out16(b, addr)
93#define writel(b, addr) sh64_out32(b, addr)
94
95#define ctrl_inb(addr) sh64_in8(ioport_map(addr, 1))
96#define ctrl_inw(addr) sh64_in16(ioport_map(addr, 2))
97#define ctrl_inl(addr) sh64_in32(ioport_map(addr, 4))
98
99#define ctrl_outb(b, addr) sh64_out8(b, ioport_map(addr, 1))
100#define ctrl_outw(b, addr) sh64_out16(b, ioport_map(addr, 2))
101#define ctrl_outl(b, addr) sh64_out32(b, ioport_map(addr, 4))
102
103#define ioread8(addr) sh64_in8(addr)
104#define ioread16(addr) sh64_in16(addr)
105#define ioread32(addr) sh64_in32(addr)
106#define iowrite8(b, addr) sh64_out8(b, addr)
107#define iowrite16(b, addr) sh64_out16(b, addr)
108#define iowrite32(b, addr) sh64_out32(b, addr)
109
110#define inb(addr) ctrl_inb(addr)
111#define inw(addr) ctrl_inw(addr)
112#define inl(addr) ctrl_inl(addr)
113#define outb(b, addr) ctrl_outb(b, addr)
114#define outw(b, addr) ctrl_outw(b, addr)
115#define outl(b, addr) ctrl_outl(b, addr)
116
117void outsw(unsigned long port, const void *addr, unsigned long count);
118void insw(unsigned long port, void *addr, unsigned long count);
119void outsl(unsigned long port, const void *addr, unsigned long count);
120void insl(unsigned long port, void *addr, unsigned long count);
121
122#define inb_p(addr) inb(addr)
123#define inw_p(addr) inw(addr)
124#define inl_p(addr) inl(addr)
125#define outb_p(x,addr) outb(x,addr)
126#define outw_p(x,addr) outw(x,addr)
127#define outl_p(x,addr) outl(x,addr)
128
129#define __raw_readb readb
130#define __raw_readw readw
131#define __raw_readl readl
132#define __raw_writeb writeb
133#define __raw_writew writew
134#define __raw_writel writel
135
136void memcpy_toio(void __iomem *to, const void *from, long count);
137void memcpy_fromio(void *to, void __iomem *from, long count);
138
139#define mmiowb()
140
141#ifdef __KERNEL__
142
143#ifdef CONFIG_SH_CAYMAN
144extern unsigned long smsc_superio_virt;
145#endif
146#ifdef CONFIG_PCI
147extern unsigned long pciio_virt;
148#endif
149
150#define IO_SPACE_LIMIT 0xffffffff
151
152/*
153 * Change virtual addresses to physical addresses and vv.
154 * These are trivial on the 1:1 Linux/SuperH mapping
155 */
156static inline unsigned long virt_to_phys(volatile void * address)
157{
158 return __pa(address);
159}
160
161static inline void * phys_to_virt(unsigned long address)
162{
163 return __va(address);
164}
165
166extern void * __ioremap(unsigned long phys_addr, unsigned long size,
167 unsigned long flags);
168
169static inline void * ioremap(unsigned long phys_addr, unsigned long size)
170{
171 return __ioremap(phys_addr, size, 1);
172}
173
174static inline void * ioremap_nocache (unsigned long phys_addr, unsigned long size)
175{
176 return __ioremap(phys_addr, size, 0);
177}
178
179extern void iounmap(void *addr);
180
181unsigned long onchip_remap(unsigned long addr, unsigned long size, const char* name);
182extern void onchip_unmap(unsigned long vaddr);
183
184/*
185 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
186 * access
187 */
188#define xlate_dev_mem_ptr(p) __va(p)
189
190/*
191 * Convert a virtual cached pointer to an uncached pointer
192 */
193#define xlate_dev_kmem_ptr(p) p
194
195#endif /* __KERNEL__ */
196#endif /* __ASM_SH64_IO_H */
diff --git a/include/asm-sh64/ioctl.h b/include/asm-sh64/ioctl.h
deleted file mode 100644
index b279fe06dfe5..000000000000
--- a/include/asm-sh64/ioctl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ioctl.h>
diff --git a/include/asm-sh64/ioctls.h b/include/asm-sh64/ioctls.h
deleted file mode 100644
index 6b0c04f63c57..000000000000
--- a/include/asm-sh64/ioctls.h
+++ /dev/null
@@ -1,116 +0,0 @@
1#ifndef __ASM_SH64_IOCTLS_H
2#define __ASM_SH64_IOCTLS_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/ioctls.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2004 Richard Curnow
13 *
14 */
15
16#include <asm/ioctl.h>
17
18#define FIOCLEX 0x6601 /* _IO('f', 1) */
19#define FIONCLEX 0x6602 /* _IO('f', 2) */
20#define FIOASYNC 0x4004667d /* _IOW('f', 125, int) */
21#define FIONBIO 0x4004667e /* _IOW('f', 126, int) */
22#define FIONREAD 0x8004667f /* _IOW('f', 127, int) */
23#define TIOCINQ FIONREAD
24#define FIOQSIZE 0x80086680 /* _IOR('f', 128, loff_t) */
25
26#define TCGETS 0x5401
27#define TCSETS 0x5402
28#define TCSETSW 0x5403
29#define TCSETSF 0x5404
30
31#define TCGETA 0x80127417 /* _IOR('t', 23, struct termio) */
32#define TCSETA 0x40127418 /* _IOW('t', 24, struct termio) */
33#define TCSETAW 0x40127419 /* _IOW('t', 25, struct termio) */
34#define TCSETAF 0x4012741c /* _IOW('t', 28, struct termio) */
35
36#define TCSBRK 0x741d /* _IO('t', 29) */
37#define TCXONC 0x741e /* _IO('t', 30) */
38#define TCFLSH 0x741f /* _IO('t', 31) */
39
40#define TIOCSWINSZ 0x40087467 /* _IOW('t', 103, struct winsize) */
41#define TIOCGWINSZ 0x80087468 /* _IOR('t', 104, struct winsize) */
42#define TIOCSTART 0x746e /* _IO('t', 110) start output, like ^Q */
43#define TIOCSTOP 0x746f /* _IO('t', 111) stop output, like ^S */
44#define TIOCOUTQ 0x80047473 /* _IOR('t', 115, int) output queue size */
45
46#define TIOCSPGRP 0x40047476 /* _IOW('t', 118, int) */
47#define TIOCGPGRP 0x80047477 /* _IOR('t', 119, int) */
48
49#define TIOCEXCL 0x540c /* _IO('T', 12) */
50#define TIOCNXCL 0x540d /* _IO('T', 13) */
51#define TIOCSCTTY 0x540e /* _IO('T', 14) */
52
53#define TIOCSTI 0x40015412 /* _IOW('T', 18, char) 0x5412 */
54#define TIOCMGET 0x80045415 /* _IOR('T', 21, unsigned int) 0x5415 */
55#define TIOCMBIS 0x40045416 /* _IOW('T', 22, unsigned int) 0x5416 */
56#define TIOCMBIC 0x40045417 /* _IOW('T', 23, unsigned int) 0x5417 */
57#define TIOCMSET 0x40045418 /* _IOW('T', 24, unsigned int) 0x5418 */
58
59#define TIOCM_LE 0x001
60#define TIOCM_DTR 0x002
61#define TIOCM_RTS 0x004
62#define TIOCM_ST 0x008
63#define TIOCM_SR 0x010
64#define TIOCM_CTS 0x020
65#define TIOCM_CAR 0x040
66#define TIOCM_RNG 0x080
67#define TIOCM_DSR 0x100
68#define TIOCM_CD TIOCM_CAR
69#define TIOCM_RI TIOCM_RNG
70
71#define TIOCGSOFTCAR 0x80045419 /* _IOR('T', 25, unsigned int) 0x5419 */
72#define TIOCSSOFTCAR 0x4004541a /* _IOW('T', 26, unsigned int) 0x541A */
73#define TIOCLINUX 0x4004541c /* _IOW('T', 28, char) 0x541C */
74#define TIOCCONS 0x541d /* _IO('T', 29) */
75#define TIOCGSERIAL 0x803c541e /* _IOR('T', 30, struct serial_struct) 0x541E */
76#define TIOCSSERIAL 0x403c541f /* _IOW('T', 31, struct serial_struct) 0x541F */
77#define TIOCPKT 0x40045420 /* _IOW('T', 32, int) 0x5420 */
78
79#define TIOCPKT_DATA 0
80#define TIOCPKT_FLUSHREAD 1
81#define TIOCPKT_FLUSHWRITE 2
82#define TIOCPKT_STOP 4
83#define TIOCPKT_START 8
84#define TIOCPKT_NOSTOP 16
85#define TIOCPKT_DOSTOP 32
86
87
88#define TIOCNOTTY 0x5422 /* _IO('T', 34) */
89#define TIOCSETD 0x40045423 /* _IOW('T', 35, int) 0x5423 */
90#define TIOCGETD 0x80045424 /* _IOR('T', 36, int) 0x5424 */
91#define TCSBRKP 0x40045424 /* _IOW('T', 37, int) 0x5425 */ /* Needed for POSIX tcsendbreak() */
92#define TIOCTTYGSTRUCT 0x8c105426 /* _IOR('T', 38, struct tty_struct) 0x5426 */ /* For debugging only */
93#define TIOCSBRK 0x5427 /* _IO('T', 39) */ /* BSD compatibility */
94#define TIOCCBRK 0x5428 /* _IO('T', 40) */ /* BSD compatibility */
95#define TIOCGSID 0x80045429 /* _IOR('T', 41, pid_t) 0x5429 */ /* Return the session ID of FD */
96#define TIOCGPTN 0x80045430 /* _IOR('T',0x30, unsigned int) 0x5430 Get Pty Number (of pty-mux device) */
97#define TIOCSPTLCK 0x40045431 /* _IOW('T',0x31, int) Lock/unlock Pty */
98
99#define TIOCSERCONFIG 0x5453 /* _IO('T', 83) */
100#define TIOCSERGWILD 0x80045454 /* _IOR('T', 84, int) 0x5454 */
101#define TIOCSERSWILD 0x40045455 /* _IOW('T', 85, int) 0x5455 */
102#define TIOCGLCKTRMIOS 0x5456
103#define TIOCSLCKTRMIOS 0x5457
104#define TIOCSERGSTRUCT 0x80d85458 /* _IOR('T', 88, struct async_struct) 0x5458 */ /* For debugging only */
105#define TIOCSERGETLSR 0x80045459 /* _IOR('T', 89, unsigned int) 0x5459 */ /* Get line status register */
106
107/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
108#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
109
110#define TIOCSERGETMULTI 0x80a8545a /* _IOR('T', 90, struct serial_multiport_struct) 0x545A */ /* Get multiport config */
111#define TIOCSERSETMULTI 0x40a8545b /* _IOW('T', 91, struct serial_multiport_struct) 0x545B */ /* Set multiport config */
112
113#define TIOCMIWAIT 0x545c /* _IO('T', 92) wait for a change on serial input line(s) */
114#define TIOCGICOUNT 0x545d /* read serial port inline interrupt counts */
115
116#endif /* __ASM_SH64_IOCTLS_H */
diff --git a/include/asm-sh64/ipcbuf.h b/include/asm-sh64/ipcbuf.h
deleted file mode 100644
index c441e35299c0..000000000000
--- a/include/asm-sh64/ipcbuf.h
+++ /dev/null
@@ -1,40 +0,0 @@
1#ifndef __ASM_SH64_IPCBUF_H__
2#define __ASM_SH64_IPCBUF_H__
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/ipcbuf.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/*
16 * The ipc64_perm structure for i386 architecture.
17 * Note extra padding because this structure is passed back and forth
18 * between kernel and user space.
19 *
20 * Pad space is left for:
21 * - 32-bit mode_t and seq
22 * - 2 miscellaneous 32-bit values
23 */
24
25struct ipc64_perm
26{
27 __kernel_key_t key;
28 __kernel_uid32_t uid;
29 __kernel_gid32_t gid;
30 __kernel_uid32_t cuid;
31 __kernel_gid32_t cgid;
32 __kernel_mode_t mode;
33 unsigned short __pad1;
34 unsigned short seq;
35 unsigned short __pad2;
36 unsigned long __unused1;
37 unsigned long __unused2;
38};
39
40#endif /* __ASM_SH64_IPCBUF_H__ */
diff --git a/include/asm-sh64/irq_regs.h b/include/asm-sh64/irq_regs.h
deleted file mode 100644
index 3dd9c0b70270..000000000000
--- a/include/asm-sh64/irq_regs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/irq_regs.h>
diff --git a/include/asm-sh64/kdebug.h b/include/asm-sh64/kdebug.h
deleted file mode 100644
index 6ece1b037665..000000000000
--- a/include/asm-sh64/kdebug.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kdebug.h>
diff --git a/include/asm-sh64/keyboard.h b/include/asm-sh64/keyboard.h
deleted file mode 100644
index 0b01c3beb2f8..000000000000
--- a/include/asm-sh64/keyboard.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * linux/include/asm-shmedia/keyboard.h
3 *
4 * Copied from i386 version:
5 * Created 3 Nov 1996 by Geert Uytterhoeven
6 */
7
8/*
9 * This file contains the i386 architecture specific keyboard definitions
10 */
11
12#ifndef __ASM_SH64_KEYBOARD_H
13#define __ASM_SH64_KEYBOARD_H
14
15#ifdef __KERNEL__
16
17#include <linux/kernel.h>
18#include <linux/ioport.h>
19#include <asm/io.h>
20
21#ifdef CONFIG_SH_CAYMAN
22#define KEYBOARD_IRQ (START_EXT_IRQS + 2) /* SMSC SuperIO IRQ 1 */
23#endif
24#define DISABLE_KBD_DURING_INTERRUPTS 0
25
26extern int pckbd_setkeycode(unsigned int scancode, unsigned int keycode);
27extern int pckbd_getkeycode(unsigned int scancode);
28extern int pckbd_translate(unsigned char scancode, unsigned char *keycode,
29 char raw_mode);
30extern char pckbd_unexpected_up(unsigned char keycode);
31extern void pckbd_leds(unsigned char leds);
32extern void pckbd_init_hw(void);
33
34#define kbd_setkeycode pckbd_setkeycode
35#define kbd_getkeycode pckbd_getkeycode
36#define kbd_translate pckbd_translate
37#define kbd_unexpected_up pckbd_unexpected_up
38#define kbd_leds pckbd_leds
39#define kbd_init_hw pckbd_init_hw
40
41/* resource allocation */
42#define kbd_request_region()
43#define kbd_request_irq(handler) request_irq(KEYBOARD_IRQ, handler, 0, \
44 "keyboard", NULL)
45
46/* How to access the keyboard macros on this platform. */
47#define kbd_read_input() inb(KBD_DATA_REG)
48#define kbd_read_status() inb(KBD_STATUS_REG)
49#define kbd_write_output(val) outb(val, KBD_DATA_REG)
50#define kbd_write_command(val) outb(val, KBD_CNTL_REG)
51
52/* Some stoneage hardware needs delays after some operations. */
53#define kbd_pause() do { } while(0)
54
55/*
56 * Machine specific bits for the PS/2 driver
57 */
58
59#ifdef CONFIG_SH_CAYMAN
60#define AUX_IRQ (START_EXT_IRQS + 6) /* SMSC SuperIO IRQ12 */
61#endif
62
63#define aux_request_irq(hand, dev_id) \
64 request_irq(AUX_IRQ, hand, IRQF_SHARED, "PS2 Mouse", dev_id)
65
66#define aux_free_irq(dev_id) free_irq(AUX_IRQ, dev_id)
67
68#endif /* __KERNEL__ */
69#endif /* __ASM_SH64_KEYBOARD_H */
70
diff --git a/include/asm-sh64/kmap_types.h b/include/asm-sh64/kmap_types.h
deleted file mode 100644
index 2ae7c7587919..000000000000
--- a/include/asm-sh64/kmap_types.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_SH64_KMAP_TYPES_H
2#define __ASM_SH64_KMAP_TYPES_H
3
4#include <asm-sh/kmap_types.h>
5
6#endif /* __ASM_SH64_KMAP_TYPES_H */
7
diff --git a/include/asm-sh64/linkage.h b/include/asm-sh64/linkage.h
deleted file mode 100644
index 1dd0e84a228d..000000000000
--- a/include/asm-sh64/linkage.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_SH64_LINKAGE_H
2#define __ASM_SH64_LINKAGE_H
3
4#include <asm-sh/linkage.h>
5
6#endif /* __ASM_SH64_LINKAGE_H */
7
diff --git a/include/asm-sh64/local.h b/include/asm-sh64/local.h
deleted file mode 100644
index d9bd95dd36e2..000000000000
--- a/include/asm-sh64/local.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_SH64_LOCAL_H
2#define __ASM_SH64_LOCAL_H
3
4#include <asm-generic/local.h>
5
6#endif /* __ASM_SH64_LOCAL_H */
7
diff --git a/include/asm-sh64/mc146818rtc.h b/include/asm-sh64/mc146818rtc.h
deleted file mode 100644
index 6cd3aec68dbe..000000000000
--- a/include/asm-sh64/mc146818rtc.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * linux/include/asm-sh64/mc146818rtc.h
3 *
4*/
5
6/* For now, an empty place-holder to get IDE to compile. */
7
diff --git a/include/asm-sh64/mman.h b/include/asm-sh64/mman.h
deleted file mode 100644
index a9be6d885c3e..000000000000
--- a/include/asm-sh64/mman.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_MMAN_H
2#define __ASM_SH64_MMAN_H
3
4#include <asm-sh/mman.h>
5
6#endif /* __ASM_SH64_MMAN_H */
diff --git a/include/asm-sh64/mmu.h b/include/asm-sh64/mmu.h
deleted file mode 100644
index ccd36d26615a..000000000000
--- a/include/asm-sh64/mmu.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __MMU_H
2#define __MMU_H
3
4/* Default "unsigned long" context */
5typedef unsigned long mm_context_t;
6
7#endif
diff --git a/include/asm-sh64/mmu_context.h b/include/asm-sh64/mmu_context.h
deleted file mode 100644
index 507bf72bb8e1..000000000000
--- a/include/asm-sh64/mmu_context.h
+++ /dev/null
@@ -1,208 +0,0 @@
1#ifndef __ASM_SH64_MMU_CONTEXT_H
2#define __ASM_SH64_MMU_CONTEXT_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/mmu_context.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 *
14 * ASID handling idea taken from MIPS implementation.
15 *
16 */
17
18#ifndef __ASSEMBLY__
19
20/*
21 * Cache of MMU context last used.
22 *
23 * The MMU "context" consists of two things:
24 * (a) TLB cache version (or cycle, top 24 bits of mmu_context_cache)
25 * (b) ASID (Address Space IDentifier, bottom 8 bits of mmu_context_cache)
26 */
27extern unsigned long mmu_context_cache;
28
29#include <asm/page.h>
30#include <asm-generic/mm_hooks.h>
31
32/* Current mm's pgd */
33extern pgd_t *mmu_pdtp_cache;
34
35#define SR_ASID_MASK 0xffffffffff00ffffULL
36#define SR_ASID_SHIFT 16
37
38#define MMU_CONTEXT_ASID_MASK 0x000000ff
39#define MMU_CONTEXT_VERSION_MASK 0xffffff00
40#define MMU_CONTEXT_FIRST_VERSION 0x00000100
41#define NO_CONTEXT 0
42
43/* ASID is 8-bit value, so it can't be 0x100 */
44#define MMU_NO_ASID 0x100
45
46
47/*
48 * Virtual Page Number mask
49 */
50#define MMU_VPN_MASK 0xfffff000
51
52static inline void
53get_new_mmu_context(struct mm_struct *mm)
54{
55 extern void flush_tlb_all(void);
56 extern void flush_cache_all(void);
57
58 unsigned long mc = ++mmu_context_cache;
59
60 if (!(mc & MMU_CONTEXT_ASID_MASK)) {
61 /* We exhaust ASID of this version.
62 Flush all TLB and start new cycle. */
63 flush_tlb_all();
64 /* We have to flush all caches as ASIDs are
65 used in cache */
66 flush_cache_all();
67 /* Fix version if needed.
68 Note that we avoid version #0/asid #0 to distingush NO_CONTEXT. */
69 if (!mc)
70 mmu_context_cache = mc = MMU_CONTEXT_FIRST_VERSION;
71 }
72 mm->context = mc;
73}
74
75/*
76 * Get MMU context if needed.
77 */
78static __inline__ void
79get_mmu_context(struct mm_struct *mm)
80{
81 if (mm) {
82 unsigned long mc = mmu_context_cache;
83 /* Check if we have old version of context.
84 If it's old, we need to get new context with new version. */
85 if ((mm->context ^ mc) & MMU_CONTEXT_VERSION_MASK)
86 get_new_mmu_context(mm);
87 }
88}
89
90/*
91 * Initialize the context related info for a new mm_struct
92 * instance.
93 */
94static inline int init_new_context(struct task_struct *tsk,
95 struct mm_struct *mm)
96{
97 mm->context = NO_CONTEXT;
98
99 return 0;
100}
101
102/*
103 * Destroy context related info for an mm_struct that is about
104 * to be put to rest.
105 */
106static inline void destroy_context(struct mm_struct *mm)
107{
108 extern void flush_tlb_mm(struct mm_struct *mm);
109
110 /* Well, at least free TLB entries */
111 flush_tlb_mm(mm);
112}
113
114#endif /* __ASSEMBLY__ */
115
116/* Common defines */
117#define TLB_STEP 0x00000010
118#define TLB_PTEH 0x00000000
119#define TLB_PTEL 0x00000008
120
121/* PTEH defines */
122#define PTEH_ASID_SHIFT 2
123#define PTEH_VALID 0x0000000000000001
124#define PTEH_SHARED 0x0000000000000002
125#define PTEH_MATCH_ASID 0x00000000000003ff
126
127#ifndef __ASSEMBLY__
128/* This has to be a common function because the next location to fill
129 * information is shared. */
130extern void __do_tlb_refill(unsigned long address, unsigned long long is_text_not_data, pte_t *pte);
131
132/* Profiling counter. */
133#ifdef CONFIG_SH64_PROC_TLB
134extern unsigned long long calls_to_do_fast_page_fault;
135#endif
136
137static inline unsigned long get_asid(void)
138{
139 unsigned long long sr;
140
141 asm volatile ("getcon " __SR ", %0\n\t"
142 : "=r" (sr));
143
144 sr = (sr >> SR_ASID_SHIFT) & MMU_CONTEXT_ASID_MASK;
145 return (unsigned long) sr;
146}
147
148/* Set ASID into SR */
149static inline void set_asid(unsigned long asid)
150{
151 unsigned long long sr, pc;
152
153 asm volatile ("getcon " __SR ", %0" : "=r" (sr));
154
155 sr = (sr & SR_ASID_MASK) | (asid << SR_ASID_SHIFT);
156
157 /*
158 * It is possible that this function may be inlined and so to avoid
159 * the assembler reporting duplicate symbols we make use of the gas trick
160 * of generating symbols using numerics and forward reference.
161 */
162 asm volatile ("movi 1, %1\n\t"
163 "shlli %1, 28, %1\n\t"
164 "or %0, %1, %1\n\t"
165 "putcon %1, " __SR "\n\t"
166 "putcon %0, " __SSR "\n\t"
167 "movi 1f, %1\n\t"
168 "ori %1, 1 , %1\n\t"
169 "putcon %1, " __SPC "\n\t"
170 "rte\n"
171 "1:\n\t"
172 : "=r" (sr), "=r" (pc) : "0" (sr));
173}
174
175/*
176 * After we have set current->mm to a new value, this activates
177 * the context for the new mm so we see the new mappings.
178 */
179static __inline__ void activate_context(struct mm_struct *mm)
180{
181 get_mmu_context(mm);
182 set_asid(mm->context & MMU_CONTEXT_ASID_MASK);
183}
184
185
186static __inline__ void switch_mm(struct mm_struct *prev,
187 struct mm_struct *next,
188 struct task_struct *tsk)
189{
190 if (prev != next) {
191 mmu_pdtp_cache = next->pgd;
192 activate_context(next);
193 }
194}
195
196#define deactivate_mm(tsk,mm) do { } while (0)
197
198#define activate_mm(prev, next) \
199 switch_mm((prev),(next),NULL)
200
201static inline void
202enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
203{
204}
205
206#endif /* __ASSEMBLY__ */
207
208#endif /* __ASM_SH64_MMU_CONTEXT_H */
diff --git a/include/asm-sh64/module.h b/include/asm-sh64/module.h
deleted file mode 100644
index c313650d3d93..000000000000
--- a/include/asm-sh64/module.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef __ASM_SH64_MODULE_H
2#define __ASM_SH64_MODULE_H
3/*
4 * This file contains the SH architecture specific module code.
5 */
6
7struct mod_arch_specific {
8 /* empty */
9};
10
11#define Elf_Shdr Elf32_Shdr
12#define Elf_Sym Elf32_Sym
13#define Elf_Ehdr Elf32_Ehdr
14
15#define module_map(x) vmalloc(x)
16#define module_unmap(x) vfree(x)
17#define module_arch_init(x) (0)
18#define arch_init_modules(x) do { } while (0)
19
20#endif /* __ASM_SH64_MODULE_H */
diff --git a/include/asm-sh64/msgbuf.h b/include/asm-sh64/msgbuf.h
deleted file mode 100644
index cf0494ce0ba8..000000000000
--- a/include/asm-sh64/msgbuf.h
+++ /dev/null
@@ -1,42 +0,0 @@
1#ifndef __ASM_SH64_MSGBUF_H
2#define __ASM_SH64_MSGBUF_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/msgbuf.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/*
16 * The msqid64_ds structure for i386 architecture.
17 * Note extra padding because this structure is passed back and forth
18 * between kernel and user space.
19 *
20 * Pad space is left for:
21 * - 64-bit time_t to solve y2038 problem
22 * - 2 miscellaneous 32-bit values
23 */
24
25struct msqid64_ds {
26 struct ipc64_perm msg_perm;
27 __kernel_time_t msg_stime; /* last msgsnd time */
28 unsigned long __unused1;
29 __kernel_time_t msg_rtime; /* last msgrcv time */
30 unsigned long __unused2;
31 __kernel_time_t msg_ctime; /* last change time */
32 unsigned long __unused3;
33 unsigned long msg_cbytes; /* current number of bytes on queue */
34 unsigned long msg_qnum; /* number of messages in queue */
35 unsigned long msg_qbytes; /* max number of bytes on queue */
36 __kernel_pid_t msg_lspid; /* pid of last msgsnd */
37 __kernel_pid_t msg_lrpid; /* last receive pid */
38 unsigned long __unused4;
39 unsigned long __unused5;
40};
41
42#endif /* __ASM_SH64_MSGBUF_H */
diff --git a/include/asm-sh64/mutex.h b/include/asm-sh64/mutex.h
deleted file mode 100644
index 458c1f7fbc18..000000000000
--- a/include/asm-sh64/mutex.h
+++ /dev/null
@@ -1,9 +0,0 @@
1/*
2 * Pull in the generic implementation for the mutex fastpath.
3 *
4 * TODO: implement optimized primitives instead, or leave the generic
5 * implementation in place, or pick the atomic_xchg() based generic
6 * implementation. (see asm-generic/mutex-xchg.h for details)
7 */
8
9#include <asm-generic/mutex-dec.h>
diff --git a/include/asm-sh64/namei.h b/include/asm-sh64/namei.h
deleted file mode 100644
index 99d759a805ce..000000000000
--- a/include/asm-sh64/namei.h
+++ /dev/null
@@ -1,24 +0,0 @@
1#ifndef __ASM_SH64_NAMEI_H
2#define __ASM_SH64_NAMEI_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/namei.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 * Included from linux/fs/namei.c
14 *
15 */
16
17/* This dummy routine maybe changed to something useful
18 * for /usr/gnemul/ emulation stuff.
19 * Look at asm-sparc/namei.h for details.
20 */
21
22#define __emul_prefix() NULL
23
24#endif /* __ASM_SH64_NAMEI_H */
diff --git a/include/asm-sh64/page.h b/include/asm-sh64/page.h
deleted file mode 100644
index 472089aefc60..000000000000
--- a/include/asm-sh64/page.h
+++ /dev/null
@@ -1,119 +0,0 @@
1#ifndef __ASM_SH64_PAGE_H
2#define __ASM_SH64_PAGE_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/page.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003, 2004 Paul Mundt
13 *
14 * benedict.gaster@superh.com 19th, 24th July 2002.
15 *
16 * Modified to take account of enabling for D-CACHE support.
17 *
18 */
19
20
21/* PAGE_SHIFT determines the page size */
22#define PAGE_SHIFT 12
23#ifdef __ASSEMBLY__
24#define PAGE_SIZE 4096
25#else
26#define PAGE_SIZE (1UL << PAGE_SHIFT)
27#endif
28#define PAGE_MASK (~(PAGE_SIZE-1))
29#define PTE_MASK PAGE_MASK
30
31#if defined(CONFIG_HUGETLB_PAGE_SIZE_64K)
32#define HPAGE_SHIFT 16
33#elif defined(CONFIG_HUGETLB_PAGE_SIZE_1MB)
34#define HPAGE_SHIFT 20
35#elif defined(CONFIG_HUGETLB_PAGE_SIZE_512MB)
36#define HPAGE_SHIFT 29
37#endif
38
39#ifdef CONFIG_HUGETLB_PAGE
40#define HPAGE_SIZE (1UL << HPAGE_SHIFT)
41#define HPAGE_MASK (~(HPAGE_SIZE-1))
42#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT-PAGE_SHIFT)
43#define ARCH_HAS_SETCLEAR_HUGE_PTE
44#endif
45
46#ifdef __KERNEL__
47#ifndef __ASSEMBLY__
48
49extern struct page *mem_map;
50extern void sh64_page_clear(void *page);
51extern void sh64_page_copy(void *from, void *to);
52
53#define clear_page(page) sh64_page_clear(page)
54#define copy_page(to,from) sh64_page_copy(from, to)
55
56#if defined(CONFIG_DCACHE_DISABLED)
57
58#define clear_user_page(page, vaddr, pg) clear_page(page)
59#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
60
61#else
62
63extern void clear_user_page(void *to, unsigned long address, struct page *pg);
64extern void copy_user_page(void *to, void *from, unsigned long address, struct page *pg);
65
66#endif /* defined(CONFIG_DCACHE_DISABLED) */
67
68/*
69 * These are used to make use of C type-checking..
70 */
71typedef struct { unsigned long long pte; } pte_t;
72typedef struct { unsigned long pmd; } pmd_t;
73typedef struct { unsigned long pgd; } pgd_t;
74typedef struct { unsigned long pgprot; } pgprot_t;
75
76#define pte_val(x) ((x).pte)
77#define pmd_val(x) ((x).pmd)
78#define pgd_val(x) ((x).pgd)
79#define pgprot_val(x) ((x).pgprot)
80
81#define __pte(x) ((pte_t) { (x) } )
82#define __pmd(x) ((pmd_t) { (x) } )
83#define __pgd(x) ((pgd_t) { (x) } )
84#define __pgprot(x) ((pgprot_t) { (x) } )
85
86#endif /* !__ASSEMBLY__ */
87
88/* to align the pointer to the (next) page boundary */
89#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
90
91/*
92 * Kconfig defined.
93 */
94#define __MEMORY_START (CONFIG_MEMORY_START)
95#define PAGE_OFFSET (CONFIG_CACHED_MEMORY_OFFSET)
96
97#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
98#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
99#define MAP_NR(addr) ((__pa(addr)-__MEMORY_START) >> PAGE_SHIFT)
100#define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
101
102#define phys_to_page(phys) (mem_map + (((phys) - __MEMORY_START) >> PAGE_SHIFT))
103#define page_to_phys(page) (((page - mem_map) << PAGE_SHIFT) + __MEMORY_START)
104
105/* PFN start number, because of __MEMORY_START */
106#define PFN_START (__MEMORY_START >> PAGE_SHIFT)
107#define ARCH_PFN_OFFSET (PFN_START)
108#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
109#define pfn_valid(pfn) (((pfn) - PFN_START) < max_mapnr)
110#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
111
112#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
113 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
114
115#include <asm-generic/memory_model.h>
116#include <asm-generic/page.h>
117
118#endif /* __KERNEL__ */
119#endif /* __ASM_SH64_PAGE_H */
diff --git a/include/asm-sh64/param.h b/include/asm-sh64/param.h
deleted file mode 100644
index f409adb41540..000000000000
--- a/include/asm-sh64/param.h
+++ /dev/null
@@ -1,42 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * include/asm-sh64/param.h
7 *
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2003 Paul Mundt
10 *
11 */
12#ifndef __ASM_SH64_PARAM_H
13#define __ASM_SH64_PARAM_H
14
15
16#ifdef __KERNEL__
17# ifdef CONFIG_SH_WDT
18# define HZ 1000 /* Needed for high-res WOVF */
19# else
20# define HZ 100
21# endif
22# define USER_HZ 100 /* User interfaces are in "ticks" */
23# define CLOCKS_PER_SEC (USER_HZ) /* frequency at which times() counts */
24#endif
25
26#ifndef HZ
27#define HZ 100
28#endif
29
30#define EXEC_PAGESIZE 4096
31
32#ifndef NGROUPS
33#define NGROUPS 32
34#endif
35
36#ifndef NOGROUP
37#define NOGROUP (-1)
38#endif
39
40#define MAXHOSTNAMELEN 64 /* max length of hostname */
41
42#endif /* __ASM_SH64_PARAM_H */
diff --git a/include/asm-sh64/pci.h b/include/asm-sh64/pci.h
deleted file mode 100644
index 57a67cf7a5c4..000000000000
--- a/include/asm-sh64/pci.h
+++ /dev/null
@@ -1,111 +0,0 @@
1#ifndef __ASM_SH64_PCI_H
2#define __ASM_SH64_PCI_H
3
4#ifdef __KERNEL__
5
6#include <linux/dma-mapping.h>
7
8/* Can be used to override the logic in pci_scan_bus for skipping
9 already-configured bus numbers - to be used for buggy BIOSes
10 or architectures with incomplete PCI setup by the loader */
11
12#define pcibios_assign_all_busses() 1
13
14/*
15 * These are currently the correct values for the STM overdrive board
16 * We need some way of setting this on a board specific way, it will
17 * not be the same on other boards I think
18 */
19#if defined(CONFIG_CPU_SUBTYPE_SH5_101) || defined(CONFIG_CPU_SUBTYPE_SH5_103)
20#define PCIBIOS_MIN_IO 0x2000
21#define PCIBIOS_MIN_MEM 0x40000000
22#endif
23
24extern void pcibios_set_master(struct pci_dev *dev);
25
26/*
27 * Set penalize isa irq function
28 */
29static inline void pcibios_penalize_isa_irq(int irq, int active)
30{
31 /* We don't do dynamic PCI IRQ allocation */
32}
33
34/* Dynamic DMA mapping stuff.
35 * SuperH has everything mapped statically like x86.
36 */
37
38/* The PCI address space does equal the physical memory
39 * address space. The networking and block device layers use
40 * this boolean for bounce buffer decisions.
41 */
42#define PCI_DMA_BUS_IS_PHYS (1)
43
44#include <linux/types.h>
45#include <linux/slab.h>
46#include <asm/scatterlist.h>
47#include <linux/string.h>
48#include <asm/io.h>
49
50/* pci_unmap_{single,page} being a nop depends upon the
51 * configuration.
52 */
53#ifdef CONFIG_SH_PCIDMA_NONCOHERENT
54#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
55 dma_addr_t ADDR_NAME;
56#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
57 __u32 LEN_NAME;
58#define pci_unmap_addr(PTR, ADDR_NAME) \
59 ((PTR)->ADDR_NAME)
60#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
61 (((PTR)->ADDR_NAME) = (VAL))
62#define pci_unmap_len(PTR, LEN_NAME) \
63 ((PTR)->LEN_NAME)
64#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
65 (((PTR)->LEN_NAME) = (VAL))
66#else
67#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
68#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
69#define pci_unmap_addr(PTR, ADDR_NAME) (0)
70#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
71#define pci_unmap_len(PTR, LEN_NAME) (0)
72#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
73#endif
74
75/* These macros should be used after a pci_map_sg call has been done
76 * to get bus addresses of each of the SG entries and their lengths.
77 * You should only work with the number of sg entries pci_map_sg
78 * returns, or alternatively stop on the first sg_dma_len(sg) which
79 * is 0.
80 */
81#define sg_dma_address(sg) ((sg)->dma_address)
82#define sg_dma_len(sg) ((sg)->length)
83
84#ifdef CONFIG_PCI
85static inline void pci_dma_burst_advice(struct pci_dev *pdev,
86 enum pci_dma_burst_strategy *strat,
87 unsigned long *strategy_parameter)
88{
89 *strat = PCI_DMA_BURST_INFINITY;
90 *strategy_parameter = ~0UL;
91}
92#endif
93
94/* Board-specific fixup routines. */
95extern void pcibios_fixup(void);
96extern void pcibios_fixup_irqs(void);
97
98#ifdef CONFIG_PCI_AUTO
99extern int pciauto_assign_resources(int busno, struct pci_channel *hose);
100#endif
101
102#endif /* __KERNEL__ */
103
104/* generic pci stuff */
105#include <asm-generic/pci.h>
106
107/* generic DMA-mapping stuff */
108#include <asm-generic/pci-dma-compat.h>
109
110#endif /* __ASM_SH64_PCI_H */
111
diff --git a/include/asm-sh64/percpu.h b/include/asm-sh64/percpu.h
deleted file mode 100644
index a01d16cd0e8c..000000000000
--- a/include/asm-sh64/percpu.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_PERCPU
2#define __ASM_SH64_PERCPU
3
4#include <asm-generic/percpu.h>
5
6#endif /* __ASM_SH64_PERCPU */
diff --git a/include/asm-sh64/pgalloc.h b/include/asm-sh64/pgalloc.h
deleted file mode 100644
index 6eccab770a6d..000000000000
--- a/include/asm-sh64/pgalloc.h
+++ /dev/null
@@ -1,125 +0,0 @@
1#ifndef __ASM_SH64_PGALLOC_H
2#define __ASM_SH64_PGALLOC_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/pgalloc.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003, 2004 Paul Mundt
13 * Copyright (C) 2003, 2004 Richard Curnow
14 *
15 */
16
17#include <linux/mm.h>
18#include <linux/quicklist.h>
19#include <asm/page.h>
20
21static inline void pgd_init(unsigned long page)
22{
23 unsigned long *pgd = (unsigned long *)page;
24 extern pte_t empty_bad_pte_table[PTRS_PER_PTE];
25 int i;
26
27 for (i = 0; i < USER_PTRS_PER_PGD; i++)
28 pgd[i] = (unsigned long)empty_bad_pte_table;
29}
30
31/*
32 * Allocate and free page tables. The xxx_kernel() versions are
33 * used to allocate a kernel page table - this turns on ASN bits
34 * if any.
35 */
36
37static inline pgd_t *get_pgd_slow(void)
38{
39 unsigned int pgd_size = (USER_PTRS_PER_PGD * sizeof(pgd_t));
40 pgd_t *ret = kmalloc(pgd_size, GFP_KERNEL);
41 return ret;
42}
43
44static inline pgd_t *pgd_alloc(struct mm_struct *mm)
45{
46 return quicklist_alloc(0, GFP_KERNEL, NULL);
47}
48
49static inline void pgd_free(pgd_t *pgd)
50{
51 quicklist_free(0, NULL, pgd);
52}
53
54static inline struct page *pte_alloc_one(struct mm_struct *mm,
55 unsigned long address)
56{
57 void *pg = quicklist_alloc(0, GFP_KERNEL, NULL);
58 return pg ? virt_to_page(pg) : NULL;
59}
60
61static inline void pte_free_kernel(pte_t *pte)
62{
63 quicklist_free(0, NULL, pte);
64}
65
66static inline void pte_free(struct page *pte)
67{
68 quicklist_free_page(0, NULL, pte);
69}
70
71static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
72 unsigned long address)
73{
74 return quicklist_alloc(0, GFP_KERNEL, NULL);
75}
76
77#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
78
79/*
80 * allocating and freeing a pmd is trivial: the 1-entry pmd is
81 * inside the pgd, so has no extra memory associated with it.
82 */
83
84#if defined(CONFIG_SH64_PGTABLE_2_LEVEL)
85
86#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
87#define pmd_free(x) do { } while (0)
88#define pgd_populate(mm, pmd, pte) BUG()
89#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
90#define __pmd_free_tlb(tlb,pmd) do { } while (0)
91
92#elif defined(CONFIG_SH64_PGTABLE_3_LEVEL)
93
94static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
95{
96 return quicklist_alloc(0, GFP_KERNEL, NULL);
97}
98
99static inline void pmd_free(pmd_t *pmd)
100{
101 quicklist_free(0, NULL, pmd);
102}
103
104#define pgd_populate(mm, pgd, pmd) pgd_set(pgd, pmd)
105#define __pmd_free_tlb(tlb,pmd) pmd_free(pmd)
106
107#else
108#error "No defined page table size"
109#endif
110
111#define pmd_populate_kernel(mm, pmd, pte) \
112 set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) (pte)))
113
114static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
115 struct page *pte)
116{
117 set_pmd(pmd, __pmd(_PAGE_TABLE + (unsigned long) page_address (pte)));
118}
119
120static inline void check_pgt_cache(void)
121{
122 quicklist_trim(0, NULL, 25, 16);
123}
124
125#endif /* __ASM_SH64_PGALLOC_H */
diff --git a/include/asm-sh64/platform.h b/include/asm-sh64/platform.h
deleted file mode 100644
index bd0d9c405a80..000000000000
--- a/include/asm-sh64/platform.h
+++ /dev/null
@@ -1,64 +0,0 @@
1#ifndef __ASM_SH64_PLATFORM_H
2#define __ASM_SH64_PLATFORM_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/platform.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 * benedict.gaster@superh.com: 3rd May 2002
14 * Added support for ramdisk, removing statically linked romfs at the same time.
15 */
16
17#include <linux/ioport.h>
18#include <asm/irq.h>
19
20
21/*
22 * Platform definition structure.
23 */
24struct sh64_platform {
25 unsigned int readonly_rootfs;
26 unsigned int ramdisk_flags;
27 unsigned int initial_root_dev;
28 unsigned int loader_type;
29 unsigned int initrd_start;
30 unsigned int initrd_size;
31 unsigned int fpu_flags;
32 unsigned int io_res_count;
33 unsigned int kram_res_count;
34 unsigned int xram_res_count;
35 unsigned int rom_res_count;
36 struct resource *io_res_p;
37 struct resource *kram_res_p;
38 struct resource *xram_res_p;
39 struct resource *rom_res_p;
40};
41
42extern struct sh64_platform platform_parms;
43
44extern unsigned long long memory_start, memory_end;
45
46extern unsigned long long fpu_in_use;
47
48extern int platform_int_priority[NR_INTC_IRQS];
49
50#define FPU_FLAGS (platform_parms.fpu_flags)
51#define STANDARD_IO_RESOURCES (platform_parms.io_res_count)
52#define STANDARD_KRAM_RESOURCES (platform_parms.kram_res_count)
53#define STANDARD_XRAM_RESOURCES (platform_parms.xram_res_count)
54#define STANDARD_ROM_RESOURCES (platform_parms.rom_res_count)
55
56/*
57 * Kernel Memory description, Respectively:
58 * code = last but one memory descriptor
59 * data = last memory descriptor
60 */
61#define code_resource (platform_parms.kram_res_p[STANDARD_KRAM_RESOURCES - 2])
62#define data_resource (platform_parms.kram_res_p[STANDARD_KRAM_RESOURCES - 1])
63
64#endif /* __ASM_SH64_PLATFORM_H */
diff --git a/include/asm-sh64/poll.h b/include/asm-sh64/poll.h
deleted file mode 100644
index ca2950267c53..000000000000
--- a/include/asm-sh64/poll.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef __ASM_SH64_POLL_H
2#define __ASM_SH64_POLL_H
3
4#include <asm-generic/poll.h>
5
6#undef POLLREMOVE
7
8#endif /* __ASM_SH64_POLL_H */
diff --git a/include/asm-sh64/ptrace.h b/include/asm-sh64/ptrace.h
deleted file mode 100644
index a6d4da519db6..000000000000
--- a/include/asm-sh64/ptrace.h
+++ /dev/null
@@ -1,37 +0,0 @@
1#ifndef __ASM_SH64_PTRACE_H
2#define __ASM_SH64_PTRACE_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/ptrace.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/*
16 * This struct defines the way the registers are stored on the
17 * kernel stack during a system call or other kernel entry.
18 */
19struct pt_regs {
20 unsigned long long pc;
21 unsigned long long sr;
22 unsigned long long syscall_nr;
23 unsigned long long regs[63];
24 unsigned long long tregs[8];
25 unsigned long long pad[2];
26};
27
28#ifdef __KERNEL__
29#define user_mode(regs) (((regs)->sr & 0x40000000)==0)
30#define instruction_pointer(regs) ((regs)->pc)
31#define profile_pc(regs) ((unsigned long)instruction_pointer(regs))
32extern void show_regs(struct pt_regs *);
33#endif
34
35#define PTRACE_O_TRACESYSGOOD 0x00000001
36
37#endif /* __ASM_SH64_PTRACE_H */
diff --git a/include/asm-sh64/resource.h b/include/asm-sh64/resource.h
deleted file mode 100644
index 8ff93944ae66..000000000000
--- a/include/asm-sh64/resource.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_RESOURCE_H
2#define __ASM_SH64_RESOURCE_H
3
4#include <asm-sh/resource.h>
5
6#endif /* __ASM_SH64_RESOURCE_H */
diff --git a/include/asm-sh64/scatterlist.h b/include/asm-sh64/scatterlist.h
deleted file mode 100644
index 5109251970e7..000000000000
--- a/include/asm-sh64/scatterlist.h
+++ /dev/null
@@ -1,28 +0,0 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * include/asm-sh64/scatterlist.h
7 *
8 * Copyright (C) 2003 Paul Mundt
9 *
10 */
11#ifndef __ASM_SH64_SCATTERLIST_H
12#define __ASM_SH64_SCATTERLIST_H
13
14#include <asm/types.h>
15
16struct scatterlist {
17#ifdef CONFIG_DEBUG_SG
18 unsigned long sg_magic;
19#endif
20 unsigned long page_link;
21 unsigned int offset;/* for highmem, page offset */
22 dma_addr_t dma_address;
23 unsigned int length;
24};
25
26#define ISA_DMA_THRESHOLD (0xffffffff)
27
28#endif /* !__ASM_SH64_SCATTERLIST_H */
diff --git a/include/asm-sh64/sci.h b/include/asm-sh64/sci.h
deleted file mode 100644
index 793c568b7820..000000000000
--- a/include/asm-sh64/sci.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-sh/sci.h>
diff --git a/include/asm-sh64/sections.h b/include/asm-sh64/sections.h
deleted file mode 100644
index 897f36bcdf85..000000000000
--- a/include/asm-sh64/sections.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef __ASM_SH64_SECTIONS_H
2#define __ASM_SH64_SECTIONS_H
3
4#include <asm-sh/sections.h>
5
6#endif /* __ASM_SH64_SECTIONS_H */
7
diff --git a/include/asm-sh64/segment.h b/include/asm-sh64/segment.h
deleted file mode 100644
index 92ac001fc483..000000000000
--- a/include/asm-sh64/segment.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_SEGMENT_H
2#define _ASM_SEGMENT_H
3
4/* Only here because we have some old header files that expect it.. */
5
6#endif /* _ASM_SEGMENT_H */
diff --git a/include/asm-sh64/semaphore-helper.h b/include/asm-sh64/semaphore-helper.h
deleted file mode 100644
index fcfafe263e86..000000000000
--- a/include/asm-sh64/semaphore-helper.h
+++ /dev/null
@@ -1,101 +0,0 @@
1#ifndef __ASM_SH64_SEMAPHORE_HELPER_H
2#define __ASM_SH64_SEMAPHORE_HELPER_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/semaphore-helper.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14#include <asm/errno.h>
15
16/*
17 * SMP- and interrupt-safe semaphores helper functions.
18 *
19 * (C) Copyright 1996 Linus Torvalds
20 * (C) Copyright 1999 Andrea Arcangeli
21 */
22
23/*
24 * These two _must_ execute atomically wrt each other.
25 *
26 * This is trivially done with load_locked/store_cond,
27 * which we have. Let the rest of the losers suck eggs.
28 */
29static __inline__ void wake_one_more(struct semaphore * sem)
30{
31 atomic_inc((atomic_t *)&sem->sleepers);
32}
33
34static __inline__ int waking_non_zero(struct semaphore *sem)
35{
36 unsigned long flags;
37 int ret = 0;
38
39 spin_lock_irqsave(&semaphore_wake_lock, flags);
40 if (sem->sleepers > 0) {
41 sem->sleepers--;
42 ret = 1;
43 }
44 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
45 return ret;
46}
47
48/*
49 * waking_non_zero_interruptible:
50 * 1 got the lock
51 * 0 go to sleep
52 * -EINTR interrupted
53 *
54 * We must undo the sem->count down_interruptible() increment while we are
55 * protected by the spinlock in order to make atomic this atomic_inc() with the
56 * atomic_read() in wake_one_more(), otherwise we can race. -arca
57 */
58static __inline__ int waking_non_zero_interruptible(struct semaphore *sem,
59 struct task_struct *tsk)
60{
61 unsigned long flags;
62 int ret = 0;
63
64 spin_lock_irqsave(&semaphore_wake_lock, flags);
65 if (sem->sleepers > 0) {
66 sem->sleepers--;
67 ret = 1;
68 } else if (signal_pending(tsk)) {
69 atomic_inc(&sem->count);
70 ret = -EINTR;
71 }
72 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
73 return ret;
74}
75
76/*
77 * waking_non_zero_trylock:
78 * 1 failed to lock
79 * 0 got the lock
80 *
81 * We must undo the sem->count down_trylock() increment while we are
82 * protected by the spinlock in order to make atomic this atomic_inc() with the
83 * atomic_read() in wake_one_more(), otherwise we can race. -arca
84 */
85static __inline__ int waking_non_zero_trylock(struct semaphore *sem)
86{
87 unsigned long flags;
88 int ret = 1;
89
90 spin_lock_irqsave(&semaphore_wake_lock, flags);
91 if (sem->sleepers <= 0)
92 atomic_inc(&sem->count);
93 else {
94 sem->sleepers--;
95 ret = 0;
96 }
97 spin_unlock_irqrestore(&semaphore_wake_lock, flags);
98 return ret;
99}
100
101#endif /* __ASM_SH64_SEMAPHORE_HELPER_H */
diff --git a/include/asm-sh64/semaphore.h b/include/asm-sh64/semaphore.h
deleted file mode 100644
index f027cc14b55b..000000000000
--- a/include/asm-sh64/semaphore.h
+++ /dev/null
@@ -1,119 +0,0 @@
1#ifndef __ASM_SH64_SEMAPHORE_H
2#define __ASM_SH64_SEMAPHORE_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/semaphore.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 * SMP- and interrupt-safe semaphores.
14 *
15 * (C) Copyright 1996 Linus Torvalds
16 *
17 * SuperH verison by Niibe Yutaka
18 * (Currently no asm implementation but generic C code...)
19 *
20 */
21
22#include <linux/linkage.h>
23#include <linux/spinlock.h>
24#include <linux/wait.h>
25#include <linux/rwsem.h>
26
27#include <asm/system.h>
28#include <asm/atomic.h>
29
30struct semaphore {
31 atomic_t count;
32 int sleepers;
33 wait_queue_head_t wait;
34};
35
36#define __SEMAPHORE_INITIALIZER(name, n) \
37{ \
38 .count = ATOMIC_INIT(n), \
39 .sleepers = 0, \
40 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
41}
42
43#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
44 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
45
46#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
47
48static inline void sema_init (struct semaphore *sem, int val)
49{
50/*
51 * *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
52 *
53 * i'd rather use the more flexible initialization above, but sadly
54 * GCC 2.7.2.3 emits a bogus warning. EGCS doesnt. Oh well.
55 */
56 atomic_set(&sem->count, val);
57 sem->sleepers = 0;
58 init_waitqueue_head(&sem->wait);
59}
60
61static inline void init_MUTEX (struct semaphore *sem)
62{
63 sema_init(sem, 1);
64}
65
66static inline void init_MUTEX_LOCKED (struct semaphore *sem)
67{
68 sema_init(sem, 0);
69}
70
71#if 0
72asmlinkage void __down_failed(void /* special register calling convention */);
73asmlinkage int __down_failed_interruptible(void /* params in registers */);
74asmlinkage int __down_failed_trylock(void /* params in registers */);
75asmlinkage void __up_wakeup(void /* special register calling convention */);
76#endif
77
78asmlinkage void __down(struct semaphore * sem);
79asmlinkage int __down_interruptible(struct semaphore * sem);
80asmlinkage int __down_trylock(struct semaphore * sem);
81asmlinkage void __up(struct semaphore * sem);
82
83extern spinlock_t semaphore_wake_lock;
84
85static inline void down(struct semaphore * sem)
86{
87 if (atomic_dec_return(&sem->count) < 0)
88 __down(sem);
89}
90
91static inline int down_interruptible(struct semaphore * sem)
92{
93 int ret = 0;
94
95 if (atomic_dec_return(&sem->count) < 0)
96 ret = __down_interruptible(sem);
97 return ret;
98}
99
100static inline int down_trylock(struct semaphore * sem)
101{
102 int ret = 0;
103
104 if (atomic_dec_return(&sem->count) < 0)
105 ret = __down_trylock(sem);
106 return ret;
107}
108
109/*
110 * Note! This is subtle. We jump to wake people up only if
111 * the semaphore was negative (== somebody was waiting on it).
112 */
113static inline void up(struct semaphore * sem)
114{
115 if (atomic_inc_return(&sem->count) <= 0)
116 __up(sem);
117}
118
119#endif /* __ASM_SH64_SEMAPHORE_H */
diff --git a/include/asm-sh64/sembuf.h b/include/asm-sh64/sembuf.h
deleted file mode 100644
index ec4d9f143577..000000000000
--- a/include/asm-sh64/sembuf.h
+++ /dev/null
@@ -1,36 +0,0 @@
1#ifndef __ASM_SH64_SEMBUF_H
2#define __ASM_SH64_SEMBUF_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/sembuf.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/*
16 * The semid64_ds structure for i386 architecture.
17 * Note extra padding because this structure is passed back and forth
18 * between kernel and user space.
19 *
20 * Pad space is left for:
21 * - 64-bit time_t to solve y2038 problem
22 * - 2 miscellaneous 32-bit values
23 */
24
25struct semid64_ds {
26 struct ipc64_perm sem_perm; /* permissions .. see ipc.h */
27 __kernel_time_t sem_otime; /* last semop time */
28 unsigned long __unused1;
29 __kernel_time_t sem_ctime; /* last change time */
30 unsigned long __unused2;
31 unsigned long sem_nsems; /* no. of semaphores in array */
32 unsigned long __unused3;
33 unsigned long __unused4;
34};
35
36#endif /* __ASM_SH64_SEMBUF_H */
diff --git a/include/asm-sh64/serial.h b/include/asm-sh64/serial.h
deleted file mode 100644
index e8d7b3f2da57..000000000000
--- a/include/asm-sh64/serial.h
+++ /dev/null
@@ -1,31 +0,0 @@
1/*
2 * include/asm-sh64/serial.h
3 *
4 * Configuration details for 8250, 16450, 16550, etc. serial ports
5 */
6
7#ifndef _ASM_SERIAL_H
8#define _ASM_SERIAL_H
9
10/*
11 * This assumes you have a 1.8432 MHz clock for your UART.
12 *
13 * It'd be nice if someone built a serial card with a 24.576 MHz
14 * clock, since the 16550A is capable of handling a top speed of 1.5
15 * megabits/second; but this requires the faster clock.
16 */
17#define BASE_BAUD ( 1843200 / 16 )
18
19#define RS_TABLE_SIZE 2
20
21#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
22
23#define SERIAL_PORT_DFNS \
24 /* UART CLK PORT IRQ FLAGS */ \
25 { 0, BASE_BAUD, 0x3F8, 4, STD_COM_FLAGS }, /* ttyS0 */ \
26 { 0, BASE_BAUD, 0x2F8, 3, STD_COM_FLAGS } /* ttyS1 */
27
28/* XXX: This should be moved ino irq.h */
29#define irq_cannonicalize(x) (x)
30
31#endif /* _ASM_SERIAL_H */
diff --git a/include/asm-sh64/setup.h b/include/asm-sh64/setup.h
deleted file mode 100644
index 5b07b14c2927..000000000000
--- a/include/asm-sh64/setup.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef __ASM_SH64_SETUP_H
2#define __ASM_SH64_SETUP_H
3
4#define COMMAND_LINE_SIZE 256
5
6#ifdef __KERNEL__
7
8#define PARAM ((unsigned char *)empty_zero_page)
9#define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
10#define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
11#define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008))
12#define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
13#define INITRD_START (*(unsigned long *) (PARAM+0x010))
14#define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
15
16#define COMMAND_LINE ((char *) (PARAM+256))
17#define COMMAND_LINE_SIZE 256
18
19#endif /* __KERNEL__ */
20
21#endif /* __ASM_SH64_SETUP_H */
22
diff --git a/include/asm-sh64/shmbuf.h b/include/asm-sh64/shmbuf.h
deleted file mode 100644
index 022f3494dd64..000000000000
--- a/include/asm-sh64/shmbuf.h
+++ /dev/null
@@ -1,53 +0,0 @@
1#ifndef __ASM_SH64_SHMBUF_H
2#define __ASM_SH64_SHMBUF_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/shmbuf.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/*
16 * The shmid64_ds structure for i386 architecture.
17 * Note extra padding because this structure is passed back and forth
18 * between kernel and user space.
19 *
20 * Pad space is left for:
21 * - 64-bit time_t to solve y2038 problem
22 * - 2 miscellaneous 32-bit values
23 */
24
25struct shmid64_ds {
26 struct ipc64_perm shm_perm; /* operation perms */
27 size_t shm_segsz; /* size of segment (bytes) */
28 __kernel_time_t shm_atime; /* last attach time */
29 unsigned long __unused1;
30 __kernel_time_t shm_dtime; /* last detach time */
31 unsigned long __unused2;
32 __kernel_time_t shm_ctime; /* last change time */
33 unsigned long __unused3;
34 __kernel_pid_t shm_cpid; /* pid of creator */
35 __kernel_pid_t shm_lpid; /* pid of last operator */
36 unsigned long shm_nattch; /* no. of current attaches */
37 unsigned long __unused4;
38 unsigned long __unused5;
39};
40
41struct shminfo64 {
42 unsigned long shmmax;
43 unsigned long shmmin;
44 unsigned long shmmni;
45 unsigned long shmseg;
46 unsigned long shmall;
47 unsigned long __unused1;
48 unsigned long __unused2;
49 unsigned long __unused3;
50 unsigned long __unused4;
51};
52
53#endif /* __ASM_SH64_SHMBUF_H */
diff --git a/include/asm-sh64/shmparam.h b/include/asm-sh64/shmparam.h
deleted file mode 100644
index 1bb820c833ee..000000000000
--- a/include/asm-sh64/shmparam.h
+++ /dev/null
@@ -1,12 +0,0 @@
1#ifndef __ASM_SH64_SHMPARAM_H
2#define __ASM_SH64_SHMPARAM_H
3
4/*
5 * Set this to a sensible safe default, we'll work out the specifics for the
6 * align mask from the cache descriptor at run-time.
7 */
8#define SHMLBA 0x4000
9
10#define __ARCH_FORCE_SHMLBA
11
12#endif /* __ASM_SH64_SHMPARAM_H */
diff --git a/include/asm-sh64/sigcontext.h b/include/asm-sh64/sigcontext.h
deleted file mode 100644
index 6293509d8cc1..000000000000
--- a/include/asm-sh64/sigcontext.h
+++ /dev/null
@@ -1,30 +0,0 @@
1#ifndef __ASM_SH64_SIGCONTEXT_H
2#define __ASM_SH64_SIGCONTEXT_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/sigcontext.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15struct sigcontext {
16 unsigned long oldmask;
17
18 /* CPU registers */
19 unsigned long long sc_regs[63];
20 unsigned long long sc_tregs[8];
21 unsigned long long sc_pc;
22 unsigned long long sc_sr;
23
24 /* FPU registers */
25 unsigned long long sc_fpregs[32];
26 unsigned int sc_fpscr;
27 unsigned int sc_fpvalid;
28};
29
30#endif /* __ASM_SH64_SIGCONTEXT_H */
diff --git a/include/asm-sh64/siginfo.h b/include/asm-sh64/siginfo.h
deleted file mode 100644
index 56ef1da534d7..000000000000
--- a/include/asm-sh64/siginfo.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_SIGINFO_H
2#define __ASM_SH64_SIGINFO_H
3
4#include <asm-generic/siginfo.h>
5
6#endif /* __ASM_SH64_SIGINFO_H */
diff --git a/include/asm-sh64/signal.h b/include/asm-sh64/signal.h
deleted file mode 100644
index 244e134730d9..000000000000
--- a/include/asm-sh64/signal.h
+++ /dev/null
@@ -1,159 +0,0 @@
1#ifndef __ASM_SH64_SIGNAL_H
2#define __ASM_SH64_SIGNAL_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/signal.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#include <linux/types.h>
16
17/* Avoid too many header ordering problems. */
18struct siginfo;
19
20#define _NSIG 64
21#define _NSIG_BPW 32
22#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
23
24typedef unsigned long old_sigset_t; /* at least 32 bits */
25
26typedef struct {
27 unsigned long sig[_NSIG_WORDS];
28} sigset_t;
29
30#define SIGHUP 1
31#define SIGINT 2
32#define SIGQUIT 3
33#define SIGILL 4
34#define SIGTRAP 5
35#define SIGABRT 6
36#define SIGIOT 6
37#define SIGBUS 7
38#define SIGFPE 8
39#define SIGKILL 9
40#define SIGUSR1 10
41#define SIGSEGV 11
42#define SIGUSR2 12
43#define SIGPIPE 13
44#define SIGALRM 14
45#define SIGTERM 15
46#define SIGSTKFLT 16
47#define SIGCHLD 17
48#define SIGCONT 18
49#define SIGSTOP 19
50#define SIGTSTP 20
51#define SIGTTIN 21
52#define SIGTTOU 22
53#define SIGURG 23
54#define SIGXCPU 24
55#define SIGXFSZ 25
56#define SIGVTALRM 26
57#define SIGPROF 27
58#define SIGWINCH 28
59#define SIGIO 29
60#define SIGPOLL SIGIO
61/*
62#define SIGLOST 29
63*/
64#define SIGPWR 30
65#define SIGSYS 31
66#define SIGUNUSED 31
67
68/* These should not be considered constants from userland. */
69#define SIGRTMIN 32
70#define SIGRTMAX (_NSIG-1)
71
72/*
73 * SA_FLAGS values:
74 *
75 * SA_ONSTACK indicates that a registered stack_t will be used.
76 * SA_RESTART flag to get restarting signals (which were the default long ago)
77 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
78 * SA_RESETHAND clears the handler when the signal is delivered.
79 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
80 * SA_NODEFER prevents the current signal from being masked in the handler.
81 *
82 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
83 * Unix names RESETHAND and NODEFER respectively.
84 */
85#define SA_NOCLDSTOP 0x00000001
86#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
87#define SA_SIGINFO 0x00000004
88#define SA_ONSTACK 0x08000000
89#define SA_RESTART 0x10000000
90#define SA_NODEFER 0x40000000
91#define SA_RESETHAND 0x80000000
92
93#define SA_NOMASK SA_NODEFER
94#define SA_ONESHOT SA_RESETHAND
95
96#define SA_RESTORER 0x04000000
97
98/*
99 * sigaltstack controls
100 */
101#define SS_ONSTACK 1
102#define SS_DISABLE 2
103
104#define MINSIGSTKSZ 2048
105#define SIGSTKSZ THREAD_SIZE
106
107#include <asm-generic/signal.h>
108
109#ifdef __KERNEL__
110struct old_sigaction {
111 __sighandler_t sa_handler;
112 old_sigset_t sa_mask;
113 unsigned long sa_flags;
114 void (*sa_restorer)(void);
115};
116
117struct sigaction {
118 __sighandler_t sa_handler;
119 unsigned long sa_flags;
120 void (*sa_restorer)(void);
121 sigset_t sa_mask; /* mask last for extensibility */
122};
123
124struct k_sigaction {
125 struct sigaction sa;
126};
127#else
128/* Here we must cater to libcs that poke about in kernel headers. */
129
130struct sigaction {
131 union {
132 __sighandler_t _sa_handler;
133 void (*_sa_sigaction)(int, struct siginfo *, void *);
134 } _u;
135 sigset_t sa_mask;
136 unsigned long sa_flags;
137 void (*sa_restorer)(void);
138};
139
140#define sa_handler _u._sa_handler
141#define sa_sigaction _u._sa_sigaction
142
143#endif /* __KERNEL__ */
144
145typedef struct sigaltstack {
146 void *ss_sp;
147 int ss_flags;
148 size_t ss_size;
149} stack_t;
150
151#ifdef __KERNEL__
152#include <asm/sigcontext.h>
153
154#define sigmask(sig) (1UL << ((sig) - 1))
155#define ptrace_signal_deliver(regs, cookie) do { } while (0)
156
157#endif /* __KERNEL__ */
158
159#endif /* __ASM_SH64_SIGNAL_H */
diff --git a/include/asm-sh64/smp.h b/include/asm-sh64/smp.h
deleted file mode 100644
index 4a4d0da39a84..000000000000
--- a/include/asm-sh64/smp.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef __ASM_SH64_SMP_H
2#define __ASM_SH64_SMP_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/smp.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#endif /* __ASM_SH64_SMP_H */
diff --git a/include/asm-sh64/socket.h b/include/asm-sh64/socket.h
deleted file mode 100644
index 1853f7246ab0..000000000000
--- a/include/asm-sh64/socket.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_SOCKET_H
2#define __ASM_SH64_SOCKET_H
3
4#include <asm-sh/socket.h>
5
6#endif /* __ASM_SH64_SOCKET_H */
diff --git a/include/asm-sh64/sockios.h b/include/asm-sh64/sockios.h
deleted file mode 100644
index 419e76f12f41..000000000000
--- a/include/asm-sh64/sockios.h
+++ /dev/null
@@ -1,25 +0,0 @@
1#ifndef __ASM_SH64_SOCKIOS_H
2#define __ASM_SH64_SOCKIOS_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/sockios.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15/* Socket-level I/O control calls. */
16#define FIOGETOWN _IOR('f', 123, int)
17#define FIOSETOWN _IOW('f', 124, int)
18
19#define SIOCATMARK _IOR('s', 7, int)
20#define SIOCSPGRP _IOW('s', 8, pid_t)
21#define SIOCGPGRP _IOR('s', 9, pid_t)
22
23#define SIOCGSTAMP _IOR('s', 100, struct timeval) /* Get stamp (timeval) */
24#define SIOCGSTAMPNS _IOR('s', 101, struct timespec) /* Get stamp (timespec) */
25#endif /* __ASM_SH64_SOCKIOS_H */
diff --git a/include/asm-sh64/spinlock.h b/include/asm-sh64/spinlock.h
deleted file mode 100644
index 296b0c9b24a2..000000000000
--- a/include/asm-sh64/spinlock.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef __ASM_SH64_SPINLOCK_H
2#define __ASM_SH64_SPINLOCK_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/spinlock.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#error "No SMP on SH64"
16
17#endif /* __ASM_SH64_SPINLOCK_H */
diff --git a/include/asm-sh64/stat.h b/include/asm-sh64/stat.h
deleted file mode 100644
index 86f551b1987e..000000000000
--- a/include/asm-sh64/stat.h
+++ /dev/null
@@ -1,88 +0,0 @@
1#ifndef __ASM_SH64_STAT_H
2#define __ASM_SH64_STAT_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/stat.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15struct __old_kernel_stat {
16 unsigned short st_dev;
17 unsigned short st_ino;
18 unsigned short st_mode;
19 unsigned short st_nlink;
20 unsigned short st_uid;
21 unsigned short st_gid;
22 unsigned short st_rdev;
23 unsigned long st_size;
24 unsigned long st_atime;
25 unsigned long st_mtime;
26 unsigned long st_ctime;
27};
28
29struct stat {
30 unsigned short st_dev;
31 unsigned short __pad1;
32 unsigned long st_ino;
33 unsigned short st_mode;
34 unsigned short st_nlink;
35 unsigned short st_uid;
36 unsigned short st_gid;
37 unsigned short st_rdev;
38 unsigned short __pad2;
39 unsigned long st_size;
40 unsigned long st_blksize;
41 unsigned long st_blocks;
42 unsigned long st_atime;
43 unsigned long st_atime_nsec;
44 unsigned long st_mtime;
45 unsigned long st_mtime_nsec;
46 unsigned long st_ctime;
47 unsigned long st_ctime_nsec;
48 unsigned long __unused4;
49 unsigned long __unused5;
50};
51
52/* This matches struct stat64 in glibc2.1, hence the absolutely
53 * insane amounts of padding around dev_t's.
54 */
55struct stat64 {
56 unsigned short st_dev;
57 unsigned char __pad0[10];
58
59 unsigned long st_ino;
60 unsigned int st_mode;
61 unsigned int st_nlink;
62
63 unsigned long st_uid;
64 unsigned long st_gid;
65
66 unsigned short st_rdev;
67 unsigned char __pad3[10];
68
69 long long st_size;
70 unsigned long st_blksize;
71
72 unsigned long st_blocks; /* Number 512-byte blocks allocated. */
73 unsigned long __pad4; /* future possible st_blocks high bits */
74
75 unsigned long st_atime;
76 unsigned long st_atime_nsec;
77
78 unsigned long st_mtime;
79 unsigned long st_mtime_nsec;
80
81 unsigned long st_ctime;
82 unsigned long st_ctime_nsec; /* will be high 32 bits of ctime someday */
83
84 unsigned long __unused1;
85 unsigned long __unused2;
86};
87
88#endif /* __ASM_SH64_STAT_H */
diff --git a/include/asm-sh64/statfs.h b/include/asm-sh64/statfs.h
deleted file mode 100644
index 083fd79b2417..000000000000
--- a/include/asm-sh64/statfs.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_STATFS_H
2#define __ASM_SH64_STATFS_H
3
4#include <asm-generic/statfs.h>
5
6#endif /* __ASM_SH64_STATFS_H */
diff --git a/include/asm-sh64/system.h b/include/asm-sh64/system.h
deleted file mode 100644
index be2a15ffcc55..000000000000
--- a/include/asm-sh64/system.h
+++ /dev/null
@@ -1,190 +0,0 @@
1#ifndef __ASM_SH64_SYSTEM_H
2#define __ASM_SH64_SYSTEM_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/system.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 * Copyright (C) 2004 Richard Curnow
14 *
15 */
16
17#include <asm/registers.h>
18#include <asm/processor.h>
19
20/*
21 * switch_to() should switch tasks to task nr n, first
22 */
23
24typedef struct {
25 unsigned long seg;
26} mm_segment_t;
27
28extern struct task_struct *sh64_switch_to(struct task_struct *prev,
29 struct thread_struct *prev_thread,
30 struct task_struct *next,
31 struct thread_struct *next_thread);
32
33#define switch_to(prev,next,last) \
34 do {\
35 if (last_task_used_math != next) {\
36 struct pt_regs *regs = next->thread.uregs;\
37 if (regs) regs->sr |= SR_FD;\
38 }\
39 last = sh64_switch_to(prev, &prev->thread, next, &next->thread);\
40 } while(0)
41
42#define nop() __asm__ __volatile__ ("nop")
43
44#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
45
46extern void __xchg_called_with_bad_pointer(void);
47
48#define mb() __asm__ __volatile__ ("synco": : :"memory")
49#define rmb() mb()
50#define wmb() __asm__ __volatile__ ("synco": : :"memory")
51#define read_barrier_depends() do { } while (0)
52
53#ifdef CONFIG_SMP
54#define smp_mb() mb()
55#define smp_rmb() rmb()
56#define smp_wmb() wmb()
57#define smp_read_barrier_depends() read_barrier_depends()
58#else
59#define smp_mb() barrier()
60#define smp_rmb() barrier()
61#define smp_wmb() barrier()
62#define smp_read_barrier_depends() do { } while (0)
63#endif /* CONFIG_SMP */
64
65#define set_mb(var, value) do { (void)xchg(&var, value); } while (0)
66
67/* Interrupt Control */
68#ifndef HARD_CLI
69#define SR_MASK_L 0x000000f0L
70#define SR_MASK_LL 0x00000000000000f0LL
71#else
72#define SR_MASK_L 0x10000000L
73#define SR_MASK_LL 0x0000000010000000LL
74#endif
75
76static __inline__ void local_irq_enable(void)
77{
78 /* cli/sti based on SR.BL */
79 unsigned long long __dummy0, __dummy1=~SR_MASK_LL;
80
81 __asm__ __volatile__("getcon " __SR ", %0\n\t"
82 "and %0, %1, %0\n\t"
83 "putcon %0, " __SR "\n\t"
84 : "=&r" (__dummy0)
85 : "r" (__dummy1));
86}
87
88static __inline__ void local_irq_disable(void)
89{
90 /* cli/sti based on SR.BL */
91 unsigned long long __dummy0, __dummy1=SR_MASK_LL;
92 __asm__ __volatile__("getcon " __SR ", %0\n\t"
93 "or %0, %1, %0\n\t"
94 "putcon %0, " __SR "\n\t"
95 : "=&r" (__dummy0)
96 : "r" (__dummy1));
97}
98
99#define local_save_flags(x) \
100(__extension__ ({ unsigned long long __dummy=SR_MASK_LL; \
101 __asm__ __volatile__( \
102 "getcon " __SR ", %0\n\t" \
103 "and %0, %1, %0" \
104 : "=&r" (x) \
105 : "r" (__dummy));}))
106
107#define local_irq_save(x) \
108(__extension__ ({ unsigned long long __d2=SR_MASK_LL, __d1; \
109 __asm__ __volatile__( \
110 "getcon " __SR ", %1\n\t" \
111 "or %1, r63, %0\n\t" \
112 "or %1, %2, %1\n\t" \
113 "putcon %1, " __SR "\n\t" \
114 "and %0, %2, %0" \
115 : "=&r" (x), "=&r" (__d1) \
116 : "r" (__d2));}));
117
118#define local_irq_restore(x) do { \
119 if ( ((x) & SR_MASK_L) == 0 ) /* dropping to 0 ? */ \
120 local_irq_enable(); /* yes...re-enable */ \
121} while (0)
122
123#define irqs_disabled() \
124({ \
125 unsigned long flags; \
126 local_save_flags(flags); \
127 (flags != 0); \
128})
129
130static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
131{
132 unsigned long flags, retval;
133
134 local_irq_save(flags);
135 retval = *m;
136 *m = val;
137 local_irq_restore(flags);
138 return retval;
139}
140
141static inline unsigned long xchg_u8(volatile unsigned char * m, unsigned long val)
142{
143 unsigned long flags, retval;
144
145 local_irq_save(flags);
146 retval = *m;
147 *m = val & 0xff;
148 local_irq_restore(flags);
149 return retval;
150}
151
152static __inline__ unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
153{
154 switch (size) {
155 case 4:
156 return xchg_u32(ptr, x);
157 break;
158 case 1:
159 return xchg_u8(ptr, x);
160 break;
161 }
162 __xchg_called_with_bad_pointer();
163 return x;
164}
165
166/* XXX
167 * disable hlt during certain critical i/o operations
168 */
169#define HAVE_DISABLE_HLT
170void disable_hlt(void);
171void enable_hlt(void);
172
173
174#define smp_mb() barrier()
175#define smp_rmb() barrier()
176#define smp_wmb() barrier()
177
178#ifdef CONFIG_SH_ALPHANUMERIC
179/* This is only used for debugging. */
180extern void print_seg(char *file,int line);
181#define PLS() print_seg(__FILE__,__LINE__)
182#else /* CONFIG_SH_ALPHANUMERIC */
183#define PLS()
184#endif /* CONFIG_SH_ALPHANUMERIC */
185
186#define PL() printk("@ <%s,%s:%d>\n",__FILE__,__FUNCTION__,__LINE__)
187
188#define arch_align_stack(x) (x)
189
190#endif /* __ASM_SH64_SYSTEM_H */
diff --git a/include/asm-sh64/termbits.h b/include/asm-sh64/termbits.h
deleted file mode 100644
index 86bde5ec1414..000000000000
--- a/include/asm-sh64/termbits.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_TERMBITS_H
2#define __ASM_SH64_TERMBITS_H
3
4#include <asm-sh/termbits.h>
5
6#endif /* __ASM_SH64_TERMBITS_H */
diff --git a/include/asm-sh64/termios.h b/include/asm-sh64/termios.h
deleted file mode 100644
index dc44e6ed3a7c..000000000000
--- a/include/asm-sh64/termios.h
+++ /dev/null
@@ -1,99 +0,0 @@
1#ifndef __ASM_SH64_TERMIOS_H
2#define __ASM_SH64_TERMIOS_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/termios.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#include <asm/termbits.h>
16#include <asm/ioctls.h>
17
18struct winsize {
19 unsigned short ws_row;
20 unsigned short ws_col;
21 unsigned short ws_xpixel;
22 unsigned short ws_ypixel;
23};
24
25#define NCC 8
26struct termio {
27 unsigned short c_iflag; /* input mode flags */
28 unsigned short c_oflag; /* output mode flags */
29 unsigned short c_cflag; /* control mode flags */
30 unsigned short c_lflag; /* local mode flags */
31 unsigned char c_line; /* line discipline */
32 unsigned char c_cc[NCC]; /* control characters */
33};
34
35/* modem lines */
36#define TIOCM_LE 0x001
37#define TIOCM_DTR 0x002
38#define TIOCM_RTS 0x004
39#define TIOCM_ST 0x008
40#define TIOCM_SR 0x010
41#define TIOCM_CTS 0x020
42#define TIOCM_CAR 0x040
43#define TIOCM_RNG 0x080
44#define TIOCM_DSR 0x100
45#define TIOCM_CD TIOCM_CAR
46#define TIOCM_RI TIOCM_RNG
47#define TIOCM_OUT1 0x2000
48#define TIOCM_OUT2 0x4000
49#define TIOCM_LOOP 0x8000
50
51/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
52
53#ifdef __KERNEL__
54
55/* intr=^C quit=^\ erase=del kill=^U
56 eof=^D vtime=\0 vmin=\1 sxtc=\0
57 start=^Q stop=^S susp=^Z eol=\0
58 reprint=^R discard=^U werase=^W lnext=^V
59 eol2=\0
60*/
61#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
62
63/*
64 * Translate a "termio" structure into a "termios". Ugh.
65 */
66#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
67 unsigned short __tmp; \
68 get_user(__tmp,&(termio)->x); \
69 *(unsigned short *) &(termios)->x = __tmp; \
70}
71
72#define user_termio_to_kernel_termios(termios, termio) \
73({ \
74 SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
75 SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
76 SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
77 SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
78 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
79})
80
81/*
82 * Translate a "termios" structure into a "termio". Ugh.
83 */
84#define kernel_termios_to_user_termio(termio, termios) \
85({ \
86 put_user((termios)->c_iflag, &(termio)->c_iflag); \
87 put_user((termios)->c_oflag, &(termio)->c_oflag); \
88 put_user((termios)->c_cflag, &(termio)->c_cflag); \
89 put_user((termios)->c_lflag, &(termio)->c_lflag); \
90 put_user((termios)->c_line, &(termio)->c_line); \
91 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
92})
93
94#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
95#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
96
97#endif /* __KERNEL__ */
98
99#endif /* __ASM_SH64_TERMIOS_H */
diff --git a/include/asm-sh64/thread_info.h b/include/asm-sh64/thread_info.h
deleted file mode 100644
index f6d5117c53af..000000000000
--- a/include/asm-sh64/thread_info.h
+++ /dev/null
@@ -1,91 +0,0 @@
1#ifndef __ASM_SH64_THREAD_INFO_H
2#define __ASM_SH64_THREAD_INFO_H
3
4/*
5 * SuperH 5 version
6 * Copyright (C) 2003 Paul Mundt
7 */
8
9#ifdef __KERNEL__
10
11#ifndef __ASSEMBLY__
12#include <asm/registers.h>
13
14/*
15 * low level task data that entry.S needs immediate access to
16 * - this struct should fit entirely inside of one cache line
17 * - this struct shares the supervisor stack pages
18 * - if the contents of this structure are changed, the assembly constants must also be changed
19 */
20struct thread_info {
21 struct task_struct *task; /* main task structure */
22 struct exec_domain *exec_domain; /* execution domain */
23 unsigned long flags; /* low level flags */
24 /* Put the 4 32-bit fields together to make asm offsetting easier. */
25 int preempt_count; /* 0 => preemptable, <0 => BUG */
26 __u16 cpu;
27
28 mm_segment_t addr_limit;
29 struct restart_block restart_block;
30
31 __u8 supervisor_stack[0];
32};
33
34/*
35 * macros/functions for gaining access to the thread information structure
36 */
37#define INIT_THREAD_INFO(tsk) \
38{ \
39 .task = &tsk, \
40 .exec_domain = &default_exec_domain, \
41 .flags = 0, \
42 .cpu = 0, \
43 .preempt_count = 1, \
44 .addr_limit = KERNEL_DS, \
45 .restart_block = { \
46 .fn = do_no_restart_syscall, \
47 }, \
48}
49
50#define init_thread_info (init_thread_union.thread_info)
51#define init_stack (init_thread_union.stack)
52
53/* how to get the thread information struct from C */
54static inline struct thread_info *current_thread_info(void)
55{
56 struct thread_info *ti;
57
58 __asm__ __volatile__ ("getcon " __KCR0 ", %0\n\t" : "=r" (ti));
59
60 return ti;
61}
62
63/* thread information allocation */
64
65
66
67#define alloc_thread_info(ti) ((struct thread_info *) __get_free_pages(GFP_KERNEL,1))
68#define free_thread_info(ti) free_pages((unsigned long) (ti), 1)
69
70#endif /* __ASSEMBLY__ */
71
72#define THREAD_SIZE 8192
73
74#define PREEMPT_ACTIVE 0x10000000
75
76/* thread information flags */
77#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
78#define TIF_SIGPENDING 2 /* signal pending */
79#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
80#define TIF_MEMDIE 4
81#define TIF_RESTORE_SIGMASK 5 /* Restore signal mask in do_signal */
82
83#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
84#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
85#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
86#define _TIF_MEMDIE (1 << TIF_MEMDIE)
87#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
88
89#endif /* __KERNEL__ */
90
91#endif /* __ASM_SH64_THREAD_INFO_H */
diff --git a/include/asm-sh64/timex.h b/include/asm-sh64/timex.h
deleted file mode 100644
index 163e2b62fe27..000000000000
--- a/include/asm-sh64/timex.h
+++ /dev/null
@@ -1,31 +0,0 @@
1#ifndef __ASM_SH64_TIMEX_H
2#define __ASM_SH64_TIMEX_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/timex.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 * Copyright (C) 2003 Paul Mundt
13 *
14 * sh-5 architecture timex specifications
15 *
16 */
17
18#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */
19#define CLOCK_TICK_FACTOR 20 /* Factor of both 1000000 and CLOCK_TICK_RATE */
20
21typedef unsigned long cycles_t;
22
23static __inline__ cycles_t get_cycles (void)
24{
25 return 0;
26}
27
28#define vxtime_lock() do {} while (0)
29#define vxtime_unlock() do {} while (0)
30
31#endif /* __ASM_SH64_TIMEX_H */
diff --git a/include/asm-sh64/tlbflush.h b/include/asm-sh64/tlbflush.h
deleted file mode 100644
index 16a164a23754..000000000000
--- a/include/asm-sh64/tlbflush.h
+++ /dev/null
@@ -1,27 +0,0 @@
1#ifndef __ASM_SH64_TLBFLUSH_H
2#define __ASM_SH64_TLBFLUSH_H
3
4#include <asm/pgalloc.h>
5
6/*
7 * TLB flushing:
8 *
9 * - flush_tlb() flushes the current mm struct TLBs
10 * - flush_tlb_all() flushes all processes TLBs
11 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
12 * - flush_tlb_page(vma, vmaddr) flushes one page
13 * - flush_tlb_range(mm, start, end) flushes a range of pages
14 *
15 */
16
17extern void flush_tlb(void);
18extern void flush_tlb_all(void);
19extern void flush_tlb_mm(struct mm_struct *mm);
20extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
21 unsigned long end);
22extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long page);
23
24extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
25
26#endif /* __ASM_SH64_TLBFLUSH_H */
27
diff --git a/include/asm-sh64/topology.h b/include/asm-sh64/topology.h
deleted file mode 100644
index 34211787345f..000000000000
--- a/include/asm-sh64/topology.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH64_TOPOLOGY_H
2#define __ASM_SH64_TOPOLOGY_H
3
4#include <asm-generic/topology.h>
5
6#endif /* __ASM_SH64_TOPOLOGY_H */
diff --git a/include/asm-sh64/types.h b/include/asm-sh64/types.h
deleted file mode 100644
index 2c7ad73b3883..000000000000
--- a/include/asm-sh64/types.h
+++ /dev/null
@@ -1,74 +0,0 @@
1#ifndef __ASM_SH64_TYPES_H
2#define __ASM_SH64_TYPES_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/types.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#ifndef __ASSEMBLY__
16
17typedef unsigned short umode_t;
18
19/*
20 * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
21 * header files exported to user space
22 */
23
24typedef __signed__ char __s8;
25typedef unsigned char __u8;
26
27typedef __signed__ short __s16;
28typedef unsigned short __u16;
29
30typedef __signed__ int __s32;
31typedef unsigned int __u32;
32
33#if defined(__GNUC__)
34__extension__ typedef __signed__ long long __s64;
35__extension__ typedef unsigned long long __u64;
36#endif
37
38#endif /* __ASSEMBLY__ */
39
40/*
41 * These aren't exported outside the kernel to avoid name space clashes
42 */
43#ifdef __KERNEL__
44
45#ifndef __ASSEMBLY__
46
47typedef __signed__ char s8;
48typedef unsigned char u8;
49
50typedef __signed__ short s16;
51typedef unsigned short u16;
52
53typedef __signed__ int s32;
54typedef unsigned int u32;
55
56typedef __signed__ long long s64;
57typedef unsigned long long u64;
58
59/* DMA addresses come in generic and 64-bit flavours. */
60
61#ifdef CONFIG_HIGHMEM64G
62typedef u64 dma_addr_t;
63#else
64typedef u32 dma_addr_t;
65#endif
66typedef u64 dma64_addr_t;
67
68#endif /* __ASSEMBLY__ */
69
70#define BITS_PER_LONG 32
71
72#endif /* __KERNEL__ */
73
74#endif /* __ASM_SH64_TYPES_H */
diff --git a/include/asm-sh64/ucontext.h b/include/asm-sh64/ucontext.h
deleted file mode 100644
index cf77a08551ca..000000000000
--- a/include/asm-sh64/ucontext.h
+++ /dev/null
@@ -1,23 +0,0 @@
1#ifndef __ASM_SH64_UCONTEXT_H
2#define __ASM_SH64_UCONTEXT_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/ucontext.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15struct ucontext {
16 unsigned long uc_flags;
17 struct ucontext *uc_link;
18 stack_t uc_stack;
19 struct sigcontext uc_mcontext;
20 sigset_t uc_sigmask; /* mask last for extensibility */
21};
22
23#endif /* __ASM_SH64_UCONTEXT_H */
diff --git a/include/asm-sh64/unaligned.h b/include/asm-sh64/unaligned.h
deleted file mode 100644
index 74481b186ae8..000000000000
--- a/include/asm-sh64/unaligned.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef __ASM_SH64_UNALIGNED_H
2#define __ASM_SH64_UNALIGNED_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/unaligned.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#include <asm-generic/unaligned.h>
16
17#endif /* __ASM_SH64_UNALIGNED_H */
diff --git a/include/asm-sh64/user.h b/include/asm-sh64/user.h
deleted file mode 100644
index eb3b33edd73e..000000000000
--- a/include/asm-sh64/user.h
+++ /dev/null
@@ -1,70 +0,0 @@
1#ifndef __ASM_SH64_USER_H
2#define __ASM_SH64_USER_H
3
4/*
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 *
9 * include/asm-sh64/user.h
10 *
11 * Copyright (C) 2000, 2001 Paolo Alberelli
12 *
13 */
14
15#include <linux/types.h>
16#include <asm/ptrace.h>
17#include <asm/page.h>
18
19/*
20 * Core file format: The core file is written in such a way that gdb
21 * can understand it and provide useful information to the user (under
22 * linux we use the `trad-core' bfd). The file contents are as follows:
23 *
24 * upage: 1 page consisting of a user struct that tells gdb
25 * what is present in the file. Directly after this is a
26 * copy of the task_struct, which is currently not used by gdb,
27 * but it may come in handy at some point. All of the registers
28 * are stored as part of the upage. The upage should always be
29 * only one page long.
30 * data: The data segment follows next. We use current->end_text to
31 * current->brk to pick up all of the user variables, plus any memory
32 * that may have been sbrk'ed. No attempt is made to determine if a
33 * page is demand-zero or if a page is totally unused, we just cover
34 * the entire range. All of the addresses are rounded in such a way
35 * that an integral number of pages is written.
36 * stack: We need the stack information in order to get a meaningful
37 * backtrace. We need to write the data from usp to
38 * current->start_stack, so we round each of these in order to be able
39 * to write an integer number of pages.
40 */
41
42struct user_fpu_struct {
43 unsigned long long fp_regs[32];
44 unsigned int fpscr;
45};
46
47struct user {
48 struct pt_regs regs; /* entire machine state */
49 struct user_fpu_struct fpu; /* Math Co-processor registers */
50 int u_fpvalid; /* True if math co-processor being used */
51 size_t u_tsize; /* text size (pages) */
52 size_t u_dsize; /* data size (pages) */
53 size_t u_ssize; /* stack size (pages) */
54 unsigned long start_code; /* text starting address */
55 unsigned long start_data; /* data starting address */
56 unsigned long start_stack; /* stack starting address */
57 long int signal; /* signal causing core dump */
58 struct regs * u_ar0; /* help gdb find registers */
59 struct user_fpu_struct* u_fpstate; /* Math Co-processor pointer */
60 unsigned long magic; /* identifies a core file */
61 char u_comm[32]; /* user command name */
62};
63
64#define NBPG PAGE_SIZE
65#define UPAGES 1
66#define HOST_TEXT_START_ADDR (u.start_code)
67#define HOST_DATA_START_ADDR (u.start_data)
68#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
69
70#endif /* __ASM_SH64_USER_H */
diff --git a/include/asm-sparc/socket.h b/include/asm-sparc/socket.h
index 7c1423997cf0..2e2bd0b7c8e3 100644
--- a/include/asm-sparc/socket.h
+++ b/include/asm-sparc/socket.h
@@ -52,6 +52,8 @@
52#define SO_TIMESTAMPNS 0x0021 52#define SO_TIMESTAMPNS 0x0021
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 0x0022
56
55/* Security levels - as per NRL IPv6 - don't actually do anything */ 57/* Security levels - as per NRL IPv6 - don't actually do anything */
56#define SO_SECURITY_AUTHENTICATION 0x5001 58#define SO_SECURITY_AUTHENTICATION 0x5001
57#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 59#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
diff --git a/include/asm-sparc/unistd.h b/include/asm-sparc/unistd.h
index 029b3e0d5e4c..0decdf763716 100644
--- a/include/asm-sparc/unistd.h
+++ b/include/asm-sparc/unistd.h
@@ -333,6 +333,15 @@
333 333
334#define NR_SYSCALLS 315 334#define NR_SYSCALLS 315
335 335
336/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
337 * it never had the plain ones and there is no value to adding those
338 * old versions into the syscall table.
339 */
340#define __IGNORE_setresuid
341#define __IGNORE_getresuid
342#define __IGNORE_setresgid
343#define __IGNORE_getresgid
344
336#ifdef __KERNEL__ 345#ifdef __KERNEL__
337#define __ARCH_WANT_IPC_PARSE_VERSION 346#define __ARCH_WANT_IPC_PARSE_VERSION
338#define __ARCH_WANT_OLD_READDIR 347#define __ARCH_WANT_OLD_READDIR
diff --git a/include/asm-sparc64/agp.h b/include/asm-sparc64/agp.h
index 58f8cb6ae767..e9fcf0e781ea 100644
--- a/include/asm-sparc64/agp.h
+++ b/include/asm-sparc64/agp.h
@@ -5,7 +5,6 @@
5 5
6#define map_page_into_agp(page) 6#define map_page_into_agp(page)
7#define unmap_page_from_agp(page) 7#define unmap_page_from_agp(page)
8#define flush_agp_mappings()
9#define flush_agp_cache() mb() 8#define flush_agp_cache() mb()
10 9
11/* Convert a physical address to an address suitable for the GART. */ 10/* Convert a physical address to an address suitable for the GART. */
diff --git a/include/asm-sparc64/dma-mapping.h b/include/asm-sparc64/dma-mapping.h
index 1fc655452b81..38cbec76a33f 100644
--- a/include/asm-sparc64/dma-mapping.h
+++ b/include/asm-sparc64/dma-mapping.h
@@ -25,15 +25,9 @@ struct dma_ops {
25 void (*sync_single_for_cpu)(struct device *dev, 25 void (*sync_single_for_cpu)(struct device *dev,
26 dma_addr_t dma_handle, size_t size, 26 dma_addr_t dma_handle, size_t size,
27 enum dma_data_direction direction); 27 enum dma_data_direction direction);
28 void (*sync_single_for_device)(struct device *dev,
29 dma_addr_t dma_handle, size_t size,
30 enum dma_data_direction direction);
31 void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg, 28 void (*sync_sg_for_cpu)(struct device *dev, struct scatterlist *sg,
32 int nelems, 29 int nelems,
33 enum dma_data_direction direction); 30 enum dma_data_direction direction);
34 void (*sync_sg_for_device)(struct device *dev, struct scatterlist *sg,
35 int nelems,
36 enum dma_data_direction direction);
37}; 31};
38extern const struct dma_ops *dma_ops; 32extern const struct dma_ops *dma_ops;
39 33
@@ -105,7 +99,7 @@ static inline void dma_sync_single_for_device(struct device *dev,
105 size_t size, 99 size_t size,
106 enum dma_data_direction direction) 100 enum dma_data_direction direction)
107{ 101{
108 dma_ops->sync_single_for_device(dev, dma_handle, size, direction); 102 /* No flushing needed to sync cpu writes to the device. */
109} 103}
110 104
111static inline void dma_sync_single_range_for_cpu(struct device *dev, 105static inline void dma_sync_single_range_for_cpu(struct device *dev,
@@ -123,7 +117,7 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
123 size_t size, 117 size_t size,
124 enum dma_data_direction direction) 118 enum dma_data_direction direction)
125{ 119{
126 dma_sync_single_for_device(dev, dma_handle+offset, size, direction); 120 /* No flushing needed to sync cpu writes to the device. */
127} 121}
128 122
129 123
@@ -138,7 +132,7 @@ static inline void dma_sync_sg_for_device(struct device *dev,
138 struct scatterlist *sg, int nelems, 132 struct scatterlist *sg, int nelems,
139 enum dma_data_direction direction) 133 enum dma_data_direction direction)
140{ 134{
141 dma_ops->sync_sg_for_device(dev, sg, nelems, direction); 135 /* No flushing needed to sync cpu writes to the device. */
142} 136}
143 137
144static inline int dma_mapping_error(dma_addr_t dma_addr) 138static inline int dma_mapping_error(dma_addr_t dma_addr)
diff --git a/include/asm-sparc64/futex.h b/include/asm-sparc64/futex.h
index 876312fe82cc..df1097d6ffbe 100644
--- a/include/asm-sparc64/futex.h
+++ b/include/asm-sparc64/futex.h
@@ -17,7 +17,8 @@
17 "3:\n" \ 17 "3:\n" \
18 " .section .fixup,#alloc,#execinstr\n" \ 18 " .section .fixup,#alloc,#execinstr\n" \
19 " .align 4\n" \ 19 " .align 4\n" \
20 "4: ba 3b\n" \ 20 "4: sethi %%hi(3b), %0\n" \
21 " jmpl %0 + %%lo(3b), %%g0\n" \
21 " mov %5, %0\n" \ 22 " mov %5, %0\n" \
22 " .previous\n" \ 23 " .previous\n" \
23 " .section __ex_table,\"a\"\n" \ 24 " .section __ex_table,\"a\"\n" \
@@ -91,7 +92,8 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
91 "2:\n" 92 "2:\n"
92 " .section .fixup,#alloc,#execinstr\n" 93 " .section .fixup,#alloc,#execinstr\n"
93 " .align 4\n" 94 " .align 4\n"
94 "3: ba 2b\n" 95 "3: sethi %%hi(2b), %0\n"
96 " jmpl %0 + %%lo(2b), %%g0\n"
95 " mov %4, %0\n" 97 " mov %4, %0\n"
96 " .previous\n" 98 " .previous\n"
97 " .section __ex_table,\"a\"\n" 99 " .section __ex_table,\"a\"\n"
diff --git a/include/asm-sparc64/hypervisor.h b/include/asm-sparc64/hypervisor.h
index 524d49835dfd..3ad45dff52f8 100644
--- a/include/asm-sparc64/hypervisor.h
+++ b/include/asm-sparc64/hypervisor.h
@@ -709,6 +709,10 @@ extern unsigned long sun4v_mmu_tsb_ctx0(unsigned long num_descriptions,
709 */ 709 */
710#define HV_FAST_MMU_DEMAP_ALL 0x24 710#define HV_FAST_MMU_DEMAP_ALL 0x24
711 711
712#ifndef __ASSEMBLY__
713extern void sun4v_mmu_demap_all(void);
714#endif
715
712/* mmu_map_perm_addr() 716/* mmu_map_perm_addr()
713 * TRAP: HV_FAST_TRAP 717 * TRAP: HV_FAST_TRAP
714 * FUNCTION: HV_FAST_MMU_MAP_PERM_ADDR 718 * FUNCTION: HV_FAST_MMU_MAP_PERM_ADDR
diff --git a/include/asm-sparc64/pci.h b/include/asm-sparc64/pci.h
index 1393e57d50fb..f59f2571295b 100644
--- a/include/asm-sparc64/pci.h
+++ b/include/asm-sparc64/pci.h
@@ -200,6 +200,10 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
200struct device_node; 200struct device_node;
201extern struct device_node *pci_device_to_OF_node(struct pci_dev *pdev); 201extern struct device_node *pci_device_to_OF_node(struct pci_dev *pdev);
202 202
203#define HAVE_ARCH_PCI_RESOURCE_TO_USER
204extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
205 const struct resource *rsrc,
206 resource_size_t *start, resource_size_t *end);
203#endif /* __KERNEL__ */ 207#endif /* __KERNEL__ */
204 208
205#endif /* __SPARC64_PCI_H */ 209#endif /* __SPARC64_PCI_H */
diff --git a/include/asm-sparc64/percpu.h b/include/asm-sparc64/percpu.h
index a1f53a4da405..bee64593023e 100644
--- a/include/asm-sparc64/percpu.h
+++ b/include/asm-sparc64/percpu.h
@@ -7,7 +7,6 @@ register unsigned long __local_per_cpu_offset asm("g5");
7 7
8#ifdef CONFIG_SMP 8#ifdef CONFIG_SMP
9 9
10#define setup_per_cpu_areas() do { } while (0)
11extern void real_setup_per_cpu_areas(void); 10extern void real_setup_per_cpu_areas(void);
12 11
13extern unsigned long __per_cpu_base; 12extern unsigned long __per_cpu_base;
@@ -16,45 +15,14 @@ extern unsigned long __per_cpu_shift;
16 (__per_cpu_base + ((unsigned long)(__cpu) << __per_cpu_shift)) 15 (__per_cpu_base + ((unsigned long)(__cpu) << __per_cpu_shift))
17#define per_cpu_offset(x) (__per_cpu_offset(x)) 16#define per_cpu_offset(x) (__per_cpu_offset(x))
18 17
19/* Separate out the type, so (int[3], foo) works. */ 18#define __my_cpu_offset __local_per_cpu_offset
20#define DEFINE_PER_CPU(type, name) \ 19
21 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
22
23#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
24 __attribute__((__section__(".data.percpu.shared_aligned"))) \
25 __typeof__(type) per_cpu__##name \
26 ____cacheline_aligned_in_smp
27
28/* var is in discarded region: offset to particular copy we want */
29#define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)))
30#define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __local_per_cpu_offset))
31#define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __local_per_cpu_offset))
32
33/* A macro to avoid #include hell... */
34#define percpu_modcopy(pcpudst, src, size) \
35do { \
36 unsigned int __i; \
37 for_each_possible_cpu(__i) \
38 memcpy((pcpudst)+__per_cpu_offset(__i), \
39 (src), (size)); \
40} while (0)
41#else /* ! SMP */ 20#else /* ! SMP */
42 21
43#define real_setup_per_cpu_areas() do { } while (0) 22#define real_setup_per_cpu_areas() do { } while (0)
44#define DEFINE_PER_CPU(type, name) \
45 __typeof__(type) per_cpu__##name
46#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
47 DEFINE_PER_CPU(type, name)
48
49#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var))
50#define __get_cpu_var(var) per_cpu__##var
51#define __raw_get_cpu_var(var) per_cpu__##var
52 23
53#endif /* SMP */ 24#endif /* SMP */
54 25
55#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name 26#include <asm-generic/percpu.h>
56
57#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
58#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
59 27
60#endif /* __ARCH_SPARC64_PERCPU__ */ 28#endif /* __ARCH_SPARC64_PERCPU__ */
diff --git a/include/asm-sparc64/socket.h b/include/asm-sparc64/socket.h
index 986441dcb8f0..44a625af6e31 100644
--- a/include/asm-sparc64/socket.h
+++ b/include/asm-sparc64/socket.h
@@ -57,4 +57,5 @@
57#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 57#define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002
58#define SO_SECURITY_ENCRYPTION_NETWORK 0x5004 58#define SO_SECURITY_ENCRYPTION_NETWORK 0x5004
59 59
60#define SO_MARK 0x0022
60#endif /* _ASM_SOCKET_H */ 61#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-sparc64/system.h b/include/asm-sparc64/system.h
index 159e62b51d70..99a669c190c7 100644
--- a/include/asm-sparc64/system.h
+++ b/include/asm-sparc64/system.h
@@ -178,7 +178,9 @@ do { if (test_thread_flag(TIF_PERFCTR)) { \
178 "ldx [%%g6 + %9], %%g4\n\t" \ 178 "ldx [%%g6 + %9], %%g4\n\t" \
179 "brz,pt %%o7, 1f\n\t" \ 179 "brz,pt %%o7, 1f\n\t" \
180 " mov %%g7, %0\n\t" \ 180 " mov %%g7, %0\n\t" \
181 "b,a ret_from_syscall\n\t" \ 181 "sethi %%hi(ret_from_syscall), %%g1\n\t" \
182 "jmpl %%g1 + %%lo(ret_from_syscall), %%g0\n\t" \
183 " nop\n\t" \
182 "1:\n\t" \ 184 "1:\n\t" \
183 : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \ 185 : "=&r" (last), "=r" (current), "=r" (current_thread_info_reg), \
184 "=r" (__local_per_cpu_offset) \ 186 "=r" (__local_per_cpu_offset) \
diff --git a/include/asm-sparc64/uaccess.h b/include/asm-sparc64/uaccess.h
index afe236ba555b..93720e7b0289 100644
--- a/include/asm-sparc64/uaccess.h
+++ b/include/asm-sparc64/uaccess.h
@@ -123,7 +123,8 @@ __asm__ __volatile__( \
123 ".section .fixup,#alloc,#execinstr\n\t" \ 123 ".section .fixup,#alloc,#execinstr\n\t" \
124 ".align 4\n" \ 124 ".align 4\n" \
125"3:\n\t" \ 125"3:\n\t" \
126 "b 2b\n\t" \ 126 "sethi %%hi(2b), %0\n\t" \
127 "jmpl %0 + %%lo(2b), %%g0\n\t" \
127 " mov %3, %0\n\n\t" \ 128 " mov %3, %0\n\n\t" \
128 ".previous\n\t" \ 129 ".previous\n\t" \
129 ".section __ex_table,\"a\"\n\t" \ 130 ".section __ex_table,\"a\"\n\t" \
@@ -165,8 +166,9 @@ __asm__ __volatile__( \
165 ".section .fixup,#alloc,#execinstr\n\t" \ 166 ".section .fixup,#alloc,#execinstr\n\t" \
166 ".align 4\n" \ 167 ".align 4\n" \
167"3:\n\t" \ 168"3:\n\t" \
169 "sethi %%hi(2b), %0\n\t" \
168 "clr %1\n\t" \ 170 "clr %1\n\t" \
169 "b 2b\n\t" \ 171 "jmpl %0 + %%lo(2b), %%g0\n\t" \
170 " mov %3, %0\n\n\t" \ 172 " mov %3, %0\n\n\t" \
171 ".previous\n\t" \ 173 ".previous\n\t" \
172 ".section __ex_table,\"a\"\n\t" \ 174 ".section __ex_table,\"a\"\n\t" \
diff --git a/include/asm-sparc64/vio.h b/include/asm-sparc64/vio.h
index f7417e91b170..d4de32f0f8af 100644
--- a/include/asm-sparc64/vio.h
+++ b/include/asm-sparc64/vio.h
@@ -8,6 +8,7 @@
8#include <linux/spinlock.h> 8#include <linux/spinlock.h>
9#include <linux/completion.h> 9#include <linux/completion.h>
10#include <linux/list.h> 10#include <linux/list.h>
11#include <linux/log2.h>
11 12
12#include <asm/ldc.h> 13#include <asm/ldc.h>
13#include <asm/mdesc.h> 14#include <asm/mdesc.h>
@@ -257,8 +258,7 @@ static inline void *vio_dring_entry(struct vio_dring_state *dr,
257static inline u32 vio_dring_avail(struct vio_dring_state *dr, 258static inline u32 vio_dring_avail(struct vio_dring_state *dr,
258 unsigned int ring_size) 259 unsigned int ring_size)
259{ 260{
260 /* Ensure build-time power-of-2. */ 261 BUILD_BUG_ON(!is_power_of_2(ring_size));
261 BUILD_BUG_ON(ring_size & (ring_size - 1));
262 262
263 return (dr->pending - 263 return (dr->pending -
264 ((dr->prod - dr->cons) & (ring_size - 1))); 264 ((dr->prod - dr->cons) & (ring_size - 1)));
diff --git a/include/asm-um/asm.h b/include/asm-um/asm.h
new file mode 100644
index 000000000000..af1269a1e9eb
--- /dev/null
+++ b/include/asm-um/asm.h
@@ -0,0 +1,6 @@
1#ifndef __UM_ASM_H
2#define __UM_ASM_H
3
4#include "asm/arch/asm.h"
5
6#endif
diff --git a/include/asm-um/linkage.h b/include/asm-um/linkage.h
index 78b862472b36..cdb3024a699a 100644
--- a/include/asm-um/linkage.h
+++ b/include/asm-um/linkage.h
@@ -6,7 +6,6 @@
6 6
7/* <linux/linkage.h> will pick sane defaults */ 7/* <linux/linkage.h> will pick sane defaults */
8#ifdef CONFIG_GPROF 8#ifdef CONFIG_GPROF
9#undef FASTCALL
10#undef fastcall 9#undef fastcall
11#endif 10#endif
12 11
diff --git a/include/asm-um/nops.h b/include/asm-um/nops.h
new file mode 100644
index 000000000000..814e9bf5dea6
--- /dev/null
+++ b/include/asm-um/nops.h
@@ -0,0 +1,6 @@
1#ifndef __UM_NOPS_H
2#define __UM_NOPS_H
3
4#include "asm/arch/nops.h"
5
6#endif
diff --git a/include/asm-um/pgtable-3level.h b/include/asm-um/pgtable-3level.h
index aa82b88db805..3ebafbaacb24 100644
--- a/include/asm-um/pgtable-3level.h
+++ b/include/asm-um/pgtable-3level.h
@@ -71,7 +71,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
71 71
72static inline void pud_clear (pud_t *pud) 72static inline void pud_clear (pud_t *pud)
73{ 73{
74 set_pud(pud, __pud(0)); 74 set_pud(pud, __pud(_PAGE_NEWPAGE));
75} 75}
76 76
77#define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK) 77#define pud_page(pud) phys_to_page(pud_val(pud) & PAGE_MASK)
diff --git a/include/asm-um/unistd.h b/include/asm-um/unistd.h
index 732c83f04c3d..38bd9d94ee46 100644
--- a/include/asm-um/unistd.h
+++ b/include/asm-um/unistd.h
@@ -14,7 +14,6 @@ extern int um_execve(const char *file, char *const argv[], char *const env[]);
14 14
15#ifdef __KERNEL__ 15#ifdef __KERNEL__
16/* We get __ARCH_WANT_OLD_STAT and __ARCH_WANT_STAT64 from the base arch */ 16/* We get __ARCH_WANT_OLD_STAT and __ARCH_WANT_STAT64 from the base arch */
17#define __ARCH_WANT_IPC_PARSE_VERSION
18#define __ARCH_WANT_OLD_READDIR 17#define __ARCH_WANT_OLD_READDIR
19#define __ARCH_WANT_SYS_ALARM 18#define __ARCH_WANT_SYS_ALARM
20#define __ARCH_WANT_SYS_GETHOSTNAME 19#define __ARCH_WANT_SYS_GETHOSTNAME
diff --git a/include/asm-v850/socket.h b/include/asm-v850/socket.h
index a4c2493b025f..e199a2bf12aa 100644
--- a/include/asm-v850/socket.h
+++ b/include/asm-v850/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* __V850_SOCKET_H__ */ 57#endif /* __V850_SOCKET_H__ */
diff --git a/include/asm-x86/Kbuild b/include/asm-x86/Kbuild
index 12db5a1cdd74..3c6f0f80e827 100644
--- a/include/asm-x86/Kbuild
+++ b/include/asm-x86/Kbuild
@@ -3,21 +3,20 @@ include include/asm-generic/Kbuild.asm
3header-y += boot.h 3header-y += boot.h
4header-y += bootparam.h 4header-y += bootparam.h
5header-y += debugreg.h 5header-y += debugreg.h
6header-y += kvm.h
6header-y += ldt.h 7header-y += ldt.h
7header-y += msr-index.h 8header-y += msr-index.h
8header-y += prctl.h 9header-y += prctl.h
9header-y += ptrace-abi.h 10header-y += ptrace-abi.h
10header-y += sigcontext32.h 11header-y += sigcontext32.h
11header-y += ucontext.h 12header-y += ucontext.h
12header-y += vsyscall32.h
13 13
14unifdef-y += e820.h 14unifdef-y += e820.h
15unifdef-y += ist.h 15unifdef-y += ist.h
16unifdef-y += mce.h 16unifdef-y += mce.h
17unifdef-y += msr.h 17unifdef-y += msr.h
18unifdef-y += mtrr.h 18unifdef-y += mtrr.h
19unifdef-y += page_32.h 19unifdef-y += page.h
20unifdef-y += page_64.h
21unifdef-y += posix_types_32.h 20unifdef-y += posix_types_32.h
22unifdef-y += posix_types_64.h 21unifdef-y += posix_types_64.h
23unifdef-y += ptrace.h 22unifdef-y += ptrace.h
diff --git a/include/asm-x86/acpi.h b/include/asm-x86/acpi.h
index 0693689d4146..98a9ca266531 100644
--- a/include/asm-x86/acpi.h
+++ b/include/asm-x86/acpi.h
@@ -1,5 +1,173 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_ACPI_H
2# include "acpi_32.h" 2#define _ASM_X86_ACPI_H
3
4/*
5 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2001 Patrick Mochel <mochel@osdl.org>
7 *
8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 */
26#include <acpi/pdc_intel.h>
27
28#include <asm/numa.h>
29#include <asm/processor.h>
30#include <asm/mmu.h>
31
32#define COMPILER_DEPENDENT_INT64 long long
33#define COMPILER_DEPENDENT_UINT64 unsigned long long
34
35/*
36 * Calling conventions:
37 *
38 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
39 * ACPI_EXTERNAL_XFACE - External ACPI interfaces
40 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
41 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
42 */
43#define ACPI_SYSTEM_XFACE
44#define ACPI_EXTERNAL_XFACE
45#define ACPI_INTERNAL_XFACE
46#define ACPI_INTERNAL_VAR_XFACE
47
48/* Asm macros */
49
50#define ACPI_ASM_MACROS
51#define BREAKPOINT3
52#define ACPI_DISABLE_IRQS() local_irq_disable()
53#define ACPI_ENABLE_IRQS() local_irq_enable()
54#define ACPI_FLUSH_CPU_CACHE() wbinvd()
55
56int __acpi_acquire_global_lock(unsigned int *lock);
57int __acpi_release_global_lock(unsigned int *lock);
58
59#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
60 ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
61
62#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
63 ((Acq) = __acpi_release_global_lock(&facs->global_lock))
64
65/*
66 * Math helper asm macros
67 */
68#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
69 asm("divl %2;" \
70 :"=a"(q32), "=d"(r32) \
71 :"r"(d32), \
72 "0"(n_lo), "1"(n_hi))
73
74
75#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
76 asm("shrl $1,%2 ;" \
77 "rcrl $1,%3;" \
78 :"=r"(n_hi), "=r"(n_lo) \
79 :"0"(n_hi), "1"(n_lo))
80
81#ifdef CONFIG_ACPI
82extern int acpi_lapic;
83extern int acpi_ioapic;
84extern int acpi_noirq;
85extern int acpi_strict;
86extern int acpi_disabled;
87extern int acpi_ht;
88extern int acpi_pci_disabled;
89extern int acpi_skip_timer_override;
90extern int acpi_use_timer_override;
91
92static inline void disable_acpi(void)
93{
94 acpi_disabled = 1;
95 acpi_ht = 0;
96 acpi_pci_disabled = 1;
97 acpi_noirq = 1;
98}
99
100/* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */
101#define FIX_ACPI_PAGES 4
102
103extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
104
105static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
106static inline void acpi_disable_pci(void)
107{
108 acpi_pci_disabled = 1;
109 acpi_noirq_set();
110}
111extern int acpi_irq_balance_set(char *str);
112
113/* routines for saving/restoring kernel state */
114extern int acpi_save_state_mem(void);
115extern void acpi_restore_state_mem(void);
116
117extern unsigned long acpi_wakeup_address;
118
119/* early initialization routine */
120extern void acpi_reserve_bootmem(void);
121
122/*
123 * Check if the CPU can handle C2 and deeper
124 */
125static inline unsigned int acpi_processor_cstate_check(unsigned int max_cstate)
126{
127 /*
128 * Early models (<=5) of AMD Opterons are not supposed to go into
129 * C2 state.
130 *
131 * Steppings 0x0A and later are good
132 */
133 if (boot_cpu_data.x86 == 0x0F &&
134 boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
135 boot_cpu_data.x86_model <= 0x05 &&
136 boot_cpu_data.x86_mask < 0x0A)
137 return 1;
138 else
139 return max_cstate;
140}
141
142#else /* !CONFIG_ACPI */
143
144#define acpi_lapic 0
145#define acpi_ioapic 0
146static inline void acpi_noirq_set(void) { }
147static inline void acpi_disable_pci(void) { }
148static inline void disable_acpi(void) { }
149
150#endif /* !CONFIG_ACPI */
151
152#define ARCH_HAS_POWER_INIT 1
153
154struct bootnode;
155
156#ifdef CONFIG_ACPI_NUMA
157extern int acpi_numa;
158extern int acpi_scan_nodes(unsigned long start, unsigned long end);
159#ifdef CONFIG_X86_64
160# define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
161#endif
162extern void acpi_fake_nodes(const struct bootnode *fake_nodes,
163 int num_nodes);
3#else 164#else
4# include "acpi_64.h" 165static inline void acpi_fake_nodes(const struct bootnode *fake_nodes,
166 int num_nodes)
167{
168}
5#endif 169#endif
170
171#define acpi_unlazy_tlb(x) leave_mm(x)
172
173#endif /*__X86_ASM_ACPI_H*/
diff --git a/include/asm-x86/acpi_32.h b/include/asm-x86/acpi_32.h
deleted file mode 100644
index 723493e6c851..000000000000
--- a/include/asm-x86/acpi_32.h
+++ /dev/null
@@ -1,143 +0,0 @@
1/*
2 * asm-i386/acpi.h
3 *
4 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 * Copyright (C) 2001 Patrick Mochel <mochel@osdl.org>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#ifndef _ASM_ACPI_H
27#define _ASM_ACPI_H
28
29#ifdef __KERNEL__
30
31#include <acpi/pdc_intel.h>
32
33#include <asm/system.h> /* defines cmpxchg */
34
35#define COMPILER_DEPENDENT_INT64 long long
36#define COMPILER_DEPENDENT_UINT64 unsigned long long
37
38/*
39 * Calling conventions:
40 *
41 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
42 * ACPI_EXTERNAL_XFACE - External ACPI interfaces
43 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
44 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
45 */
46#define ACPI_SYSTEM_XFACE
47#define ACPI_EXTERNAL_XFACE
48#define ACPI_INTERNAL_XFACE
49#define ACPI_INTERNAL_VAR_XFACE
50
51/* Asm macros */
52
53#define ACPI_ASM_MACROS
54#define BREAKPOINT3
55#define ACPI_DISABLE_IRQS() local_irq_disable()
56#define ACPI_ENABLE_IRQS() local_irq_enable()
57#define ACPI_FLUSH_CPU_CACHE() wbinvd()
58
59int __acpi_acquire_global_lock(unsigned int *lock);
60int __acpi_release_global_lock(unsigned int *lock);
61
62#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
63 ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
64
65#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
66 ((Acq) = __acpi_release_global_lock(&facs->global_lock))
67
68/*
69 * Math helper asm macros
70 */
71#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
72 asm("divl %2;" \
73 :"=a"(q32), "=d"(r32) \
74 :"r"(d32), \
75 "0"(n_lo), "1"(n_hi))
76
77
78#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
79 asm("shrl $1,%2;" \
80 "rcrl $1,%3;" \
81 :"=r"(n_hi), "=r"(n_lo) \
82 :"0"(n_hi), "1"(n_lo))
83
84extern void early_quirks(void);
85
86#ifdef CONFIG_ACPI
87extern int acpi_lapic;
88extern int acpi_ioapic;
89extern int acpi_noirq;
90extern int acpi_strict;
91extern int acpi_disabled;
92extern int acpi_ht;
93extern int acpi_pci_disabled;
94static inline void disable_acpi(void)
95{
96 acpi_disabled = 1;
97 acpi_ht = 0;
98 acpi_pci_disabled = 1;
99 acpi_noirq = 1;
100}
101
102/* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */
103#define FIX_ACPI_PAGES 4
104
105extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
106
107#ifdef CONFIG_X86_IO_APIC
108extern int acpi_skip_timer_override;
109extern int acpi_use_timer_override;
110#endif
111
112static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
113static inline void acpi_disable_pci(void)
114{
115 acpi_pci_disabled = 1;
116 acpi_noirq_set();
117}
118extern int acpi_irq_balance_set(char *str);
119
120/* routines for saving/restoring kernel state */
121extern int acpi_save_state_mem(void);
122extern void acpi_restore_state_mem(void);
123
124extern unsigned long acpi_wakeup_address;
125
126/* early initialization routine */
127extern void acpi_reserve_bootmem(void);
128
129#else /* !CONFIG_ACPI */
130
131#define acpi_lapic 0
132#define acpi_ioapic 0
133static inline void acpi_noirq_set(void) { }
134static inline void acpi_disable_pci(void) { }
135static inline void disable_acpi(void) { }
136
137#endif /* !CONFIG_ACPI */
138
139#define ARCH_HAS_POWER_INIT 1
140
141#endif /*__KERNEL__*/
142
143#endif /*_ASM_ACPI_H*/
diff --git a/include/asm-x86/acpi_64.h b/include/asm-x86/acpi_64.h
deleted file mode 100644
index 98173357dd89..000000000000
--- a/include/asm-x86/acpi_64.h
+++ /dev/null
@@ -1,153 +0,0 @@
1/*
2 * asm-x86_64/acpi.h
3 *
4 * Copyright (C) 2001 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
5 * Copyright (C) 2001 Patrick Mochel <mochel@osdl.org>
6 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 */
25
26#ifndef _ASM_ACPI_H
27#define _ASM_ACPI_H
28
29#ifdef __KERNEL__
30
31#include <acpi/pdc_intel.h>
32#include <asm/numa.h>
33
34#define COMPILER_DEPENDENT_INT64 long long
35#define COMPILER_DEPENDENT_UINT64 unsigned long long
36
37/*
38 * Calling conventions:
39 *
40 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads)
41 * ACPI_EXTERNAL_XFACE - External ACPI interfaces
42 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces
43 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces
44 */
45#define ACPI_SYSTEM_XFACE
46#define ACPI_EXTERNAL_XFACE
47#define ACPI_INTERNAL_XFACE
48#define ACPI_INTERNAL_VAR_XFACE
49
50/* Asm macros */
51
52#define ACPI_ASM_MACROS
53#define BREAKPOINT3
54#define ACPI_DISABLE_IRQS() local_irq_disable()
55#define ACPI_ENABLE_IRQS() local_irq_enable()
56#define ACPI_FLUSH_CPU_CACHE() wbinvd()
57
58int __acpi_acquire_global_lock(unsigned int *lock);
59int __acpi_release_global_lock(unsigned int *lock);
60
61#define ACPI_ACQUIRE_GLOBAL_LOCK(facs, Acq) \
62 ((Acq) = __acpi_acquire_global_lock(&facs->global_lock))
63
64#define ACPI_RELEASE_GLOBAL_LOCK(facs, Acq) \
65 ((Acq) = __acpi_release_global_lock(&facs->global_lock))
66
67/*
68 * Math helper asm macros
69 */
70#define ACPI_DIV_64_BY_32(n_hi, n_lo, d32, q32, r32) \
71 asm("divl %2;" \
72 :"=a"(q32), "=d"(r32) \
73 :"r"(d32), \
74 "0"(n_lo), "1"(n_hi))
75
76
77#define ACPI_SHIFT_RIGHT_64(n_hi, n_lo) \
78 asm("shrl $1,%2;" \
79 "rcrl $1,%3;" \
80 :"=r"(n_hi), "=r"(n_lo) \
81 :"0"(n_hi), "1"(n_lo))
82
83#ifdef CONFIG_ACPI
84extern int acpi_lapic;
85extern int acpi_ioapic;
86extern int acpi_noirq;
87extern int acpi_strict;
88extern int acpi_disabled;
89extern int acpi_pci_disabled;
90extern int acpi_ht;
91static inline void disable_acpi(void)
92{
93 acpi_disabled = 1;
94 acpi_ht = 0;
95 acpi_pci_disabled = 1;
96 acpi_noirq = 1;
97}
98
99/* Fixmap pages to reserve for ACPI boot-time tables (see fixmap.h) */
100#define FIX_ACPI_PAGES 4
101
102extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq);
103static inline void acpi_noirq_set(void) { acpi_noirq = 1; }
104static inline void acpi_disable_pci(void)
105{
106 acpi_pci_disabled = 1;
107 acpi_noirq_set();
108}
109extern int acpi_irq_balance_set(char *str);
110
111/* routines for saving/restoring kernel state */
112extern int acpi_save_state_mem(void);
113extern void acpi_restore_state_mem(void);
114
115extern unsigned long acpi_wakeup_address;
116
117/* early initialization routine */
118extern void acpi_reserve_bootmem(void);
119
120#else /* !CONFIG_ACPI */
121
122#define acpi_lapic 0
123#define acpi_ioapic 0
124static inline void acpi_noirq_set(void) { }
125static inline void acpi_disable_pci(void) { }
126
127#endif /* !CONFIG_ACPI */
128
129extern int acpi_numa;
130extern int acpi_scan_nodes(unsigned long start, unsigned long end);
131#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
132
133extern int acpi_disabled;
134extern int acpi_pci_disabled;
135
136#define ARCH_HAS_POWER_INIT 1
137
138extern int acpi_skip_timer_override;
139extern int acpi_use_timer_override;
140
141#ifdef CONFIG_ACPI_NUMA
142extern void __init acpi_fake_nodes(const struct bootnode *fake_nodes,
143 int num_nodes);
144#else
145static inline void acpi_fake_nodes(const struct bootnode *fake_nodes,
146 int num_nodes)
147{
148}
149#endif
150
151#endif /*__KERNEL__*/
152
153#endif /*_ASM_ACPI_H*/
diff --git a/include/asm-x86/agp.h b/include/asm-x86/agp.h
index 62df2a9e7130..e4004a9f6a9a 100644
--- a/include/asm-x86/agp.h
+++ b/include/asm-x86/agp.h
@@ -12,13 +12,8 @@
12 * page. This avoids data corruption on some CPUs. 12 * page. This avoids data corruption on some CPUs.
13 */ 13 */
14 14
15/* 15#define map_page_into_agp(page) set_pages_uc(page, 1)
16 * Caller's responsibility to call global_flush_tlb() for performance 16#define unmap_page_from_agp(page) set_pages_wb(page, 1)
17 * reasons
18 */
19#define map_page_into_agp(page) change_page_attr(page, 1, PAGE_KERNEL_NOCACHE)
20#define unmap_page_from_agp(page) change_page_attr(page, 1, PAGE_KERNEL)
21#define flush_agp_mappings() global_flush_tlb()
22 17
23/* 18/*
24 * Could use CLFLUSH here if the cpu supports it. But then it would 19 * Could use CLFLUSH here if the cpu supports it. But then it would
diff --git a/include/asm-x86/alternative.h b/include/asm-x86/alternative.h
index 9eef6a32a130..d8bacf3c4b08 100644
--- a/include/asm-x86/alternative.h
+++ b/include/asm-x86/alternative.h
@@ -1,5 +1,161 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_ALTERNATIVE_H
2# include "alternative_32.h" 2#define _ASM_X86_ALTERNATIVE_H
3
4#include <linux/types.h>
5#include <linux/stddef.h>
6#include <asm/asm.h>
7
8/*
9 * Alternative inline assembly for SMP.
10 *
11 * The LOCK_PREFIX macro defined here replaces the LOCK and
12 * LOCK_PREFIX macros used everywhere in the source tree.
13 *
14 * SMP alternatives use the same data structures as the other
15 * alternatives and the X86_FEATURE_UP flag to indicate the case of a
16 * UP system running a SMP kernel. The existing apply_alternatives()
17 * works fine for patching a SMP kernel for UP.
18 *
19 * The SMP alternative tables can be kept after boot and contain both
20 * UP and SMP versions of the instructions to allow switching back to
21 * SMP at runtime, when hotplugging in a new CPU, which is especially
22 * useful in virtualized environments.
23 *
24 * The very common lock prefix is handled as special case in a
25 * separate table which is a pure address list without replacement ptr
26 * and size information. That keeps the table sizes small.
27 */
28
29#ifdef CONFIG_SMP
30#define LOCK_PREFIX \
31 ".section .smp_locks,\"a\"\n" \
32 _ASM_ALIGN "\n" \
33 _ASM_PTR "661f\n" /* address */ \
34 ".previous\n" \
35 "661:\n\tlock; "
36
37#else /* ! CONFIG_SMP */
38#define LOCK_PREFIX ""
39#endif
40
41/* This must be included *after* the definition of LOCK_PREFIX */
42#include <asm/cpufeature.h>
43
44struct alt_instr {
45 u8 *instr; /* original instruction */
46 u8 *replacement;
47 u8 cpuid; /* cpuid bit set for replacement */
48 u8 instrlen; /* length of original instruction */
49 u8 replacementlen; /* length of new instruction, <= instrlen */
50 u8 pad1;
51#ifdef CONFIG_X86_64
52 u32 pad2;
53#endif
54};
55
56extern void alternative_instructions(void);
57extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
58
59struct module;
60
61#ifdef CONFIG_SMP
62extern void alternatives_smp_module_add(struct module *mod, char *name,
63 void *locks, void *locks_end,
64 void *text, void *text_end);
65extern void alternatives_smp_module_del(struct module *mod);
66extern void alternatives_smp_switch(int smp);
67#else
68static inline void alternatives_smp_module_add(struct module *mod, char *name,
69 void *locks, void *locks_end,
70 void *text, void *text_end) {}
71static inline void alternatives_smp_module_del(struct module *mod) {}
72static inline void alternatives_smp_switch(int smp) {}
73#endif /* CONFIG_SMP */
74
75/*
76 * Alternative instructions for different CPU types or capabilities.
77 *
78 * This allows to use optimized instructions even on generic binary
79 * kernels.
80 *
81 * length of oldinstr must be longer or equal the length of newinstr
82 * It can be padded with nops as needed.
83 *
84 * For non barrier like inlines please define new variants
85 * without volatile and memory clobber.
86 */
87#define alternative(oldinstr, newinstr, feature) \
88 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
89 ".section .altinstructions,\"a\"\n" \
90 _ASM_ALIGN "\n" \
91 _ASM_PTR "661b\n" /* label */ \
92 _ASM_PTR "663f\n" /* new instruction */ \
93 " .byte %c0\n" /* feature bit */ \
94 " .byte 662b-661b\n" /* sourcelen */ \
95 " .byte 664f-663f\n" /* replacementlen */ \
96 ".previous\n" \
97 ".section .altinstr_replacement,\"ax\"\n" \
98 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
99 ".previous" :: "i" (feature) : "memory")
100
101/*
102 * Alternative inline assembly with input.
103 *
104 * Pecularities:
105 * No memory clobber here.
106 * Argument numbers start with 1.
107 * Best is to use constraints that are fixed size (like (%1) ... "r")
108 * If you use variable sized constraints like "m" or "g" in the
109 * replacement make sure to pad to the worst case length.
110 */
111#define alternative_input(oldinstr, newinstr, feature, input...) \
112 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
113 ".section .altinstructions,\"a\"\n" \
114 _ASM_ALIGN "\n" \
115 _ASM_PTR "661b\n" /* label */ \
116 _ASM_PTR "663f\n" /* new instruction */ \
117 " .byte %c0\n" /* feature bit */ \
118 " .byte 662b-661b\n" /* sourcelen */ \
119 " .byte 664f-663f\n" /* replacementlen */ \
120 ".previous\n" \
121 ".section .altinstr_replacement,\"ax\"\n" \
122 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
123 ".previous" :: "i" (feature), ##input)
124
125/* Like alternative_input, but with a single output argument */
126#define alternative_io(oldinstr, newinstr, feature, output, input...) \
127 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
128 ".section .altinstructions,\"a\"\n" \
129 _ASM_ALIGN "\n" \
130 _ASM_PTR "661b\n" /* label */ \
131 _ASM_PTR "663f\n" /* new instruction */ \
132 " .byte %c[feat]\n" /* feature bit */ \
133 " .byte 662b-661b\n" /* sourcelen */ \
134 " .byte 664f-663f\n" /* replacementlen */ \
135 ".previous\n" \
136 ".section .altinstr_replacement,\"ax\"\n" \
137 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
138 ".previous" : output : [feat] "i" (feature), ##input)
139
140/*
141 * use this macro(s) if you need more than one output parameter
142 * in alternative_io
143 */
144#define ASM_OUTPUT2(a, b) a, b
145
146struct paravirt_patch_site;
147#ifdef CONFIG_PARAVIRT
148void apply_paravirt(struct paravirt_patch_site *start,
149 struct paravirt_patch_site *end);
3#else 150#else
4# include "alternative_64.h" 151static inline void
152apply_paravirt(struct paravirt_patch_site *start,
153 struct paravirt_patch_site *end)
154{}
155#define __parainstructions NULL
156#define __parainstructions_end NULL
5#endif 157#endif
158
159extern void text_poke(void *addr, unsigned char *opcode, int len);
160
161#endif /* _ASM_X86_ALTERNATIVE_H */
diff --git a/include/asm-x86/alternative_32.h b/include/asm-x86/alternative_32.h
deleted file mode 100644
index bda6c810c0f4..000000000000
--- a/include/asm-x86/alternative_32.h
+++ /dev/null
@@ -1,154 +0,0 @@
1#ifndef _I386_ALTERNATIVE_H
2#define _I386_ALTERNATIVE_H
3
4#include <asm/types.h>
5#include <linux/stddef.h>
6#include <linux/types.h>
7
8struct alt_instr {
9 u8 *instr; /* original instruction */
10 u8 *replacement;
11 u8 cpuid; /* cpuid bit set for replacement */
12 u8 instrlen; /* length of original instruction */
13 u8 replacementlen; /* length of new instruction, <= instrlen */
14 u8 pad;
15};
16
17extern void alternative_instructions(void);
18extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
19
20struct module;
21#ifdef CONFIG_SMP
22extern void alternatives_smp_module_add(struct module *mod, char *name,
23 void *locks, void *locks_end,
24 void *text, void *text_end);
25extern void alternatives_smp_module_del(struct module *mod);
26extern void alternatives_smp_switch(int smp);
27#else
28static inline void alternatives_smp_module_add(struct module *mod, char *name,
29 void *locks, void *locks_end,
30 void *text, void *text_end) {}
31static inline void alternatives_smp_module_del(struct module *mod) {}
32static inline void alternatives_smp_switch(int smp) {}
33#endif /* CONFIG_SMP */
34
35/*
36 * Alternative instructions for different CPU types or capabilities.
37 *
38 * This allows to use optimized instructions even on generic binary
39 * kernels.
40 *
41 * length of oldinstr must be longer or equal the length of newinstr
42 * It can be padded with nops as needed.
43 *
44 * For non barrier like inlines please define new variants
45 * without volatile and memory clobber.
46 */
47#define alternative(oldinstr, newinstr, feature) \
48 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
49 ".section .altinstructions,\"a\"\n" \
50 " .align 4\n" \
51 " .long 661b\n" /* label */ \
52 " .long 663f\n" /* new instruction */ \
53 " .byte %c0\n" /* feature bit */ \
54 " .byte 662b-661b\n" /* sourcelen */ \
55 " .byte 664f-663f\n" /* replacementlen */ \
56 ".previous\n" \
57 ".section .altinstr_replacement,\"ax\"\n" \
58 "663:\n\t" newinstr "\n664:\n" /* replacement */\
59 ".previous" :: "i" (feature) : "memory")
60
61/*
62 * Alternative inline assembly with input.
63 *
64 * Pecularities:
65 * No memory clobber here.
66 * Argument numbers start with 1.
67 * Best is to use constraints that are fixed size (like (%1) ... "r")
68 * If you use variable sized constraints like "m" or "g" in the
69 * replacement maake sure to pad to the worst case length.
70 */
71#define alternative_input(oldinstr, newinstr, feature, input...) \
72 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
73 ".section .altinstructions,\"a\"\n" \
74 " .align 4\n" \
75 " .long 661b\n" /* label */ \
76 " .long 663f\n" /* new instruction */ \
77 " .byte %c0\n" /* feature bit */ \
78 " .byte 662b-661b\n" /* sourcelen */ \
79 " .byte 664f-663f\n" /* replacementlen */ \
80 ".previous\n" \
81 ".section .altinstr_replacement,\"ax\"\n" \
82 "663:\n\t" newinstr "\n664:\n" /* replacement */\
83 ".previous" :: "i" (feature), ##input)
84
85/* Like alternative_input, but with a single output argument */
86#define alternative_io(oldinstr, newinstr, feature, output, input...) \
87 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
88 ".section .altinstructions,\"a\"\n" \
89 " .align 4\n" \
90 " .long 661b\n" /* label */ \
91 " .long 663f\n" /* new instruction */ \
92 " .byte %c[feat]\n" /* feature bit */ \
93 " .byte 662b-661b\n" /* sourcelen */ \
94 " .byte 664f-663f\n" /* replacementlen */ \
95 ".previous\n" \
96 ".section .altinstr_replacement,\"ax\"\n" \
97 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
98 ".previous" : output : [feat] "i" (feature), ##input)
99
100/*
101 * use this macro(s) if you need more than one output parameter
102 * in alternative_io
103 */
104#define ASM_OUTPUT2(a, b) a, b
105
106/*
107 * Alternative inline assembly for SMP.
108 *
109 * The LOCK_PREFIX macro defined here replaces the LOCK and
110 * LOCK_PREFIX macros used everywhere in the source tree.
111 *
112 * SMP alternatives use the same data structures as the other
113 * alternatives and the X86_FEATURE_UP flag to indicate the case of a
114 * UP system running a SMP kernel. The existing apply_alternatives()
115 * works fine for patching a SMP kernel for UP.
116 *
117 * The SMP alternative tables can be kept after boot and contain both
118 * UP and SMP versions of the instructions to allow switching back to
119 * SMP at runtime, when hotplugging in a new CPU, which is especially
120 * useful in virtualized environments.
121 *
122 * The very common lock prefix is handled as special case in a
123 * separate table which is a pure address list without replacement ptr
124 * and size information. That keeps the table sizes small.
125 */
126
127#ifdef CONFIG_SMP
128#define LOCK_PREFIX \
129 ".section .smp_locks,\"a\"\n" \
130 " .align 4\n" \
131 " .long 661f\n" /* address */ \
132 ".previous\n" \
133 "661:\n\tlock; "
134
135#else /* ! CONFIG_SMP */
136#define LOCK_PREFIX ""
137#endif
138
139struct paravirt_patch_site;
140#ifdef CONFIG_PARAVIRT
141void apply_paravirt(struct paravirt_patch_site *start,
142 struct paravirt_patch_site *end);
143#else
144static inline void
145apply_paravirt(struct paravirt_patch_site *start,
146 struct paravirt_patch_site *end)
147{}
148#define __parainstructions NULL
149#define __parainstructions_end NULL
150#endif
151
152extern void text_poke(void *addr, unsigned char *opcode, int len);
153
154#endif /* _I386_ALTERNATIVE_H */
diff --git a/include/asm-x86/alternative_64.h b/include/asm-x86/alternative_64.h
deleted file mode 100644
index ab161e810151..000000000000
--- a/include/asm-x86/alternative_64.h
+++ /dev/null
@@ -1,159 +0,0 @@
1#ifndef _X86_64_ALTERNATIVE_H
2#define _X86_64_ALTERNATIVE_H
3
4#ifdef __KERNEL__
5
6#include <linux/types.h>
7#include <linux/stddef.h>
8
9/*
10 * Alternative inline assembly for SMP.
11 *
12 * The LOCK_PREFIX macro defined here replaces the LOCK and
13 * LOCK_PREFIX macros used everywhere in the source tree.
14 *
15 * SMP alternatives use the same data structures as the other
16 * alternatives and the X86_FEATURE_UP flag to indicate the case of a
17 * UP system running a SMP kernel. The existing apply_alternatives()
18 * works fine for patching a SMP kernel for UP.
19 *
20 * The SMP alternative tables can be kept after boot and contain both
21 * UP and SMP versions of the instructions to allow switching back to
22 * SMP at runtime, when hotplugging in a new CPU, which is especially
23 * useful in virtualized environments.
24 *
25 * The very common lock prefix is handled as special case in a
26 * separate table which is a pure address list without replacement ptr
27 * and size information. That keeps the table sizes small.
28 */
29
30#ifdef CONFIG_SMP
31#define LOCK_PREFIX \
32 ".section .smp_locks,\"a\"\n" \
33 " .align 8\n" \
34 " .quad 661f\n" /* address */ \
35 ".previous\n" \
36 "661:\n\tlock; "
37
38#else /* ! CONFIG_SMP */
39#define LOCK_PREFIX ""
40#endif
41
42/* This must be included *after* the definition of LOCK_PREFIX */
43#include <asm/cpufeature.h>
44
45struct alt_instr {
46 u8 *instr; /* original instruction */
47 u8 *replacement;
48 u8 cpuid; /* cpuid bit set for replacement */
49 u8 instrlen; /* length of original instruction */
50 u8 replacementlen; /* length of new instruction, <= instrlen */
51 u8 pad[5];
52};
53
54extern void alternative_instructions(void);
55extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
56
57struct module;
58
59#ifdef CONFIG_SMP
60extern void alternatives_smp_module_add(struct module *mod, char *name,
61 void *locks, void *locks_end,
62 void *text, void *text_end);
63extern void alternatives_smp_module_del(struct module *mod);
64extern void alternatives_smp_switch(int smp);
65#else
66static inline void alternatives_smp_module_add(struct module *mod, char *name,
67 void *locks, void *locks_end,
68 void *text, void *text_end) {}
69static inline void alternatives_smp_module_del(struct module *mod) {}
70static inline void alternatives_smp_switch(int smp) {}
71#endif
72
73#endif
74
75/*
76 * Alternative instructions for different CPU types or capabilities.
77 *
78 * This allows to use optimized instructions even on generic binary
79 * kernels.
80 *
81 * length of oldinstr must be longer or equal the length of newinstr
82 * It can be padded with nops as needed.
83 *
84 * For non barrier like inlines please define new variants
85 * without volatile and memory clobber.
86 */
87#define alternative(oldinstr, newinstr, feature) \
88 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
89 ".section .altinstructions,\"a\"\n" \
90 " .align 8\n" \
91 " .quad 661b\n" /* label */ \
92 " .quad 663f\n" /* new instruction */ \
93 " .byte %c0\n" /* feature bit */ \
94 " .byte 662b-661b\n" /* sourcelen */ \
95 " .byte 664f-663f\n" /* replacementlen */ \
96 ".previous\n" \
97 ".section .altinstr_replacement,\"ax\"\n" \
98 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
99 ".previous" :: "i" (feature) : "memory")
100
101/*
102 * Alternative inline assembly with input.
103 *
104 * Pecularities:
105 * No memory clobber here.
106 * Argument numbers start with 1.
107 * Best is to use constraints that are fixed size (like (%1) ... "r")
108 * If you use variable sized constraints like "m" or "g" in the
109 * replacement make sure to pad to the worst case length.
110 */
111#define alternative_input(oldinstr, newinstr, feature, input...) \
112 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
113 ".section .altinstructions,\"a\"\n" \
114 " .align 8\n" \
115 " .quad 661b\n" /* label */ \
116 " .quad 663f\n" /* new instruction */ \
117 " .byte %c0\n" /* feature bit */ \
118 " .byte 662b-661b\n" /* sourcelen */ \
119 " .byte 664f-663f\n" /* replacementlen */ \
120 ".previous\n" \
121 ".section .altinstr_replacement,\"ax\"\n" \
122 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
123 ".previous" :: "i" (feature), ##input)
124
125/* Like alternative_input, but with a single output argument */
126#define alternative_io(oldinstr, newinstr, feature, output, input...) \
127 asm volatile ("661:\n\t" oldinstr "\n662:\n" \
128 ".section .altinstructions,\"a\"\n" \
129 " .align 8\n" \
130 " .quad 661b\n" /* label */ \
131 " .quad 663f\n" /* new instruction */ \
132 " .byte %c[feat]\n" /* feature bit */ \
133 " .byte 662b-661b\n" /* sourcelen */ \
134 " .byte 664f-663f\n" /* replacementlen */ \
135 ".previous\n" \
136 ".section .altinstr_replacement,\"ax\"\n" \
137 "663:\n\t" newinstr "\n664:\n" /* replacement */ \
138 ".previous" : output : [feat] "i" (feature), ##input)
139
140/*
141 * use this macro(s) if you need more than one output parameter
142 * in alternative_io
143 */
144#define ASM_OUTPUT2(a, b) a, b
145
146struct paravirt_patch;
147#ifdef CONFIG_PARAVIRT
148void apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end);
149#else
150static inline void
151apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
152{}
153#define __parainstructions NULL
154#define __parainstructions_end NULL
155#endif
156
157extern void text_poke(void *addr, unsigned char *opcode, int len);
158
159#endif /* _X86_64_ALTERNATIVE_H */
diff --git a/include/asm-x86/apic.h b/include/asm-x86/apic.h
index 9fbcc0bd2ac4..bcfc07fd3661 100644
--- a/include/asm-x86/apic.h
+++ b/include/asm-x86/apic.h
@@ -1,5 +1,140 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_APIC_H
2# include "apic_32.h" 2#define _ASM_X86_APIC_H
3
4#include <linux/pm.h>
5#include <linux/delay.h>
6#include <asm/fixmap.h>
7#include <asm/apicdef.h>
8#include <asm/processor.h>
9#include <asm/system.h>
10
11#define ARCH_APICTIMER_STOPS_ON_C3 1
12
13#define Dprintk(x...)
14
15/*
16 * Debugging macros
17 */
18#define APIC_QUIET 0
19#define APIC_VERBOSE 1
20#define APIC_DEBUG 2
21
22/*
23 * Define the default level of output to be very little
24 * This can be turned up by using apic=verbose for more
25 * information and apic=debug for _lots_ of information.
26 * apic_verbosity is defined in apic.c
27 */
28#define apic_printk(v, s, a...) do { \
29 if ((v) <= apic_verbosity) \
30 printk(s, ##a); \
31 } while (0)
32
33
34extern void generic_apic_probe(void);
35
36#ifdef CONFIG_X86_LOCAL_APIC
37
38extern int apic_verbosity;
39extern int timer_over_8254;
40extern int local_apic_timer_c2_ok;
41extern int local_apic_timer_disabled;
42
43extern int apic_runs_main_timer;
44extern int ioapic_force;
45extern int disable_apic;
46extern int disable_apic_timer;
47extern unsigned boot_cpu_id;
48
49/*
50 * Basic functions accessing APICs.
51 */
52#ifdef CONFIG_PARAVIRT
53#include <asm/paravirt.h>
3#else 54#else
4# include "apic_64.h" 55#define apic_write native_apic_write
56#define apic_write_atomic native_apic_write_atomic
57#define apic_read native_apic_read
58#define setup_boot_clock setup_boot_APIC_clock
59#define setup_secondary_clock setup_secondary_APIC_clock
5#endif 60#endif
61
62static inline void native_apic_write(unsigned long reg, u32 v)
63{
64 *((volatile u32 *)(APIC_BASE + reg)) = v;
65}
66
67static inline void native_apic_write_atomic(unsigned long reg, u32 v)
68{
69 (void) xchg((u32*)(APIC_BASE + reg), v);
70}
71
72static inline u32 native_apic_read(unsigned long reg)
73{
74 return *((volatile u32 *)(APIC_BASE + reg));
75}
76
77extern void apic_wait_icr_idle(void);
78extern u32 safe_apic_wait_icr_idle(void);
79extern int get_physical_broadcast(void);
80
81#ifdef CONFIG_X86_GOOD_APIC
82# define FORCE_READ_AROUND_WRITE 0
83# define apic_read_around(x)
84# define apic_write_around(x, y) apic_write((x), (y))
85#else
86# define FORCE_READ_AROUND_WRITE 1
87# define apic_read_around(x) apic_read(x)
88# define apic_write_around(x, y) apic_write_atomic((x), (y))
89#endif
90
91static inline void ack_APIC_irq(void)
92{
93 /*
94 * ack_APIC_irq() actually gets compiled as a single instruction:
95 * - a single rmw on Pentium/82489DX
96 * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
97 * ... yummie.
98 */
99
100 /* Docs say use 0 for future compatibility */
101 apic_write_around(APIC_EOI, 0);
102}
103
104extern int lapic_get_maxlvt(void);
105extern void clear_local_APIC(void);
106extern void connect_bsp_APIC(void);
107extern void disconnect_bsp_APIC(int virt_wire_setup);
108extern void disable_local_APIC(void);
109extern void lapic_shutdown(void);
110extern int verify_local_APIC(void);
111extern void cache_APIC_registers(void);
112extern void sync_Arb_IDs(void);
113extern void init_bsp_APIC(void);
114extern void setup_local_APIC(void);
115extern void end_local_APIC_setup(void);
116extern void init_apic_mappings(void);
117extern void setup_boot_APIC_clock(void);
118extern void setup_secondary_APIC_clock(void);
119extern int APIC_init_uniprocessor(void);
120extern void enable_NMI_through_LVT0(void);
121
122/*
123 * On 32bit this is mach-xxx local
124 */
125#ifdef CONFIG_X86_64
126extern void setup_apic_routing(void);
127#endif
128
129extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
130extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
131
132extern int apic_is_clustered_box(void);
133
134#else /* !CONFIG_X86_LOCAL_APIC */
135static inline void lapic_shutdown(void) { }
136#define local_apic_timer_c2_ok 1
137
138#endif /* !CONFIG_X86_LOCAL_APIC */
139
140#endif /* __ASM_APIC_H */
diff --git a/include/asm-x86/apic_32.h b/include/asm-x86/apic_32.h
deleted file mode 100644
index 4091b33dcb10..000000000000
--- a/include/asm-x86/apic_32.h
+++ /dev/null
@@ -1,126 +0,0 @@
1#ifndef __ASM_APIC_H
2#define __ASM_APIC_H
3
4#include <linux/pm.h>
5#include <linux/delay.h>
6#include <asm/fixmap.h>
7#include <asm/apicdef.h>
8#include <asm/processor.h>
9#include <asm/system.h>
10
11#define Dprintk(x...)
12
13/*
14 * Debugging macros
15 */
16#define APIC_QUIET 0
17#define APIC_VERBOSE 1
18#define APIC_DEBUG 2
19
20extern int apic_verbosity;
21
22/*
23 * Define the default level of output to be very little
24 * This can be turned up by using apic=verbose for more
25 * information and apic=debug for _lots_ of information.
26 * apic_verbosity is defined in apic.c
27 */
28#define apic_printk(v, s, a...) do { \
29 if ((v) <= apic_verbosity) \
30 printk(s, ##a); \
31 } while (0)
32
33
34extern void generic_apic_probe(void);
35
36#ifdef CONFIG_X86_LOCAL_APIC
37
38/*
39 * Basic functions accessing APICs.
40 */
41#ifdef CONFIG_PARAVIRT
42#include <asm/paravirt.h>
43#else
44#define apic_write native_apic_write
45#define apic_write_atomic native_apic_write_atomic
46#define apic_read native_apic_read
47#define setup_boot_clock setup_boot_APIC_clock
48#define setup_secondary_clock setup_secondary_APIC_clock
49#endif
50
51static __inline fastcall void native_apic_write(unsigned long reg,
52 unsigned long v)
53{
54 *((volatile unsigned long *)(APIC_BASE+reg)) = v;
55}
56
57static __inline fastcall void native_apic_write_atomic(unsigned long reg,
58 unsigned long v)
59{
60 xchg((volatile unsigned long *)(APIC_BASE+reg), v);
61}
62
63static __inline fastcall unsigned long native_apic_read(unsigned long reg)
64{
65 return *((volatile unsigned long *)(APIC_BASE+reg));
66}
67
68void apic_wait_icr_idle(void);
69unsigned long safe_apic_wait_icr_idle(void);
70int get_physical_broadcast(void);
71
72#ifdef CONFIG_X86_GOOD_APIC
73# define FORCE_READ_AROUND_WRITE 0
74# define apic_read_around(x)
75# define apic_write_around(x,y) apic_write((x),(y))
76#else
77# define FORCE_READ_AROUND_WRITE 1
78# define apic_read_around(x) apic_read(x)
79# define apic_write_around(x,y) apic_write_atomic((x),(y))
80#endif
81
82static inline void ack_APIC_irq(void)
83{
84 /*
85 * ack_APIC_irq() actually gets compiled as a single instruction:
86 * - a single rmw on Pentium/82489DX
87 * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
88 * ... yummie.
89 */
90
91 /* Docs say use 0 for future compatibility */
92 apic_write_around(APIC_EOI, 0);
93}
94
95extern int lapic_get_maxlvt(void);
96extern void clear_local_APIC(void);
97extern void connect_bsp_APIC (void);
98extern void disconnect_bsp_APIC (int virt_wire_setup);
99extern void disable_local_APIC (void);
100extern void lapic_shutdown (void);
101extern int verify_local_APIC (void);
102extern void cache_APIC_registers (void);
103extern void sync_Arb_IDs (void);
104extern void init_bsp_APIC (void);
105extern void setup_local_APIC (void);
106extern void init_apic_mappings (void);
107extern void smp_local_timer_interrupt (void);
108extern void setup_boot_APIC_clock (void);
109extern void setup_secondary_APIC_clock (void);
110extern int APIC_init_uniprocessor (void);
111
112extern void enable_NMI_through_LVT0 (void * dummy);
113
114#define ARCH_APICTIMER_STOPS_ON_C3 1
115
116extern int timer_over_8254;
117extern int local_apic_timer_c2_ok;
118
119extern int local_apic_timer_disabled;
120
121#else /* !CONFIG_X86_LOCAL_APIC */
122static inline void lapic_shutdown(void) { }
123
124#endif /* !CONFIG_X86_LOCAL_APIC */
125
126#endif /* __ASM_APIC_H */
diff --git a/include/asm-x86/apic_64.h b/include/asm-x86/apic_64.h
deleted file mode 100644
index 2747a11a2b19..000000000000
--- a/include/asm-x86/apic_64.h
+++ /dev/null
@@ -1,102 +0,0 @@
1#ifndef __ASM_APIC_H
2#define __ASM_APIC_H
3
4#include <linux/pm.h>
5#include <linux/delay.h>
6#include <asm/fixmap.h>
7#include <asm/apicdef.h>
8#include <asm/system.h>
9
10#define Dprintk(x...)
11
12/*
13 * Debugging macros
14 */
15#define APIC_QUIET 0
16#define APIC_VERBOSE 1
17#define APIC_DEBUG 2
18
19extern int apic_verbosity;
20extern int apic_runs_main_timer;
21extern int ioapic_force;
22extern int disable_apic_timer;
23
24/*
25 * Define the default level of output to be very little
26 * This can be turned up by using apic=verbose for more
27 * information and apic=debug for _lots_ of information.
28 * apic_verbosity is defined in apic.c
29 */
30#define apic_printk(v, s, a...) do { \
31 if ((v) <= apic_verbosity) \
32 printk(s, ##a); \
33 } while (0)
34
35struct pt_regs;
36
37/*
38 * Basic functions accessing APICs.
39 */
40
41static __inline void apic_write(unsigned long reg, unsigned int v)
42{
43 *((volatile unsigned int *)(APIC_BASE+reg)) = v;
44}
45
46static __inline unsigned int apic_read(unsigned long reg)
47{
48 return *((volatile unsigned int *)(APIC_BASE+reg));
49}
50
51extern void apic_wait_icr_idle(void);
52extern unsigned int safe_apic_wait_icr_idle(void);
53
54static inline void ack_APIC_irq(void)
55{
56 /*
57 * ack_APIC_irq() actually gets compiled as a single instruction:
58 * - a single rmw on Pentium/82489DX
59 * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
60 * ... yummie.
61 */
62
63 /* Docs say use 0 for future compatibility */
64 apic_write(APIC_EOI, 0);
65}
66
67extern int get_maxlvt (void);
68extern void clear_local_APIC (void);
69extern void connect_bsp_APIC (void);
70extern void disconnect_bsp_APIC (int virt_wire_setup);
71extern void disable_local_APIC (void);
72extern void lapic_shutdown (void);
73extern int verify_local_APIC (void);
74extern void cache_APIC_registers (void);
75extern void sync_Arb_IDs (void);
76extern void init_bsp_APIC (void);
77extern void setup_local_APIC (void);
78extern void init_apic_mappings (void);
79extern void smp_local_timer_interrupt (void);
80extern void setup_boot_APIC_clock (void);
81extern void setup_secondary_APIC_clock (void);
82extern int APIC_init_uniprocessor (void);
83extern void setup_apic_routing(void);
84
85extern void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector,
86 unsigned char msg_type, unsigned char mask);
87
88extern int apic_is_clustered_box(void);
89
90#define K8_APIC_EXT_LVT_BASE 0x500
91#define K8_APIC_EXT_INT_MSG_FIX 0x0
92#define K8_APIC_EXT_INT_MSG_SMI 0x2
93#define K8_APIC_EXT_INT_MSG_NMI 0x4
94#define K8_APIC_EXT_INT_MSG_EXT 0x7
95#define K8_APIC_EXT_LVT_ENTRY_THRESHOLD 0
96
97#define ARCH_APICTIMER_STOPS_ON_C3 1
98
99extern unsigned boot_cpu_id;
100extern int local_apic_timer_c2_ok;
101
102#endif /* __ASM_APIC_H */
diff --git a/include/asm-x86/apicdef.h b/include/asm-x86/apicdef.h
index 4542c220bf4d..550af7a6f88e 100644
--- a/include/asm-x86/apicdef.h
+++ b/include/asm-x86/apicdef.h
@@ -1,5 +1,413 @@
1#ifndef _ASM_X86_APICDEF_H
2#define _ASM_X86_APICDEF_H
3
4/*
5 * Constants for various Intel APICs. (local APIC, IOAPIC, etc.)
6 *
7 * Alan Cox <Alan.Cox@linux.org>, 1995.
8 * Ingo Molnar <mingo@redhat.com>, 1999, 2000
9 */
10
11#define APIC_DEFAULT_PHYS_BASE 0xfee00000
12
13#define APIC_ID 0x20
14
15#ifdef CONFIG_X86_64
16# define APIC_ID_MASK (0xFFu<<24)
17# define GET_APIC_ID(x) (((x)>>24)&0xFFu)
18# define SET_APIC_ID(x) (((x)<<24))
19#endif
20
21#define APIC_LVR 0x30
22#define APIC_LVR_MASK 0xFF00FF
23#define GET_APIC_VERSION(x) ((x)&0xFFu)
24#define GET_APIC_MAXLVT(x) (((x)>>16)&0xFFu)
25#define APIC_INTEGRATED(x) ((x)&0xF0u)
26#define APIC_XAPIC(x) ((x) >= 0x14)
27#define APIC_TASKPRI 0x80
28#define APIC_TPRI_MASK 0xFFu
29#define APIC_ARBPRI 0x90
30#define APIC_ARBPRI_MASK 0xFFu
31#define APIC_PROCPRI 0xA0
32#define APIC_EOI 0xB0
33#define APIC_EIO_ACK 0x0
34#define APIC_RRR 0xC0
35#define APIC_LDR 0xD0
36#define APIC_LDR_MASK (0xFFu<<24)
37#define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFFu)
38#define SET_APIC_LOGICAL_ID(x) (((x)<<24))
39#define APIC_ALL_CPUS 0xFFu
40#define APIC_DFR 0xE0
41#define APIC_DFR_CLUSTER 0x0FFFFFFFul
42#define APIC_DFR_FLAT 0xFFFFFFFFul
43#define APIC_SPIV 0xF0
44#define APIC_SPIV_FOCUS_DISABLED (1<<9)
45#define APIC_SPIV_APIC_ENABLED (1<<8)
46#define APIC_ISR 0x100
47#define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */
48#define APIC_TMR 0x180
49#define APIC_IRR 0x200
50#define APIC_ESR 0x280
51#define APIC_ESR_SEND_CS 0x00001
52#define APIC_ESR_RECV_CS 0x00002
53#define APIC_ESR_SEND_ACC 0x00004
54#define APIC_ESR_RECV_ACC 0x00008
55#define APIC_ESR_SENDILL 0x00020
56#define APIC_ESR_RECVILL 0x00040
57#define APIC_ESR_ILLREGA 0x00080
58#define APIC_ICR 0x300
59#define APIC_DEST_SELF 0x40000
60#define APIC_DEST_ALLINC 0x80000
61#define APIC_DEST_ALLBUT 0xC0000
62#define APIC_ICR_RR_MASK 0x30000
63#define APIC_ICR_RR_INVALID 0x00000
64#define APIC_ICR_RR_INPROG 0x10000
65#define APIC_ICR_RR_VALID 0x20000
66#define APIC_INT_LEVELTRIG 0x08000
67#define APIC_INT_ASSERT 0x04000
68#define APIC_ICR_BUSY 0x01000
69#define APIC_DEST_LOGICAL 0x00800
70#define APIC_DEST_PHYSICAL 0x00000
71#define APIC_DM_FIXED 0x00000
72#define APIC_DM_LOWEST 0x00100
73#define APIC_DM_SMI 0x00200
74#define APIC_DM_REMRD 0x00300
75#define APIC_DM_NMI 0x00400
76#define APIC_DM_INIT 0x00500
77#define APIC_DM_STARTUP 0x00600
78#define APIC_DM_EXTINT 0x00700
79#define APIC_VECTOR_MASK 0x000FF
80#define APIC_ICR2 0x310
81#define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF)
82#define SET_APIC_DEST_FIELD(x) ((x)<<24)
83#define APIC_LVTT 0x320
84#define APIC_LVTTHMR 0x330
85#define APIC_LVTPC 0x340
86#define APIC_LVT0 0x350
87#define APIC_LVT_TIMER_BASE_MASK (0x3<<18)
88#define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3)
89#define SET_APIC_TIMER_BASE(x) (((x)<<18))
90#define APIC_TIMER_BASE_CLKIN 0x0
91#define APIC_TIMER_BASE_TMBASE 0x1
92#define APIC_TIMER_BASE_DIV 0x2
93#define APIC_LVT_TIMER_PERIODIC (1<<17)
94#define APIC_LVT_MASKED (1<<16)
95#define APIC_LVT_LEVEL_TRIGGER (1<<15)
96#define APIC_LVT_REMOTE_IRR (1<<14)
97#define APIC_INPUT_POLARITY (1<<13)
98#define APIC_SEND_PENDING (1<<12)
99#define APIC_MODE_MASK 0x700
100#define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7)
101#define SET_APIC_DELIVERY_MODE(x, y) (((x)&~0x700)|((y)<<8))
102#define APIC_MODE_FIXED 0x0
103#define APIC_MODE_NMI 0x4
104#define APIC_MODE_EXTINT 0x7
105#define APIC_LVT1 0x360
106#define APIC_LVTERR 0x370
107#define APIC_TMICT 0x380
108#define APIC_TMCCT 0x390
109#define APIC_TDCR 0x3E0
110#define APIC_TDR_DIV_TMBASE (1<<2)
111#define APIC_TDR_DIV_1 0xB
112#define APIC_TDR_DIV_2 0x0
113#define APIC_TDR_DIV_4 0x1
114#define APIC_TDR_DIV_8 0x2
115#define APIC_TDR_DIV_16 0x3
116#define APIC_TDR_DIV_32 0x8
117#define APIC_TDR_DIV_64 0x9
118#define APIC_TDR_DIV_128 0xA
119#define APIC_EILVT0 0x500
120#define APIC_EILVT_NR_AMD_K8 1 /* Number of extended interrupts */
121#define APIC_EILVT_NR_AMD_10H 4
122#define APIC_EILVT_LVTOFF(x) (((x)>>4)&0xF)
123#define APIC_EILVT_MSG_FIX 0x0
124#define APIC_EILVT_MSG_SMI 0x2
125#define APIC_EILVT_MSG_NMI 0x4
126#define APIC_EILVT_MSG_EXT 0x7
127#define APIC_EILVT_MASKED (1<<16)
128#define APIC_EILVT1 0x510
129#define APIC_EILVT2 0x520
130#define APIC_EILVT3 0x530
131
132#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
133
1#ifdef CONFIG_X86_32 134#ifdef CONFIG_X86_32
2# include "apicdef_32.h" 135# define MAX_IO_APICS 64
3#else 136#else
4# include "apicdef_64.h" 137# define MAX_IO_APICS 128
138# define MAX_LOCAL_APIC 256
139#endif
140
141/*
142 * All x86-64 systems are xAPIC compatible.
143 * In the following, "apicid" is a physical APIC ID.
144 */
145#define XAPIC_DEST_CPUS_SHIFT 4
146#define XAPIC_DEST_CPUS_MASK ((1u << XAPIC_DEST_CPUS_SHIFT) - 1)
147#define XAPIC_DEST_CLUSTER_MASK (XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT)
148#define APIC_CLUSTER(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK)
149#define APIC_CLUSTERID(apicid) (APIC_CLUSTER(apicid) >> XAPIC_DEST_CPUS_SHIFT)
150#define APIC_CPUID(apicid) ((apicid) & XAPIC_DEST_CPUS_MASK)
151#define NUM_APIC_CLUSTERS ((BAD_APICID + 1) >> XAPIC_DEST_CPUS_SHIFT)
152
153/*
154 * the local APIC register structure, memory mapped. Not terribly well
155 * tested, but we might eventually use this one in the future - the
156 * problem why we cannot use it right now is the P5 APIC, it has an
157 * errata which cannot take 8-bit reads and writes, only 32-bit ones ...
158 */
159#define u32 unsigned int
160
161struct local_apic {
162
163/*000*/ struct { u32 __reserved[4]; } __reserved_01;
164
165/*010*/ struct { u32 __reserved[4]; } __reserved_02;
166
167/*020*/ struct { /* APIC ID Register */
168 u32 __reserved_1 : 24,
169 phys_apic_id : 4,
170 __reserved_2 : 4;
171 u32 __reserved[3];
172 } id;
173
174/*030*/ const
175 struct { /* APIC Version Register */
176 u32 version : 8,
177 __reserved_1 : 8,
178 max_lvt : 8,
179 __reserved_2 : 8;
180 u32 __reserved[3];
181 } version;
182
183/*040*/ struct { u32 __reserved[4]; } __reserved_03;
184
185/*050*/ struct { u32 __reserved[4]; } __reserved_04;
186
187/*060*/ struct { u32 __reserved[4]; } __reserved_05;
188
189/*070*/ struct { u32 __reserved[4]; } __reserved_06;
190
191/*080*/ struct { /* Task Priority Register */
192 u32 priority : 8,
193 __reserved_1 : 24;
194 u32 __reserved_2[3];
195 } tpr;
196
197/*090*/ const
198 struct { /* Arbitration Priority Register */
199 u32 priority : 8,
200 __reserved_1 : 24;
201 u32 __reserved_2[3];
202 } apr;
203
204/*0A0*/ const
205 struct { /* Processor Priority Register */
206 u32 priority : 8,
207 __reserved_1 : 24;
208 u32 __reserved_2[3];
209 } ppr;
210
211/*0B0*/ struct { /* End Of Interrupt Register */
212 u32 eoi;
213 u32 __reserved[3];
214 } eoi;
215
216/*0C0*/ struct { u32 __reserved[4]; } __reserved_07;
217
218/*0D0*/ struct { /* Logical Destination Register */
219 u32 __reserved_1 : 24,
220 logical_dest : 8;
221 u32 __reserved_2[3];
222 } ldr;
223
224/*0E0*/ struct { /* Destination Format Register */
225 u32 __reserved_1 : 28,
226 model : 4;
227 u32 __reserved_2[3];
228 } dfr;
229
230/*0F0*/ struct { /* Spurious Interrupt Vector Register */
231 u32 spurious_vector : 8,
232 apic_enabled : 1,
233 focus_cpu : 1,
234 __reserved_2 : 22;
235 u32 __reserved_3[3];
236 } svr;
237
238/*100*/ struct { /* In Service Register */
239/*170*/ u32 bitfield;
240 u32 __reserved[3];
241 } isr [8];
242
243/*180*/ struct { /* Trigger Mode Register */
244/*1F0*/ u32 bitfield;
245 u32 __reserved[3];
246 } tmr [8];
247
248/*200*/ struct { /* Interrupt Request Register */
249/*270*/ u32 bitfield;
250 u32 __reserved[3];
251 } irr [8];
252
253/*280*/ union { /* Error Status Register */
254 struct {
255 u32 send_cs_error : 1,
256 receive_cs_error : 1,
257 send_accept_error : 1,
258 receive_accept_error : 1,
259 __reserved_1 : 1,
260 send_illegal_vector : 1,
261 receive_illegal_vector : 1,
262 illegal_register_address : 1,
263 __reserved_2 : 24;
264 u32 __reserved_3[3];
265 } error_bits;
266 struct {
267 u32 errors;
268 u32 __reserved_3[3];
269 } all_errors;
270 } esr;
271
272/*290*/ struct { u32 __reserved[4]; } __reserved_08;
273
274/*2A0*/ struct { u32 __reserved[4]; } __reserved_09;
275
276/*2B0*/ struct { u32 __reserved[4]; } __reserved_10;
277
278/*2C0*/ struct { u32 __reserved[4]; } __reserved_11;
279
280/*2D0*/ struct { u32 __reserved[4]; } __reserved_12;
281
282/*2E0*/ struct { u32 __reserved[4]; } __reserved_13;
283
284/*2F0*/ struct { u32 __reserved[4]; } __reserved_14;
285
286/*300*/ struct { /* Interrupt Command Register 1 */
287 u32 vector : 8,
288 delivery_mode : 3,
289 destination_mode : 1,
290 delivery_status : 1,
291 __reserved_1 : 1,
292 level : 1,
293 trigger : 1,
294 __reserved_2 : 2,
295 shorthand : 2,
296 __reserved_3 : 12;
297 u32 __reserved_4[3];
298 } icr1;
299
300/*310*/ struct { /* Interrupt Command Register 2 */
301 union {
302 u32 __reserved_1 : 24,
303 phys_dest : 4,
304 __reserved_2 : 4;
305 u32 __reserved_3 : 24,
306 logical_dest : 8;
307 } dest;
308 u32 __reserved_4[3];
309 } icr2;
310
311/*320*/ struct { /* LVT - Timer */
312 u32 vector : 8,
313 __reserved_1 : 4,
314 delivery_status : 1,
315 __reserved_2 : 3,
316 mask : 1,
317 timer_mode : 1,
318 __reserved_3 : 14;
319 u32 __reserved_4[3];
320 } lvt_timer;
321
322/*330*/ struct { /* LVT - Thermal Sensor */
323 u32 vector : 8,
324 delivery_mode : 3,
325 __reserved_1 : 1,
326 delivery_status : 1,
327 __reserved_2 : 3,
328 mask : 1,
329 __reserved_3 : 15;
330 u32 __reserved_4[3];
331 } lvt_thermal;
332
333/*340*/ struct { /* LVT - Performance Counter */
334 u32 vector : 8,
335 delivery_mode : 3,
336 __reserved_1 : 1,
337 delivery_status : 1,
338 __reserved_2 : 3,
339 mask : 1,
340 __reserved_3 : 15;
341 u32 __reserved_4[3];
342 } lvt_pc;
343
344/*350*/ struct { /* LVT - LINT0 */
345 u32 vector : 8,
346 delivery_mode : 3,
347 __reserved_1 : 1,
348 delivery_status : 1,
349 polarity : 1,
350 remote_irr : 1,
351 trigger : 1,
352 mask : 1,
353 __reserved_2 : 15;
354 u32 __reserved_3[3];
355 } lvt_lint0;
356
357/*360*/ struct { /* LVT - LINT1 */
358 u32 vector : 8,
359 delivery_mode : 3,
360 __reserved_1 : 1,
361 delivery_status : 1,
362 polarity : 1,
363 remote_irr : 1,
364 trigger : 1,
365 mask : 1,
366 __reserved_2 : 15;
367 u32 __reserved_3[3];
368 } lvt_lint1;
369
370/*370*/ struct { /* LVT - Error */
371 u32 vector : 8,
372 __reserved_1 : 4,
373 delivery_status : 1,
374 __reserved_2 : 3,
375 mask : 1,
376 __reserved_3 : 15;
377 u32 __reserved_4[3];
378 } lvt_error;
379
380/*380*/ struct { /* Timer Initial Count Register */
381 u32 initial_count;
382 u32 __reserved_2[3];
383 } timer_icr;
384
385/*390*/ const
386 struct { /* Timer Current Count Register */
387 u32 curr_count;
388 u32 __reserved_2[3];
389 } timer_ccr;
390
391/*3A0*/ struct { u32 __reserved[4]; } __reserved_16;
392
393/*3B0*/ struct { u32 __reserved[4]; } __reserved_17;
394
395/*3C0*/ struct { u32 __reserved[4]; } __reserved_18;
396
397/*3D0*/ struct { u32 __reserved[4]; } __reserved_19;
398
399/*3E0*/ struct { /* Timer Divide Configuration Register */
400 u32 divisor : 4,
401 __reserved_1 : 28;
402 u32 __reserved_2[3];
403 } timer_dcr;
404
405/*3F0*/ struct { u32 __reserved[4]; } __reserved_20;
406
407} __attribute__ ((packed));
408
409#undef u32
410
411#define BAD_APICID 0xFFu
412
5#endif 413#endif
diff --git a/include/asm-x86/apicdef_32.h b/include/asm-x86/apicdef_32.h
deleted file mode 100644
index 9f6995341fdc..000000000000
--- a/include/asm-x86/apicdef_32.h
+++ /dev/null
@@ -1,375 +0,0 @@
1#ifndef __ASM_APICDEF_H
2#define __ASM_APICDEF_H
3
4/*
5 * Constants for various Intel APICs. (local APIC, IOAPIC, etc.)
6 *
7 * Alan Cox <Alan.Cox@linux.org>, 1995.
8 * Ingo Molnar <mingo@redhat.com>, 1999, 2000
9 */
10
11#define APIC_DEFAULT_PHYS_BASE 0xfee00000
12
13#define APIC_ID 0x20
14#define APIC_LVR 0x30
15#define APIC_LVR_MASK 0xFF00FF
16#define GET_APIC_VERSION(x) ((x)&0xFF)
17#define GET_APIC_MAXLVT(x) (((x)>>16)&0xFF)
18#define APIC_INTEGRATED(x) ((x)&0xF0)
19#define APIC_XAPIC(x) ((x) >= 0x14)
20#define APIC_TASKPRI 0x80
21#define APIC_TPRI_MASK 0xFF
22#define APIC_ARBPRI 0x90
23#define APIC_ARBPRI_MASK 0xFF
24#define APIC_PROCPRI 0xA0
25#define APIC_EOI 0xB0
26#define APIC_EIO_ACK 0x0 /* Write this to the EOI register */
27#define APIC_RRR 0xC0
28#define APIC_LDR 0xD0
29#define APIC_LDR_MASK (0xFF<<24)
30#define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFF)
31#define SET_APIC_LOGICAL_ID(x) (((x)<<24))
32#define APIC_ALL_CPUS 0xFF
33#define APIC_DFR 0xE0
34#define APIC_DFR_CLUSTER 0x0FFFFFFFul
35#define APIC_DFR_FLAT 0xFFFFFFFFul
36#define APIC_SPIV 0xF0
37#define APIC_SPIV_FOCUS_DISABLED (1<<9)
38#define APIC_SPIV_APIC_ENABLED (1<<8)
39#define APIC_ISR 0x100
40#define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */
41#define APIC_TMR 0x180
42#define APIC_IRR 0x200
43#define APIC_ESR 0x280
44#define APIC_ESR_SEND_CS 0x00001
45#define APIC_ESR_RECV_CS 0x00002
46#define APIC_ESR_SEND_ACC 0x00004
47#define APIC_ESR_RECV_ACC 0x00008
48#define APIC_ESR_SENDILL 0x00020
49#define APIC_ESR_RECVILL 0x00040
50#define APIC_ESR_ILLREGA 0x00080
51#define APIC_ICR 0x300
52#define APIC_DEST_SELF 0x40000
53#define APIC_DEST_ALLINC 0x80000
54#define APIC_DEST_ALLBUT 0xC0000
55#define APIC_ICR_RR_MASK 0x30000
56#define APIC_ICR_RR_INVALID 0x00000
57#define APIC_ICR_RR_INPROG 0x10000
58#define APIC_ICR_RR_VALID 0x20000
59#define APIC_INT_LEVELTRIG 0x08000
60#define APIC_INT_ASSERT 0x04000
61#define APIC_ICR_BUSY 0x01000
62#define APIC_DEST_LOGICAL 0x00800
63#define APIC_DM_FIXED 0x00000
64#define APIC_DM_LOWEST 0x00100
65#define APIC_DM_SMI 0x00200
66#define APIC_DM_REMRD 0x00300
67#define APIC_DM_NMI 0x00400
68#define APIC_DM_INIT 0x00500
69#define APIC_DM_STARTUP 0x00600
70#define APIC_DM_EXTINT 0x00700
71#define APIC_VECTOR_MASK 0x000FF
72#define APIC_ICR2 0x310
73#define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF)
74#define SET_APIC_DEST_FIELD(x) ((x)<<24)
75#define APIC_LVTT 0x320
76#define APIC_LVTTHMR 0x330
77#define APIC_LVTPC 0x340
78#define APIC_LVT0 0x350
79#define APIC_LVT_TIMER_BASE_MASK (0x3<<18)
80#define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3)
81#define SET_APIC_TIMER_BASE(x) (((x)<<18))
82#define APIC_TIMER_BASE_CLKIN 0x0
83#define APIC_TIMER_BASE_TMBASE 0x1
84#define APIC_TIMER_BASE_DIV 0x2
85#define APIC_LVT_TIMER_PERIODIC (1<<17)
86#define APIC_LVT_MASKED (1<<16)
87#define APIC_LVT_LEVEL_TRIGGER (1<<15)
88#define APIC_LVT_REMOTE_IRR (1<<14)
89#define APIC_INPUT_POLARITY (1<<13)
90#define APIC_SEND_PENDING (1<<12)
91#define APIC_MODE_MASK 0x700
92#define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7)
93#define SET_APIC_DELIVERY_MODE(x,y) (((x)&~0x700)|((y)<<8))
94#define APIC_MODE_FIXED 0x0
95#define APIC_MODE_NMI 0x4
96#define APIC_MODE_EXTINT 0x7
97#define APIC_LVT1 0x360
98#define APIC_LVTERR 0x370
99#define APIC_TMICT 0x380
100#define APIC_TMCCT 0x390
101#define APIC_TDCR 0x3E0
102#define APIC_TDR_DIV_TMBASE (1<<2)
103#define APIC_TDR_DIV_1 0xB
104#define APIC_TDR_DIV_2 0x0
105#define APIC_TDR_DIV_4 0x1
106#define APIC_TDR_DIV_8 0x2
107#define APIC_TDR_DIV_16 0x3
108#define APIC_TDR_DIV_32 0x8
109#define APIC_TDR_DIV_64 0x9
110#define APIC_TDR_DIV_128 0xA
111
112#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
113
114#define MAX_IO_APICS 64
115
116/*
117 * the local APIC register structure, memory mapped. Not terribly well
118 * tested, but we might eventually use this one in the future - the
119 * problem why we cannot use it right now is the P5 APIC, it has an
120 * errata which cannot take 8-bit reads and writes, only 32-bit ones ...
121 */
122#define u32 unsigned int
123
124
125struct local_apic {
126
127/*000*/ struct { u32 __reserved[4]; } __reserved_01;
128
129/*010*/ struct { u32 __reserved[4]; } __reserved_02;
130
131/*020*/ struct { /* APIC ID Register */
132 u32 __reserved_1 : 24,
133 phys_apic_id : 4,
134 __reserved_2 : 4;
135 u32 __reserved[3];
136 } id;
137
138/*030*/ const
139 struct { /* APIC Version Register */
140 u32 version : 8,
141 __reserved_1 : 8,
142 max_lvt : 8,
143 __reserved_2 : 8;
144 u32 __reserved[3];
145 } version;
146
147/*040*/ struct { u32 __reserved[4]; } __reserved_03;
148
149/*050*/ struct { u32 __reserved[4]; } __reserved_04;
150
151/*060*/ struct { u32 __reserved[4]; } __reserved_05;
152
153/*070*/ struct { u32 __reserved[4]; } __reserved_06;
154
155/*080*/ struct { /* Task Priority Register */
156 u32 priority : 8,
157 __reserved_1 : 24;
158 u32 __reserved_2[3];
159 } tpr;
160
161/*090*/ const
162 struct { /* Arbitration Priority Register */
163 u32 priority : 8,
164 __reserved_1 : 24;
165 u32 __reserved_2[3];
166 } apr;
167
168/*0A0*/ const
169 struct { /* Processor Priority Register */
170 u32 priority : 8,
171 __reserved_1 : 24;
172 u32 __reserved_2[3];
173 } ppr;
174
175/*0B0*/ struct { /* End Of Interrupt Register */
176 u32 eoi;
177 u32 __reserved[3];
178 } eoi;
179
180/*0C0*/ struct { u32 __reserved[4]; } __reserved_07;
181
182/*0D0*/ struct { /* Logical Destination Register */
183 u32 __reserved_1 : 24,
184 logical_dest : 8;
185 u32 __reserved_2[3];
186 } ldr;
187
188/*0E0*/ struct { /* Destination Format Register */
189 u32 __reserved_1 : 28,
190 model : 4;
191 u32 __reserved_2[3];
192 } dfr;
193
194/*0F0*/ struct { /* Spurious Interrupt Vector Register */
195 u32 spurious_vector : 8,
196 apic_enabled : 1,
197 focus_cpu : 1,
198 __reserved_2 : 22;
199 u32 __reserved_3[3];
200 } svr;
201
202/*100*/ struct { /* In Service Register */
203/*170*/ u32 bitfield;
204 u32 __reserved[3];
205 } isr [8];
206
207/*180*/ struct { /* Trigger Mode Register */
208/*1F0*/ u32 bitfield;
209 u32 __reserved[3];
210 } tmr [8];
211
212/*200*/ struct { /* Interrupt Request Register */
213/*270*/ u32 bitfield;
214 u32 __reserved[3];
215 } irr [8];
216
217/*280*/ union { /* Error Status Register */
218 struct {
219 u32 send_cs_error : 1,
220 receive_cs_error : 1,
221 send_accept_error : 1,
222 receive_accept_error : 1,
223 __reserved_1 : 1,
224 send_illegal_vector : 1,
225 receive_illegal_vector : 1,
226 illegal_register_address : 1,
227 __reserved_2 : 24;
228 u32 __reserved_3[3];
229 } error_bits;
230 struct {
231 u32 errors;
232 u32 __reserved_3[3];
233 } all_errors;
234 } esr;
235
236/*290*/ struct { u32 __reserved[4]; } __reserved_08;
237
238/*2A0*/ struct { u32 __reserved[4]; } __reserved_09;
239
240/*2B0*/ struct { u32 __reserved[4]; } __reserved_10;
241
242/*2C0*/ struct { u32 __reserved[4]; } __reserved_11;
243
244/*2D0*/ struct { u32 __reserved[4]; } __reserved_12;
245
246/*2E0*/ struct { u32 __reserved[4]; } __reserved_13;
247
248/*2F0*/ struct { u32 __reserved[4]; } __reserved_14;
249
250/*300*/ struct { /* Interrupt Command Register 1 */
251 u32 vector : 8,
252 delivery_mode : 3,
253 destination_mode : 1,
254 delivery_status : 1,
255 __reserved_1 : 1,
256 level : 1,
257 trigger : 1,
258 __reserved_2 : 2,
259 shorthand : 2,
260 __reserved_3 : 12;
261 u32 __reserved_4[3];
262 } icr1;
263
264/*310*/ struct { /* Interrupt Command Register 2 */
265 union {
266 u32 __reserved_1 : 24,
267 phys_dest : 4,
268 __reserved_2 : 4;
269 u32 __reserved_3 : 24,
270 logical_dest : 8;
271 } dest;
272 u32 __reserved_4[3];
273 } icr2;
274
275/*320*/ struct { /* LVT - Timer */
276 u32 vector : 8,
277 __reserved_1 : 4,
278 delivery_status : 1,
279 __reserved_2 : 3,
280 mask : 1,
281 timer_mode : 1,
282 __reserved_3 : 14;
283 u32 __reserved_4[3];
284 } lvt_timer;
285
286/*330*/ struct { /* LVT - Thermal Sensor */
287 u32 vector : 8,
288 delivery_mode : 3,
289 __reserved_1 : 1,
290 delivery_status : 1,
291 __reserved_2 : 3,
292 mask : 1,
293 __reserved_3 : 15;
294 u32 __reserved_4[3];
295 } lvt_thermal;
296
297/*340*/ struct { /* LVT - Performance Counter */
298 u32 vector : 8,
299 delivery_mode : 3,
300 __reserved_1 : 1,
301 delivery_status : 1,
302 __reserved_2 : 3,
303 mask : 1,
304 __reserved_3 : 15;
305 u32 __reserved_4[3];
306 } lvt_pc;
307
308/*350*/ struct { /* LVT - LINT0 */
309 u32 vector : 8,
310 delivery_mode : 3,
311 __reserved_1 : 1,
312 delivery_status : 1,
313 polarity : 1,
314 remote_irr : 1,
315 trigger : 1,
316 mask : 1,
317 __reserved_2 : 15;
318 u32 __reserved_3[3];
319 } lvt_lint0;
320
321/*360*/ struct { /* LVT - LINT1 */
322 u32 vector : 8,
323 delivery_mode : 3,
324 __reserved_1 : 1,
325 delivery_status : 1,
326 polarity : 1,
327 remote_irr : 1,
328 trigger : 1,
329 mask : 1,
330 __reserved_2 : 15;
331 u32 __reserved_3[3];
332 } lvt_lint1;
333
334/*370*/ struct { /* LVT - Error */
335 u32 vector : 8,
336 __reserved_1 : 4,
337 delivery_status : 1,
338 __reserved_2 : 3,
339 mask : 1,
340 __reserved_3 : 15;
341 u32 __reserved_4[3];
342 } lvt_error;
343
344/*380*/ struct { /* Timer Initial Count Register */
345 u32 initial_count;
346 u32 __reserved_2[3];
347 } timer_icr;
348
349/*390*/ const
350 struct { /* Timer Current Count Register */
351 u32 curr_count;
352 u32 __reserved_2[3];
353 } timer_ccr;
354
355/*3A0*/ struct { u32 __reserved[4]; } __reserved_16;
356
357/*3B0*/ struct { u32 __reserved[4]; } __reserved_17;
358
359/*3C0*/ struct { u32 __reserved[4]; } __reserved_18;
360
361/*3D0*/ struct { u32 __reserved[4]; } __reserved_19;
362
363/*3E0*/ struct { /* Timer Divide Configuration Register */
364 u32 divisor : 4,
365 __reserved_1 : 28;
366 u32 __reserved_2[3];
367 } timer_dcr;
368
369/*3F0*/ struct { u32 __reserved[4]; } __reserved_20;
370
371} __attribute__ ((packed));
372
373#undef u32
374
375#endif
diff --git a/include/asm-x86/apicdef_64.h b/include/asm-x86/apicdef_64.h
deleted file mode 100644
index 1dd40067c67c..000000000000
--- a/include/asm-x86/apicdef_64.h
+++ /dev/null
@@ -1,392 +0,0 @@
1#ifndef __ASM_APICDEF_H
2#define __ASM_APICDEF_H
3
4/*
5 * Constants for various Intel APICs. (local APIC, IOAPIC, etc.)
6 *
7 * Alan Cox <Alan.Cox@linux.org>, 1995.
8 * Ingo Molnar <mingo@redhat.com>, 1999, 2000
9 */
10
11#define APIC_DEFAULT_PHYS_BASE 0xfee00000
12
13#define APIC_ID 0x20
14#define APIC_ID_MASK (0xFFu<<24)
15#define GET_APIC_ID(x) (((x)>>24)&0xFFu)
16#define SET_APIC_ID(x) (((x)<<24))
17#define APIC_LVR 0x30
18#define APIC_LVR_MASK 0xFF00FF
19#define GET_APIC_VERSION(x) ((x)&0xFFu)
20#define GET_APIC_MAXLVT(x) (((x)>>16)&0xFFu)
21#define APIC_INTEGRATED(x) ((x)&0xF0u)
22#define APIC_TASKPRI 0x80
23#define APIC_TPRI_MASK 0xFFu
24#define APIC_ARBPRI 0x90
25#define APIC_ARBPRI_MASK 0xFFu
26#define APIC_PROCPRI 0xA0
27#define APIC_EOI 0xB0
28#define APIC_EIO_ACK 0x0 /* Write this to the EOI register */
29#define APIC_RRR 0xC0
30#define APIC_LDR 0xD0
31#define APIC_LDR_MASK (0xFFu<<24)
32#define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFFu)
33#define SET_APIC_LOGICAL_ID(x) (((x)<<24))
34#define APIC_ALL_CPUS 0xFFu
35#define APIC_DFR 0xE0
36#define APIC_DFR_CLUSTER 0x0FFFFFFFul
37#define APIC_DFR_FLAT 0xFFFFFFFFul
38#define APIC_SPIV 0xF0
39#define APIC_SPIV_FOCUS_DISABLED (1<<9)
40#define APIC_SPIV_APIC_ENABLED (1<<8)
41#define APIC_ISR 0x100
42#define APIC_ISR_NR 0x8 /* Number of 32 bit ISR registers. */
43#define APIC_TMR 0x180
44#define APIC_IRR 0x200
45#define APIC_ESR 0x280
46#define APIC_ESR_SEND_CS 0x00001
47#define APIC_ESR_RECV_CS 0x00002
48#define APIC_ESR_SEND_ACC 0x00004
49#define APIC_ESR_RECV_ACC 0x00008
50#define APIC_ESR_SENDILL 0x00020
51#define APIC_ESR_RECVILL 0x00040
52#define APIC_ESR_ILLREGA 0x00080
53#define APIC_ICR 0x300
54#define APIC_DEST_SELF 0x40000
55#define APIC_DEST_ALLINC 0x80000
56#define APIC_DEST_ALLBUT 0xC0000
57#define APIC_ICR_RR_MASK 0x30000
58#define APIC_ICR_RR_INVALID 0x00000
59#define APIC_ICR_RR_INPROG 0x10000
60#define APIC_ICR_RR_VALID 0x20000
61#define APIC_INT_LEVELTRIG 0x08000
62#define APIC_INT_ASSERT 0x04000
63#define APIC_ICR_BUSY 0x01000
64#define APIC_DEST_LOGICAL 0x00800
65#define APIC_DEST_PHYSICAL 0x00000
66#define APIC_DM_FIXED 0x00000
67#define APIC_DM_LOWEST 0x00100
68#define APIC_DM_SMI 0x00200
69#define APIC_DM_REMRD 0x00300
70#define APIC_DM_NMI 0x00400
71#define APIC_DM_INIT 0x00500
72#define APIC_DM_STARTUP 0x00600
73#define APIC_DM_EXTINT 0x00700
74#define APIC_VECTOR_MASK 0x000FF
75#define APIC_ICR2 0x310
76#define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF)
77#define SET_APIC_DEST_FIELD(x) ((x)<<24)
78#define APIC_LVTT 0x320
79#define APIC_LVTTHMR 0x330
80#define APIC_LVTPC 0x340
81#define APIC_LVT0 0x350
82#define APIC_LVT_TIMER_BASE_MASK (0x3<<18)
83#define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3)
84#define SET_APIC_TIMER_BASE(x) (((x)<<18))
85#define APIC_TIMER_BASE_CLKIN 0x0
86#define APIC_TIMER_BASE_TMBASE 0x1
87#define APIC_TIMER_BASE_DIV 0x2
88#define APIC_LVT_TIMER_PERIODIC (1<<17)
89#define APIC_LVT_MASKED (1<<16)
90#define APIC_LVT_LEVEL_TRIGGER (1<<15)
91#define APIC_LVT_REMOTE_IRR (1<<14)
92#define APIC_INPUT_POLARITY (1<<13)
93#define APIC_SEND_PENDING (1<<12)
94#define APIC_MODE_MASK 0x700
95#define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7)
96#define SET_APIC_DELIVERY_MODE(x,y) (((x)&~0x700)|((y)<<8))
97#define APIC_MODE_FIXED 0x0
98#define APIC_MODE_NMI 0x4
99#define APIC_MODE_EXTINT 0x7
100#define APIC_LVT1 0x360
101#define APIC_LVTERR 0x370
102#define APIC_TMICT 0x380
103#define APIC_TMCCT 0x390
104#define APIC_TDCR 0x3E0
105#define APIC_TDR_DIV_TMBASE (1<<2)
106#define APIC_TDR_DIV_1 0xB
107#define APIC_TDR_DIV_2 0x0
108#define APIC_TDR_DIV_4 0x1
109#define APIC_TDR_DIV_8 0x2
110#define APIC_TDR_DIV_16 0x3
111#define APIC_TDR_DIV_32 0x8
112#define APIC_TDR_DIV_64 0x9
113#define APIC_TDR_DIV_128 0xA
114
115#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
116
117#define MAX_IO_APICS 128
118#define MAX_LOCAL_APIC 256
119
120/*
121 * All x86-64 systems are xAPIC compatible.
122 * In the following, "apicid" is a physical APIC ID.
123 */
124#define XAPIC_DEST_CPUS_SHIFT 4
125#define XAPIC_DEST_CPUS_MASK ((1u << XAPIC_DEST_CPUS_SHIFT) - 1)
126#define XAPIC_DEST_CLUSTER_MASK (XAPIC_DEST_CPUS_MASK << XAPIC_DEST_CPUS_SHIFT)
127#define APIC_CLUSTER(apicid) ((apicid) & XAPIC_DEST_CLUSTER_MASK)
128#define APIC_CLUSTERID(apicid) (APIC_CLUSTER(apicid) >> XAPIC_DEST_CPUS_SHIFT)
129#define APIC_CPUID(apicid) ((apicid) & XAPIC_DEST_CPUS_MASK)
130#define NUM_APIC_CLUSTERS ((BAD_APICID + 1) >> XAPIC_DEST_CPUS_SHIFT)
131
132/*
133 * the local APIC register structure, memory mapped. Not terribly well
134 * tested, but we might eventually use this one in the future - the
135 * problem why we cannot use it right now is the P5 APIC, it has an
136 * errata which cannot take 8-bit reads and writes, only 32-bit ones ...
137 */
138#define u32 unsigned int
139
140struct local_apic {
141
142/*000*/ struct { u32 __reserved[4]; } __reserved_01;
143
144/*010*/ struct { u32 __reserved[4]; } __reserved_02;
145
146/*020*/ struct { /* APIC ID Register */
147 u32 __reserved_1 : 24,
148 phys_apic_id : 4,
149 __reserved_2 : 4;
150 u32 __reserved[3];
151 } id;
152
153/*030*/ const
154 struct { /* APIC Version Register */
155 u32 version : 8,
156 __reserved_1 : 8,
157 max_lvt : 8,
158 __reserved_2 : 8;
159 u32 __reserved[3];
160 } version;
161
162/*040*/ struct { u32 __reserved[4]; } __reserved_03;
163
164/*050*/ struct { u32 __reserved[4]; } __reserved_04;
165
166/*060*/ struct { u32 __reserved[4]; } __reserved_05;
167
168/*070*/ struct { u32 __reserved[4]; } __reserved_06;
169
170/*080*/ struct { /* Task Priority Register */
171 u32 priority : 8,
172 __reserved_1 : 24;
173 u32 __reserved_2[3];
174 } tpr;
175
176/*090*/ const
177 struct { /* Arbitration Priority Register */
178 u32 priority : 8,
179 __reserved_1 : 24;
180 u32 __reserved_2[3];
181 } apr;
182
183/*0A0*/ const
184 struct { /* Processor Priority Register */
185 u32 priority : 8,
186 __reserved_1 : 24;
187 u32 __reserved_2[3];
188 } ppr;
189
190/*0B0*/ struct { /* End Of Interrupt Register */
191 u32 eoi;
192 u32 __reserved[3];
193 } eoi;
194
195/*0C0*/ struct { u32 __reserved[4]; } __reserved_07;
196
197/*0D0*/ struct { /* Logical Destination Register */
198 u32 __reserved_1 : 24,
199 logical_dest : 8;
200 u32 __reserved_2[3];
201 } ldr;
202
203/*0E0*/ struct { /* Destination Format Register */
204 u32 __reserved_1 : 28,
205 model : 4;
206 u32 __reserved_2[3];
207 } dfr;
208
209/*0F0*/ struct { /* Spurious Interrupt Vector Register */
210 u32 spurious_vector : 8,
211 apic_enabled : 1,
212 focus_cpu : 1,
213 __reserved_2 : 22;
214 u32 __reserved_3[3];
215 } svr;
216
217/*100*/ struct { /* In Service Register */
218/*170*/ u32 bitfield;
219 u32 __reserved[3];
220 } isr [8];
221
222/*180*/ struct { /* Trigger Mode Register */
223/*1F0*/ u32 bitfield;
224 u32 __reserved[3];
225 } tmr [8];
226
227/*200*/ struct { /* Interrupt Request Register */
228/*270*/ u32 bitfield;
229 u32 __reserved[3];
230 } irr [8];
231
232/*280*/ union { /* Error Status Register */
233 struct {
234 u32 send_cs_error : 1,
235 receive_cs_error : 1,
236 send_accept_error : 1,
237 receive_accept_error : 1,
238 __reserved_1 : 1,
239 send_illegal_vector : 1,
240 receive_illegal_vector : 1,
241 illegal_register_address : 1,
242 __reserved_2 : 24;
243 u32 __reserved_3[3];
244 } error_bits;
245 struct {
246 u32 errors;
247 u32 __reserved_3[3];
248 } all_errors;
249 } esr;
250
251/*290*/ struct { u32 __reserved[4]; } __reserved_08;
252
253/*2A0*/ struct { u32 __reserved[4]; } __reserved_09;
254
255/*2B0*/ struct { u32 __reserved[4]; } __reserved_10;
256
257/*2C0*/ struct { u32 __reserved[4]; } __reserved_11;
258
259/*2D0*/ struct { u32 __reserved[4]; } __reserved_12;
260
261/*2E0*/ struct { u32 __reserved[4]; } __reserved_13;
262
263/*2F0*/ struct { u32 __reserved[4]; } __reserved_14;
264
265/*300*/ struct { /* Interrupt Command Register 1 */
266 u32 vector : 8,
267 delivery_mode : 3,
268 destination_mode : 1,
269 delivery_status : 1,
270 __reserved_1 : 1,
271 level : 1,
272 trigger : 1,
273 __reserved_2 : 2,
274 shorthand : 2,
275 __reserved_3 : 12;
276 u32 __reserved_4[3];
277 } icr1;
278
279/*310*/ struct { /* Interrupt Command Register 2 */
280 union {
281 u32 __reserved_1 : 24,
282 phys_dest : 4,
283 __reserved_2 : 4;
284 u32 __reserved_3 : 24,
285 logical_dest : 8;
286 } dest;
287 u32 __reserved_4[3];
288 } icr2;
289
290/*320*/ struct { /* LVT - Timer */
291 u32 vector : 8,
292 __reserved_1 : 4,
293 delivery_status : 1,
294 __reserved_2 : 3,
295 mask : 1,
296 timer_mode : 1,
297 __reserved_3 : 14;
298 u32 __reserved_4[3];
299 } lvt_timer;
300
301/*330*/ struct { /* LVT - Thermal Sensor */
302 u32 vector : 8,
303 delivery_mode : 3,
304 __reserved_1 : 1,
305 delivery_status : 1,
306 __reserved_2 : 3,
307 mask : 1,
308 __reserved_3 : 15;
309 u32 __reserved_4[3];
310 } lvt_thermal;
311
312/*340*/ struct { /* LVT - Performance Counter */
313 u32 vector : 8,
314 delivery_mode : 3,
315 __reserved_1 : 1,
316 delivery_status : 1,
317 __reserved_2 : 3,
318 mask : 1,
319 __reserved_3 : 15;
320 u32 __reserved_4[3];
321 } lvt_pc;
322
323/*350*/ struct { /* LVT - LINT0 */
324 u32 vector : 8,
325 delivery_mode : 3,
326 __reserved_1 : 1,
327 delivery_status : 1,
328 polarity : 1,
329 remote_irr : 1,
330 trigger : 1,
331 mask : 1,
332 __reserved_2 : 15;
333 u32 __reserved_3[3];
334 } lvt_lint0;
335
336/*360*/ struct { /* LVT - LINT1 */
337 u32 vector : 8,
338 delivery_mode : 3,
339 __reserved_1 : 1,
340 delivery_status : 1,
341 polarity : 1,
342 remote_irr : 1,
343 trigger : 1,
344 mask : 1,
345 __reserved_2 : 15;
346 u32 __reserved_3[3];
347 } lvt_lint1;
348
349/*370*/ struct { /* LVT - Error */
350 u32 vector : 8,
351 __reserved_1 : 4,
352 delivery_status : 1,
353 __reserved_2 : 3,
354 mask : 1,
355 __reserved_3 : 15;
356 u32 __reserved_4[3];
357 } lvt_error;
358
359/*380*/ struct { /* Timer Initial Count Register */
360 u32 initial_count;
361 u32 __reserved_2[3];
362 } timer_icr;
363
364/*390*/ const
365 struct { /* Timer Current Count Register */
366 u32 curr_count;
367 u32 __reserved_2[3];
368 } timer_ccr;
369
370/*3A0*/ struct { u32 __reserved[4]; } __reserved_16;
371
372/*3B0*/ struct { u32 __reserved[4]; } __reserved_17;
373
374/*3C0*/ struct { u32 __reserved[4]; } __reserved_18;
375
376/*3D0*/ struct { u32 __reserved[4]; } __reserved_19;
377
378/*3E0*/ struct { /* Timer Divide Configuration Register */
379 u32 divisor : 4,
380 __reserved_1 : 28;
381 u32 __reserved_2[3];
382 } timer_dcr;
383
384/*3F0*/ struct { u32 __reserved[4]; } __reserved_20;
385
386} __attribute__ ((packed));
387
388#undef u32
389
390#define BAD_APICID 0xFFu
391
392#endif
diff --git a/include/asm-x86/arch_hooks.h b/include/asm-x86/arch_hooks.h
index a8c1fca9726d..768aee8a04ef 100644
--- a/include/asm-x86/arch_hooks.h
+++ b/include/asm-x86/arch_hooks.h
@@ -6,7 +6,7 @@
6/* 6/*
7 * linux/include/asm/arch_hooks.h 7 * linux/include/asm/arch_hooks.h
8 * 8 *
9 * define the architecture specific hooks 9 * define the architecture specific hooks
10 */ 10 */
11 11
12/* these aren't arch hooks, they are generic routines 12/* these aren't arch hooks, they are generic routines
@@ -24,7 +24,4 @@ extern void trap_init_hook(void);
24extern void time_init_hook(void); 24extern void time_init_hook(void);
25extern void mca_nmi_hook(void); 25extern void mca_nmi_hook(void);
26 26
27extern int setup_early_printk(char *);
28extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2)));
29
30#endif 27#endif
diff --git a/include/asm-x86/asm.h b/include/asm-x86/asm.h
new file mode 100644
index 000000000000..1a6980a60fc6
--- /dev/null
+++ b/include/asm-x86/asm.h
@@ -0,0 +1,32 @@
1#ifndef _ASM_X86_ASM_H
2#define _ASM_X86_ASM_H
3
4#ifdef CONFIG_X86_32
5/* 32 bits */
6
7# define _ASM_PTR " .long "
8# define _ASM_ALIGN " .balign 4 "
9# define _ASM_MOV_UL " movl "
10
11# define _ASM_INC " incl "
12# define _ASM_DEC " decl "
13# define _ASM_ADD " addl "
14# define _ASM_SUB " subl "
15# define _ASM_XADD " xaddl "
16
17#else
18/* 64 bits */
19
20# define _ASM_PTR " .quad "
21# define _ASM_ALIGN " .balign 8 "
22# define _ASM_MOV_UL " movq "
23
24# define _ASM_INC " incq "
25# define _ASM_DEC " decq "
26# define _ASM_ADD " addq "
27# define _ASM_SUB " subq "
28# define _ASM_XADD " xaddq "
29
30#endif /* CONFIG_X86_32 */
31
32#endif /* _ASM_X86_ASM_H */
diff --git a/include/asm-x86/bitops.h b/include/asm-x86/bitops.h
index 07e3f6d4fe47..1a23ce1a5697 100644
--- a/include/asm-x86/bitops.h
+++ b/include/asm-x86/bitops.h
@@ -1,5 +1,321 @@
1#ifndef _ASM_X86_BITOPS_H
2#define _ASM_X86_BITOPS_H
3
4/*
5 * Copyright 1992, Linus Torvalds.
6 */
7
8#ifndef _LINUX_BITOPS_H
9#error only <linux/bitops.h> can be included directly
10#endif
11
12#include <linux/compiler.h>
13#include <asm/alternative.h>
14
15/*
16 * These have to be done with inline assembly: that way the bit-setting
17 * is guaranteed to be atomic. All bit operations return 0 if the bit
18 * was cleared before the operation and != 0 if it was not.
19 *
20 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
21 */
22
23#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
24/* Technically wrong, but this avoids compilation errors on some gcc
25 versions. */
26#define ADDR "=m" (*(volatile long *) addr)
27#else
28#define ADDR "+m" (*(volatile long *) addr)
29#endif
30
31/**
32 * set_bit - Atomically set a bit in memory
33 * @nr: the bit to set
34 * @addr: the address to start counting from
35 *
36 * This function is atomic and may not be reordered. See __set_bit()
37 * if you do not require the atomic guarantees.
38 *
39 * Note: there are no guarantees that this function will not be reordered
40 * on non x86 architectures, so if you are writing portable code,
41 * make sure not to rely on its reordering guarantees.
42 *
43 * Note that @nr may be almost arbitrarily large; this function is not
44 * restricted to acting on a single-word quantity.
45 */
46static inline void set_bit(int nr, volatile void *addr)
47{
48 asm volatile(LOCK_PREFIX "bts %1,%0"
49 : ADDR
50 : "Ir" (nr) : "memory");
51}
52
53/**
54 * __set_bit - Set a bit in memory
55 * @nr: the bit to set
56 * @addr: the address to start counting from
57 *
58 * Unlike set_bit(), this function is non-atomic and may be reordered.
59 * If it's called on the same region of memory simultaneously, the effect
60 * may be that only one operation succeeds.
61 */
62static inline void __set_bit(int nr, volatile void *addr)
63{
64 asm volatile("bts %1,%0"
65 : ADDR
66 : "Ir" (nr) : "memory");
67}
68
69
70/**
71 * clear_bit - Clears a bit in memory
72 * @nr: Bit to clear
73 * @addr: Address to start counting from
74 *
75 * clear_bit() is atomic and may not be reordered. However, it does
76 * not contain a memory barrier, so if it is used for locking purposes,
77 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
78 * in order to ensure changes are visible on other processors.
79 */
80static inline void clear_bit(int nr, volatile void *addr)
81{
82 asm volatile(LOCK_PREFIX "btr %1,%0"
83 : ADDR
84 : "Ir" (nr));
85}
86
87/*
88 * clear_bit_unlock - Clears a bit in memory
89 * @nr: Bit to clear
90 * @addr: Address to start counting from
91 *
92 * clear_bit() is atomic and implies release semantics before the memory
93 * operation. It can be used for an unlock.
94 */
95static inline void clear_bit_unlock(unsigned nr, volatile void *addr)
96{
97 barrier();
98 clear_bit(nr, addr);
99}
100
101static inline void __clear_bit(int nr, volatile void *addr)
102{
103 asm volatile("btr %1,%0" : ADDR : "Ir" (nr));
104}
105
106/*
107 * __clear_bit_unlock - Clears a bit in memory
108 * @nr: Bit to clear
109 * @addr: Address to start counting from
110 *
111 * __clear_bit() is non-atomic and implies release semantics before the memory
112 * operation. It can be used for an unlock if no other CPUs can concurrently
113 * modify other bits in the word.
114 *
115 * No memory barrier is required here, because x86 cannot reorder stores past
116 * older loads. Same principle as spin_unlock.
117 */
118static inline void __clear_bit_unlock(unsigned nr, volatile void *addr)
119{
120 barrier();
121 __clear_bit(nr, addr);
122}
123
124#define smp_mb__before_clear_bit() barrier()
125#define smp_mb__after_clear_bit() barrier()
126
127/**
128 * __change_bit - Toggle a bit in memory
129 * @nr: the bit to change
130 * @addr: the address to start counting from
131 *
132 * Unlike change_bit(), this function is non-atomic and may be reordered.
133 * If it's called on the same region of memory simultaneously, the effect
134 * may be that only one operation succeeds.
135 */
136static inline void __change_bit(int nr, volatile void *addr)
137{
138 asm volatile("btc %1,%0" : ADDR : "Ir" (nr));
139}
140
141/**
142 * change_bit - Toggle a bit in memory
143 * @nr: Bit to change
144 * @addr: Address to start counting from
145 *
146 * change_bit() is atomic and may not be reordered.
147 * Note that @nr may be almost arbitrarily large; this function is not
148 * restricted to acting on a single-word quantity.
149 */
150static inline void change_bit(int nr, volatile void *addr)
151{
152 asm volatile(LOCK_PREFIX "btc %1,%0"
153 : ADDR : "Ir" (nr));
154}
155
156/**
157 * test_and_set_bit - Set a bit and return its old value
158 * @nr: Bit to set
159 * @addr: Address to count from
160 *
161 * This operation is atomic and cannot be reordered.
162 * It also implies a memory barrier.
163 */
164static inline int test_and_set_bit(int nr, volatile void *addr)
165{
166 int oldbit;
167
168 asm volatile(LOCK_PREFIX "bts %2,%1\n\t"
169 "sbb %0,%0"
170 : "=r" (oldbit), ADDR
171 : "Ir" (nr) : "memory");
172
173 return oldbit;
174}
175
176/**
177 * test_and_set_bit_lock - Set a bit and return its old value for lock
178 * @nr: Bit to set
179 * @addr: Address to count from
180 *
181 * This is the same as test_and_set_bit on x86.
182 */
183static inline int test_and_set_bit_lock(int nr, volatile void *addr)
184{
185 return test_and_set_bit(nr, addr);
186}
187
188/**
189 * __test_and_set_bit - Set a bit and return its old value
190 * @nr: Bit to set
191 * @addr: Address to count from
192 *
193 * This operation is non-atomic and can be reordered.
194 * If two examples of this operation race, one can appear to succeed
195 * but actually fail. You must protect multiple accesses with a lock.
196 */
197static inline int __test_and_set_bit(int nr, volatile void *addr)
198{
199 int oldbit;
200
201 asm("bts %2,%1\n\t"
202 "sbb %0,%0"
203 : "=r" (oldbit), ADDR
204 : "Ir" (nr));
205 return oldbit;
206}
207
208/**
209 * test_and_clear_bit - Clear a bit and return its old value
210 * @nr: Bit to clear
211 * @addr: Address to count from
212 *
213 * This operation is atomic and cannot be reordered.
214 * It also implies a memory barrier.
215 */
216static inline int test_and_clear_bit(int nr, volatile void *addr)
217{
218 int oldbit;
219
220 asm volatile(LOCK_PREFIX "btr %2,%1\n\t"
221 "sbb %0,%0"
222 : "=r" (oldbit), ADDR
223 : "Ir" (nr) : "memory");
224
225 return oldbit;
226}
227
228/**
229 * __test_and_clear_bit - Clear a bit and return its old value
230 * @nr: Bit to clear
231 * @addr: Address to count from
232 *
233 * This operation is non-atomic and can be reordered.
234 * If two examples of this operation race, one can appear to succeed
235 * but actually fail. You must protect multiple accesses with a lock.
236 */
237static inline int __test_and_clear_bit(int nr, volatile void *addr)
238{
239 int oldbit;
240
241 asm volatile("btr %2,%1\n\t"
242 "sbb %0,%0"
243 : "=r" (oldbit), ADDR
244 : "Ir" (nr));
245 return oldbit;
246}
247
248/* WARNING: non atomic and it can be reordered! */
249static inline int __test_and_change_bit(int nr, volatile void *addr)
250{
251 int oldbit;
252
253 asm volatile("btc %2,%1\n\t"
254 "sbb %0,%0"
255 : "=r" (oldbit), ADDR
256 : "Ir" (nr) : "memory");
257
258 return oldbit;
259}
260
261/**
262 * test_and_change_bit - Change a bit and return its old value
263 * @nr: Bit to change
264 * @addr: Address to count from
265 *
266 * This operation is atomic and cannot be reordered.
267 * It also implies a memory barrier.
268 */
269static inline int test_and_change_bit(int nr, volatile void *addr)
270{
271 int oldbit;
272
273 asm volatile(LOCK_PREFIX "btc %2,%1\n\t"
274 "sbb %0,%0"
275 : "=r" (oldbit), ADDR
276 : "Ir" (nr) : "memory");
277
278 return oldbit;
279}
280
281static inline int constant_test_bit(int nr, const volatile void *addr)
282{
283 return ((1UL << (nr % BITS_PER_LONG)) &
284 (((unsigned long *)addr)[nr / BITS_PER_LONG])) != 0;
285}
286
287static inline int variable_test_bit(int nr, volatile const void *addr)
288{
289 int oldbit;
290
291 asm volatile("bt %2,%1\n\t"
292 "sbb %0,%0"
293 : "=r" (oldbit)
294 : "m" (*(unsigned long *)addr), "Ir" (nr));
295
296 return oldbit;
297}
298
299#if 0 /* Fool kernel-doc since it doesn't do macros yet */
300/**
301 * test_bit - Determine whether a bit is set
302 * @nr: bit number to test
303 * @addr: Address to start counting from
304 */
305static int test_bit(int nr, const volatile unsigned long *addr);
306#endif
307
308#define test_bit(nr,addr) \
309 (__builtin_constant_p(nr) ? \
310 constant_test_bit((nr),(addr)) : \
311 variable_test_bit((nr),(addr)))
312
313#undef ADDR
314
1#ifdef CONFIG_X86_32 315#ifdef CONFIG_X86_32
2# include "bitops_32.h" 316# include "bitops_32.h"
3#else 317#else
4# include "bitops_64.h" 318# include "bitops_64.h"
5#endif 319#endif
320
321#endif /* _ASM_X86_BITOPS_H */
diff --git a/include/asm-x86/bitops_32.h b/include/asm-x86/bitops_32.h
index 0b40f6d20bea..e4d75fcf9c03 100644
--- a/include/asm-x86/bitops_32.h
+++ b/include/asm-x86/bitops_32.h
@@ -5,320 +5,12 @@
5 * Copyright 1992, Linus Torvalds. 5 * Copyright 1992, Linus Torvalds.
6 */ 6 */
7 7
8#ifndef _LINUX_BITOPS_H
9#error only <linux/bitops.h> can be included directly
10#endif
11
12#include <linux/compiler.h>
13#include <asm/alternative.h>
14
15/*
16 * These have to be done with inline assembly: that way the bit-setting
17 * is guaranteed to be atomic. All bit operations return 0 if the bit
18 * was cleared before the operation and != 0 if it was not.
19 *
20 * bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
21 */
22
23#define ADDR (*(volatile long *) addr)
24
25/**
26 * set_bit - Atomically set a bit in memory
27 * @nr: the bit to set
28 * @addr: the address to start counting from
29 *
30 * This function is atomic and may not be reordered. See __set_bit()
31 * if you do not require the atomic guarantees.
32 *
33 * Note: there are no guarantees that this function will not be reordered
34 * on non x86 architectures, so if you are writing portable code,
35 * make sure not to rely on its reordering guarantees.
36 *
37 * Note that @nr may be almost arbitrarily large; this function is not
38 * restricted to acting on a single-word quantity.
39 */
40static inline void set_bit(int nr, volatile unsigned long * addr)
41{
42 __asm__ __volatile__( LOCK_PREFIX
43 "btsl %1,%0"
44 :"+m" (ADDR)
45 :"Ir" (nr));
46}
47
48/**
49 * __set_bit - Set a bit in memory
50 * @nr: the bit to set
51 * @addr: the address to start counting from
52 *
53 * Unlike set_bit(), this function is non-atomic and may be reordered.
54 * If it's called on the same region of memory simultaneously, the effect
55 * may be that only one operation succeeds.
56 */
57static inline void __set_bit(int nr, volatile unsigned long * addr)
58{
59 __asm__(
60 "btsl %1,%0"
61 :"+m" (ADDR)
62 :"Ir" (nr));
63}
64
65/**
66 * clear_bit - Clears a bit in memory
67 * @nr: Bit to clear
68 * @addr: Address to start counting from
69 *
70 * clear_bit() is atomic and may not be reordered. However, it does
71 * not contain a memory barrier, so if it is used for locking purposes,
72 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
73 * in order to ensure changes are visible on other processors.
74 */
75static inline void clear_bit(int nr, volatile unsigned long * addr)
76{
77 __asm__ __volatile__( LOCK_PREFIX
78 "btrl %1,%0"
79 :"+m" (ADDR)
80 :"Ir" (nr));
81}
82
83/*
84 * clear_bit_unlock - Clears a bit in memory
85 * @nr: Bit to clear
86 * @addr: Address to start counting from
87 *
88 * clear_bit() is atomic and implies release semantics before the memory
89 * operation. It can be used for an unlock.
90 */
91static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
92{
93 barrier();
94 clear_bit(nr, addr);
95}
96
97static inline void __clear_bit(int nr, volatile unsigned long * addr)
98{
99 __asm__ __volatile__(
100 "btrl %1,%0"
101 :"+m" (ADDR)
102 :"Ir" (nr));
103}
104
105/*
106 * __clear_bit_unlock - Clears a bit in memory
107 * @nr: Bit to clear
108 * @addr: Address to start counting from
109 *
110 * __clear_bit() is non-atomic and implies release semantics before the memory
111 * operation. It can be used for an unlock if no other CPUs can concurrently
112 * modify other bits in the word.
113 *
114 * No memory barrier is required here, because x86 cannot reorder stores past
115 * older loads. Same principle as spin_unlock.
116 */
117static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
118{
119 barrier();
120 __clear_bit(nr, addr);
121}
122
123#define smp_mb__before_clear_bit() barrier()
124#define smp_mb__after_clear_bit() barrier()
125
126/**
127 * __change_bit - Toggle a bit in memory
128 * @nr: the bit to change
129 * @addr: the address to start counting from
130 *
131 * Unlike change_bit(), this function is non-atomic and may be reordered.
132 * If it's called on the same region of memory simultaneously, the effect
133 * may be that only one operation succeeds.
134 */
135static inline void __change_bit(int nr, volatile unsigned long * addr)
136{
137 __asm__ __volatile__(
138 "btcl %1,%0"
139 :"+m" (ADDR)
140 :"Ir" (nr));
141}
142
143/**
144 * change_bit - Toggle a bit in memory
145 * @nr: Bit to change
146 * @addr: Address to start counting from
147 *
148 * change_bit() is atomic and may not be reordered. It may be
149 * reordered on other architectures than x86.
150 * Note that @nr may be almost arbitrarily large; this function is not
151 * restricted to acting on a single-word quantity.
152 */
153static inline void change_bit(int nr, volatile unsigned long * addr)
154{
155 __asm__ __volatile__( LOCK_PREFIX
156 "btcl %1,%0"
157 :"+m" (ADDR)
158 :"Ir" (nr));
159}
160
161/**
162 * test_and_set_bit - Set a bit and return its old value
163 * @nr: Bit to set
164 * @addr: Address to count from
165 *
166 * This operation is atomic and cannot be reordered.
167 * It may be reordered on other architectures than x86.
168 * It also implies a memory barrier.
169 */
170static inline int test_and_set_bit(int nr, volatile unsigned long * addr)
171{
172 int oldbit;
173
174 __asm__ __volatile__( LOCK_PREFIX
175 "btsl %2,%1\n\tsbbl %0,%0"
176 :"=r" (oldbit),"+m" (ADDR)
177 :"Ir" (nr) : "memory");
178 return oldbit;
179}
180
181/**
182 * test_and_set_bit_lock - Set a bit and return its old value for lock
183 * @nr: Bit to set
184 * @addr: Address to count from
185 *
186 * This is the same as test_and_set_bit on x86.
187 */
188static inline int test_and_set_bit_lock(int nr, volatile unsigned long *addr)
189{
190 return test_and_set_bit(nr, addr);
191}
192
193/**
194 * __test_and_set_bit - Set a bit and return its old value
195 * @nr: Bit to set
196 * @addr: Address to count from
197 *
198 * This operation is non-atomic and can be reordered.
199 * If two examples of this operation race, one can appear to succeed
200 * but actually fail. You must protect multiple accesses with a lock.
201 */
202static inline int __test_and_set_bit(int nr, volatile unsigned long * addr)
203{
204 int oldbit;
205
206 __asm__(
207 "btsl %2,%1\n\tsbbl %0,%0"
208 :"=r" (oldbit),"+m" (ADDR)
209 :"Ir" (nr));
210 return oldbit;
211}
212
213/**
214 * test_and_clear_bit - Clear a bit and return its old value
215 * @nr: Bit to clear
216 * @addr: Address to count from
217 *
218 * This operation is atomic and cannot be reordered.
219 * It can be reorderdered on other architectures other than x86.
220 * It also implies a memory barrier.
221 */
222static inline int test_and_clear_bit(int nr, volatile unsigned long * addr)
223{
224 int oldbit;
225
226 __asm__ __volatile__( LOCK_PREFIX
227 "btrl %2,%1\n\tsbbl %0,%0"
228 :"=r" (oldbit),"+m" (ADDR)
229 :"Ir" (nr) : "memory");
230 return oldbit;
231}
232
233/**
234 * __test_and_clear_bit - Clear a bit and return its old value
235 * @nr: Bit to clear
236 * @addr: Address to count from
237 *
238 * This operation is non-atomic and can be reordered.
239 * If two examples of this operation race, one can appear to succeed
240 * but actually fail. You must protect multiple accesses with a lock.
241 */
242static inline int __test_and_clear_bit(int nr, volatile unsigned long *addr)
243{
244 int oldbit;
245
246 __asm__(
247 "btrl %2,%1\n\tsbbl %0,%0"
248 :"=r" (oldbit),"+m" (ADDR)
249 :"Ir" (nr));
250 return oldbit;
251}
252
253/* WARNING: non atomic and it can be reordered! */
254static inline int __test_and_change_bit(int nr, volatile unsigned long *addr)
255{
256 int oldbit;
257
258 __asm__ __volatile__(
259 "btcl %2,%1\n\tsbbl %0,%0"
260 :"=r" (oldbit),"+m" (ADDR)
261 :"Ir" (nr) : "memory");
262 return oldbit;
263}
264
265/**
266 * test_and_change_bit - Change a bit and return its old value
267 * @nr: Bit to change
268 * @addr: Address to count from
269 *
270 * This operation is atomic and cannot be reordered.
271 * It also implies a memory barrier.
272 */
273static inline int test_and_change_bit(int nr, volatile unsigned long* addr)
274{
275 int oldbit;
276
277 __asm__ __volatile__( LOCK_PREFIX
278 "btcl %2,%1\n\tsbbl %0,%0"
279 :"=r" (oldbit),"+m" (ADDR)
280 :"Ir" (nr) : "memory");
281 return oldbit;
282}
283
284#if 0 /* Fool kernel-doc since it doesn't do macros yet */
285/**
286 * test_bit - Determine whether a bit is set
287 * @nr: bit number to test
288 * @addr: Address to start counting from
289 */
290static int test_bit(int nr, const volatile void * addr);
291#endif
292
293static __always_inline int constant_test_bit(int nr, const volatile unsigned long *addr)
294{
295 return ((1UL << (nr & 31)) & (addr[nr >> 5])) != 0;
296}
297
298static inline int variable_test_bit(int nr, const volatile unsigned long * addr)
299{
300 int oldbit;
301
302 __asm__ __volatile__(
303 "btl %2,%1\n\tsbbl %0,%0"
304 :"=r" (oldbit)
305 :"m" (ADDR),"Ir" (nr));
306 return oldbit;
307}
308
309#define test_bit(nr,addr) \
310(__builtin_constant_p(nr) ? \
311 constant_test_bit((nr),(addr)) : \
312 variable_test_bit((nr),(addr)))
313
314#undef ADDR
315
316/** 8/**
317 * find_first_zero_bit - find the first zero bit in a memory region 9 * find_first_zero_bit - find the first zero bit in a memory region
318 * @addr: The address to start the search at 10 * @addr: The address to start the search at
319 * @size: The maximum size to search 11 * @size: The maximum size to search
320 * 12 *
321 * Returns the bit-number of the first zero bit, not the number of the byte 13 * Returns the bit number of the first zero bit, not the number of the byte
322 * containing a bit. 14 * containing a bit.
323 */ 15 */
324static inline int find_first_zero_bit(const unsigned long *addr, unsigned size) 16static inline int find_first_zero_bit(const unsigned long *addr, unsigned size)
@@ -348,7 +40,7 @@ static inline int find_first_zero_bit(const unsigned long *addr, unsigned size)
348/** 40/**
349 * find_next_zero_bit - find the first zero bit in a memory region 41 * find_next_zero_bit - find the first zero bit in a memory region
350 * @addr: The address to base the search on 42 * @addr: The address to base the search on
351 * @offset: The bitnumber to start searching at 43 * @offset: The bit number to start searching at
352 * @size: The maximum size to search 44 * @size: The maximum size to search
353 */ 45 */
354int find_next_zero_bit(const unsigned long *addr, int size, int offset); 46int find_next_zero_bit(const unsigned long *addr, int size, int offset);
@@ -372,7 +64,7 @@ static inline unsigned long __ffs(unsigned long word)
372 * @addr: The address to start the search at 64 * @addr: The address to start the search at
373 * @size: The maximum size to search 65 * @size: The maximum size to search
374 * 66 *
375 * Returns the bit-number of the first set bit, not the number of the byte 67 * Returns the bit number of the first set bit, not the number of the byte
376 * containing a bit. 68 * containing a bit.
377 */ 69 */
378static inline unsigned find_first_bit(const unsigned long *addr, unsigned size) 70static inline unsigned find_first_bit(const unsigned long *addr, unsigned size)
@@ -391,7 +83,7 @@ static inline unsigned find_first_bit(const unsigned long *addr, unsigned size)
391/** 83/**
392 * find_next_bit - find the first set bit in a memory region 84 * find_next_bit - find the first set bit in a memory region
393 * @addr: The address to base the search on 85 * @addr: The address to base the search on
394 * @offset: The bitnumber to start searching at 86 * @offset: The bit number to start searching at
395 * @size: The maximum size to search 87 * @size: The maximum size to search
396 */ 88 */
397int find_next_bit(const unsigned long *addr, int size, int offset); 89int find_next_bit(const unsigned long *addr, int size, int offset);
@@ -460,10 +152,10 @@ static inline int fls(int x)
460 152
461#include <asm-generic/bitops/ext2-non-atomic.h> 153#include <asm-generic/bitops/ext2-non-atomic.h>
462 154
463#define ext2_set_bit_atomic(lock,nr,addr) \ 155#define ext2_set_bit_atomic(lock, nr, addr) \
464 test_and_set_bit((nr),(unsigned long*)addr) 156 test_and_set_bit((nr), (unsigned long *)addr)
465#define ext2_clear_bit_atomic(lock,nr, addr) \ 157#define ext2_clear_bit_atomic(lock, nr, addr) \
466 test_and_clear_bit((nr),(unsigned long*)addr) 158 test_and_clear_bit((nr), (unsigned long *)addr)
467 159
468#include <asm-generic/bitops/minix.h> 160#include <asm-generic/bitops/minix.h>
469 161
diff --git a/include/asm-x86/bitops_64.h b/include/asm-x86/bitops_64.h
index 766bcc0470a6..48adbf56ca60 100644
--- a/include/asm-x86/bitops_64.h
+++ b/include/asm-x86/bitops_64.h
@@ -5,303 +5,6 @@
5 * Copyright 1992, Linus Torvalds. 5 * Copyright 1992, Linus Torvalds.
6 */ 6 */
7 7
8#ifndef _LINUX_BITOPS_H
9#error only <linux/bitops.h> can be included directly
10#endif
11
12#include <asm/alternative.h>
13
14#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1)
15/* Technically wrong, but this avoids compilation errors on some gcc
16 versions. */
17#define ADDR "=m" (*(volatile long *) addr)
18#else
19#define ADDR "+m" (*(volatile long *) addr)
20#endif
21
22/**
23 * set_bit - Atomically set a bit in memory
24 * @nr: the bit to set
25 * @addr: the address to start counting from
26 *
27 * This function is atomic and may not be reordered. See __set_bit()
28 * if you do not require the atomic guarantees.
29 * Note that @nr may be almost arbitrarily large; this function is not
30 * restricted to acting on a single-word quantity.
31 */
32static inline void set_bit(int nr, volatile void *addr)
33{
34 __asm__ __volatile__( LOCK_PREFIX
35 "btsl %1,%0"
36 :ADDR
37 :"dIr" (nr) : "memory");
38}
39
40/**
41 * __set_bit - Set a bit in memory
42 * @nr: the bit to set
43 * @addr: the address to start counting from
44 *
45 * Unlike set_bit(), this function is non-atomic and may be reordered.
46 * If it's called on the same region of memory simultaneously, the effect
47 * may be that only one operation succeeds.
48 */
49static inline void __set_bit(int nr, volatile void *addr)
50{
51 __asm__ volatile(
52 "btsl %1,%0"
53 :ADDR
54 :"dIr" (nr) : "memory");
55}
56
57/**
58 * clear_bit - Clears a bit in memory
59 * @nr: Bit to clear
60 * @addr: Address to start counting from
61 *
62 * clear_bit() is atomic and may not be reordered. However, it does
63 * not contain a memory barrier, so if it is used for locking purposes,
64 * you should call smp_mb__before_clear_bit() and/or smp_mb__after_clear_bit()
65 * in order to ensure changes are visible on other processors.
66 */
67static inline void clear_bit(int nr, volatile void *addr)
68{
69 __asm__ __volatile__( LOCK_PREFIX
70 "btrl %1,%0"
71 :ADDR
72 :"dIr" (nr));
73}
74
75/*
76 * clear_bit_unlock - Clears a bit in memory
77 * @nr: Bit to clear
78 * @addr: Address to start counting from
79 *
80 * clear_bit() is atomic and implies release semantics before the memory
81 * operation. It can be used for an unlock.
82 */
83static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
84{
85 barrier();
86 clear_bit(nr, addr);
87}
88
89static inline void __clear_bit(int nr, volatile void *addr)
90{
91 __asm__ __volatile__(
92 "btrl %1,%0"
93 :ADDR
94 :"dIr" (nr));
95}
96
97/*
98 * __clear_bit_unlock - Clears a bit in memory
99 * @nr: Bit to clear
100 * @addr: Address to start counting from
101 *
102 * __clear_bit() is non-atomic and implies release semantics before the memory
103 * operation. It can be used for an unlock if no other CPUs can concurrently
104 * modify other bits in the word.
105 *
106 * No memory barrier is required here, because x86 cannot reorder stores past
107 * older loads. Same principle as spin_unlock.
108 */
109static inline void __clear_bit_unlock(unsigned long nr, volatile unsigned long *addr)
110{
111 barrier();
112 __clear_bit(nr, addr);
113}
114
115#define smp_mb__before_clear_bit() barrier()
116#define smp_mb__after_clear_bit() barrier()
117
118/**
119 * __change_bit - Toggle a bit in memory
120 * @nr: the bit to change
121 * @addr: the address to start counting from
122 *
123 * Unlike change_bit(), this function is non-atomic and may be reordered.
124 * If it's called on the same region of memory simultaneously, the effect
125 * may be that only one operation succeeds.
126 */
127static inline void __change_bit(int nr, volatile void *addr)
128{
129 __asm__ __volatile__(
130 "btcl %1,%0"
131 :ADDR
132 :"dIr" (nr));
133}
134
135/**
136 * change_bit - Toggle a bit in memory
137 * @nr: Bit to change
138 * @addr: Address to start counting from
139 *
140 * change_bit() is atomic and may not be reordered.
141 * Note that @nr may be almost arbitrarily large; this function is not
142 * restricted to acting on a single-word quantity.
143 */
144static inline void change_bit(int nr, volatile void *addr)
145{
146 __asm__ __volatile__( LOCK_PREFIX
147 "btcl %1,%0"
148 :ADDR
149 :"dIr" (nr));
150}
151
152/**
153 * test_and_set_bit - Set a bit and return its old value
154 * @nr: Bit to set
155 * @addr: Address to count from
156 *
157 * This operation is atomic and cannot be reordered.
158 * It also implies a memory barrier.
159 */
160static inline int test_and_set_bit(int nr, volatile void *addr)
161{
162 int oldbit;
163
164 __asm__ __volatile__( LOCK_PREFIX
165 "btsl %2,%1\n\tsbbl %0,%0"
166 :"=r" (oldbit),ADDR
167 :"dIr" (nr) : "memory");
168 return oldbit;
169}
170
171/**
172 * test_and_set_bit_lock - Set a bit and return its old value for lock
173 * @nr: Bit to set
174 * @addr: Address to count from
175 *
176 * This is the same as test_and_set_bit on x86.
177 */
178static inline int test_and_set_bit_lock(int nr, volatile void *addr)
179{
180 return test_and_set_bit(nr, addr);
181}
182
183/**
184 * __test_and_set_bit - Set a bit and return its old value
185 * @nr: Bit to set
186 * @addr: Address to count from
187 *
188 * This operation is non-atomic and can be reordered.
189 * If two examples of this operation race, one can appear to succeed
190 * but actually fail. You must protect multiple accesses with a lock.
191 */
192static inline int __test_and_set_bit(int nr, volatile void *addr)
193{
194 int oldbit;
195
196 __asm__(
197 "btsl %2,%1\n\tsbbl %0,%0"
198 :"=r" (oldbit),ADDR
199 :"dIr" (nr));
200 return oldbit;
201}
202
203/**
204 * test_and_clear_bit - Clear a bit and return its old value
205 * @nr: Bit to clear
206 * @addr: Address to count from
207 *
208 * This operation is atomic and cannot be reordered.
209 * It also implies a memory barrier.
210 */
211static inline int test_and_clear_bit(int nr, volatile void *addr)
212{
213 int oldbit;
214
215 __asm__ __volatile__( LOCK_PREFIX
216 "btrl %2,%1\n\tsbbl %0,%0"
217 :"=r" (oldbit),ADDR
218 :"dIr" (nr) : "memory");
219 return oldbit;
220}
221
222/**
223 * __test_and_clear_bit - Clear a bit and return its old value
224 * @nr: Bit to clear
225 * @addr: Address to count from
226 *
227 * This operation is non-atomic and can be reordered.
228 * If two examples of this operation race, one can appear to succeed
229 * but actually fail. You must protect multiple accesses with a lock.
230 */
231static inline int __test_and_clear_bit(int nr, volatile void *addr)
232{
233 int oldbit;
234
235 __asm__(
236 "btrl %2,%1\n\tsbbl %0,%0"
237 :"=r" (oldbit),ADDR
238 :"dIr" (nr));
239 return oldbit;
240}
241
242/* WARNING: non atomic and it can be reordered! */
243static inline int __test_and_change_bit(int nr, volatile void *addr)
244{
245 int oldbit;
246
247 __asm__ __volatile__(
248 "btcl %2,%1\n\tsbbl %0,%0"
249 :"=r" (oldbit),ADDR
250 :"dIr" (nr) : "memory");
251 return oldbit;
252}
253
254/**
255 * test_and_change_bit - Change a bit and return its old value
256 * @nr: Bit to change
257 * @addr: Address to count from
258 *
259 * This operation is atomic and cannot be reordered.
260 * It also implies a memory barrier.
261 */
262static inline int test_and_change_bit(int nr, volatile void *addr)
263{
264 int oldbit;
265
266 __asm__ __volatile__( LOCK_PREFIX
267 "btcl %2,%1\n\tsbbl %0,%0"
268 :"=r" (oldbit),ADDR
269 :"dIr" (nr) : "memory");
270 return oldbit;
271}
272
273#if 0 /* Fool kernel-doc since it doesn't do macros yet */
274/**
275 * test_bit - Determine whether a bit is set
276 * @nr: bit number to test
277 * @addr: Address to start counting from
278 */
279static int test_bit(int nr, const volatile void *addr);
280#endif
281
282static inline int constant_test_bit(int nr, const volatile void *addr)
283{
284 return ((1UL << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
285}
286
287static inline int variable_test_bit(int nr, volatile const void *addr)
288{
289 int oldbit;
290
291 __asm__ __volatile__(
292 "btl %2,%1\n\tsbbl %0,%0"
293 :"=r" (oldbit)
294 :"m" (*(volatile long *)addr),"dIr" (nr));
295 return oldbit;
296}
297
298#define test_bit(nr,addr) \
299(__builtin_constant_p(nr) ? \
300 constant_test_bit((nr),(addr)) : \
301 variable_test_bit((nr),(addr)))
302
303#undef ADDR
304
305extern long find_first_zero_bit(const unsigned long *addr, unsigned long size); 8extern long find_first_zero_bit(const unsigned long *addr, unsigned long size);
306extern long find_next_zero_bit(const unsigned long *addr, long size, long offset); 9extern long find_next_zero_bit(const unsigned long *addr, long size, long offset);
307extern long find_first_bit(const unsigned long *addr, unsigned long size); 10extern long find_first_bit(const unsigned long *addr, unsigned long size);
diff --git a/include/asm-x86/bootparam.h b/include/asm-x86/bootparam.h
index 19f3ddf2df4b..51151356840f 100644
--- a/include/asm-x86/bootparam.h
+++ b/include/asm-x86/bootparam.h
@@ -54,13 +54,14 @@ struct sys_desc_table {
54}; 54};
55 55
56struct efi_info { 56struct efi_info {
57 __u32 _pad1; 57 __u32 efi_loader_signature;
58 __u32 efi_systab; 58 __u32 efi_systab;
59 __u32 efi_memdesc_size; 59 __u32 efi_memdesc_size;
60 __u32 efi_memdesc_version; 60 __u32 efi_memdesc_version;
61 __u32 efi_memmap; 61 __u32 efi_memmap;
62 __u32 efi_memmap_size; 62 __u32 efi_memmap_size;
63 __u32 _pad2[2]; 63 __u32 efi_systab_hi;
64 __u32 efi_memmap_hi;
64}; 65};
65 66
66/* The so-called "zeropage" */ 67/* The so-called "zeropage" */
diff --git a/include/asm-x86/bug.h b/include/asm-x86/bug.h
index fd8bdc639c48..8d477a201392 100644
--- a/include/asm-x86/bug.h
+++ b/include/asm-x86/bug.h
@@ -33,9 +33,6 @@
33 } while(0) 33 } while(0)
34#endif 34#endif
35 35
36void out_of_line_bug(void);
37#else /* CONFIG_BUG */
38static inline void out_of_line_bug(void) { }
39#endif /* !CONFIG_BUG */ 36#endif /* !CONFIG_BUG */
40 37
41#include <asm-generic/bug.h> 38#include <asm-generic/bug.h>
diff --git a/include/asm-x86/bugs.h b/include/asm-x86/bugs.h
index aac8317420af..3fcc30dc0731 100644
--- a/include/asm-x86/bugs.h
+++ b/include/asm-x86/bugs.h
@@ -1,6 +1,7 @@
1#ifndef _ASM_X86_BUGS_H 1#ifndef _ASM_X86_BUGS_H
2#define _ASM_X86_BUGS_H 2#define _ASM_X86_BUGS_H
3 3
4void check_bugs(void); 4extern void check_bugs(void);
5extern int ppro_with_ram_bug(void);
5 6
6#endif /* _ASM_X86_BUGS_H */ 7#endif /* _ASM_X86_BUGS_H */
diff --git a/include/asm-x86/byteorder.h b/include/asm-x86/byteorder.h
index 1f2d6d5bf20d..fe2f2e5d51ba 100644
--- a/include/asm-x86/byteorder.h
+++ b/include/asm-x86/byteorder.h
@@ -30,13 +30,13 @@ static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val)
30 } v; 30 } v;
31 v.u = val; 31 v.u = val;
32#ifdef CONFIG_X86_BSWAP 32#ifdef CONFIG_X86_BSWAP
33 asm("bswapl %0 ; bswapl %1 ; xchgl %0,%1" 33 __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1"
34 : "=r" (v.s.a), "=r" (v.s.b) 34 : "=r" (v.s.a), "=r" (v.s.b)
35 : "0" (v.s.a), "1" (v.s.b)); 35 : "0" (v.s.a), "1" (v.s.b));
36#else 36#else
37 v.s.a = ___arch__swab32(v.s.a); 37 v.s.a = ___arch__swab32(v.s.a);
38 v.s.b = ___arch__swab32(v.s.b); 38 v.s.b = ___arch__swab32(v.s.b);
39 asm("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b)); 39 __asm__("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
40#endif 40#endif
41 return v.u; 41 return v.u;
42} 42}
diff --git a/include/asm-x86/cacheflush.h b/include/asm-x86/cacheflush.h
index 9411a2d3f19c..8dd8c5e3cc7f 100644
--- a/include/asm-x86/cacheflush.h
+++ b/include/asm-x86/cacheflush.h
@@ -24,18 +24,35 @@
24#define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 24#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
25 memcpy(dst, src, len) 25 memcpy(dst, src, len)
26 26
27void global_flush_tlb(void); 27int __deprecated_for_modules change_page_attr(struct page *page, int numpages,
28int change_page_attr(struct page *page, int numpages, pgprot_t prot); 28 pgprot_t prot);
29int change_page_attr_addr(unsigned long addr, int numpages, pgprot_t prot); 29
30void clflush_cache_range(void *addr, int size); 30int set_pages_uc(struct page *page, int numpages);
31 31int set_pages_wb(struct page *page, int numpages);
32#ifdef CONFIG_DEBUG_PAGEALLOC 32int set_pages_x(struct page *page, int numpages);
33/* internal debugging function */ 33int set_pages_nx(struct page *page, int numpages);
34void kernel_map_pages(struct page *page, int numpages, int enable); 34int set_pages_ro(struct page *page, int numpages);
35#endif 35int set_pages_rw(struct page *page, int numpages);
36
37int set_memory_uc(unsigned long addr, int numpages);
38int set_memory_wb(unsigned long addr, int numpages);
39int set_memory_x(unsigned long addr, int numpages);
40int set_memory_nx(unsigned long addr, int numpages);
41int set_memory_ro(unsigned long addr, int numpages);
42int set_memory_rw(unsigned long addr, int numpages);
43int set_memory_np(unsigned long addr, int numpages);
44
45void clflush_cache_range(void *addr, unsigned int size);
36 46
37#ifdef CONFIG_DEBUG_RODATA 47#ifdef CONFIG_DEBUG_RODATA
38void mark_rodata_ro(void); 48void mark_rodata_ro(void);
39#endif 49#endif
50#ifdef CONFIG_DEBUG_RODATA_TEST
51void rodata_test(void);
52#else
53static inline void rodata_test(void)
54{
55}
56#endif
40 57
41#endif 58#endif
diff --git a/include/asm-x86/calling.h b/include/asm-x86/calling.h
index 6f4f63af96e1..f13e62e2cb3e 100644
--- a/include/asm-x86/calling.h
+++ b/include/asm-x86/calling.h
@@ -1,162 +1,168 @@
1/* 1/*
2 * Some macros to handle stack frames in assembly. 2 * Some macros to handle stack frames in assembly.
3 */ 3 */
4 4
5#define R15 0
6#define R14 8
7#define R13 16
8#define R12 24
9#define RBP 32
10#define RBX 40
5 11
6#define R15 0
7#define R14 8
8#define R13 16
9#define R12 24
10#define RBP 32
11#define RBX 40
12/* arguments: interrupts/non tracing syscalls only save upto here*/ 12/* arguments: interrupts/non tracing syscalls only save upto here*/
13#define R11 48 13#define R11 48
14#define R10 56 14#define R10 56
15#define R9 64 15#define R9 64
16#define R8 72 16#define R8 72
17#define RAX 80 17#define RAX 80
18#define RCX 88 18#define RCX 88
19#define RDX 96 19#define RDX 96
20#define RSI 104 20#define RSI 104
21#define RDI 112 21#define RDI 112
22#define ORIG_RAX 120 /* + error_code */ 22#define ORIG_RAX 120 /* + error_code */
23/* end of arguments */ 23/* end of arguments */
24
24/* cpu exception frame or undefined in case of fast syscall. */ 25/* cpu exception frame or undefined in case of fast syscall. */
25#define RIP 128 26#define RIP 128
26#define CS 136 27#define CS 136
27#define EFLAGS 144 28#define EFLAGS 144
28#define RSP 152 29#define RSP 152
29#define SS 160 30#define SS 160
30#define ARGOFFSET R11 31
31#define SWFRAME ORIG_RAX 32#define ARGOFFSET R11
33#define SWFRAME ORIG_RAX
32 34
33 .macro SAVE_ARGS addskip=0,norcx=0,nor891011=0 35 .macro SAVE_ARGS addskip=0, norcx=0, nor891011=0
34 subq $9*8+\addskip,%rsp 36 subq $9*8+\addskip, %rsp
35 CFI_ADJUST_CFA_OFFSET 9*8+\addskip 37 CFI_ADJUST_CFA_OFFSET 9*8+\addskip
36 movq %rdi,8*8(%rsp) 38 movq %rdi, 8*8(%rsp)
37 CFI_REL_OFFSET rdi,8*8 39 CFI_REL_OFFSET rdi, 8*8
38 movq %rsi,7*8(%rsp) 40 movq %rsi, 7*8(%rsp)
39 CFI_REL_OFFSET rsi,7*8 41 CFI_REL_OFFSET rsi, 7*8
40 movq %rdx,6*8(%rsp) 42 movq %rdx, 6*8(%rsp)
41 CFI_REL_OFFSET rdx,6*8 43 CFI_REL_OFFSET rdx, 6*8
42 .if \norcx 44 .if \norcx
43 .else 45 .else
44 movq %rcx,5*8(%rsp) 46 movq %rcx, 5*8(%rsp)
45 CFI_REL_OFFSET rcx,5*8 47 CFI_REL_OFFSET rcx, 5*8
46 .endif 48 .endif
47 movq %rax,4*8(%rsp) 49 movq %rax, 4*8(%rsp)
48 CFI_REL_OFFSET rax,4*8 50 CFI_REL_OFFSET rax, 4*8
49 .if \nor891011 51 .if \nor891011
50 .else 52 .else
51 movq %r8,3*8(%rsp) 53 movq %r8, 3*8(%rsp)
52 CFI_REL_OFFSET r8,3*8 54 CFI_REL_OFFSET r8, 3*8
53 movq %r9,2*8(%rsp) 55 movq %r9, 2*8(%rsp)
54 CFI_REL_OFFSET r9,2*8 56 CFI_REL_OFFSET r9, 2*8
55 movq %r10,1*8(%rsp) 57 movq %r10, 1*8(%rsp)
56 CFI_REL_OFFSET r10,1*8 58 CFI_REL_OFFSET r10, 1*8
57 movq %r11,(%rsp) 59 movq %r11, (%rsp)
58 CFI_REL_OFFSET r11,0*8 60 CFI_REL_OFFSET r11, 0*8
59 .endif 61 .endif
60 .endm 62 .endm
61 63
62#define ARG_SKIP 9*8 64#define ARG_SKIP 9*8
63 .macro RESTORE_ARGS skiprax=0,addskip=0,skiprcx=0,skipr11=0,skipr8910=0,skiprdx=0 65
66 .macro RESTORE_ARGS skiprax=0, addskip=0, skiprcx=0, skipr11=0, \
67 skipr8910=0, skiprdx=0
64 .if \skipr11 68 .if \skipr11
65 .else 69 .else
66 movq (%rsp),%r11 70 movq (%rsp), %r11
67 CFI_RESTORE r11 71 CFI_RESTORE r11
68 .endif 72 .endif
69 .if \skipr8910 73 .if \skipr8910
70 .else 74 .else
71 movq 1*8(%rsp),%r10 75 movq 1*8(%rsp), %r10
72 CFI_RESTORE r10 76 CFI_RESTORE r10
73 movq 2*8(%rsp),%r9 77 movq 2*8(%rsp), %r9
74 CFI_RESTORE r9 78 CFI_RESTORE r9
75 movq 3*8(%rsp),%r8 79 movq 3*8(%rsp), %r8
76 CFI_RESTORE r8 80 CFI_RESTORE r8
77 .endif 81 .endif
78 .if \skiprax 82 .if \skiprax
79 .else 83 .else
80 movq 4*8(%rsp),%rax 84 movq 4*8(%rsp), %rax
81 CFI_RESTORE rax 85 CFI_RESTORE rax
82 .endif 86 .endif
83 .if \skiprcx 87 .if \skiprcx
84 .else 88 .else
85 movq 5*8(%rsp),%rcx 89 movq 5*8(%rsp), %rcx
86 CFI_RESTORE rcx 90 CFI_RESTORE rcx
87 .endif 91 .endif
88 .if \skiprdx 92 .if \skiprdx
89 .else 93 .else
90 movq 6*8(%rsp),%rdx 94 movq 6*8(%rsp), %rdx
91 CFI_RESTORE rdx 95 CFI_RESTORE rdx
92 .endif 96 .endif
93 movq 7*8(%rsp),%rsi 97 movq 7*8(%rsp), %rsi
94 CFI_RESTORE rsi 98 CFI_RESTORE rsi
95 movq 8*8(%rsp),%rdi 99 movq 8*8(%rsp), %rdi
96 CFI_RESTORE rdi 100 CFI_RESTORE rdi
97 .if ARG_SKIP+\addskip > 0 101 .if ARG_SKIP+\addskip > 0
98 addq $ARG_SKIP+\addskip,%rsp 102 addq $ARG_SKIP+\addskip, %rsp
99 CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip) 103 CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip)
100 .endif 104 .endif
101 .endm 105 .endm
102 106
103 .macro LOAD_ARGS offset 107 .macro LOAD_ARGS offset
104 movq \offset(%rsp),%r11 108 movq \offset(%rsp), %r11
105 movq \offset+8(%rsp),%r10 109 movq \offset+8(%rsp), %r10
106 movq \offset+16(%rsp),%r9 110 movq \offset+16(%rsp), %r9
107 movq \offset+24(%rsp),%r8 111 movq \offset+24(%rsp), %r8
108 movq \offset+40(%rsp),%rcx 112 movq \offset+40(%rsp), %rcx
109 movq \offset+48(%rsp),%rdx 113 movq \offset+48(%rsp), %rdx
110 movq \offset+56(%rsp),%rsi 114 movq \offset+56(%rsp), %rsi
111 movq \offset+64(%rsp),%rdi 115 movq \offset+64(%rsp), %rdi
112 movq \offset+72(%rsp),%rax 116 movq \offset+72(%rsp), %rax
113 .endm 117 .endm
114 118
115#define REST_SKIP 6*8 119#define REST_SKIP 6*8
120
116 .macro SAVE_REST 121 .macro SAVE_REST
117 subq $REST_SKIP,%rsp 122 subq $REST_SKIP, %rsp
118 CFI_ADJUST_CFA_OFFSET REST_SKIP 123 CFI_ADJUST_CFA_OFFSET REST_SKIP
119 movq %rbx,5*8(%rsp) 124 movq %rbx, 5*8(%rsp)
120 CFI_REL_OFFSET rbx,5*8 125 CFI_REL_OFFSET rbx, 5*8
121 movq %rbp,4*8(%rsp) 126 movq %rbp, 4*8(%rsp)
122 CFI_REL_OFFSET rbp,4*8 127 CFI_REL_OFFSET rbp, 4*8
123 movq %r12,3*8(%rsp) 128 movq %r12, 3*8(%rsp)
124 CFI_REL_OFFSET r12,3*8 129 CFI_REL_OFFSET r12, 3*8
125 movq %r13,2*8(%rsp) 130 movq %r13, 2*8(%rsp)
126 CFI_REL_OFFSET r13,2*8 131 CFI_REL_OFFSET r13, 2*8
127 movq %r14,1*8(%rsp) 132 movq %r14, 1*8(%rsp)
128 CFI_REL_OFFSET r14,1*8 133 CFI_REL_OFFSET r14, 1*8
129 movq %r15,(%rsp) 134 movq %r15, (%rsp)
130 CFI_REL_OFFSET r15,0*8 135 CFI_REL_OFFSET r15, 0*8
131 .endm 136 .endm
132 137
133 .macro RESTORE_REST 138 .macro RESTORE_REST
134 movq (%rsp),%r15 139 movq (%rsp), %r15
135 CFI_RESTORE r15 140 CFI_RESTORE r15
136 movq 1*8(%rsp),%r14 141 movq 1*8(%rsp), %r14
137 CFI_RESTORE r14 142 CFI_RESTORE r14
138 movq 2*8(%rsp),%r13 143 movq 2*8(%rsp), %r13
139 CFI_RESTORE r13 144 CFI_RESTORE r13
140 movq 3*8(%rsp),%r12 145 movq 3*8(%rsp), %r12
141 CFI_RESTORE r12 146 CFI_RESTORE r12
142 movq 4*8(%rsp),%rbp 147 movq 4*8(%rsp), %rbp
143 CFI_RESTORE rbp 148 CFI_RESTORE rbp
144 movq 5*8(%rsp),%rbx 149 movq 5*8(%rsp), %rbx
145 CFI_RESTORE rbx 150 CFI_RESTORE rbx
146 addq $REST_SKIP,%rsp 151 addq $REST_SKIP, %rsp
147 CFI_ADJUST_CFA_OFFSET -(REST_SKIP) 152 CFI_ADJUST_CFA_OFFSET -(REST_SKIP)
148 .endm 153 .endm
149 154
150 .macro SAVE_ALL 155 .macro SAVE_ALL
151 SAVE_ARGS 156 SAVE_ARGS
152 SAVE_REST 157 SAVE_REST
153 .endm 158 .endm
154 159
155 .macro RESTORE_ALL addskip=0 160 .macro RESTORE_ALL addskip=0
156 RESTORE_REST 161 RESTORE_REST
157 RESTORE_ARGS 0,\addskip 162 RESTORE_ARGS 0, \addskip
158 .endm 163 .endm
159 164
160 .macro icebp 165 .macro icebp
161 .byte 0xf1 166 .byte 0xf1
162 .endm 167 .endm
168
diff --git a/include/asm-x86/checksum_64.h b/include/asm-x86/checksum_64.h
index 419fe88a0342..e5f79997decc 100644
--- a/include/asm-x86/checksum_64.h
+++ b/include/asm-x86/checksum_64.h
@@ -4,7 +4,7 @@
4/* 4/*
5 * Checksums for x86-64 5 * Checksums for x86-64
6 * Copyright 2002 by Andi Kleen, SuSE Labs 6 * Copyright 2002 by Andi Kleen, SuSE Labs
7 * with some code from asm-i386/checksum.h 7 * with some code from asm-x86/checksum.h
8 */ 8 */
9 9
10#include <linux/compiler.h> 10#include <linux/compiler.h>
diff --git a/include/asm-x86/cmpxchg_32.h b/include/asm-x86/cmpxchg_32.h
index f86ede28f6dc..cea1dae288a7 100644
--- a/include/asm-x86/cmpxchg_32.h
+++ b/include/asm-x86/cmpxchg_32.h
@@ -105,15 +105,24 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
105 105
106#ifdef CONFIG_X86_CMPXCHG 106#ifdef CONFIG_X86_CMPXCHG
107#define __HAVE_ARCH_CMPXCHG 1 107#define __HAVE_ARCH_CMPXCHG 1
108#define cmpxchg(ptr,o,n)\ 108#define cmpxchg(ptr, o, n) \
109 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ 109 ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o), \
110 (unsigned long)(n),sizeof(*(ptr)))) 110 (unsigned long)(n), sizeof(*(ptr))))
111#define sync_cmpxchg(ptr,o,n)\ 111#define sync_cmpxchg(ptr, o, n) \
112 ((__typeof__(*(ptr)))__sync_cmpxchg((ptr),(unsigned long)(o),\ 112 ((__typeof__(*(ptr)))__sync_cmpxchg((ptr), (unsigned long)(o), \
113 (unsigned long)(n),sizeof(*(ptr)))) 113 (unsigned long)(n), sizeof(*(ptr))))
114#define cmpxchg_local(ptr,o,n)\ 114#define cmpxchg_local(ptr, o, n) \
115 ((__typeof__(*(ptr)))__cmpxchg_local((ptr),(unsigned long)(o),\ 115 ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
116 (unsigned long)(n),sizeof(*(ptr)))) 116 (unsigned long)(n), sizeof(*(ptr))))
117#endif
118
119#ifdef CONFIG_X86_CMPXCHG64
120#define cmpxchg64(ptr, o, n) \
121 ((__typeof__(*(ptr)))__cmpxchg64((ptr), (unsigned long long)(o), \
122 (unsigned long long)(n)))
123#define cmpxchg64_local(ptr, o, n) \
124 ((__typeof__(*(ptr)))__cmpxchg64_local((ptr), (unsigned long long)(o),\
125 (unsigned long long)(n)))
117#endif 126#endif
118 127
119static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, 128static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
@@ -203,6 +212,34 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
203 return old; 212 return old;
204} 213}
205 214
215static inline unsigned long long __cmpxchg64(volatile void *ptr,
216 unsigned long long old, unsigned long long new)
217{
218 unsigned long long prev;
219 __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3"
220 : "=A"(prev)
221 : "b"((unsigned long)new),
222 "c"((unsigned long)(new >> 32)),
223 "m"(*__xg(ptr)),
224 "0"(old)
225 : "memory");
226 return prev;
227}
228
229static inline unsigned long long __cmpxchg64_local(volatile void *ptr,
230 unsigned long long old, unsigned long long new)
231{
232 unsigned long long prev;
233 __asm__ __volatile__("cmpxchg8b %3"
234 : "=A"(prev)
235 : "b"((unsigned long)new),
236 "c"((unsigned long)(new >> 32)),
237 "m"(*__xg(ptr)),
238 "0"(old)
239 : "memory");
240 return prev;
241}
242
206#ifndef CONFIG_X86_CMPXCHG 243#ifndef CONFIG_X86_CMPXCHG
207/* 244/*
208 * Building a kernel capable running on 80386. It may be necessary to 245 * Building a kernel capable running on 80386. It may be necessary to
@@ -228,7 +265,7 @@ static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
228 return old; 265 return old;
229} 266}
230 267
231#define cmpxchg(ptr,o,n) \ 268#define cmpxchg(ptr, o, n) \
232({ \ 269({ \
233 __typeof__(*(ptr)) __ret; \ 270 __typeof__(*(ptr)) __ret; \
234 if (likely(boot_cpu_data.x86 > 3)) \ 271 if (likely(boot_cpu_data.x86 > 3)) \
@@ -239,7 +276,7 @@ static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
239 (unsigned long)(n), sizeof(*(ptr))); \ 276 (unsigned long)(n), sizeof(*(ptr))); \
240 __ret; \ 277 __ret; \
241}) 278})
242#define cmpxchg_local(ptr,o,n) \ 279#define cmpxchg_local(ptr, o, n) \
243({ \ 280({ \
244 __typeof__(*(ptr)) __ret; \ 281 __typeof__(*(ptr)) __ret; \
245 if (likely(boot_cpu_data.x86 > 3)) \ 282 if (likely(boot_cpu_data.x86 > 3)) \
@@ -252,38 +289,37 @@ static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
252}) 289})
253#endif 290#endif
254 291
255static inline unsigned long long __cmpxchg64(volatile void *ptr, unsigned long long old, 292#ifndef CONFIG_X86_CMPXCHG64
256 unsigned long long new) 293/*
257{ 294 * Building a kernel capable running on 80386 and 80486. It may be necessary
258 unsigned long long prev; 295 * to simulate the cmpxchg8b on the 80386 and 80486 CPU.
259 __asm__ __volatile__(LOCK_PREFIX "cmpxchg8b %3" 296 */
260 : "=A"(prev)
261 : "b"((unsigned long)new),
262 "c"((unsigned long)(new >> 32)),
263 "m"(*__xg(ptr)),
264 "0"(old)
265 : "memory");
266 return prev;
267}
268 297
269static inline unsigned long long __cmpxchg64_local(volatile void *ptr, 298extern unsigned long long cmpxchg_486_u64(volatile void *, u64, u64);
270 unsigned long long old, unsigned long long new) 299
271{ 300#define cmpxchg64(ptr, o, n) \
272 unsigned long long prev; 301({ \
273 __asm__ __volatile__("cmpxchg8b %3" 302 __typeof__(*(ptr)) __ret; \
274 : "=A"(prev) 303 if (likely(boot_cpu_data.x86 > 4)) \
275 : "b"((unsigned long)new), 304 __ret = __cmpxchg64((ptr), (unsigned long long)(o), \
276 "c"((unsigned long)(new >> 32)), 305 (unsigned long long)(n)); \
277 "m"(*__xg(ptr)), 306 else \
278 "0"(old) 307 __ret = cmpxchg_486_u64((ptr), (unsigned long long)(o), \
279 : "memory"); 308 (unsigned long long)(n)); \
280 return prev; 309 __ret; \
281} 310})
311#define cmpxchg64_local(ptr, o, n) \
312({ \
313 __typeof__(*(ptr)) __ret; \
314 if (likely(boot_cpu_data.x86 > 4)) \
315 __ret = __cmpxchg64_local((ptr), (unsigned long long)(o), \
316 (unsigned long long)(n)); \
317 else \
318 __ret = cmpxchg_486_u64((ptr), (unsigned long long)(o), \
319 (unsigned long long)(n)); \
320 __ret; \
321})
322
323#endif
282 324
283#define cmpxchg64(ptr,o,n)\
284 ((__typeof__(*(ptr)))__cmpxchg64((ptr),(unsigned long long)(o),\
285 (unsigned long long)(n)))
286#define cmpxchg64_local(ptr,o,n)\
287 ((__typeof__(*(ptr)))__cmpxchg64_local((ptr),(unsigned long long)(o),\
288 (unsigned long long)(n)))
289#endif 325#endif
diff --git a/include/asm-x86/compat.h b/include/asm-x86/compat.h
index 66ba7987184a..b270ee04959e 100644
--- a/include/asm-x86/compat.h
+++ b/include/asm-x86/compat.h
@@ -207,7 +207,7 @@ static inline compat_uptr_t ptr_to_compat(void __user *uptr)
207static __inline__ void __user *compat_alloc_user_space(long len) 207static __inline__ void __user *compat_alloc_user_space(long len)
208{ 208{
209 struct pt_regs *regs = task_pt_regs(current); 209 struct pt_regs *regs = task_pt_regs(current);
210 return (void __user *)regs->rsp - len; 210 return (void __user *)regs->sp - len;
211} 211}
212 212
213static inline int is_compat_task(void) 213static inline int is_compat_task(void)
diff --git a/include/asm-x86/cpu.h b/include/asm-x86/cpu.h
index b1bc7b1b64b0..73f2ea84fd74 100644
--- a/include/asm-x86/cpu.h
+++ b/include/asm-x86/cpu.h
@@ -7,11 +7,12 @@
7#include <linux/nodemask.h> 7#include <linux/nodemask.h>
8#include <linux/percpu.h> 8#include <linux/percpu.h>
9 9
10struct i386_cpu { 10struct x86_cpu {
11 struct cpu cpu; 11 struct cpu cpu;
12}; 12};
13extern int arch_register_cpu(int num); 13
14#ifdef CONFIG_HOTPLUG_CPU 14#ifdef CONFIG_HOTPLUG_CPU
15extern int arch_register_cpu(int num);
15extern void arch_unregister_cpu(int); 16extern void arch_unregister_cpu(int);
16#endif 17#endif
17 18
diff --git a/include/asm-x86/cpufeature.h b/include/asm-x86/cpufeature.h
index b7160a4598d7..3fb7dfa7fc91 100644
--- a/include/asm-x86/cpufeature.h
+++ b/include/asm-x86/cpufeature.h
@@ -1,5 +1,207 @@
1#ifdef CONFIG_X86_32 1/*
2# include "cpufeature_32.h" 2 * Defines x86 CPU feature bits
3 */
4#ifndef _ASM_X86_CPUFEATURE_H
5#define _ASM_X86_CPUFEATURE_H
6
7#ifndef __ASSEMBLY__
8#include <linux/bitops.h>
9#endif
10#include <asm/required-features.h>
11
12#define NCAPINTS 8 /* N 32-bit words worth of info */
13
14/* Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0 */
15#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
16#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */
17#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */
18#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */
19#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */
20#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */
21#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */
22#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */
23#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */
24#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */
25#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */
26#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */
27#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */
28#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */
29#define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
30#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */
31#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
32#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
33#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
34#define X86_FEATURE_DS (0*32+21) /* Debug Store */
35#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
36#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
37#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
38 /* of FPU context), and CR4.OSFXSR available */
39#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
40#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
41#define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */
42#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */
43#define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */
44#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */
45
46/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
47/* Don't duplicate feature flags which are redundant with Intel! */
48#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */
49#define X86_FEATURE_MP (1*32+19) /* MP Capable. */
50#define X86_FEATURE_NX (1*32+20) /* Execute Disable */
51#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
52#define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */
53#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
54#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */
55#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
56
57/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */
58#define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */
59#define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */
60#define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */
61
62/* Other features, Linux-defined mapping, word 3 */
63/* This range is used for feature bits which conflict or are synthesized */
64#define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */
65#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */
66#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
67#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
68/* cpu types for specific tunings: */
69#define X86_FEATURE_K8 (3*32+ 4) /* Opteron, Athlon64 */
70#define X86_FEATURE_K7 (3*32+ 5) /* Athlon */
71#define X86_FEATURE_P3 (3*32+ 6) /* P3 */
72#define X86_FEATURE_P4 (3*32+ 7) /* P4 */
73#define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */
74#define X86_FEATURE_UP (3*32+ 9) /* smp kernel running on up */
75#define X86_FEATURE_FXSAVE_LEAK (3*32+10) /* FXSAVE leaks FOP/FIP/FOP */
76#define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */
77#define X86_FEATURE_PEBS (3*32+12) /* Precise-Event Based Sampling */
78#define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */
79/* 14 free */
80/* 15 free */
81#define X86_FEATURE_REP_GOOD (3*32+16) /* rep microcode works well on this CPU */
82#define X86_FEATURE_MFENCE_RDTSC (3*32+17) /* Mfence synchronizes RDTSC */
83#define X86_FEATURE_LFENCE_RDTSC (3*32+18) /* Lfence synchronizes RDTSC */
84
85/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
86#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
87#define X86_FEATURE_MWAIT (4*32+ 3) /* Monitor/Mwait support */
88#define X86_FEATURE_DSCPL (4*32+ 4) /* CPL Qualified Debug Store */
89#define X86_FEATURE_EST (4*32+ 7) /* Enhanced SpeedStep */
90#define X86_FEATURE_TM2 (4*32+ 8) /* Thermal Monitor 2 */
91#define X86_FEATURE_CID (4*32+10) /* Context ID */
92#define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */
93#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */
94#define X86_FEATURE_DCA (4*32+18) /* Direct Cache Access */
95
96/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
97#define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */
98#define X86_FEATURE_XSTORE_EN (5*32+ 3) /* on-CPU RNG enabled */
99#define X86_FEATURE_XCRYPT (5*32+ 6) /* on-CPU crypto (xcrypt insn) */
100#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */
101#define X86_FEATURE_ACE2 (5*32+ 8) /* Advanced Cryptography Engine v2 */
102#define X86_FEATURE_ACE2_EN (5*32+ 9) /* ACE v2 enabled */
103#define X86_FEATURE_PHE (5*32+ 10) /* PadLock Hash Engine */
104#define X86_FEATURE_PHE_EN (5*32+ 11) /* PHE enabled */
105#define X86_FEATURE_PMM (5*32+ 12) /* PadLock Montgomery Multiplier */
106#define X86_FEATURE_PMM_EN (5*32+ 13) /* PMM enabled */
107
108/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
109#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
110#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
111
112/*
113 * Auxiliary flags: Linux defined - For features scattered in various
114 * CPUID levels like 0x6, 0xA etc
115 */
116#define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */
117
118#define cpu_has(c, bit) \
119 (__builtin_constant_p(bit) && \
120 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
121 (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
122 (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
123 (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
124 (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
125 (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
126 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
127 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \
128 ? 1 : \
129 test_bit(bit, (unsigned long *)((c)->x86_capability)))
130#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
131
132#define set_cpu_cap(c, bit) set_bit(bit, (unsigned long *)((c)->x86_capability))
133#define clear_cpu_cap(c, bit) clear_bit(bit, (unsigned long *)((c)->x86_capability))
134#define setup_clear_cpu_cap(bit) do { \
135 clear_cpu_cap(&boot_cpu_data, bit); \
136 set_bit(bit, cleared_cpu_caps); \
137} while (0)
138#define setup_force_cpu_cap(bit) do { \
139 set_cpu_cap(&boot_cpu_data, bit); \
140 clear_bit(bit, cleared_cpu_caps); \
141} while (0)
142
143#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
144#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
145#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
146#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
147#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
148#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
149#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
150#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
151#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
152#define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
153#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
154#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
155#define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
156#define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2)
157#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
158#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
159#define cpu_has_mp boot_cpu_has(X86_FEATURE_MP)
160#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
161#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
162#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
163#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
164#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
165#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
166#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
167#define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN)
168#define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2)
169#define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN)
170#define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE)
171#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
172#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
173#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
174#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
175#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
176#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
177#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
178
179#if defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_64)
180# define cpu_has_invlpg 1
3#else 181#else
4# include "cpufeature_64.h" 182# define cpu_has_invlpg (boot_cpu_data.x86 > 3)
5#endif 183#endif
184
185#ifdef CONFIG_X86_64
186
187#undef cpu_has_vme
188#define cpu_has_vme 0
189
190#undef cpu_has_pae
191#define cpu_has_pae ___BUG___
192
193#undef cpu_has_mp
194#define cpu_has_mp 1
195
196#undef cpu_has_k6_mtrr
197#define cpu_has_k6_mtrr 0
198
199#undef cpu_has_cyrix_arr
200#define cpu_has_cyrix_arr 0
201
202#undef cpu_has_centaur_mcr
203#define cpu_has_centaur_mcr 0
204
205#endif /* CONFIG_X86_64 */
206
207#endif /* _ASM_X86_CPUFEATURE_H */
diff --git a/include/asm-x86/cpufeature_32.h b/include/asm-x86/cpufeature_32.h
deleted file mode 100644
index f17e688dfb05..000000000000
--- a/include/asm-x86/cpufeature_32.h
+++ /dev/null
@@ -1,176 +0,0 @@
1/*
2 * cpufeature.h
3 *
4 * Defines x86 CPU feature bits
5 */
6
7#ifndef __ASM_I386_CPUFEATURE_H
8#define __ASM_I386_CPUFEATURE_H
9
10#ifndef __ASSEMBLY__
11#include <linux/bitops.h>
12#endif
13#include <asm/required-features.h>
14
15#define NCAPINTS 8 /* N 32-bit words worth of info */
16
17/* Intel-defined CPU features, CPUID level 0x00000001 (edx), word 0 */
18#define X86_FEATURE_FPU (0*32+ 0) /* Onboard FPU */
19#define X86_FEATURE_VME (0*32+ 1) /* Virtual Mode Extensions */
20#define X86_FEATURE_DE (0*32+ 2) /* Debugging Extensions */
21#define X86_FEATURE_PSE (0*32+ 3) /* Page Size Extensions */
22#define X86_FEATURE_TSC (0*32+ 4) /* Time Stamp Counter */
23#define X86_FEATURE_MSR (0*32+ 5) /* Model-Specific Registers, RDMSR, WRMSR */
24#define X86_FEATURE_PAE (0*32+ 6) /* Physical Address Extensions */
25#define X86_FEATURE_MCE (0*32+ 7) /* Machine Check Architecture */
26#define X86_FEATURE_CX8 (0*32+ 8) /* CMPXCHG8 instruction */
27#define X86_FEATURE_APIC (0*32+ 9) /* Onboard APIC */
28#define X86_FEATURE_SEP (0*32+11) /* SYSENTER/SYSEXIT */
29#define X86_FEATURE_MTRR (0*32+12) /* Memory Type Range Registers */
30#define X86_FEATURE_PGE (0*32+13) /* Page Global Enable */
31#define X86_FEATURE_MCA (0*32+14) /* Machine Check Architecture */
32#define X86_FEATURE_CMOV (0*32+15) /* CMOV instruction (FCMOVCC and FCOMI too if FPU present) */
33#define X86_FEATURE_PAT (0*32+16) /* Page Attribute Table */
34#define X86_FEATURE_PSE36 (0*32+17) /* 36-bit PSEs */
35#define X86_FEATURE_PN (0*32+18) /* Processor serial number */
36#define X86_FEATURE_CLFLSH (0*32+19) /* Supports the CLFLUSH instruction */
37#define X86_FEATURE_DS (0*32+21) /* Debug Store */
38#define X86_FEATURE_ACPI (0*32+22) /* ACPI via MSR */
39#define X86_FEATURE_MMX (0*32+23) /* Multimedia Extensions */
40#define X86_FEATURE_FXSR (0*32+24) /* FXSAVE and FXRSTOR instructions (fast save and restore */
41 /* of FPU context), and CR4.OSFXSR available */
42#define X86_FEATURE_XMM (0*32+25) /* Streaming SIMD Extensions */
43#define X86_FEATURE_XMM2 (0*32+26) /* Streaming SIMD Extensions-2 */
44#define X86_FEATURE_SELFSNOOP (0*32+27) /* CPU self snoop */
45#define X86_FEATURE_HT (0*32+28) /* Hyper-Threading */
46#define X86_FEATURE_ACC (0*32+29) /* Automatic clock control */
47#define X86_FEATURE_IA64 (0*32+30) /* IA-64 processor */
48
49/* AMD-defined CPU features, CPUID level 0x80000001, word 1 */
50/* Don't duplicate feature flags which are redundant with Intel! */
51#define X86_FEATURE_SYSCALL (1*32+11) /* SYSCALL/SYSRET */
52#define X86_FEATURE_MP (1*32+19) /* MP Capable. */
53#define X86_FEATURE_NX (1*32+20) /* Execute Disable */
54#define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */
55#define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */
56#define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */
57#define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */
58#define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
59
60/* Transmeta-defined CPU features, CPUID level 0x80860001, word 2 */
61#define X86_FEATURE_RECOVERY (2*32+ 0) /* CPU in recovery mode */
62#define X86_FEATURE_LONGRUN (2*32+ 1) /* Longrun power control */
63#define X86_FEATURE_LRTI (2*32+ 3) /* LongRun table interface */
64
65/* Other features, Linux-defined mapping, word 3 */
66/* This range is used for feature bits which conflict or are synthesized */
67#define X86_FEATURE_CXMMX (3*32+ 0) /* Cyrix MMX extensions */
68#define X86_FEATURE_K6_MTRR (3*32+ 1) /* AMD K6 nonstandard MTRRs */
69#define X86_FEATURE_CYRIX_ARR (3*32+ 2) /* Cyrix ARRs (= MTRRs) */
70#define X86_FEATURE_CENTAUR_MCR (3*32+ 3) /* Centaur MCRs (= MTRRs) */
71/* cpu types for specific tunings: */
72#define X86_FEATURE_K8 (3*32+ 4) /* Opteron, Athlon64 */
73#define X86_FEATURE_K7 (3*32+ 5) /* Athlon */
74#define X86_FEATURE_P3 (3*32+ 6) /* P3 */
75#define X86_FEATURE_P4 (3*32+ 7) /* P4 */
76#define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */
77#define X86_FEATURE_UP (3*32+ 9) /* smp kernel running on up */
78#define X86_FEATURE_FXSAVE_LEAK (3*32+10) /* FXSAVE leaks FOP/FIP/FOP */
79#define X86_FEATURE_ARCH_PERFMON (3*32+11) /* Intel Architectural PerfMon */
80#define X86_FEATURE_PEBS (3*32+12) /* Precise-Event Based Sampling */
81#define X86_FEATURE_BTS (3*32+13) /* Branch Trace Store */
82/* 14 free */
83#define X86_FEATURE_SYNC_RDTSC (3*32+15) /* RDTSC synchronizes the CPU */
84#define X86_FEATURE_REP_GOOD (3*32+16) /* rep microcode works well on this CPU */
85
86/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
87#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
88#define X86_FEATURE_MWAIT (4*32+ 3) /* Monitor/Mwait support */
89#define X86_FEATURE_DSCPL (4*32+ 4) /* CPL Qualified Debug Store */
90#define X86_FEATURE_EST (4*32+ 7) /* Enhanced SpeedStep */
91#define X86_FEATURE_TM2 (4*32+ 8) /* Thermal Monitor 2 */
92#define X86_FEATURE_CID (4*32+10) /* Context ID */
93#define X86_FEATURE_CX16 (4*32+13) /* CMPXCHG16B */
94#define X86_FEATURE_XTPR (4*32+14) /* Send Task Priority Messages */
95#define X86_FEATURE_DCA (4*32+18) /* Direct Cache Access */
96
97/* VIA/Cyrix/Centaur-defined CPU features, CPUID level 0xC0000001, word 5 */
98#define X86_FEATURE_XSTORE (5*32+ 2) /* on-CPU RNG present (xstore insn) */
99#define X86_FEATURE_XSTORE_EN (5*32+ 3) /* on-CPU RNG enabled */
100#define X86_FEATURE_XCRYPT (5*32+ 6) /* on-CPU crypto (xcrypt insn) */
101#define X86_FEATURE_XCRYPT_EN (5*32+ 7) /* on-CPU crypto enabled */
102#define X86_FEATURE_ACE2 (5*32+ 8) /* Advanced Cryptography Engine v2 */
103#define X86_FEATURE_ACE2_EN (5*32+ 9) /* ACE v2 enabled */
104#define X86_FEATURE_PHE (5*32+ 10) /* PadLock Hash Engine */
105#define X86_FEATURE_PHE_EN (5*32+ 11) /* PHE enabled */
106#define X86_FEATURE_PMM (5*32+ 12) /* PadLock Montgomery Multiplier */
107#define X86_FEATURE_PMM_EN (5*32+ 13) /* PMM enabled */
108
109/* More extended AMD flags: CPUID level 0x80000001, ecx, word 6 */
110#define X86_FEATURE_LAHF_LM (6*32+ 0) /* LAHF/SAHF in long mode */
111#define X86_FEATURE_CMP_LEGACY (6*32+ 1) /* If yes HyperThreading not valid */
112
113/*
114 * Auxiliary flags: Linux defined - For features scattered in various
115 * CPUID levels like 0x6, 0xA etc
116 */
117#define X86_FEATURE_IDA (7*32+ 0) /* Intel Dynamic Acceleration */
118
119#define cpu_has(c, bit) \
120 (__builtin_constant_p(bit) && \
121 ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || \
122 (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || \
123 (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || \
124 (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || \
125 (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || \
126 (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || \
127 (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || \
128 (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) \
129 ? 1 : \
130 test_bit(bit, (c)->x86_capability))
131#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
132
133#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
134#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
135#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
136#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
137#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
138#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
139#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
140#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
141#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
142#define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
143#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
144#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
145#define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
146#define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2)
147#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
148#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
149#define cpu_has_mp boot_cpu_has(X86_FEATURE_MP)
150#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
151#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
152#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
153#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
154#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
155#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
156#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
157#define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN)
158#define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2)
159#define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN)
160#define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE)
161#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
162#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
163#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
164#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
165#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
166#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
167#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
168
169#endif /* __ASM_I386_CPUFEATURE_H */
170
171/*
172 * Local Variables:
173 * mode:c
174 * comment-column:42
175 * End:
176 */
diff --git a/include/asm-x86/cpufeature_64.h b/include/asm-x86/cpufeature_64.h
deleted file mode 100644
index e18496b7b850..000000000000
--- a/include/asm-x86/cpufeature_64.h
+++ /dev/null
@@ -1,30 +0,0 @@
1/*
2 * cpufeature_32.h
3 *
4 * Defines x86 CPU feature bits
5 */
6
7#ifndef __ASM_X8664_CPUFEATURE_H
8#define __ASM_X8664_CPUFEATURE_H
9
10#include "cpufeature_32.h"
11
12#undef cpu_has_vme
13#define cpu_has_vme 0
14
15#undef cpu_has_pae
16#define cpu_has_pae ___BUG___
17
18#undef cpu_has_mp
19#define cpu_has_mp 1 /* XXX */
20
21#undef cpu_has_k6_mtrr
22#define cpu_has_k6_mtrr 0
23
24#undef cpu_has_cyrix_arr
25#define cpu_has_cyrix_arr 0
26
27#undef cpu_has_centaur_mcr
28#define cpu_has_centaur_mcr 0
29
30#endif /* __ASM_X8664_CPUFEATURE_H */
diff --git a/include/asm-x86/desc.h b/include/asm-x86/desc.h
index 6065c5092265..5b6a05d3a771 100644
--- a/include/asm-x86/desc.h
+++ b/include/asm-x86/desc.h
@@ -1,5 +1,381 @@
1#ifndef _ASM_DESC_H_
2#define _ASM_DESC_H_
3
4#ifndef __ASSEMBLY__
5#include <asm/desc_defs.h>
6#include <asm/ldt.h>
7#include <asm/mmu.h>
8#include <linux/smp.h>
9
10static inline void fill_ldt(struct desc_struct *desc,
11 const struct user_desc *info)
12{
13 desc->limit0 = info->limit & 0x0ffff;
14 desc->base0 = info->base_addr & 0x0000ffff;
15
16 desc->base1 = (info->base_addr & 0x00ff0000) >> 16;
17 desc->type = (info->read_exec_only ^ 1) << 1;
18 desc->type |= info->contents << 2;
19 desc->s = 1;
20 desc->dpl = 0x3;
21 desc->p = info->seg_not_present ^ 1;
22 desc->limit = (info->limit & 0xf0000) >> 16;
23 desc->avl = info->useable;
24 desc->d = info->seg_32bit;
25 desc->g = info->limit_in_pages;
26 desc->base2 = (info->base_addr & 0xff000000) >> 24;
27}
28
29extern struct desc_ptr idt_descr;
30extern gate_desc idt_table[];
31
32#ifdef CONFIG_X86_64
33extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
34extern struct desc_ptr cpu_gdt_descr[];
35/* the cpu gdt accessor */
36#define get_cpu_gdt_table(x) ((struct desc_struct *)cpu_gdt_descr[x].address)
37
38static inline void pack_gate(gate_desc *gate, unsigned type, unsigned long func,
39 unsigned dpl, unsigned ist, unsigned seg)
40{
41 gate->offset_low = PTR_LOW(func);
42 gate->segment = __KERNEL_CS;
43 gate->ist = ist;
44 gate->p = 1;
45 gate->dpl = dpl;
46 gate->zero0 = 0;
47 gate->zero1 = 0;
48 gate->type = type;
49 gate->offset_middle = PTR_MIDDLE(func);
50 gate->offset_high = PTR_HIGH(func);
51}
52
53#else
54struct gdt_page {
55 struct desc_struct gdt[GDT_ENTRIES];
56} __attribute__((aligned(PAGE_SIZE)));
57DECLARE_PER_CPU(struct gdt_page, gdt_page);
58
59static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
60{
61 return per_cpu(gdt_page, cpu).gdt;
62}
63
64static inline void pack_gate(gate_desc *gate, unsigned char type,
65 unsigned long base, unsigned dpl, unsigned flags, unsigned short seg)
66
67{
68 gate->a = (seg << 16) | (base & 0xffff);
69 gate->b = (base & 0xffff0000) |
70 (((0x80 | type | (dpl << 5)) & 0xff) << 8);
71}
72
73#endif
74
75static inline int desc_empty(const void *ptr)
76{
77 const u32 *desc = ptr;
78 return !(desc[0] | desc[1]);
79}
80
81#ifdef CONFIG_PARAVIRT
82#include <asm/paravirt.h>
83#else
84#define load_TR_desc() native_load_tr_desc()
85#define load_gdt(dtr) native_load_gdt(dtr)
86#define load_idt(dtr) native_load_idt(dtr)
87#define load_tr(tr) __asm__ __volatile("ltr %0"::"m" (tr))
88#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"m" (ldt))
89
90#define store_gdt(dtr) native_store_gdt(dtr)
91#define store_idt(dtr) native_store_idt(dtr)
92#define store_tr(tr) (tr = native_store_tr())
93#define store_ldt(ldt) __asm__ ("sldt %0":"=m" (ldt))
94
95#define load_TLS(t, cpu) native_load_tls(t, cpu)
96#define set_ldt native_set_ldt
97
98#define write_ldt_entry(dt, entry, desc) \
99 native_write_ldt_entry(dt, entry, desc)
100#define write_gdt_entry(dt, entry, desc, type) \
101 native_write_gdt_entry(dt, entry, desc, type)
102#define write_idt_entry(dt, entry, g) native_write_idt_entry(dt, entry, g)
103#endif
104
105static inline void native_write_idt_entry(gate_desc *idt, int entry,
106 const gate_desc *gate)
107{
108 memcpy(&idt[entry], gate, sizeof(*gate));
109}
110
111static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry,
112 const void *desc)
113{
114 memcpy(&ldt[entry], desc, 8);
115}
116
117static inline void native_write_gdt_entry(struct desc_struct *gdt, int entry,
118 const void *desc, int type)
119{
120 unsigned int size;
121 switch (type) {
122 case DESC_TSS:
123 size = sizeof(tss_desc);
124 break;
125 case DESC_LDT:
126 size = sizeof(ldt_desc);
127 break;
128 default:
129 size = sizeof(struct desc_struct);
130 break;
131 }
132 memcpy(&gdt[entry], desc, size);
133}
134
135static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
136 unsigned long limit, unsigned char type,
137 unsigned char flags)
138{
139 desc->a = ((base & 0xffff) << 16) | (limit & 0xffff);
140 desc->b = (base & 0xff000000) | ((base & 0xff0000) >> 16) |
141 (limit & 0x000f0000) | ((type & 0xff) << 8) |
142 ((flags & 0xf) << 20);
143 desc->p = 1;
144}
145
146
147static inline void set_tssldt_descriptor(void *d, unsigned long addr,
148 unsigned type, unsigned size)
149{
150#ifdef CONFIG_X86_64
151 struct ldttss_desc64 *desc = d;
152 memset(desc, 0, sizeof(*desc));
153 desc->limit0 = size & 0xFFFF;
154 desc->base0 = PTR_LOW(addr);
155 desc->base1 = PTR_MIDDLE(addr) & 0xFF;
156 desc->type = type;
157 desc->p = 1;
158 desc->limit1 = (size >> 16) & 0xF;
159 desc->base2 = (PTR_MIDDLE(addr) >> 8) & 0xFF;
160 desc->base3 = PTR_HIGH(addr);
161#else
162
163 pack_descriptor((struct desc_struct *)d, addr, size, 0x80 | type, 0);
164#endif
165}
166
167static inline void __set_tss_desc(unsigned cpu, unsigned int entry, void *addr)
168{
169 struct desc_struct *d = get_cpu_gdt_table(cpu);
170 tss_desc tss;
171
172 /*
173 * sizeof(unsigned long) coming from an extra "long" at the end
174 * of the iobitmap. See tss_struct definition in processor.h
175 *
176 * -1? seg base+limit should be pointing to the address of the
177 * last valid byte
178 */
179 set_tssldt_descriptor(&tss, (unsigned long)addr, DESC_TSS,
180 IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
181 write_gdt_entry(d, entry, &tss, DESC_TSS);
182}
183
184#define set_tss_desc(cpu, addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
185
186static inline void native_set_ldt(const void *addr, unsigned int entries)
187{
188 if (likely(entries == 0))
189 __asm__ __volatile__("lldt %w0"::"q" (0));
190 else {
191 unsigned cpu = smp_processor_id();
192 ldt_desc ldt;
193
194 set_tssldt_descriptor(&ldt, (unsigned long)addr,
195 DESC_LDT, entries * sizeof(ldt) - 1);
196 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT,
197 &ldt, DESC_LDT);
198 __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
199 }
200}
201
202static inline void native_load_tr_desc(void)
203{
204 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
205}
206
207static inline void native_load_gdt(const struct desc_ptr *dtr)
208{
209 asm volatile("lgdt %0"::"m" (*dtr));
210}
211
212static inline void native_load_idt(const struct desc_ptr *dtr)
213{
214 asm volatile("lidt %0"::"m" (*dtr));
215}
216
217static inline void native_store_gdt(struct desc_ptr *dtr)
218{
219 asm volatile("sgdt %0":"=m" (*dtr));
220}
221
222static inline void native_store_idt(struct desc_ptr *dtr)
223{
224 asm volatile("sidt %0":"=m" (*dtr));
225}
226
227static inline unsigned long native_store_tr(void)
228{
229 unsigned long tr;
230 asm volatile("str %0":"=r" (tr));
231 return tr;
232}
233
234static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
235{
236 unsigned int i;
237 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
238
239 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
240 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
241}
242
243#define _LDT_empty(info) (\
244 (info)->base_addr == 0 && \
245 (info)->limit == 0 && \
246 (info)->contents == 0 && \
247 (info)->read_exec_only == 1 && \
248 (info)->seg_32bit == 0 && \
249 (info)->limit_in_pages == 0 && \
250 (info)->seg_not_present == 1 && \
251 (info)->useable == 0)
252
253#ifdef CONFIG_X86_64
254#define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0))
255#else
256#define LDT_empty(info) (_LDT_empty(info))
257#endif
258
259static inline void clear_LDT(void)
260{
261 set_ldt(NULL, 0);
262}
263
264/*
265 * load one particular LDT into the current CPU
266 */
267static inline void load_LDT_nolock(mm_context_t *pc)
268{
269 set_ldt(pc->ldt, pc->size);
270}
271
272static inline void load_LDT(mm_context_t *pc)
273{
274 preempt_disable();
275 load_LDT_nolock(pc);
276 preempt_enable();
277}
278
279static inline unsigned long get_desc_base(const struct desc_struct *desc)
280{
281 return desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24);
282}
283
284static inline unsigned long get_desc_limit(const struct desc_struct *desc)
285{
286 return desc->limit0 | (desc->limit << 16);
287}
288
289static inline void _set_gate(int gate, unsigned type, void *addr,
290 unsigned dpl, unsigned ist, unsigned seg)
291{
292 gate_desc s;
293 pack_gate(&s, type, (unsigned long)addr, dpl, ist, seg);
294 /*
295 * does not need to be atomic because it is only done once at
296 * setup time
297 */
298 write_idt_entry(idt_table, gate, &s);
299}
300
301/*
302 * This needs to use 'idt_table' rather than 'idt', and
303 * thus use the _nonmapped_ version of the IDT, as the
304 * Pentium F0 0F bugfix can have resulted in the mapped
305 * IDT being write-protected.
306 */
307static inline void set_intr_gate(unsigned int n, void *addr)
308{
309 BUG_ON((unsigned)n > 0xFF);
310 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
311}
312
313/*
314 * This routine sets up an interrupt gate at directory privilege level 3.
315 */
316static inline void set_system_intr_gate(unsigned int n, void *addr)
317{
318 BUG_ON((unsigned)n > 0xFF);
319 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
320}
321
322static inline void set_trap_gate(unsigned int n, void *addr)
323{
324 BUG_ON((unsigned)n > 0xFF);
325 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
326}
327
328static inline void set_system_gate(unsigned int n, void *addr)
329{
330 BUG_ON((unsigned)n > 0xFF);
1#ifdef CONFIG_X86_32 331#ifdef CONFIG_X86_32
2# include "desc_32.h" 332 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
333#else
334 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
335#endif
336}
337
338static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
339{
340 BUG_ON((unsigned)n > 0xFF);
341 _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
342}
343
344static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
345{
346 BUG_ON((unsigned)n > 0xFF);
347 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
348}
349
350static inline void set_system_gate_ist(int n, void *addr, unsigned ist)
351{
352 BUG_ON((unsigned)n > 0xFF);
353 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
354}
355
3#else 356#else
4# include "desc_64.h" 357/*
358 * GET_DESC_BASE reads the descriptor base of the specified segment.
359 *
360 * Args:
361 * idx - descriptor index
362 * gdt - GDT pointer
363 * base - 32bit register to which the base will be written
364 * lo_w - lo word of the "base" register
365 * lo_b - lo byte of the "base" register
366 * hi_b - hi byte of the low word of the "base" register
367 *
368 * Example:
369 * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
370 * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
371 */
372#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
373 movb idx*8+4(gdt), lo_b; \
374 movb idx*8+7(gdt), hi_b; \
375 shll $16, base; \
376 movw idx*8+2(gdt), lo_w;
377
378
379#endif /* __ASSEMBLY__ */
380
5#endif 381#endif
diff --git a/include/asm-x86/desc_32.h b/include/asm-x86/desc_32.h
deleted file mode 100644
index c547403f341d..000000000000
--- a/include/asm-x86/desc_32.h
+++ /dev/null
@@ -1,244 +0,0 @@
1#ifndef __ARCH_DESC_H
2#define __ARCH_DESC_H
3
4#include <asm/ldt.h>
5#include <asm/segment.h>
6
7#ifndef __ASSEMBLY__
8
9#include <linux/preempt.h>
10#include <linux/smp.h>
11#include <linux/percpu.h>
12
13#include <asm/mmu.h>
14
15struct Xgt_desc_struct {
16 unsigned short size;
17 unsigned long address __attribute__((packed));
18 unsigned short pad;
19} __attribute__ ((packed));
20
21struct gdt_page
22{
23 struct desc_struct gdt[GDT_ENTRIES];
24} __attribute__((aligned(PAGE_SIZE)));
25DECLARE_PER_CPU(struct gdt_page, gdt_page);
26
27static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
28{
29 return per_cpu(gdt_page, cpu).gdt;
30}
31
32extern struct Xgt_desc_struct idt_descr;
33extern struct desc_struct idt_table[];
34extern void set_intr_gate(unsigned int irq, void * addr);
35
36static inline void pack_descriptor(__u32 *a, __u32 *b,
37 unsigned long base, unsigned long limit, unsigned char type, unsigned char flags)
38{
39 *a = ((base & 0xffff) << 16) | (limit & 0xffff);
40 *b = (base & 0xff000000) | ((base & 0xff0000) >> 16) |
41 (limit & 0x000f0000) | ((type & 0xff) << 8) | ((flags & 0xf) << 20);
42}
43
44static inline void pack_gate(__u32 *a, __u32 *b,
45 unsigned long base, unsigned short seg, unsigned char type, unsigned char flags)
46{
47 *a = (seg << 16) | (base & 0xffff);
48 *b = (base & 0xffff0000) | ((type & 0xff) << 8) | (flags & 0xff);
49}
50
51#define DESCTYPE_LDT 0x82 /* present, system, DPL-0, LDT */
52#define DESCTYPE_TSS 0x89 /* present, system, DPL-0, 32-bit TSS */
53#define DESCTYPE_TASK 0x85 /* present, system, DPL-0, task gate */
54#define DESCTYPE_INT 0x8e /* present, system, DPL-0, interrupt gate */
55#define DESCTYPE_TRAP 0x8f /* present, system, DPL-0, trap gate */
56#define DESCTYPE_DPL3 0x60 /* DPL-3 */
57#define DESCTYPE_S 0x10 /* !system */
58
59#ifdef CONFIG_PARAVIRT
60#include <asm/paravirt.h>
61#else
62#define load_TR_desc() native_load_tr_desc()
63#define load_gdt(dtr) native_load_gdt(dtr)
64#define load_idt(dtr) native_load_idt(dtr)
65#define load_tr(tr) __asm__ __volatile("ltr %0"::"m" (tr))
66#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"m" (ldt))
67
68#define store_gdt(dtr) native_store_gdt(dtr)
69#define store_idt(dtr) native_store_idt(dtr)
70#define store_tr(tr) (tr = native_store_tr())
71#define store_ldt(ldt) __asm__ ("sldt %0":"=m" (ldt))
72
73#define load_TLS(t, cpu) native_load_tls(t, cpu)
74#define set_ldt native_set_ldt
75
76#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
77#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
78#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
79#endif
80
81static inline void write_dt_entry(struct desc_struct *dt,
82 int entry, u32 entry_low, u32 entry_high)
83{
84 dt[entry].a = entry_low;
85 dt[entry].b = entry_high;
86}
87
88static inline void native_set_ldt(const void *addr, unsigned int entries)
89{
90 if (likely(entries == 0))
91 __asm__ __volatile__("lldt %w0"::"q" (0));
92 else {
93 unsigned cpu = smp_processor_id();
94 __u32 a, b;
95
96 pack_descriptor(&a, &b, (unsigned long)addr,
97 entries * sizeof(struct desc_struct) - 1,
98 DESCTYPE_LDT, 0);
99 write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
100 __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
101 }
102}
103
104
105static inline void native_load_tr_desc(void)
106{
107 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
108}
109
110static inline void native_load_gdt(const struct Xgt_desc_struct *dtr)
111{
112 asm volatile("lgdt %0"::"m" (*dtr));
113}
114
115static inline void native_load_idt(const struct Xgt_desc_struct *dtr)
116{
117 asm volatile("lidt %0"::"m" (*dtr));
118}
119
120static inline void native_store_gdt(struct Xgt_desc_struct *dtr)
121{
122 asm ("sgdt %0":"=m" (*dtr));
123}
124
125static inline void native_store_idt(struct Xgt_desc_struct *dtr)
126{
127 asm ("sidt %0":"=m" (*dtr));
128}
129
130static inline unsigned long native_store_tr(void)
131{
132 unsigned long tr;
133 asm ("str %0":"=r" (tr));
134 return tr;
135}
136
137static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
138{
139 unsigned int i;
140 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
141
142 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
143 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
144}
145
146static inline void _set_gate(int gate, unsigned int type, void *addr, unsigned short seg)
147{
148 __u32 a, b;
149 pack_gate(&a, &b, (unsigned long)addr, seg, type, 0);
150 write_idt_entry(idt_table, gate, a, b);
151}
152
153static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const void *addr)
154{
155 __u32 a, b;
156 pack_descriptor(&a, &b, (unsigned long)addr,
157 offsetof(struct tss_struct, __cacheline_filler) - 1,
158 DESCTYPE_TSS, 0);
159 write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
160}
161
162
163#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
164
165#define LDT_entry_a(info) \
166 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
167
168#define LDT_entry_b(info) \
169 (((info)->base_addr & 0xff000000) | \
170 (((info)->base_addr & 0x00ff0000) >> 16) | \
171 ((info)->limit & 0xf0000) | \
172 (((info)->read_exec_only ^ 1) << 9) | \
173 ((info)->contents << 10) | \
174 (((info)->seg_not_present ^ 1) << 15) | \
175 ((info)->seg_32bit << 22) | \
176 ((info)->limit_in_pages << 23) | \
177 ((info)->useable << 20) | \
178 0x7000)
179
180#define LDT_empty(info) (\
181 (info)->base_addr == 0 && \
182 (info)->limit == 0 && \
183 (info)->contents == 0 && \
184 (info)->read_exec_only == 1 && \
185 (info)->seg_32bit == 0 && \
186 (info)->limit_in_pages == 0 && \
187 (info)->seg_not_present == 1 && \
188 (info)->useable == 0 )
189
190static inline void clear_LDT(void)
191{
192 set_ldt(NULL, 0);
193}
194
195/*
196 * load one particular LDT into the current CPU
197 */
198static inline void load_LDT_nolock(mm_context_t *pc)
199{
200 set_ldt(pc->ldt, pc->size);
201}
202
203static inline void load_LDT(mm_context_t *pc)
204{
205 preempt_disable();
206 load_LDT_nolock(pc);
207 preempt_enable();
208}
209
210static inline unsigned long get_desc_base(unsigned long *desc)
211{
212 unsigned long base;
213 base = ((desc[0] >> 16) & 0x0000ffff) |
214 ((desc[1] << 16) & 0x00ff0000) |
215 (desc[1] & 0xff000000);
216 return base;
217}
218
219#else /* __ASSEMBLY__ */
220
221/*
222 * GET_DESC_BASE reads the descriptor base of the specified segment.
223 *
224 * Args:
225 * idx - descriptor index
226 * gdt - GDT pointer
227 * base - 32bit register to which the base will be written
228 * lo_w - lo word of the "base" register
229 * lo_b - lo byte of the "base" register
230 * hi_b - hi byte of the low word of the "base" register
231 *
232 * Example:
233 * GET_DESC_BASE(GDT_ENTRY_ESPFIX_SS, %ebx, %eax, %ax, %al, %ah)
234 * Will read the base address of GDT_ENTRY_ESPFIX_SS and put it into %eax.
235 */
236#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) \
237 movb idx*8+4(gdt), lo_b; \
238 movb idx*8+7(gdt), hi_b; \
239 shll $16, base; \
240 movw idx*8+2(gdt), lo_w;
241
242#endif /* !__ASSEMBLY__ */
243
244#endif
diff --git a/include/asm-x86/desc_64.h b/include/asm-x86/desc_64.h
index 7d9c938e69fd..8b137891791f 100644
--- a/include/asm-x86/desc_64.h
+++ b/include/asm-x86/desc_64.h
@@ -1,204 +1 @@
1/* Written 2000 by Andi Kleen */
2#ifndef __ARCH_DESC_H
3#define __ARCH_DESC_H
4
5#include <linux/threads.h>
6#include <asm/ldt.h>
7
8#ifndef __ASSEMBLY__
9
10#include <linux/string.h>
11#include <linux/smp.h>
12#include <asm/desc_defs.h>
13
14#include <asm/segment.h>
15#include <asm/mmu.h>
16
17extern struct desc_struct cpu_gdt_table[GDT_ENTRIES];
18
19#define load_TR_desc() asm volatile("ltr %w0"::"r" (GDT_ENTRY_TSS*8))
20#define load_LDT_desc() asm volatile("lldt %w0"::"r" (GDT_ENTRY_LDT*8))
21#define clear_LDT() asm volatile("lldt %w0"::"r" (0))
22
23static inline unsigned long __store_tr(void)
24{
25 unsigned long tr;
26
27 asm volatile ("str %w0":"=r" (tr));
28 return tr;
29}
30
31#define store_tr(tr) (tr) = __store_tr()
32
33/*
34 * This is the ldt that every process will get unless we need
35 * something other than this.
36 */
37extern struct desc_struct default_ldt[];
38extern struct gate_struct idt_table[];
39extern struct desc_ptr cpu_gdt_descr[];
40
41/* the cpu gdt accessor */
42#define cpu_gdt(_cpu) ((struct desc_struct *)cpu_gdt_descr[_cpu].address)
43
44static inline void load_gdt(const struct desc_ptr *ptr)
45{
46 asm volatile("lgdt %w0"::"m" (*ptr));
47}
48
49static inline void store_gdt(struct desc_ptr *ptr)
50{
51 asm("sgdt %w0":"=m" (*ptr));
52}
53
54static inline void _set_gate(void *adr, unsigned type, unsigned long func, unsigned dpl, unsigned ist)
55{
56 struct gate_struct s;
57 s.offset_low = PTR_LOW(func);
58 s.segment = __KERNEL_CS;
59 s.ist = ist;
60 s.p = 1;
61 s.dpl = dpl;
62 s.zero0 = 0;
63 s.zero1 = 0;
64 s.type = type;
65 s.offset_middle = PTR_MIDDLE(func);
66 s.offset_high = PTR_HIGH(func);
67 /* does not need to be atomic because it is only done once at setup time */
68 memcpy(adr, &s, 16);
69}
70
71static inline void set_intr_gate(int nr, void *func)
72{
73 BUG_ON((unsigned)nr > 0xFF);
74 _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 0, 0);
75}
76
77static inline void set_intr_gate_ist(int nr, void *func, unsigned ist)
78{
79 BUG_ON((unsigned)nr > 0xFF);
80 _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 0, ist);
81}
82
83static inline void set_system_gate(int nr, void *func)
84{
85 BUG_ON((unsigned)nr > 0xFF);
86 _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, 0);
87}
88
89static inline void set_system_gate_ist(int nr, void *func, unsigned ist)
90{
91 _set_gate(&idt_table[nr], GATE_INTERRUPT, (unsigned long) func, 3, ist);
92}
93
94static inline void load_idt(const struct desc_ptr *ptr)
95{
96 asm volatile("lidt %w0"::"m" (*ptr));
97}
98
99static inline void store_idt(struct desc_ptr *dtr)
100{
101 asm("sidt %w0":"=m" (*dtr));
102}
103
104static inline void set_tssldt_descriptor(void *ptr, unsigned long tss, unsigned type,
105 unsigned size)
106{
107 struct ldttss_desc d;
108 memset(&d,0,sizeof(d));
109 d.limit0 = size & 0xFFFF;
110 d.base0 = PTR_LOW(tss);
111 d.base1 = PTR_MIDDLE(tss) & 0xFF;
112 d.type = type;
113 d.p = 1;
114 d.limit1 = (size >> 16) & 0xF;
115 d.base2 = (PTR_MIDDLE(tss) >> 8) & 0xFF;
116 d.base3 = PTR_HIGH(tss);
117 memcpy(ptr, &d, 16);
118}
119
120static inline void set_tss_desc(unsigned cpu, void *addr)
121{
122 /*
123 * sizeof(unsigned long) coming from an extra "long" at the end
124 * of the iobitmap. See tss_struct definition in processor.h
125 *
126 * -1? seg base+limit should be pointing to the address of the
127 * last valid byte
128 */
129 set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_TSS],
130 (unsigned long)addr, DESC_TSS,
131 IO_BITMAP_OFFSET + IO_BITMAP_BYTES + sizeof(unsigned long) - 1);
132}
133
134static inline void set_ldt_desc(unsigned cpu, void *addr, int size)
135{
136 set_tssldt_descriptor(&cpu_gdt(cpu)[GDT_ENTRY_LDT], (unsigned long)addr,
137 DESC_LDT, size * 8 - 1);
138}
139
140#define LDT_entry_a(info) \
141 ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
142/* Don't allow setting of the lm bit. It is useless anyways because
143 64bit system calls require __USER_CS. */
144#define LDT_entry_b(info) \
145 (((info)->base_addr & 0xff000000) | \
146 (((info)->base_addr & 0x00ff0000) >> 16) | \
147 ((info)->limit & 0xf0000) | \
148 (((info)->read_exec_only ^ 1) << 9) | \
149 ((info)->contents << 10) | \
150 (((info)->seg_not_present ^ 1) << 15) | \
151 ((info)->seg_32bit << 22) | \
152 ((info)->limit_in_pages << 23) | \
153 ((info)->useable << 20) | \
154 /* ((info)->lm << 21) | */ \
155 0x7000)
156
157#define LDT_empty(info) (\
158 (info)->base_addr == 0 && \
159 (info)->limit == 0 && \
160 (info)->contents == 0 && \
161 (info)->read_exec_only == 1 && \
162 (info)->seg_32bit == 0 && \
163 (info)->limit_in_pages == 0 && \
164 (info)->seg_not_present == 1 && \
165 (info)->useable == 0 && \
166 (info)->lm == 0)
167
168static inline void load_TLS(struct thread_struct *t, unsigned int cpu)
169{
170 unsigned int i;
171 u64 *gdt = (u64 *)(cpu_gdt(cpu) + GDT_ENTRY_TLS_MIN);
172
173 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
174 gdt[i] = t->tls_array[i];
175}
176
177/*
178 * load one particular LDT into the current CPU
179 */
180static inline void load_LDT_nolock (mm_context_t *pc, int cpu)
181{
182 int count = pc->size;
183
184 if (likely(!count)) {
185 clear_LDT();
186 return;
187 }
188
189 set_ldt_desc(cpu, pc->ldt, count);
190 load_LDT_desc();
191}
192
193static inline void load_LDT(mm_context_t *pc)
194{
195 int cpu = get_cpu();
196 load_LDT_nolock(pc, cpu);
197 put_cpu();
198}
199
200extern struct desc_ptr idt_descr;
201
202#endif /* !__ASSEMBLY__ */
203
204#endif
diff --git a/include/asm-x86/desc_defs.h b/include/asm-x86/desc_defs.h
index 089004070099..e33f078b3e54 100644
--- a/include/asm-x86/desc_defs.h
+++ b/include/asm-x86/desc_defs.h
@@ -11,26 +11,36 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14/*
15 * FIXME: Acessing the desc_struct through its fields is more elegant,
16 * and should be the one valid thing to do. However, a lot of open code
17 * still touches the a and b acessors, and doing this allow us to do it
18 * incrementally. We keep the signature as a struct, rather than an union,
19 * so we can get rid of it transparently in the future -- glommer
20 */
14// 8 byte segment descriptor 21// 8 byte segment descriptor
15struct desc_struct { 22struct desc_struct {
16 u16 limit0; 23 union {
17 u16 base0; 24 struct { unsigned int a, b; };
18 unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1; 25 struct {
19 unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8; 26 u16 limit0;
20} __attribute__((packed)); 27 u16 base0;
28 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
29 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
30 };
21 31
22struct n_desc_struct { 32 };
23 unsigned int a,b; 33} __attribute__((packed));
24};
25 34
26enum { 35enum {
27 GATE_INTERRUPT = 0xE, 36 GATE_INTERRUPT = 0xE,
28 GATE_TRAP = 0xF, 37 GATE_TRAP = 0xF,
29 GATE_CALL = 0xC, 38 GATE_CALL = 0xC,
39 GATE_TASK = 0x5,
30}; 40};
31 41
32// 16byte gate 42// 16byte gate
33struct gate_struct { 43struct gate_struct64 {
34 u16 offset_low; 44 u16 offset_low;
35 u16 segment; 45 u16 segment;
36 unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1; 46 unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
@@ -39,17 +49,18 @@ struct gate_struct {
39 u32 zero1; 49 u32 zero1;
40} __attribute__((packed)); 50} __attribute__((packed));
41 51
42#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF) 52#define PTR_LOW(x) ((unsigned long long)(x) & 0xFFFF)
43#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF) 53#define PTR_MIDDLE(x) (((unsigned long long)(x) >> 16) & 0xFFFF)
44#define PTR_HIGH(x) ((unsigned long)(x) >> 32) 54#define PTR_HIGH(x) ((unsigned long long)(x) >> 32)
45 55
46enum { 56enum {
47 DESC_TSS = 0x9, 57 DESC_TSS = 0x9,
48 DESC_LDT = 0x2, 58 DESC_LDT = 0x2,
59 DESCTYPE_S = 0x10, /* !system */
49}; 60};
50 61
51// LDT or TSS descriptor in the GDT. 16 bytes. 62// LDT or TSS descriptor in the GDT. 16 bytes.
52struct ldttss_desc { 63struct ldttss_desc64 {
53 u16 limit0; 64 u16 limit0;
54 u16 base0; 65 u16 base0;
55 unsigned base1 : 8, type : 5, dpl : 2, p : 1; 66 unsigned base1 : 8, type : 5, dpl : 2, p : 1;
@@ -58,6 +69,16 @@ struct ldttss_desc {
58 u32 zero1; 69 u32 zero1;
59} __attribute__((packed)); 70} __attribute__((packed));
60 71
72#ifdef CONFIG_X86_64
73typedef struct gate_struct64 gate_desc;
74typedef struct ldttss_desc64 ldt_desc;
75typedef struct ldttss_desc64 tss_desc;
76#else
77typedef struct desc_struct gate_desc;
78typedef struct desc_struct ldt_desc;
79typedef struct desc_struct tss_desc;
80#endif
81
61struct desc_ptr { 82struct desc_ptr {
62 unsigned short size; 83 unsigned short size;
63 unsigned long address; 84 unsigned long address;
diff --git a/include/asm-x86/dma.h b/include/asm-x86/dma.h
index 9f936c61a4e5..e9733ce89880 100644
--- a/include/asm-x86/dma.h
+++ b/include/asm-x86/dma.h
@@ -1,5 +1,319 @@
1/*
2 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
3 * Written by Hennus Bergman, 1992.
4 * High DMA channel support & info by Hannu Savolainen
5 * and John Boyd, Nov. 1992.
6 */
7
8#ifndef _ASM_X86_DMA_H
9#define _ASM_X86_DMA_H
10
11#include <linux/spinlock.h> /* And spinlocks */
12#include <asm/io.h> /* need byte IO */
13#include <linux/delay.h>
14
15
16#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
17#define dma_outb outb_p
18#else
19#define dma_outb outb
20#endif
21
22#define dma_inb inb
23
24/*
25 * NOTES about DMA transfers:
26 *
27 * controller 1: channels 0-3, byte operations, ports 00-1F
28 * controller 2: channels 4-7, word operations, ports C0-DF
29 *
30 * - ALL registers are 8 bits only, regardless of transfer size
31 * - channel 4 is not used - cascades 1 into 2.
32 * - channels 0-3 are byte - addresses/counts are for physical bytes
33 * - channels 5-7 are word - addresses/counts are for physical words
34 * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
35 * - transfer count loaded to registers is 1 less than actual count
36 * - controller 2 offsets are all even (2x offsets for controller 1)
37 * - page registers for 5-7 don't use data bit 0, represent 128K pages
38 * - page registers for 0-3 use bit 0, represent 64K pages
39 *
40 * DMA transfers are limited to the lower 16MB of _physical_ memory.
41 * Note that addresses loaded into registers must be _physical_ addresses,
42 * not logical addresses (which may differ if paging is active).
43 *
44 * Address mapping for channels 0-3:
45 *
46 * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
47 * | ... | | ... | | ... |
48 * | ... | | ... | | ... |
49 * | ... | | ... | | ... |
50 * P7 ... P0 A7 ... A0 A7 ... A0
51 * | Page | Addr MSB | Addr LSB | (DMA registers)
52 *
53 * Address mapping for channels 5-7:
54 *
55 * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
56 * | ... | \ \ ... \ \ \ ... \ \
57 * | ... | \ \ ... \ \ \ ... \ (not used)
58 * | ... | \ \ ... \ \ \ ... \
59 * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
60 * | Page | Addr MSB | Addr LSB | (DMA registers)
61 *
62 * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
63 * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
64 * the hardware level, so odd-byte transfers aren't possible).
65 *
66 * Transfer count (_not # bytes_) is limited to 64K, represented as actual
67 * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
68 * and up to 128K bytes may be transferred on channels 5-7 in one operation.
69 *
70 */
71
72#define MAX_DMA_CHANNELS 8
73
1#ifdef CONFIG_X86_32 74#ifdef CONFIG_X86_32
2# include "dma_32.h" 75
76/* The maximum address that we can perform a DMA transfer to on this platform */
77#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000)
78
79#else
80
81/* 16MB ISA DMA zone */
82#define MAX_DMA_PFN ((16*1024*1024) >> PAGE_SHIFT)
83
84/* 4GB broken PCI/AGP hardware bus master zone */
85#define MAX_DMA32_PFN ((4UL*1024*1024*1024) >> PAGE_SHIFT)
86
87/* Compat define for old dma zone */
88#define MAX_DMA_ADDRESS ((unsigned long)__va(MAX_DMA_PFN << PAGE_SHIFT))
89
90#endif
91
92/* 8237 DMA controllers */
93#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
94#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
95
96/* DMA controller registers */
97#define DMA1_CMD_REG 0x08 /* command register (w) */
98#define DMA1_STAT_REG 0x08 /* status register (r) */
99#define DMA1_REQ_REG 0x09 /* request register (w) */
100#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
101#define DMA1_MODE_REG 0x0B /* mode register (w) */
102#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
103#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
104#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
105#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
106#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
107
108#define DMA2_CMD_REG 0xD0 /* command register (w) */
109#define DMA2_STAT_REG 0xD0 /* status register (r) */
110#define DMA2_REQ_REG 0xD2 /* request register (w) */
111#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
112#define DMA2_MODE_REG 0xD6 /* mode register (w) */
113#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
114#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
115#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
116#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
117#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
118
119#define DMA_ADDR_0 0x00 /* DMA address registers */
120#define DMA_ADDR_1 0x02
121#define DMA_ADDR_2 0x04
122#define DMA_ADDR_3 0x06
123#define DMA_ADDR_4 0xC0
124#define DMA_ADDR_5 0xC4
125#define DMA_ADDR_6 0xC8
126#define DMA_ADDR_7 0xCC
127
128#define DMA_CNT_0 0x01 /* DMA count registers */
129#define DMA_CNT_1 0x03
130#define DMA_CNT_2 0x05
131#define DMA_CNT_3 0x07
132#define DMA_CNT_4 0xC2
133#define DMA_CNT_5 0xC6
134#define DMA_CNT_6 0xCA
135#define DMA_CNT_7 0xCE
136
137#define DMA_PAGE_0 0x87 /* DMA page registers */
138#define DMA_PAGE_1 0x83
139#define DMA_PAGE_2 0x81
140#define DMA_PAGE_3 0x82
141#define DMA_PAGE_5 0x8B
142#define DMA_PAGE_6 0x89
143#define DMA_PAGE_7 0x8A
144
145/* I/O to memory, no autoinit, increment, single mode */
146#define DMA_MODE_READ 0x44
147/* memory to I/O, no autoinit, increment, single mode */
148#define DMA_MODE_WRITE 0x48
149/* pass thru DREQ->HRQ, DACK<-HLDA only */
150#define DMA_MODE_CASCADE 0xC0
151
152#define DMA_AUTOINIT 0x10
153
154
155extern spinlock_t dma_spin_lock;
156
157static __inline__ unsigned long claim_dma_lock(void)
158{
159 unsigned long flags;
160 spin_lock_irqsave(&dma_spin_lock, flags);
161 return flags;
162}
163
164static __inline__ void release_dma_lock(unsigned long flags)
165{
166 spin_unlock_irqrestore(&dma_spin_lock, flags);
167}
168
169/* enable/disable a specific DMA channel */
170static __inline__ void enable_dma(unsigned int dmanr)
171{
172 if (dmanr <= 3)
173 dma_outb(dmanr, DMA1_MASK_REG);
174 else
175 dma_outb(dmanr & 3, DMA2_MASK_REG);
176}
177
178static __inline__ void disable_dma(unsigned int dmanr)
179{
180 if (dmanr <= 3)
181 dma_outb(dmanr | 4, DMA1_MASK_REG);
182 else
183 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
184}
185
186/* Clear the 'DMA Pointer Flip Flop'.
187 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
188 * Use this once to initialize the FF to a known state.
189 * After that, keep track of it. :-)
190 * --- In order to do that, the DMA routines below should ---
191 * --- only be used while holding the DMA lock ! ---
192 */
193static __inline__ void clear_dma_ff(unsigned int dmanr)
194{
195 if (dmanr <= 3)
196 dma_outb(0, DMA1_CLEAR_FF_REG);
197 else
198 dma_outb(0, DMA2_CLEAR_FF_REG);
199}
200
201/* set mode (above) for a specific DMA channel */
202static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
203{
204 if (dmanr <= 3)
205 dma_outb(mode | dmanr, DMA1_MODE_REG);
206 else
207 dma_outb(mode | (dmanr & 3), DMA2_MODE_REG);
208}
209
210/* Set only the page register bits of the transfer address.
211 * This is used for successive transfers when we know the contents of
212 * the lower 16 bits of the DMA current address register, but a 64k boundary
213 * may have been crossed.
214 */
215static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
216{
217 switch (dmanr) {
218 case 0:
219 dma_outb(pagenr, DMA_PAGE_0);
220 break;
221 case 1:
222 dma_outb(pagenr, DMA_PAGE_1);
223 break;
224 case 2:
225 dma_outb(pagenr, DMA_PAGE_2);
226 break;
227 case 3:
228 dma_outb(pagenr, DMA_PAGE_3);
229 break;
230 case 5:
231 dma_outb(pagenr & 0xfe, DMA_PAGE_5);
232 break;
233 case 6:
234 dma_outb(pagenr & 0xfe, DMA_PAGE_6);
235 break;
236 case 7:
237 dma_outb(pagenr & 0xfe, DMA_PAGE_7);
238 break;
239 }
240}
241
242
243/* Set transfer address & page bits for specific DMA channel.
244 * Assumes dma flipflop is clear.
245 */
246static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
247{
248 set_dma_page(dmanr, a>>16);
249 if (dmanr <= 3) {
250 dma_outb(a & 0xff, ((dmanr & 3) << 1) + IO_DMA1_BASE);
251 dma_outb((a >> 8) & 0xff, ((dmanr & 3) << 1) + IO_DMA1_BASE);
252 } else {
253 dma_outb((a >> 1) & 0xff, ((dmanr & 3) << 2) + IO_DMA2_BASE);
254 dma_outb((a >> 9) & 0xff, ((dmanr & 3) << 2) + IO_DMA2_BASE);
255 }
256}
257
258
259/* Set transfer size (max 64k for DMA0..3, 128k for DMA5..7) for
260 * a specific DMA channel.
261 * You must ensure the parameters are valid.
262 * NOTE: from a manual: "the number of transfers is one more
263 * than the initial word count"! This is taken into account.
264 * Assumes dma flip-flop is clear.
265 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
266 */
267static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
268{
269 count--;
270 if (dmanr <= 3) {
271 dma_outb(count & 0xff, ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE);
272 dma_outb((count >> 8) & 0xff,
273 ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE);
274 } else {
275 dma_outb((count >> 1) & 0xff,
276 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
277 dma_outb((count >> 9) & 0xff,
278 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
279 }
280}
281
282
283/* Get DMA residue count. After a DMA transfer, this
284 * should return zero. Reading this while a DMA transfer is
285 * still in progress will return unpredictable results.
286 * If called before the channel has been used, it may return 1.
287 * Otherwise, it returns the number of _bytes_ left to transfer.
288 *
289 * Assumes DMA flip-flop is clear.
290 */
291static __inline__ int get_dma_residue(unsigned int dmanr)
292{
293 unsigned int io_port;
294 /* using short to get 16-bit wrap around */
295 unsigned short count;
296
297 io_port = (dmanr <= 3) ? ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE
298 : ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE;
299
300 count = 1 + dma_inb(io_port);
301 count += dma_inb(io_port) << 8;
302
303 return (dmanr <= 3) ? count : (count << 1);
304}
305
306
307/* These are in kernel/dma.c: */
308extern int request_dma(unsigned int dmanr, const char *device_id);
309extern void free_dma(unsigned int dmanr);
310
311/* From PCI */
312
313#ifdef CONFIG_PCI
314extern int isa_dma_bridge_buggy;
3#else 315#else
4# include "dma_64.h" 316#define isa_dma_bridge_buggy (0)
5#endif 317#endif
318
319#endif /* _ASM_X86_DMA_H */
diff --git a/include/asm-x86/dma_32.h b/include/asm-x86/dma_32.h
deleted file mode 100644
index d23aac8e1a50..000000000000
--- a/include/asm-x86/dma_32.h
+++ /dev/null
@@ -1,297 +0,0 @@
1/* $Id: dma.h,v 1.7 1992/12/14 00:29:34 root Exp root $
2 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
3 * Written by Hennus Bergman, 1992.
4 * High DMA channel support & info by Hannu Savolainen
5 * and John Boyd, Nov. 1992.
6 */
7
8#ifndef _ASM_DMA_H
9#define _ASM_DMA_H
10
11#include <linux/spinlock.h> /* And spinlocks */
12#include <asm/io.h> /* need byte IO */
13#include <linux/delay.h>
14
15
16#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
17#define dma_outb outb_p
18#else
19#define dma_outb outb
20#endif
21
22#define dma_inb inb
23
24/*
25 * NOTES about DMA transfers:
26 *
27 * controller 1: channels 0-3, byte operations, ports 00-1F
28 * controller 2: channels 4-7, word operations, ports C0-DF
29 *
30 * - ALL registers are 8 bits only, regardless of transfer size
31 * - channel 4 is not used - cascades 1 into 2.
32 * - channels 0-3 are byte - addresses/counts are for physical bytes
33 * - channels 5-7 are word - addresses/counts are for physical words
34 * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
35 * - transfer count loaded to registers is 1 less than actual count
36 * - controller 2 offsets are all even (2x offsets for controller 1)
37 * - page registers for 5-7 don't use data bit 0, represent 128K pages
38 * - page registers for 0-3 use bit 0, represent 64K pages
39 *
40 * DMA transfers are limited to the lower 16MB of _physical_ memory.
41 * Note that addresses loaded into registers must be _physical_ addresses,
42 * not logical addresses (which may differ if paging is active).
43 *
44 * Address mapping for channels 0-3:
45 *
46 * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
47 * | ... | | ... | | ... |
48 * | ... | | ... | | ... |
49 * | ... | | ... | | ... |
50 * P7 ... P0 A7 ... A0 A7 ... A0
51 * | Page | Addr MSB | Addr LSB | (DMA registers)
52 *
53 * Address mapping for channels 5-7:
54 *
55 * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
56 * | ... | \ \ ... \ \ \ ... \ \
57 * | ... | \ \ ... \ \ \ ... \ (not used)
58 * | ... | \ \ ... \ \ \ ... \
59 * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
60 * | Page | Addr MSB | Addr LSB | (DMA registers)
61 *
62 * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
63 * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
64 * the hardware level, so odd-byte transfers aren't possible).
65 *
66 * Transfer count (_not # bytes_) is limited to 64K, represented as actual
67 * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
68 * and up to 128K bytes may be transferred on channels 5-7 in one operation.
69 *
70 */
71
72#define MAX_DMA_CHANNELS 8
73
74/* The maximum address that we can perform a DMA transfer to on this platform */
75#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000)
76
77/* 8237 DMA controllers */
78#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
79#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
80
81/* DMA controller registers */
82#define DMA1_CMD_REG 0x08 /* command register (w) */
83#define DMA1_STAT_REG 0x08 /* status register (r) */
84#define DMA1_REQ_REG 0x09 /* request register (w) */
85#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
86#define DMA1_MODE_REG 0x0B /* mode register (w) */
87#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
88#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
89#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
90#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
91#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
92
93#define DMA2_CMD_REG 0xD0 /* command register (w) */
94#define DMA2_STAT_REG 0xD0 /* status register (r) */
95#define DMA2_REQ_REG 0xD2 /* request register (w) */
96#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
97#define DMA2_MODE_REG 0xD6 /* mode register (w) */
98#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
99#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
100#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
101#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
102#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
103
104#define DMA_ADDR_0 0x00 /* DMA address registers */
105#define DMA_ADDR_1 0x02
106#define DMA_ADDR_2 0x04
107#define DMA_ADDR_3 0x06
108#define DMA_ADDR_4 0xC0
109#define DMA_ADDR_5 0xC4
110#define DMA_ADDR_6 0xC8
111#define DMA_ADDR_7 0xCC
112
113#define DMA_CNT_0 0x01 /* DMA count registers */
114#define DMA_CNT_1 0x03
115#define DMA_CNT_2 0x05
116#define DMA_CNT_3 0x07
117#define DMA_CNT_4 0xC2
118#define DMA_CNT_5 0xC6
119#define DMA_CNT_6 0xCA
120#define DMA_CNT_7 0xCE
121
122#define DMA_PAGE_0 0x87 /* DMA page registers */
123#define DMA_PAGE_1 0x83
124#define DMA_PAGE_2 0x81
125#define DMA_PAGE_3 0x82
126#define DMA_PAGE_5 0x8B
127#define DMA_PAGE_6 0x89
128#define DMA_PAGE_7 0x8A
129
130#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
131#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
132#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
133
134#define DMA_AUTOINIT 0x10
135
136
137extern spinlock_t dma_spin_lock;
138
139static __inline__ unsigned long claim_dma_lock(void)
140{
141 unsigned long flags;
142 spin_lock_irqsave(&dma_spin_lock, flags);
143 return flags;
144}
145
146static __inline__ void release_dma_lock(unsigned long flags)
147{
148 spin_unlock_irqrestore(&dma_spin_lock, flags);
149}
150
151/* enable/disable a specific DMA channel */
152static __inline__ void enable_dma(unsigned int dmanr)
153{
154 if (dmanr<=3)
155 dma_outb(dmanr, DMA1_MASK_REG);
156 else
157 dma_outb(dmanr & 3, DMA2_MASK_REG);
158}
159
160static __inline__ void disable_dma(unsigned int dmanr)
161{
162 if (dmanr<=3)
163 dma_outb(dmanr | 4, DMA1_MASK_REG);
164 else
165 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
166}
167
168/* Clear the 'DMA Pointer Flip Flop'.
169 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
170 * Use this once to initialize the FF to a known state.
171 * After that, keep track of it. :-)
172 * --- In order to do that, the DMA routines below should ---
173 * --- only be used while holding the DMA lock ! ---
174 */
175static __inline__ void clear_dma_ff(unsigned int dmanr)
176{
177 if (dmanr<=3)
178 dma_outb(0, DMA1_CLEAR_FF_REG);
179 else
180 dma_outb(0, DMA2_CLEAR_FF_REG);
181}
182
183/* set mode (above) for a specific DMA channel */
184static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
185{
186 if (dmanr<=3)
187 dma_outb(mode | dmanr, DMA1_MODE_REG);
188 else
189 dma_outb(mode | (dmanr&3), DMA2_MODE_REG);
190}
191
192/* Set only the page register bits of the transfer address.
193 * This is used for successive transfers when we know the contents of
194 * the lower 16 bits of the DMA current address register, but a 64k boundary
195 * may have been crossed.
196 */
197static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
198{
199 switch(dmanr) {
200 case 0:
201 dma_outb(pagenr, DMA_PAGE_0);
202 break;
203 case 1:
204 dma_outb(pagenr, DMA_PAGE_1);
205 break;
206 case 2:
207 dma_outb(pagenr, DMA_PAGE_2);
208 break;
209 case 3:
210 dma_outb(pagenr, DMA_PAGE_3);
211 break;
212 case 5:
213 dma_outb(pagenr & 0xfe, DMA_PAGE_5);
214 break;
215 case 6:
216 dma_outb(pagenr & 0xfe, DMA_PAGE_6);
217 break;
218 case 7:
219 dma_outb(pagenr & 0xfe, DMA_PAGE_7);
220 break;
221 }
222}
223
224
225/* Set transfer address & page bits for specific DMA channel.
226 * Assumes dma flipflop is clear.
227 */
228static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
229{
230 set_dma_page(dmanr, a>>16);
231 if (dmanr <= 3) {
232 dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
233 dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
234 } else {
235 dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
236 dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
237 }
238}
239
240
241/* Set transfer size (max 64k for DMA0..3, 128k for DMA5..7) for
242 * a specific DMA channel.
243 * You must ensure the parameters are valid.
244 * NOTE: from a manual: "the number of transfers is one more
245 * than the initial word count"! This is taken into account.
246 * Assumes dma flip-flop is clear.
247 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
248 */
249static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
250{
251 count--;
252 if (dmanr <= 3) {
253 dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
254 dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
255 } else {
256 dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
257 dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
258 }
259}
260
261
262/* Get DMA residue count. After a DMA transfer, this
263 * should return zero. Reading this while a DMA transfer is
264 * still in progress will return unpredictable results.
265 * If called before the channel has been used, it may return 1.
266 * Otherwise, it returns the number of _bytes_ left to transfer.
267 *
268 * Assumes DMA flip-flop is clear.
269 */
270static __inline__ int get_dma_residue(unsigned int dmanr)
271{
272 unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
273 : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
274
275 /* using short to get 16-bit wrap around */
276 unsigned short count;
277
278 count = 1 + dma_inb(io_port);
279 count += dma_inb(io_port) << 8;
280
281 return (dmanr<=3)? count : (count<<1);
282}
283
284
285/* These are in kernel/dma.c: */
286extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */
287extern void free_dma(unsigned int dmanr); /* release it again */
288
289/* From PCI */
290
291#ifdef CONFIG_PCI
292extern int isa_dma_bridge_buggy;
293#else
294#define isa_dma_bridge_buggy (0)
295#endif
296
297#endif /* _ASM_DMA_H */
diff --git a/include/asm-x86/dma_64.h b/include/asm-x86/dma_64.h
deleted file mode 100644
index a37c16f06289..000000000000
--- a/include/asm-x86/dma_64.h
+++ /dev/null
@@ -1,304 +0,0 @@
1/*
2 * linux/include/asm/dma.h: Defines for using and allocating dma channels.
3 * Written by Hennus Bergman, 1992.
4 * High DMA channel support & info by Hannu Savolainen
5 * and John Boyd, Nov. 1992.
6 */
7
8#ifndef _ASM_DMA_H
9#define _ASM_DMA_H
10
11#include <linux/spinlock.h> /* And spinlocks */
12#include <asm/io.h> /* need byte IO */
13#include <linux/delay.h>
14
15
16#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
17#define dma_outb outb_p
18#else
19#define dma_outb outb
20#endif
21
22#define dma_inb inb
23
24/*
25 * NOTES about DMA transfers:
26 *
27 * controller 1: channels 0-3, byte operations, ports 00-1F
28 * controller 2: channels 4-7, word operations, ports C0-DF
29 *
30 * - ALL registers are 8 bits only, regardless of transfer size
31 * - channel 4 is not used - cascades 1 into 2.
32 * - channels 0-3 are byte - addresses/counts are for physical bytes
33 * - channels 5-7 are word - addresses/counts are for physical words
34 * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
35 * - transfer count loaded to registers is 1 less than actual count
36 * - controller 2 offsets are all even (2x offsets for controller 1)
37 * - page registers for 5-7 don't use data bit 0, represent 128K pages
38 * - page registers for 0-3 use bit 0, represent 64K pages
39 *
40 * DMA transfers are limited to the lower 16MB of _physical_ memory.
41 * Note that addresses loaded into registers must be _physical_ addresses,
42 * not logical addresses (which may differ if paging is active).
43 *
44 * Address mapping for channels 0-3:
45 *
46 * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
47 * | ... | | ... | | ... |
48 * | ... | | ... | | ... |
49 * | ... | | ... | | ... |
50 * P7 ... P0 A7 ... A0 A7 ... A0
51 * | Page | Addr MSB | Addr LSB | (DMA registers)
52 *
53 * Address mapping for channels 5-7:
54 *
55 * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
56 * | ... | \ \ ... \ \ \ ... \ \
57 * | ... | \ \ ... \ \ \ ... \ (not used)
58 * | ... | \ \ ... \ \ \ ... \
59 * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
60 * | Page | Addr MSB | Addr LSB | (DMA registers)
61 *
62 * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
63 * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
64 * the hardware level, so odd-byte transfers aren't possible).
65 *
66 * Transfer count (_not # bytes_) is limited to 64K, represented as actual
67 * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
68 * and up to 128K bytes may be transferred on channels 5-7 in one operation.
69 *
70 */
71
72#define MAX_DMA_CHANNELS 8
73
74
75/* 16MB ISA DMA zone */
76#define MAX_DMA_PFN ((16*1024*1024) >> PAGE_SHIFT)
77
78/* 4GB broken PCI/AGP hardware bus master zone */
79#define MAX_DMA32_PFN ((4UL*1024*1024*1024) >> PAGE_SHIFT)
80
81/* Compat define for old dma zone */
82#define MAX_DMA_ADDRESS ((unsigned long)__va(MAX_DMA_PFN << PAGE_SHIFT))
83
84/* 8237 DMA controllers */
85#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
86#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
87
88/* DMA controller registers */
89#define DMA1_CMD_REG 0x08 /* command register (w) */
90#define DMA1_STAT_REG 0x08 /* status register (r) */
91#define DMA1_REQ_REG 0x09 /* request register (w) */
92#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
93#define DMA1_MODE_REG 0x0B /* mode register (w) */
94#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
95#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
96#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
97#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
98#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
99
100#define DMA2_CMD_REG 0xD0 /* command register (w) */
101#define DMA2_STAT_REG 0xD0 /* status register (r) */
102#define DMA2_REQ_REG 0xD2 /* request register (w) */
103#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
104#define DMA2_MODE_REG 0xD6 /* mode register (w) */
105#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
106#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
107#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
108#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
109#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
110
111#define DMA_ADDR_0 0x00 /* DMA address registers */
112#define DMA_ADDR_1 0x02
113#define DMA_ADDR_2 0x04
114#define DMA_ADDR_3 0x06
115#define DMA_ADDR_4 0xC0
116#define DMA_ADDR_5 0xC4
117#define DMA_ADDR_6 0xC8
118#define DMA_ADDR_7 0xCC
119
120#define DMA_CNT_0 0x01 /* DMA count registers */
121#define DMA_CNT_1 0x03
122#define DMA_CNT_2 0x05
123#define DMA_CNT_3 0x07
124#define DMA_CNT_4 0xC2
125#define DMA_CNT_5 0xC6
126#define DMA_CNT_6 0xCA
127#define DMA_CNT_7 0xCE
128
129#define DMA_PAGE_0 0x87 /* DMA page registers */
130#define DMA_PAGE_1 0x83
131#define DMA_PAGE_2 0x81
132#define DMA_PAGE_3 0x82
133#define DMA_PAGE_5 0x8B
134#define DMA_PAGE_6 0x89
135#define DMA_PAGE_7 0x8A
136
137#define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
138#define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
139#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
140
141#define DMA_AUTOINIT 0x10
142
143
144extern spinlock_t dma_spin_lock;
145
146static __inline__ unsigned long claim_dma_lock(void)
147{
148 unsigned long flags;
149 spin_lock_irqsave(&dma_spin_lock, flags);
150 return flags;
151}
152
153static __inline__ void release_dma_lock(unsigned long flags)
154{
155 spin_unlock_irqrestore(&dma_spin_lock, flags);
156}
157
158/* enable/disable a specific DMA channel */
159static __inline__ void enable_dma(unsigned int dmanr)
160{
161 if (dmanr<=3)
162 dma_outb(dmanr, DMA1_MASK_REG);
163 else
164 dma_outb(dmanr & 3, DMA2_MASK_REG);
165}
166
167static __inline__ void disable_dma(unsigned int dmanr)
168{
169 if (dmanr<=3)
170 dma_outb(dmanr | 4, DMA1_MASK_REG);
171 else
172 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
173}
174
175/* Clear the 'DMA Pointer Flip Flop'.
176 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
177 * Use this once to initialize the FF to a known state.
178 * After that, keep track of it. :-)
179 * --- In order to do that, the DMA routines below should ---
180 * --- only be used while holding the DMA lock ! ---
181 */
182static __inline__ void clear_dma_ff(unsigned int dmanr)
183{
184 if (dmanr<=3)
185 dma_outb(0, DMA1_CLEAR_FF_REG);
186 else
187 dma_outb(0, DMA2_CLEAR_FF_REG);
188}
189
190/* set mode (above) for a specific DMA channel */
191static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
192{
193 if (dmanr<=3)
194 dma_outb(mode | dmanr, DMA1_MODE_REG);
195 else
196 dma_outb(mode | (dmanr&3), DMA2_MODE_REG);
197}
198
199/* Set only the page register bits of the transfer address.
200 * This is used for successive transfers when we know the contents of
201 * the lower 16 bits of the DMA current address register, but a 64k boundary
202 * may have been crossed.
203 */
204static __inline__ void set_dma_page(unsigned int dmanr, char pagenr)
205{
206 switch(dmanr) {
207 case 0:
208 dma_outb(pagenr, DMA_PAGE_0);
209 break;
210 case 1:
211 dma_outb(pagenr, DMA_PAGE_1);
212 break;
213 case 2:
214 dma_outb(pagenr, DMA_PAGE_2);
215 break;
216 case 3:
217 dma_outb(pagenr, DMA_PAGE_3);
218 break;
219 case 5:
220 dma_outb(pagenr & 0xfe, DMA_PAGE_5);
221 break;
222 case 6:
223 dma_outb(pagenr & 0xfe, DMA_PAGE_6);
224 break;
225 case 7:
226 dma_outb(pagenr & 0xfe, DMA_PAGE_7);
227 break;
228 }
229}
230
231
232/* Set transfer address & page bits for specific DMA channel.
233 * Assumes dma flipflop is clear.
234 */
235static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int a)
236{
237 set_dma_page(dmanr, a>>16);
238 if (dmanr <= 3) {
239 dma_outb( a & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
240 dma_outb( (a>>8) & 0xff, ((dmanr&3)<<1) + IO_DMA1_BASE );
241 } else {
242 dma_outb( (a>>1) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
243 dma_outb( (a>>9) & 0xff, ((dmanr&3)<<2) + IO_DMA2_BASE );
244 }
245}
246
247
248/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
249 * a specific DMA channel.
250 * You must ensure the parameters are valid.
251 * NOTE: from a manual: "the number of transfers is one more
252 * than the initial word count"! This is taken into account.
253 * Assumes dma flip-flop is clear.
254 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
255 */
256static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
257{
258 count--;
259 if (dmanr <= 3) {
260 dma_outb( count & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
261 dma_outb( (count>>8) & 0xff, ((dmanr&3)<<1) + 1 + IO_DMA1_BASE );
262 } else {
263 dma_outb( (count>>1) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
264 dma_outb( (count>>9) & 0xff, ((dmanr&3)<<2) + 2 + IO_DMA2_BASE );
265 }
266}
267
268
269/* Get DMA residue count. After a DMA transfer, this
270 * should return zero. Reading this while a DMA transfer is
271 * still in progress will return unpredictable results.
272 * If called before the channel has been used, it may return 1.
273 * Otherwise, it returns the number of _bytes_ left to transfer.
274 *
275 * Assumes DMA flip-flop is clear.
276 */
277static __inline__ int get_dma_residue(unsigned int dmanr)
278{
279 unsigned int io_port = (dmanr<=3)? ((dmanr&3)<<1) + 1 + IO_DMA1_BASE
280 : ((dmanr&3)<<2) + 2 + IO_DMA2_BASE;
281
282 /* using short to get 16-bit wrap around */
283 unsigned short count;
284
285 count = 1 + dma_inb(io_port);
286 count += dma_inb(io_port) << 8;
287
288 return (dmanr<=3)? count : (count<<1);
289}
290
291
292/* These are in kernel/dma.c: */
293extern int request_dma(unsigned int dmanr, const char * device_id); /* reserve a DMA channel */
294extern void free_dma(unsigned int dmanr); /* release it again */
295
296/* From PCI */
297
298#ifdef CONFIG_PCI
299extern int isa_dma_bridge_buggy;
300#else
301#define isa_dma_bridge_buggy (0)
302#endif
303
304#endif /* _ASM_DMA_H */
diff --git a/include/asm-x86/dmi.h b/include/asm-x86/dmi.h
index 8e2b0e6aa8e7..1241e6ad1935 100644
--- a/include/asm-x86/dmi.h
+++ b/include/asm-x86/dmi.h
@@ -5,9 +5,6 @@
5 5
6#ifdef CONFIG_X86_32 6#ifdef CONFIG_X86_32
7 7
8/* Use early IO mappings for DMI because it's initialized early */
9#define dmi_ioremap bt_ioremap
10#define dmi_iounmap bt_iounmap
11#define dmi_alloc alloc_bootmem 8#define dmi_alloc alloc_bootmem
12 9
13#else /* CONFIG_X86_32 */ 10#else /* CONFIG_X86_32 */
@@ -22,14 +19,15 @@ extern char dmi_alloc_data[DMI_MAX_DATA];
22static inline void *dmi_alloc(unsigned len) 19static inline void *dmi_alloc(unsigned len)
23{ 20{
24 int idx = dmi_alloc_index; 21 int idx = dmi_alloc_index;
25 if ((dmi_alloc_index += len) > DMI_MAX_DATA) 22 if ((dmi_alloc_index + len) > DMI_MAX_DATA)
26 return NULL; 23 return NULL;
24 dmi_alloc_index += len;
27 return dmi_alloc_data + idx; 25 return dmi_alloc_data + idx;
28} 26}
29 27
28#endif
29
30#define dmi_ioremap early_ioremap 30#define dmi_ioremap early_ioremap
31#define dmi_iounmap early_iounmap 31#define dmi_iounmap early_iounmap
32 32
33#endif 33#endif
34
35#endif
diff --git a/include/asm-x86/ds.h b/include/asm-x86/ds.h
new file mode 100644
index 000000000000..7881368142fa
--- /dev/null
+++ b/include/asm-x86/ds.h
@@ -0,0 +1,72 @@
1/*
2 * Debug Store (DS) support
3 *
4 * This provides a low-level interface to the hardware's Debug Store
5 * feature that is used for last branch recording (LBR) and
6 * precise-event based sampling (PEBS).
7 *
8 * Different architectures use a different DS layout/pointer size.
9 * The below functions therefore work on a void*.
10 *
11 *
12 * Since there is no user for PEBS, yet, only LBR (or branch
13 * trace store, BTS) is supported.
14 *
15 *
16 * Copyright (C) 2007 Intel Corporation.
17 * Markus Metzger <markus.t.metzger@intel.com>, Dec 2007
18 */
19
20#ifndef _ASM_X86_DS_H
21#define _ASM_X86_DS_H
22
23#include <linux/types.h>
24#include <linux/init.h>
25
26struct cpuinfo_x86;
27
28
29/* a branch trace record entry
30 *
31 * In order to unify the interface between various processor versions,
32 * we use the below data structure for all processors.
33 */
34enum bts_qualifier {
35 BTS_INVALID = 0,
36 BTS_BRANCH,
37 BTS_TASK_ARRIVES,
38 BTS_TASK_DEPARTS
39};
40
41struct bts_struct {
42 u64 qualifier;
43 union {
44 /* BTS_BRANCH */
45 struct {
46 u64 from_ip;
47 u64 to_ip;
48 } lbr;
49 /* BTS_TASK_ARRIVES or
50 BTS_TASK_DEPARTS */
51 u64 jiffies;
52 } variant;
53};
54
55/* Overflow handling mechanisms */
56#define DS_O_SIGNAL 1 /* send overflow signal */
57#define DS_O_WRAP 2 /* wrap around */
58
59extern int ds_allocate(void **, size_t);
60extern int ds_free(void **);
61extern int ds_get_bts_size(void *);
62extern int ds_get_bts_end(void *);
63extern int ds_get_bts_index(void *);
64extern int ds_set_overflow(void *, int);
65extern int ds_get_overflow(void *);
66extern int ds_clear(void *);
67extern int ds_read_bts(void *, int, struct bts_struct *);
68extern int ds_write_bts(void *, const struct bts_struct *);
69extern unsigned long ds_debugctl_mask(void);
70extern void __cpuinit ds_init_intel(struct cpuinfo_x86 *c);
71
72#endif /* _ASM_X86_DS_H */
diff --git a/include/asm-x86/e820.h b/include/asm-x86/e820.h
index 3e214f39fad3..7004251fc66b 100644
--- a/include/asm-x86/e820.h
+++ b/include/asm-x86/e820.h
@@ -22,6 +22,12 @@ struct e820map {
22}; 22};
23#endif /* __ASSEMBLY__ */ 23#endif /* __ASSEMBLY__ */
24 24
25#define ISA_START_ADDRESS 0xa0000
26#define ISA_END_ADDRESS 0x100000
27
28#define BIOS_BEGIN 0x000a0000
29#define BIOS_END 0x00100000
30
25#ifdef __KERNEL__ 31#ifdef __KERNEL__
26#ifdef CONFIG_X86_32 32#ifdef CONFIG_X86_32
27# include "e820_32.h" 33# include "e820_32.h"
diff --git a/include/asm-x86/e820_32.h b/include/asm-x86/e820_32.h
index 03f60c690c8a..f1da7ebd1905 100644
--- a/include/asm-x86/e820_32.h
+++ b/include/asm-x86/e820_32.h
@@ -12,20 +12,28 @@
12#ifndef __E820_HEADER 12#ifndef __E820_HEADER
13#define __E820_HEADER 13#define __E820_HEADER
14 14
15#include <linux/ioport.h>
16
15#define HIGH_MEMORY (1024*1024) 17#define HIGH_MEMORY (1024*1024)
16 18
17#ifndef __ASSEMBLY__ 19#ifndef __ASSEMBLY__
18 20
19extern struct e820map e820; 21extern struct e820map e820;
22extern void update_e820(void);
20 23
21extern int e820_all_mapped(unsigned long start, unsigned long end, 24extern int e820_all_mapped(unsigned long start, unsigned long end,
22 unsigned type); 25 unsigned type);
23extern int e820_any_mapped(u64 start, u64 end, unsigned type); 26extern int e820_any_mapped(u64 start, u64 end, unsigned type);
24extern void find_max_pfn(void); 27extern void find_max_pfn(void);
25extern void register_bootmem_low_pages(unsigned long max_low_pfn); 28extern void register_bootmem_low_pages(unsigned long max_low_pfn);
29extern void add_memory_region(unsigned long long start,
30 unsigned long long size, int type);
26extern void e820_register_memory(void); 31extern void e820_register_memory(void);
27extern void limit_regions(unsigned long long size); 32extern void limit_regions(unsigned long long size);
28extern void print_memory_map(char *who); 33extern void print_memory_map(char *who);
34extern void init_iomem_resources(struct resource *code_resource,
35 struct resource *data_resource,
36 struct resource *bss_resource);
29 37
30#if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION) 38#if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION)
31extern void e820_mark_nosave_regions(void); 39extern void e820_mark_nosave_regions(void);
@@ -35,5 +43,6 @@ static inline void e820_mark_nosave_regions(void)
35} 43}
36#endif 44#endif
37 45
46
38#endif/*!__ASSEMBLY__*/ 47#endif/*!__ASSEMBLY__*/
39#endif/*__E820_HEADER*/ 48#endif/*__E820_HEADER*/
diff --git a/include/asm-x86/e820_64.h b/include/asm-x86/e820_64.h
index 0bd4787a5d57..a560c4f5d500 100644
--- a/include/asm-x86/e820_64.h
+++ b/include/asm-x86/e820_64.h
@@ -11,19 +11,25 @@
11#ifndef __E820_HEADER 11#ifndef __E820_HEADER
12#define __E820_HEADER 12#define __E820_HEADER
13 13
14#include <linux/ioport.h>
15
14#ifndef __ASSEMBLY__ 16#ifndef __ASSEMBLY__
15extern unsigned long find_e820_area(unsigned long start, unsigned long end, 17extern unsigned long find_e820_area(unsigned long start, unsigned long end,
16 unsigned size); 18 unsigned size, unsigned long align);
17extern void add_memory_region(unsigned long start, unsigned long size, 19extern void add_memory_region(unsigned long start, unsigned long size,
18 int type); 20 int type);
19extern void setup_memory_region(void); 21extern void setup_memory_region(void);
20extern void contig_e820_setup(void); 22extern void contig_e820_setup(void);
21extern unsigned long e820_end_of_ram(void); 23extern unsigned long e820_end_of_ram(void);
22extern void e820_reserve_resources(void); 24extern void e820_reserve_resources(struct resource *code_resource,
25 struct resource *data_resource, struct resource *bss_resource);
23extern void e820_mark_nosave_regions(void); 26extern void e820_mark_nosave_regions(void);
24extern void e820_print_map(char *who);
25extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type); 27extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type);
26extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type); 28extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type);
29extern int e820_any_non_reserved(unsigned long start, unsigned long end);
30extern int is_memory_any_valid(unsigned long start, unsigned long end);
31extern int e820_all_non_reserved(unsigned long start, unsigned long end);
32extern int is_memory_all_valid(unsigned long start, unsigned long end);
27extern unsigned long e820_hole_size(unsigned long start, unsigned long end); 33extern unsigned long e820_hole_size(unsigned long start, unsigned long end);
28 34
29extern void e820_setup_gap(void); 35extern void e820_setup_gap(void);
@@ -33,9 +39,11 @@ extern void e820_register_active_regions(int nid,
33extern void finish_e820_parsing(void); 39extern void finish_e820_parsing(void);
34 40
35extern struct e820map e820; 41extern struct e820map e820;
42extern void update_e820(void);
43
44extern void reserve_early(unsigned long start, unsigned long end, char *name);
45extern void early_res_to_bootmem(void);
36 46
37extern unsigned ebda_addr, ebda_size;
38extern unsigned long nodemap_addr, nodemap_size;
39#endif/*!__ASSEMBLY__*/ 47#endif/*!__ASSEMBLY__*/
40 48
41#endif/*__E820_HEADER*/ 49#endif/*__E820_HEADER*/
diff --git a/include/asm-x86/efi.h b/include/asm-x86/efi.h
new file mode 100644
index 000000000000..9c68a1f098d8
--- /dev/null
+++ b/include/asm-x86/efi.h
@@ -0,0 +1,97 @@
1#ifndef _ASM_X86_EFI_H
2#define _ASM_X86_EFI_H
3
4#ifdef CONFIG_X86_32
5
6extern unsigned long asmlinkage efi_call_phys(void *, ...);
7
8#define efi_call_phys0(f) efi_call_phys(f)
9#define efi_call_phys1(f, a1) efi_call_phys(f, a1)
10#define efi_call_phys2(f, a1, a2) efi_call_phys(f, a1, a2)
11#define efi_call_phys3(f, a1, a2, a3) efi_call_phys(f, a1, a2, a3)
12#define efi_call_phys4(f, a1, a2, a3, a4) \
13 efi_call_phys(f, a1, a2, a3, a4)
14#define efi_call_phys5(f, a1, a2, a3, a4, a5) \
15 efi_call_phys(f, a1, a2, a3, a4, a5)
16#define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
17 efi_call_phys(f, a1, a2, a3, a4, a5, a6)
18/*
19 * Wrap all the virtual calls in a way that forces the parameters on the stack.
20 */
21
22#define efi_call_virt(f, args...) \
23 ((efi_##f##_t __attribute__((regparm(0)))*)efi.systab->runtime->f)(args)
24
25#define efi_call_virt0(f) efi_call_virt(f)
26#define efi_call_virt1(f, a1) efi_call_virt(f, a1)
27#define efi_call_virt2(f, a1, a2) efi_call_virt(f, a1, a2)
28#define efi_call_virt3(f, a1, a2, a3) efi_call_virt(f, a1, a2, a3)
29#define efi_call_virt4(f, a1, a2, a3, a4) \
30 efi_call_virt(f, a1, a2, a3, a4)
31#define efi_call_virt5(f, a1, a2, a3, a4, a5) \
32 efi_call_virt(f, a1, a2, a3, a4, a5)
33#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
34 efi_call_virt(f, a1, a2, a3, a4, a5, a6)
35
36#define efi_ioremap(addr, size) ioremap(addr, size)
37
38#else /* !CONFIG_X86_32 */
39
40#define MAX_EFI_IO_PAGES 100
41
42extern u64 efi_call0(void *fp);
43extern u64 efi_call1(void *fp, u64 arg1);
44extern u64 efi_call2(void *fp, u64 arg1, u64 arg2);
45extern u64 efi_call3(void *fp, u64 arg1, u64 arg2, u64 arg3);
46extern u64 efi_call4(void *fp, u64 arg1, u64 arg2, u64 arg3, u64 arg4);
47extern u64 efi_call5(void *fp, u64 arg1, u64 arg2, u64 arg3,
48 u64 arg4, u64 arg5);
49extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
50 u64 arg4, u64 arg5, u64 arg6);
51
52#define efi_call_phys0(f) \
53 efi_call0((void *)(f))
54#define efi_call_phys1(f, a1) \
55 efi_call1((void *)(f), (u64)(a1))
56#define efi_call_phys2(f, a1, a2) \
57 efi_call2((void *)(f), (u64)(a1), (u64)(a2))
58#define efi_call_phys3(f, a1, a2, a3) \
59 efi_call3((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3))
60#define efi_call_phys4(f, a1, a2, a3, a4) \
61 efi_call4((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
62 (u64)(a4))
63#define efi_call_phys5(f, a1, a2, a3, a4, a5) \
64 efi_call5((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
65 (u64)(a4), (u64)(a5))
66#define efi_call_phys6(f, a1, a2, a3, a4, a5, a6) \
67 efi_call6((void *)(f), (u64)(a1), (u64)(a2), (u64)(a3), \
68 (u64)(a4), (u64)(a5), (u64)(a6))
69
70#define efi_call_virt0(f) \
71 efi_call0((void *)(efi.systab->runtime->f))
72#define efi_call_virt1(f, a1) \
73 efi_call1((void *)(efi.systab->runtime->f), (u64)(a1))
74#define efi_call_virt2(f, a1, a2) \
75 efi_call2((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2))
76#define efi_call_virt3(f, a1, a2, a3) \
77 efi_call3((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
78 (u64)(a3))
79#define efi_call_virt4(f, a1, a2, a3, a4) \
80 efi_call4((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
81 (u64)(a3), (u64)(a4))
82#define efi_call_virt5(f, a1, a2, a3, a4, a5) \
83 efi_call5((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
84 (u64)(a3), (u64)(a4), (u64)(a5))
85#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
86 efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
87 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
88
89extern void *efi_ioremap(unsigned long offset, unsigned long size);
90
91#endif /* CONFIG_X86_32 */
92
93extern void efi_reserve_bootmem(void);
94extern void efi_call_phys_prelog(void);
95extern void efi_call_phys_epilog(void);
96
97#endif
diff --git a/include/asm-x86/elf.h b/include/asm-x86/elf.h
index ec42a4d2e83b..d9c94e707289 100644
--- a/include/asm-x86/elf.h
+++ b/include/asm-x86/elf.h
@@ -73,18 +73,23 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
73#endif 73#endif
74 74
75#ifdef __KERNEL__ 75#ifdef __KERNEL__
76#include <asm/vdso.h>
76 77
77#ifdef CONFIG_X86_32 78extern unsigned int vdso_enabled;
78#include <asm/processor.h>
79#include <asm/system.h> /* for savesegment */
80#include <asm/desc.h>
81 79
82/* 80/*
83 * This is used to ensure we don't load something for the wrong architecture. 81 * This is used to ensure we don't load something for the wrong architecture.
84 */ 82 */
85#define elf_check_arch(x) \ 83#define elf_check_arch_ia32(x) \
86 (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486)) 84 (((x)->e_machine == EM_386) || ((x)->e_machine == EM_486))
87 85
86#ifdef CONFIG_X86_32
87#include <asm/processor.h>
88#include <asm/system.h> /* for savesegment */
89#include <asm/desc.h>
90
91#define elf_check_arch(x) elf_check_arch_ia32(x)
92
88/* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx 93/* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx
89 contains a pointer to a function which might be registered using `atexit'. 94 contains a pointer to a function which might be registered using `atexit'.
90 This provides a mean for the dynamic linker to call DT_FINI functions for 95 This provides a mean for the dynamic linker to call DT_FINI functions for
@@ -96,36 +101,38 @@ typedef struct user_fxsr_struct elf_fpxregset_t;
96 just to make things more deterministic. 101 just to make things more deterministic.
97 */ 102 */
98#define ELF_PLAT_INIT(_r, load_addr) do { \ 103#define ELF_PLAT_INIT(_r, load_addr) do { \
99 _r->ebx = 0; _r->ecx = 0; _r->edx = 0; \ 104 _r->bx = 0; _r->cx = 0; _r->dx = 0; \
100 _r->esi = 0; _r->edi = 0; _r->ebp = 0; \ 105 _r->si = 0; _r->di = 0; _r->bp = 0; \
101 _r->eax = 0; \ 106 _r->ax = 0; \
102} while (0) 107} while (0)
103 108
104/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is 109/*
105 now struct_user_regs, they are different) */ 110 * regs is struct pt_regs, pr_reg is elf_gregset_t (which is
106 111 * now struct_user_regs, they are different)
107#define ELF_CORE_COPY_REGS(pr_reg, regs) \ 112 */
108 pr_reg[0] = regs->ebx; \ 113
109 pr_reg[1] = regs->ecx; \ 114#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
110 pr_reg[2] = regs->edx; \ 115 pr_reg[0] = regs->bx; \
111 pr_reg[3] = regs->esi; \ 116 pr_reg[1] = regs->cx; \
112 pr_reg[4] = regs->edi; \ 117 pr_reg[2] = regs->dx; \
113 pr_reg[5] = regs->ebp; \ 118 pr_reg[3] = regs->si; \
114 pr_reg[6] = regs->eax; \ 119 pr_reg[4] = regs->di; \
115 pr_reg[7] = regs->xds & 0xffff; \ 120 pr_reg[5] = regs->bp; \
116 pr_reg[8] = regs->xes & 0xffff; \ 121 pr_reg[6] = regs->ax; \
117 pr_reg[9] = regs->xfs & 0xffff; \ 122 pr_reg[7] = regs->ds & 0xffff; \
118 savesegment(gs,pr_reg[10]); \ 123 pr_reg[8] = regs->es & 0xffff; \
119 pr_reg[11] = regs->orig_eax; \ 124 pr_reg[9] = regs->fs & 0xffff; \
120 pr_reg[12] = regs->eip; \ 125 savesegment(gs, pr_reg[10]); \
121 pr_reg[13] = regs->xcs & 0xffff; \ 126 pr_reg[11] = regs->orig_ax; \
122 pr_reg[14] = regs->eflags; \ 127 pr_reg[12] = regs->ip; \
123 pr_reg[15] = regs->esp; \ 128 pr_reg[13] = regs->cs & 0xffff; \
124 pr_reg[16] = regs->xss & 0xffff; 129 pr_reg[14] = regs->flags; \
130 pr_reg[15] = regs->sp; \
131 pr_reg[16] = regs->ss & 0xffff; \
132} while (0);
125 133
126#define ELF_PLATFORM (utsname()->machine) 134#define ELF_PLATFORM (utsname()->machine)
127#define set_personality_64bit() do { } while (0) 135#define set_personality_64bit() do { } while (0)
128extern unsigned int vdso_enabled;
129 136
130#else /* CONFIG_X86_32 */ 137#else /* CONFIG_X86_32 */
131 138
@@ -137,28 +144,57 @@ extern unsigned int vdso_enabled;
137#define elf_check_arch(x) \ 144#define elf_check_arch(x) \
138 ((x)->e_machine == EM_X86_64) 145 ((x)->e_machine == EM_X86_64)
139 146
147#define compat_elf_check_arch(x) elf_check_arch_ia32(x)
148
149static inline void start_ia32_thread(struct pt_regs *regs, u32 ip, u32 sp)
150{
151 asm volatile("movl %0,%%fs" :: "r" (0));
152 asm volatile("movl %0,%%es; movl %0,%%ds" : : "r" (__USER32_DS));
153 load_gs_index(0);
154 regs->ip = ip;
155 regs->sp = sp;
156 regs->flags = X86_EFLAGS_IF;
157 regs->cs = __USER32_CS;
158 regs->ss = __USER32_DS;
159}
160
161static inline void elf_common_init(struct thread_struct *t,
162 struct pt_regs *regs, const u16 ds)
163{
164 regs->ax = regs->bx = regs->cx = regs->dx = 0;
165 regs->si = regs->di = regs->bp = 0;
166 regs->r8 = regs->r9 = regs->r10 = regs->r11 = 0;
167 regs->r12 = regs->r13 = regs->r14 = regs->r15 = 0;
168 t->fs = t->gs = 0;
169 t->fsindex = t->gsindex = 0;
170 t->ds = t->es = ds;
171}
172
140#define ELF_PLAT_INIT(_r, load_addr) do { \ 173#define ELF_PLAT_INIT(_r, load_addr) do { \
141 struct task_struct *cur = current; \ 174 elf_common_init(&current->thread, _r, 0); \
142 (_r)->rbx = 0; (_r)->rcx = 0; (_r)->rdx = 0; \
143 (_r)->rsi = 0; (_r)->rdi = 0; (_r)->rbp = 0; \
144 (_r)->rax = 0; \
145 (_r)->r8 = 0; \
146 (_r)->r9 = 0; \
147 (_r)->r10 = 0; \
148 (_r)->r11 = 0; \
149 (_r)->r12 = 0; \
150 (_r)->r13 = 0; \
151 (_r)->r14 = 0; \
152 (_r)->r15 = 0; \
153 cur->thread.fs = 0; cur->thread.gs = 0; \
154 cur->thread.fsindex = 0; cur->thread.gsindex = 0; \
155 cur->thread.ds = 0; cur->thread.es = 0; \
156 clear_thread_flag(TIF_IA32); \ 175 clear_thread_flag(TIF_IA32); \
157} while (0) 176} while (0)
158 177
159/* regs is struct pt_regs, pr_reg is elf_gregset_t (which is 178#define COMPAT_ELF_PLAT_INIT(regs, load_addr) \
160 now struct_user_regs, they are different). Assumes current is the process 179 elf_common_init(&current->thread, regs, __USER_DS)
161 getting dumped. */ 180#define compat_start_thread(regs, ip, sp) do { \
181 start_ia32_thread(regs, ip, sp); \
182 set_fs(USER_DS); \
183 } while (0)
184#define COMPAT_SET_PERSONALITY(ex, ibcs2) do { \
185 if (test_thread_flag(TIF_IA32)) \
186 clear_thread_flag(TIF_ABI_PENDING); \
187 else \
188 set_thread_flag(TIF_ABI_PENDING); \
189 current->personality |= force_personality32; \
190 } while (0)
191#define COMPAT_ELF_PLATFORM ("i686")
192
193/*
194 * regs is struct pt_regs, pr_reg is elf_gregset_t (which is
195 * now struct_user_regs, they are different). Assumes current is the process
196 * getting dumped.
197 */
162 198
163#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ 199#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
164 unsigned v; \ 200 unsigned v; \
@@ -166,22 +202,22 @@ extern unsigned int vdso_enabled;
166 (pr_reg)[1] = (regs)->r14; \ 202 (pr_reg)[1] = (regs)->r14; \
167 (pr_reg)[2] = (regs)->r13; \ 203 (pr_reg)[2] = (regs)->r13; \
168 (pr_reg)[3] = (regs)->r12; \ 204 (pr_reg)[3] = (regs)->r12; \
169 (pr_reg)[4] = (regs)->rbp; \ 205 (pr_reg)[4] = (regs)->bp; \
170 (pr_reg)[5] = (regs)->rbx; \ 206 (pr_reg)[5] = (regs)->bx; \
171 (pr_reg)[6] = (regs)->r11; \ 207 (pr_reg)[6] = (regs)->r11; \
172 (pr_reg)[7] = (regs)->r10; \ 208 (pr_reg)[7] = (regs)->r10; \
173 (pr_reg)[8] = (regs)->r9; \ 209 (pr_reg)[8] = (regs)->r9; \
174 (pr_reg)[9] = (regs)->r8; \ 210 (pr_reg)[9] = (regs)->r8; \
175 (pr_reg)[10] = (regs)->rax; \ 211 (pr_reg)[10] = (regs)->ax; \
176 (pr_reg)[11] = (regs)->rcx; \ 212 (pr_reg)[11] = (regs)->cx; \
177 (pr_reg)[12] = (regs)->rdx; \ 213 (pr_reg)[12] = (regs)->dx; \
178 (pr_reg)[13] = (regs)->rsi; \ 214 (pr_reg)[13] = (regs)->si; \
179 (pr_reg)[14] = (regs)->rdi; \ 215 (pr_reg)[14] = (regs)->di; \
180 (pr_reg)[15] = (regs)->orig_rax; \ 216 (pr_reg)[15] = (regs)->orig_ax; \
181 (pr_reg)[16] = (regs)->rip; \ 217 (pr_reg)[16] = (regs)->ip; \
182 (pr_reg)[17] = (regs)->cs; \ 218 (pr_reg)[17] = (regs)->cs; \
183 (pr_reg)[18] = (regs)->eflags; \ 219 (pr_reg)[18] = (regs)->flags; \
184 (pr_reg)[19] = (regs)->rsp; \ 220 (pr_reg)[19] = (regs)->sp; \
185 (pr_reg)[20] = (regs)->ss; \ 221 (pr_reg)[20] = (regs)->ss; \
186 (pr_reg)[21] = current->thread.fs; \ 222 (pr_reg)[21] = current->thread.fs; \
187 (pr_reg)[22] = current->thread.gs; \ 223 (pr_reg)[22] = current->thread.gs; \
@@ -189,15 +225,17 @@ extern unsigned int vdso_enabled;
189 asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \ 225 asm("movl %%es,%0" : "=r" (v)); (pr_reg)[24] = v; \
190 asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \ 226 asm("movl %%fs,%0" : "=r" (v)); (pr_reg)[25] = v; \
191 asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \ 227 asm("movl %%gs,%0" : "=r" (v)); (pr_reg)[26] = v; \
192} while(0); 228} while (0);
193 229
194/* I'm not sure if we can use '-' here */ 230/* I'm not sure if we can use '-' here */
195#define ELF_PLATFORM ("x86_64") 231#define ELF_PLATFORM ("x86_64")
196extern void set_personality_64bit(void); 232extern void set_personality_64bit(void);
197extern int vdso_enabled; 233extern unsigned int sysctl_vsyscall32;
234extern int force_personality32;
198 235
199#endif /* !CONFIG_X86_32 */ 236#endif /* !CONFIG_X86_32 */
200 237
238#define CORE_DUMP_USE_REGSET
201#define USE_ELF_CORE_DUMP 239#define USE_ELF_CORE_DUMP
202#define ELF_EXEC_PAGESIZE 4096 240#define ELF_EXEC_PAGESIZE 4096
203 241
@@ -232,43 +270,24 @@ extern int vdso_enabled;
232 270
233struct task_struct; 271struct task_struct;
234 272
235extern int dump_task_regs (struct task_struct *, elf_gregset_t *); 273#define ARCH_DLINFO_IA32(vdso_enabled) \
236extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *); 274do if (vdso_enabled) { \
237 275 NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
238#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs) 276 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \
239#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs) 277} while (0)
240 278
241#ifdef CONFIG_X86_32 279#ifdef CONFIG_X86_32
242extern int dump_task_extended_fpu (struct task_struct *,
243 struct user_fxsr_struct *);
244#define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) \
245 dump_task_extended_fpu(tsk, elf_xfpregs)
246#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
247 280
248#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO)) 281#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO))
249#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
250#define VDSO_PRELINK 0
251
252#define VDSO_SYM(x) \
253 (VDSO_CURRENT_BASE + (unsigned long)(x) - VDSO_PRELINK)
254
255#define VDSO_HIGH_EHDR ((const struct elfhdr *) VDSO_HIGH_BASE)
256#define VDSO_EHDR ((const struct elfhdr *) VDSO_CURRENT_BASE)
257 282
258extern void __kernel_vsyscall; 283#define ARCH_DLINFO ARCH_DLINFO_IA32(vdso_enabled)
259
260#define VDSO_ENTRY VDSO_SYM(&__kernel_vsyscall)
261 284
262/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */ 285/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
263 286
264#define ARCH_DLINFO \
265do if (vdso_enabled) { \
266 NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \
267 NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \
268} while (0)
269
270#else /* CONFIG_X86_32 */ 287#else /* CONFIG_X86_32 */
271 288
289#define VDSO_HIGH_BASE 0xffffe000U /* CONFIG_COMPAT_VDSO address */
290
272/* 1GB for 64bit, 8MB for 32bit */ 291/* 1GB for 64bit, 8MB for 32bit */
273#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) 292#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff)
274 293
@@ -277,14 +296,31 @@ do if (vdso_enabled) { \
277 NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\ 296 NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\
278} while (0) 297} while (0)
279 298
299#define AT_SYSINFO 32
300
301#define COMPAT_ARCH_DLINFO ARCH_DLINFO_IA32(sysctl_vsyscall32)
302
303#define COMPAT_ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
304
280#endif /* !CONFIG_X86_32 */ 305#endif /* !CONFIG_X86_32 */
281 306
307#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
308
309#define VDSO_ENTRY \
310 ((unsigned long) VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
311
282struct linux_binprm; 312struct linux_binprm;
283 313
284#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1 314#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
285extern int arch_setup_additional_pages(struct linux_binprm *bprm, 315extern int arch_setup_additional_pages(struct linux_binprm *bprm,
286 int executable_stack); 316 int executable_stack);
287 317
318extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
319#define compat_arch_setup_additional_pages syscall32_setup_pages
320
321extern unsigned long arch_randomize_brk(struct mm_struct *mm);
322#define arch_randomize_brk arch_randomize_brk
323
288#endif /* __KERNEL__ */ 324#endif /* __KERNEL__ */
289 325
290#endif 326#endif
diff --git a/include/asm-x86/emergency-restart.h b/include/asm-x86/emergency-restart.h
index 680c39563345..8e6aef19f8f0 100644
--- a/include/asm-x86/emergency-restart.h
+++ b/include/asm-x86/emergency-restart.h
@@ -1,6 +1,18 @@
1#ifndef _ASM_EMERGENCY_RESTART_H 1#ifndef _ASM_EMERGENCY_RESTART_H
2#define _ASM_EMERGENCY_RESTART_H 2#define _ASM_EMERGENCY_RESTART_H
3 3
4enum reboot_type {
5 BOOT_TRIPLE = 't',
6 BOOT_KBD = 'k',
7#ifdef CONFIG_X86_32
8 BOOT_BIOS = 'b',
9#endif
10 BOOT_ACPI = 'a',
11 BOOT_EFI = 'e'
12};
13
14extern enum reboot_type reboot_type;
15
4extern void machine_emergency_restart(void); 16extern void machine_emergency_restart(void);
5 17
6#endif /* _ASM_EMERGENCY_RESTART_H */ 18#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/include/asm-x86/fixmap_32.h b/include/asm-x86/fixmap_32.h
index 249e753ac805..a7404d50686b 100644
--- a/include/asm-x86/fixmap_32.h
+++ b/include/asm-x86/fixmap_32.h
@@ -65,7 +65,7 @@ enum fixed_addresses {
65#endif 65#endif
66#ifdef CONFIG_X86_VISWS_APIC 66#ifdef CONFIG_X86_VISWS_APIC
67 FIX_CO_CPU, /* Cobalt timer */ 67 FIX_CO_CPU, /* Cobalt timer */
68 FIX_CO_APIC, /* Cobalt APIC Redirection Table */ 68 FIX_CO_APIC, /* Cobalt APIC Redirection Table */
69 FIX_LI_PCIA, /* Lithium PCI Bridge A */ 69 FIX_LI_PCIA, /* Lithium PCI Bridge A */
70 FIX_LI_PCIB, /* Lithium PCI Bridge B */ 70 FIX_LI_PCIB, /* Lithium PCI Bridge B */
71#endif 71#endif
@@ -74,7 +74,7 @@ enum fixed_addresses {
74#endif 74#endif
75#ifdef CONFIG_X86_CYCLONE_TIMER 75#ifdef CONFIG_X86_CYCLONE_TIMER
76 FIX_CYCLONE_TIMER, /*cyclone timer register*/ 76 FIX_CYCLONE_TIMER, /*cyclone timer register*/
77#endif 77#endif
78#ifdef CONFIG_HIGHMEM 78#ifdef CONFIG_HIGHMEM
79 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */ 79 FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
80 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1, 80 FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
@@ -90,11 +90,23 @@ enum fixed_addresses {
90 FIX_PARAVIRT_BOOTMAP, 90 FIX_PARAVIRT_BOOTMAP,
91#endif 91#endif
92 __end_of_permanent_fixed_addresses, 92 __end_of_permanent_fixed_addresses,
93 /* temporary boot-time mappings, used before ioremap() is functional */ 93 /*
94#define NR_FIX_BTMAPS 16 94 * 256 temporary boot-time mappings, used by early_ioremap(),
95 FIX_BTMAP_END = __end_of_permanent_fixed_addresses, 95 * before ioremap() is functional.
96 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1, 96 *
97 * We round it up to the next 512 pages boundary so that we
98 * can have a single pgd entry and a single pte table:
99 */
100#define NR_FIX_BTMAPS 64
101#define FIX_BTMAPS_NESTING 4
102 FIX_BTMAP_END =
103 __end_of_permanent_fixed_addresses + 512 -
104 (__end_of_permanent_fixed_addresses & 511),
105 FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS*FIX_BTMAPS_NESTING - 1,
97 FIX_WP_TEST, 106 FIX_WP_TEST,
107#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
108 FIX_OHCI1394_BASE,
109#endif
98 __end_of_fixed_addresses 110 __end_of_fixed_addresses
99}; 111};
100 112
diff --git a/include/asm-x86/fixmap_64.h b/include/asm-x86/fixmap_64.h
index cdfbe4a6ae6f..70ddb21e6458 100644
--- a/include/asm-x86/fixmap_64.h
+++ b/include/asm-x86/fixmap_64.h
@@ -15,6 +15,7 @@
15#include <asm/apicdef.h> 15#include <asm/apicdef.h>
16#include <asm/page.h> 16#include <asm/page.h>
17#include <asm/vsyscall.h> 17#include <asm/vsyscall.h>
18#include <asm/efi.h>
18 19
19/* 20/*
20 * Here we define all the compile-time 'special' virtual 21 * Here we define all the compile-time 'special' virtual
@@ -41,6 +42,11 @@ enum fixed_addresses {
41 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */ 42 FIX_APIC_BASE, /* local (CPU) APIC) -- required for SMP or not */
42 FIX_IO_APIC_BASE_0, 43 FIX_IO_APIC_BASE_0,
43 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1, 44 FIX_IO_APIC_BASE_END = FIX_IO_APIC_BASE_0 + MAX_IO_APICS-1,
45 FIX_EFI_IO_MAP_LAST_PAGE,
46 FIX_EFI_IO_MAP_FIRST_PAGE = FIX_EFI_IO_MAP_LAST_PAGE+MAX_EFI_IO_PAGES-1,
47#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
48 FIX_OHCI1394_BASE,
49#endif
44 __end_of_fixed_addresses 50 __end_of_fixed_addresses
45}; 51};
46 52
diff --git a/include/asm-x86/fpu32.h b/include/asm-x86/fpu32.h
deleted file mode 100644
index 4153db5c0c31..000000000000
--- a/include/asm-x86/fpu32.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef _FPU32_H
2#define _FPU32_H 1
3
4struct _fpstate_ia32;
5
6int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf, int fsave);
7int save_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf,
8 struct pt_regs *regs, int fsave);
9
10#endif
diff --git a/include/asm-x86/futex.h b/include/asm-x86/futex.h
index 1f4610e0c613..9d919264923a 100644
--- a/include/asm-x86/futex.h
+++ b/include/asm-x86/futex.h
@@ -1,5 +1,135 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_FUTEX_H
2# include "futex_32.h" 2#define _ASM_X86_FUTEX_H
3#else 3
4# include "futex_64.h" 4#ifdef __KERNEL__
5
6#include <linux/futex.h>
7
8#include <asm/asm.h>
9#include <asm/errno.h>
10#include <asm/processor.h>
11#include <asm/system.h>
12#include <asm/uaccess.h>
13
14#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
15 __asm__ __volatile( \
16"1: " insn "\n" \
17"2: .section .fixup,\"ax\"\n \
183: mov %3, %1\n \
19 jmp 2b\n \
20 .previous\n \
21 .section __ex_table,\"a\"\n \
22 .align 8\n" \
23 _ASM_PTR "1b,3b\n \
24 .previous" \
25 : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
26 : "i" (-EFAULT), "0" (oparg), "1" (0))
27
28#define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
29 __asm__ __volatile( \
30"1: movl %2, %0\n \
31 movl %0, %3\n" \
32 insn "\n" \
33"2: lock; cmpxchgl %3, %2\n \
34 jnz 1b\n \
353: .section .fixup,\"ax\"\n \
364: mov %5, %1\n \
37 jmp 3b\n \
38 .previous\n \
39 .section __ex_table,\"a\"\n \
40 .align 8\n" \
41 _ASM_PTR "1b,4b,2b,4b\n \
42 .previous" \
43 : "=&a" (oldval), "=&r" (ret), "+m" (*uaddr), \
44 "=&r" (tem) \
45 : "r" (oparg), "i" (-EFAULT), "1" (0))
46
47static inline int
48futex_atomic_op_inuser(int encoded_op, int __user *uaddr)
49{
50 int op = (encoded_op >> 28) & 7;
51 int cmp = (encoded_op >> 24) & 15;
52 int oparg = (encoded_op << 8) >> 20;
53 int cmparg = (encoded_op << 20) >> 20;
54 int oldval = 0, ret, tem;
55
56 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
57 oparg = 1 << oparg;
58
59 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
60 return -EFAULT;
61
62#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_BSWAP)
63 /* Real i386 machines can only support FUTEX_OP_SET */
64 if (op != FUTEX_OP_SET && boot_cpu_data.x86 == 3)
65 return -ENOSYS;
66#endif
67
68 pagefault_disable();
69
70 switch (op) {
71 case FUTEX_OP_SET:
72 __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
73 break;
74 case FUTEX_OP_ADD:
75 __futex_atomic_op1("lock; xaddl %0, %2", ret, oldval,
76 uaddr, oparg);
77 break;
78 case FUTEX_OP_OR:
79 __futex_atomic_op2("orl %4, %3", ret, oldval, uaddr, oparg);
80 break;
81 case FUTEX_OP_ANDN:
82 __futex_atomic_op2("andl %4, %3", ret, oldval, uaddr, ~oparg);
83 break;
84 case FUTEX_OP_XOR:
85 __futex_atomic_op2("xorl %4, %3", ret, oldval, uaddr, oparg);
86 break;
87 default:
88 ret = -ENOSYS;
89 }
90
91 pagefault_enable();
92
93 if (!ret) {
94 switch (cmp) {
95 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
96 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
97 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
98 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
99 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
100 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
101 default: ret = -ENOSYS;
102 }
103 }
104 return ret;
105}
106
107static inline int
108futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
109{
110 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
111 return -EFAULT;
112
113 __asm__ __volatile__(
114
115 "1: lock; cmpxchgl %3, %1 \n"
116 "2: .section .fixup, \"ax\" \n"
117 "3: mov %2, %0 \n"
118 " jmp 2b \n"
119 " .previous \n"
120
121 " .section __ex_table, \"a\" \n"
122 " .align 8 \n"
123 _ASM_PTR " 1b,3b \n"
124 " .previous \n"
125
126 : "=a" (oldval), "+m" (*uaddr)
127 : "i" (-EFAULT), "r" (newval), "0" (oldval)
128 : "memory"
129 );
130
131 return oldval;
132}
133
134#endif
5#endif 135#endif
diff --git a/include/asm-x86/futex_32.h b/include/asm-x86/futex_32.h
deleted file mode 100644
index 438ef0ec7101..000000000000
--- a/include/asm-x86/futex_32.h
+++ /dev/null
@@ -1,135 +0,0 @@
1#ifndef _ASM_FUTEX_H
2#define _ASM_FUTEX_H
3
4#ifdef __KERNEL__
5
6#include <linux/futex.h>
7#include <asm/errno.h>
8#include <asm/system.h>
9#include <asm/processor.h>
10#include <asm/uaccess.h>
11
12#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13 __asm__ __volatile ( \
14"1: " insn "\n" \
15"2: .section .fixup,\"ax\"\n\
163: mov %3, %1\n\
17 jmp 2b\n\
18 .previous\n\
19 .section __ex_table,\"a\"\n\
20 .align 8\n\
21 .long 1b,3b\n\
22 .previous" \
23 : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
24 : "i" (-EFAULT), "0" (oparg), "1" (0))
25
26#define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
27 __asm__ __volatile ( \
28"1: movl %2, %0\n\
29 movl %0, %3\n" \
30 insn "\n" \
31"2: " LOCK_PREFIX "cmpxchgl %3, %2\n\
32 jnz 1b\n\
333: .section .fixup,\"ax\"\n\
344: mov %5, %1\n\
35 jmp 3b\n\
36 .previous\n\
37 .section __ex_table,\"a\"\n\
38 .align 8\n\
39 .long 1b,4b,2b,4b\n\
40 .previous" \
41 : "=&a" (oldval), "=&r" (ret), "+m" (*uaddr), \
42 "=&r" (tem) \
43 : "r" (oparg), "i" (-EFAULT), "1" (0))
44
45static inline int
46futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
47{
48 int op = (encoded_op >> 28) & 7;
49 int cmp = (encoded_op >> 24) & 15;
50 int oparg = (encoded_op << 8) >> 20;
51 int cmparg = (encoded_op << 20) >> 20;
52 int oldval = 0, ret, tem;
53 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
54 oparg = 1 << oparg;
55
56 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
57 return -EFAULT;
58
59 pagefault_disable();
60
61 if (op == FUTEX_OP_SET)
62 __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
63 else {
64#ifndef CONFIG_X86_BSWAP
65 if (boot_cpu_data.x86 == 3)
66 ret = -ENOSYS;
67 else
68#endif
69 switch (op) {
70 case FUTEX_OP_ADD:
71 __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret,
72 oldval, uaddr, oparg);
73 break;
74 case FUTEX_OP_OR:
75 __futex_atomic_op2("orl %4, %3", ret, oldval, uaddr,
76 oparg);
77 break;
78 case FUTEX_OP_ANDN:
79 __futex_atomic_op2("andl %4, %3", ret, oldval, uaddr,
80 ~oparg);
81 break;
82 case FUTEX_OP_XOR:
83 __futex_atomic_op2("xorl %4, %3", ret, oldval, uaddr,
84 oparg);
85 break;
86 default:
87 ret = -ENOSYS;
88 }
89 }
90
91 pagefault_enable();
92
93 if (!ret) {
94 switch (cmp) {
95 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
96 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
97 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
98 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
99 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
100 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
101 default: ret = -ENOSYS;
102 }
103 }
104 return ret;
105}
106
107static inline int
108futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
109{
110 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
111 return -EFAULT;
112
113 __asm__ __volatile__(
114 "1: " LOCK_PREFIX "cmpxchgl %3, %1 \n"
115
116 "2: .section .fixup, \"ax\" \n"
117 "3: mov %2, %0 \n"
118 " jmp 2b \n"
119 " .previous \n"
120
121 " .section __ex_table, \"a\" \n"
122 " .align 8 \n"
123 " .long 1b,3b \n"
124 " .previous \n"
125
126 : "=a" (oldval), "+m" (*uaddr)
127 : "i" (-EFAULT), "r" (newval), "0" (oldval)
128 : "memory"
129 );
130
131 return oldval;
132}
133
134#endif
135#endif
diff --git a/include/asm-x86/futex_64.h b/include/asm-x86/futex_64.h
deleted file mode 100644
index 5cdfb08013c3..000000000000
--- a/include/asm-x86/futex_64.h
+++ /dev/null
@@ -1,125 +0,0 @@
1#ifndef _ASM_FUTEX_H
2#define _ASM_FUTEX_H
3
4#ifdef __KERNEL__
5
6#include <linux/futex.h>
7#include <asm/errno.h>
8#include <asm/system.h>
9#include <asm/uaccess.h>
10
11#define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
12 __asm__ __volatile ( \
13"1: " insn "\n" \
14"2: .section .fixup,\"ax\"\n\
153: mov %3, %1\n\
16 jmp 2b\n\
17 .previous\n\
18 .section __ex_table,\"a\"\n\
19 .align 8\n\
20 .quad 1b,3b\n\
21 .previous" \
22 : "=r" (oldval), "=r" (ret), "=m" (*uaddr) \
23 : "i" (-EFAULT), "m" (*uaddr), "0" (oparg), "1" (0))
24
25#define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
26 __asm__ __volatile ( \
27"1: movl %2, %0\n\
28 movl %0, %3\n" \
29 insn "\n" \
30"2: " LOCK_PREFIX "cmpxchgl %3, %2\n\
31 jnz 1b\n\
323: .section .fixup,\"ax\"\n\
334: mov %5, %1\n\
34 jmp 3b\n\
35 .previous\n\
36 .section __ex_table,\"a\"\n\
37 .align 8\n\
38 .quad 1b,4b,2b,4b\n\
39 .previous" \
40 : "=&a" (oldval), "=&r" (ret), "=m" (*uaddr), \
41 "=&r" (tem) \
42 : "r" (oparg), "i" (-EFAULT), "m" (*uaddr), "1" (0))
43
44static inline int
45futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
46{
47 int op = (encoded_op >> 28) & 7;
48 int cmp = (encoded_op >> 24) & 15;
49 int oparg = (encoded_op << 8) >> 20;
50 int cmparg = (encoded_op << 20) >> 20;
51 int oldval = 0, ret, tem;
52 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
53 oparg = 1 << oparg;
54
55 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
56 return -EFAULT;
57
58 pagefault_disable();
59
60 switch (op) {
61 case FUTEX_OP_SET:
62 __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
63 break;
64 case FUTEX_OP_ADD:
65 __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
66 uaddr, oparg);
67 break;
68 case FUTEX_OP_OR:
69 __futex_atomic_op2("orl %4, %3", ret, oldval, uaddr, oparg);
70 break;
71 case FUTEX_OP_ANDN:
72 __futex_atomic_op2("andl %4, %3", ret, oldval, uaddr, ~oparg);
73 break;
74 case FUTEX_OP_XOR:
75 __futex_atomic_op2("xorl %4, %3", ret, oldval, uaddr, oparg);
76 break;
77 default:
78 ret = -ENOSYS;
79 }
80
81 pagefault_enable();
82
83 if (!ret) {
84 switch (cmp) {
85 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
86 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
87 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
88 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
89 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
90 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
91 default: ret = -ENOSYS;
92 }
93 }
94 return ret;
95}
96
97static inline int
98futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
99{
100 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
101 return -EFAULT;
102
103 __asm__ __volatile__(
104 "1: " LOCK_PREFIX "cmpxchgl %3, %1 \n"
105
106 "2: .section .fixup, \"ax\" \n"
107 "3: mov %2, %0 \n"
108 " jmp 2b \n"
109 " .previous \n"
110
111 " .section __ex_table, \"a\" \n"
112 " .align 8 \n"
113 " .quad 1b,3b \n"
114 " .previous \n"
115
116 : "=a" (oldval), "=m" (*uaddr)
117 : "i" (-EFAULT), "r" (newval), "0" (oldval)
118 : "memory"
119 );
120
121 return oldval;
122}
123
124#endif
125#endif
diff --git a/include/asm-x86/gart.h b/include/asm-x86/gart.h
new file mode 100644
index 000000000000..90958ed993fa
--- /dev/null
+++ b/include/asm-x86/gart.h
@@ -0,0 +1,34 @@
1#ifndef _ASM_X8664_IOMMU_H
2#define _ASM_X8664_IOMMU_H 1
3
4extern void pci_iommu_shutdown(void);
5extern void no_iommu_init(void);
6extern int force_iommu, no_iommu;
7extern int iommu_detected;
8#ifdef CONFIG_GART_IOMMU
9extern void gart_iommu_init(void);
10extern void gart_iommu_shutdown(void);
11extern void __init gart_parse_options(char *);
12extern void early_gart_iommu_check(void);
13extern void gart_iommu_hole_init(void);
14extern int fallback_aper_order;
15extern int fallback_aper_force;
16extern int gart_iommu_aperture;
17extern int gart_iommu_aperture_allowed;
18extern int gart_iommu_aperture_disabled;
19extern int fix_aperture;
20#else
21#define gart_iommu_aperture 0
22#define gart_iommu_aperture_allowed 0
23
24static inline void early_gart_iommu_check(void)
25{
26}
27
28static inline void gart_iommu_shutdown(void)
29{
30}
31
32#endif
33
34#endif
diff --git a/include/asm-x86/geode.h b/include/asm-x86/geode.h
index 771af336734f..811fe14f70b2 100644
--- a/include/asm-x86/geode.h
+++ b/include/asm-x86/geode.h
@@ -121,9 +121,15 @@ extern int geode_get_dev_base(unsigned int dev);
121#define GPIO_MAP_Z 0xE8 121#define GPIO_MAP_Z 0xE8
122#define GPIO_MAP_W 0xEC 122#define GPIO_MAP_W 0xEC
123 123
124extern void geode_gpio_set(unsigned int, unsigned int); 124static inline u32 geode_gpio(unsigned int nr)
125extern void geode_gpio_clear(unsigned int, unsigned int); 125{
126extern int geode_gpio_isset(unsigned int, unsigned int); 126 BUG_ON(nr > 28);
127 return 1 << nr;
128}
129
130extern void geode_gpio_set(u32, unsigned int);
131extern void geode_gpio_clear(u32, unsigned int);
132extern int geode_gpio_isset(u32, unsigned int);
127extern void geode_gpio_setup_event(unsigned int, int, int); 133extern void geode_gpio_setup_event(unsigned int, int, int);
128extern void geode_gpio_set_irq(unsigned int, unsigned int); 134extern void geode_gpio_set_irq(unsigned int, unsigned int);
129 135
diff --git a/include/asm-x86/gpio.h b/include/asm-x86/gpio.h
new file mode 100644
index 000000000000..ff87fca0caf9
--- /dev/null
+++ b/include/asm-x86/gpio.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_I386_GPIO_H
2#define _ASM_I386_GPIO_H
3
4#include <gpio.h>
5
6#endif /* _ASM_I386_GPIO_H */
diff --git a/include/asm-x86/hpet.h b/include/asm-x86/hpet.h
index b1f3c1ea55d9..6a9b4ac59bf7 100644
--- a/include/asm-x86/hpet.h
+++ b/include/asm-x86/hpet.h
@@ -61,6 +61,7 @@ extern unsigned long force_hpet_address;
61extern int hpet_force_user; 61extern int hpet_force_user;
62extern int is_hpet_enabled(void); 62extern int is_hpet_enabled(void);
63extern int hpet_enable(void); 63extern int hpet_enable(void);
64extern void hpet_disable(void);
64extern unsigned long hpet_readl(unsigned long a); 65extern unsigned long hpet_readl(unsigned long a);
65extern void force_hpet_resume(void); 66extern void force_hpet_resume(void);
66 67
@@ -68,6 +69,7 @@ extern void force_hpet_resume(void);
68 69
69#include <linux/interrupt.h> 70#include <linux/interrupt.h>
70 71
72typedef irqreturn_t (*rtc_irq_handler)(int interrupt, void *cookie);
71extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); 73extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
72extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); 74extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
73extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, 75extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min,
@@ -76,13 +78,16 @@ extern int hpet_set_periodic_freq(unsigned long freq);
76extern int hpet_rtc_dropped_irq(void); 78extern int hpet_rtc_dropped_irq(void);
77extern int hpet_rtc_timer_init(void); 79extern int hpet_rtc_timer_init(void);
78extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); 80extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
81extern int hpet_register_irq_handler(rtc_irq_handler handler);
82extern void hpet_unregister_irq_handler(rtc_irq_handler handler);
79 83
80#endif /* CONFIG_HPET_EMULATE_RTC */ 84#endif /* CONFIG_HPET_EMULATE_RTC */
81 85
82#else 86#else /* CONFIG_HPET_TIMER */
83 87
84static inline int hpet_enable(void) { return 0; } 88static inline int hpet_enable(void) { return 0; }
85static inline unsigned long hpet_readl(unsigned long a) { return 0; } 89static inline unsigned long hpet_readl(unsigned long a) { return 0; }
90static inline int is_hpet_enabled(void) { return 0; }
86 91
87#endif /* CONFIG_HPET_TIMER */ 92#endif
88#endif /* ASM_X86_HPET_H */ 93#endif /* ASM_X86_HPET_H */
diff --git a/include/asm-x86/hw_irq_32.h b/include/asm-x86/hw_irq_32.h
index 0bedbdf5e907..6d65fbb6358b 100644
--- a/include/asm-x86/hw_irq_32.h
+++ b/include/asm-x86/hw_irq_32.h
@@ -26,19 +26,19 @@
26 * Interrupt entry/exit code at both C and assembly level 26 * Interrupt entry/exit code at both C and assembly level
27 */ 27 */
28 28
29extern void (*interrupt[NR_IRQS])(void); 29extern void (*const interrupt[NR_IRQS])(void);
30 30
31#ifdef CONFIG_SMP 31#ifdef CONFIG_SMP
32fastcall void reschedule_interrupt(void); 32void reschedule_interrupt(void);
33fastcall void invalidate_interrupt(void); 33void invalidate_interrupt(void);
34fastcall void call_function_interrupt(void); 34void call_function_interrupt(void);
35#endif 35#endif
36 36
37#ifdef CONFIG_X86_LOCAL_APIC 37#ifdef CONFIG_X86_LOCAL_APIC
38fastcall void apic_timer_interrupt(void); 38void apic_timer_interrupt(void);
39fastcall void error_interrupt(void); 39void error_interrupt(void);
40fastcall void spurious_interrupt(void); 40void spurious_interrupt(void);
41fastcall void thermal_interrupt(void); 41void thermal_interrupt(void);
42#define platform_legacy_irq(irq) ((irq) < 16) 42#define platform_legacy_irq(irq) ((irq) < 16)
43#endif 43#endif
44 44
diff --git a/include/asm-x86/hw_irq_64.h b/include/asm-x86/hw_irq_64.h
index a470d59da678..312a58d6dac6 100644
--- a/include/asm-x86/hw_irq_64.h
+++ b/include/asm-x86/hw_irq_64.h
@@ -135,11 +135,13 @@ extern void init_8259A(int aeoi);
135extern void send_IPI_self(int vector); 135extern void send_IPI_self(int vector);
136extern void init_VISWS_APIC_irqs(void); 136extern void init_VISWS_APIC_irqs(void);
137extern void setup_IO_APIC(void); 137extern void setup_IO_APIC(void);
138extern void enable_IO_APIC(void);
138extern void disable_IO_APIC(void); 139extern void disable_IO_APIC(void);
139extern void print_IO_APIC(void); 140extern void print_IO_APIC(void);
140extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn); 141extern int IO_APIC_get_PCI_irq_vector(int bus, int slot, int fn);
141extern void send_IPI(int dest, int vector); 142extern void send_IPI(int dest, int vector);
142extern void setup_ioapic_dest(void); 143extern void setup_ioapic_dest(void);
144extern void native_init_IRQ(void);
143 145
144extern unsigned long io_apic_irqs; 146extern unsigned long io_apic_irqs;
145 147
diff --git a/include/asm-x86/i387.h b/include/asm-x86/i387.h
index a8bbed349664..ba8105ca822b 100644
--- a/include/asm-x86/i387.h
+++ b/include/asm-x86/i387.h
@@ -1,5 +1,360 @@
1#ifdef CONFIG_X86_32 1/*
2# include "i387_32.h" 2 * Copyright (C) 1994 Linus Torvalds
3 *
4 * Pentium III FXSR, SSE support
5 * General FPU state handling cleanups
6 * Gareth Hughes <gareth@valinux.com>, May 2000
7 * x86-64 work by Andi Kleen 2002
8 */
9
10#ifndef _ASM_X86_I387_H
11#define _ASM_X86_I387_H
12
13#include <linux/sched.h>
14#include <linux/kernel_stat.h>
15#include <linux/regset.h>
16#include <asm/processor.h>
17#include <asm/sigcontext.h>
18#include <asm/user.h>
19#include <asm/uaccess.h>
20
21extern void fpu_init(void);
22extern unsigned int mxcsr_feature_mask;
23extern void mxcsr_feature_mask_init(void);
24extern void init_fpu(struct task_struct *child);
25extern asmlinkage void math_state_restore(void);
26
27extern user_regset_active_fn fpregs_active, xfpregs_active;
28extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get;
29extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set;
30
31#ifdef CONFIG_IA32_EMULATION
32struct _fpstate_ia32;
33extern int save_i387_ia32(struct _fpstate_ia32 __user *buf);
34extern int restore_i387_ia32(struct _fpstate_ia32 __user *buf);
35#endif
36
37#ifdef CONFIG_X86_64
38
39/* Ignore delayed exceptions from user space */
40static inline void tolerant_fwait(void)
41{
42 asm volatile("1: fwait\n"
43 "2:\n"
44 " .section __ex_table,\"a\"\n"
45 " .align 8\n"
46 " .quad 1b,2b\n"
47 " .previous\n");
48}
49
50static inline int restore_fpu_checking(struct i387_fxsave_struct *fx)
51{
52 int err;
53
54 asm volatile("1: rex64/fxrstor (%[fx])\n\t"
55 "2:\n"
56 ".section .fixup,\"ax\"\n"
57 "3: movl $-1,%[err]\n"
58 " jmp 2b\n"
59 ".previous\n"
60 ".section __ex_table,\"a\"\n"
61 " .align 8\n"
62 " .quad 1b,3b\n"
63 ".previous"
64 : [err] "=r" (err)
65#if 0 /* See comment in __save_init_fpu() below. */
66 : [fx] "r" (fx), "m" (*fx), "0" (0));
67#else
68 : [fx] "cdaSDb" (fx), "m" (*fx), "0" (0));
69#endif
70 if (unlikely(err))
71 init_fpu(current);
72 return err;
73}
74
75#define X87_FSW_ES (1 << 7) /* Exception Summary */
76
77/* AMD CPUs don't save/restore FDP/FIP/FOP unless an exception
78 is pending. Clear the x87 state here by setting it to fixed
79 values. The kernel data segment can be sometimes 0 and sometimes
80 new user value. Both should be ok.
81 Use the PDA as safe address because it should be already in L1. */
82static inline void clear_fpu_state(struct i387_fxsave_struct *fx)
83{
84 if (unlikely(fx->swd & X87_FSW_ES))
85 asm volatile("fnclex");
86 alternative_input(ASM_NOP8 ASM_NOP2,
87 " emms\n" /* clear stack tags */
88 " fildl %%gs:0", /* load to clear state */
89 X86_FEATURE_FXSAVE_LEAK);
90}
91
92static inline int save_i387_checking(struct i387_fxsave_struct __user *fx)
93{
94 int err;
95
96 asm volatile("1: rex64/fxsave (%[fx])\n\t"
97 "2:\n"
98 ".section .fixup,\"ax\"\n"
99 "3: movl $-1,%[err]\n"
100 " jmp 2b\n"
101 ".previous\n"
102 ".section __ex_table,\"a\"\n"
103 " .align 8\n"
104 " .quad 1b,3b\n"
105 ".previous"
106 : [err] "=r" (err), "=m" (*fx)
107#if 0 /* See comment in __fxsave_clear() below. */
108 : [fx] "r" (fx), "0" (0));
109#else
110 : [fx] "cdaSDb" (fx), "0" (0));
111#endif
112 if (unlikely(err) && __clear_user(fx, sizeof(struct i387_fxsave_struct)))
113 err = -EFAULT;
114 /* No need to clear here because the caller clears USED_MATH */
115 return err;
116}
117
118static inline void __save_init_fpu(struct task_struct *tsk)
119{
120 /* Using "rex64; fxsave %0" is broken because, if the memory operand
121 uses any extended registers for addressing, a second REX prefix
122 will be generated (to the assembler, rex64 followed by semicolon
123 is a separate instruction), and hence the 64-bitness is lost. */
124#if 0
125 /* Using "fxsaveq %0" would be the ideal choice, but is only supported
126 starting with gas 2.16. */
127 __asm__ __volatile__("fxsaveq %0"
128 : "=m" (tsk->thread.i387.fxsave));
129#elif 0
130 /* Using, as a workaround, the properly prefixed form below isn't
131 accepted by any binutils version so far released, complaining that
132 the same type of prefix is used twice if an extended register is
133 needed for addressing (fix submitted to mainline 2005-11-21). */
134 __asm__ __volatile__("rex64/fxsave %0"
135 : "=m" (tsk->thread.i387.fxsave));
136#else
137 /* This, however, we can work around by forcing the compiler to select
138 an addressing mode that doesn't require extended registers. */
139 __asm__ __volatile__("rex64/fxsave %P2(%1)"
140 : "=m" (tsk->thread.i387.fxsave)
141 : "cdaSDb" (tsk),
142 "i" (offsetof(__typeof__(*tsk),
143 thread.i387.fxsave)));
144#endif
145 clear_fpu_state(&tsk->thread.i387.fxsave);
146 task_thread_info(tsk)->status &= ~TS_USEDFPU;
147}
148
149/*
150 * Signal frame handlers.
151 */
152
153static inline int save_i387(struct _fpstate __user *buf)
154{
155 struct task_struct *tsk = current;
156 int err = 0;
157
158 BUILD_BUG_ON(sizeof(struct user_i387_struct) !=
159 sizeof(tsk->thread.i387.fxsave));
160
161 if ((unsigned long)buf % 16)
162 printk("save_i387: bad fpstate %p\n", buf);
163
164 if (!used_math())
165 return 0;
166 clear_used_math(); /* trigger finit */
167 if (task_thread_info(tsk)->status & TS_USEDFPU) {
168 err = save_i387_checking((struct i387_fxsave_struct __user *)buf);
169 if (err) return err;
170 task_thread_info(tsk)->status &= ~TS_USEDFPU;
171 stts();
172 } else {
173 if (__copy_to_user(buf, &tsk->thread.i387.fxsave,
174 sizeof(struct i387_fxsave_struct)))
175 return -1;
176 }
177 return 1;
178}
179
180/*
181 * This restores directly out of user space. Exceptions are handled.
182 */
183static inline int restore_i387(struct _fpstate __user *buf)
184{
185 set_used_math();
186 if (!(task_thread_info(current)->status & TS_USEDFPU)) {
187 clts();
188 task_thread_info(current)->status |= TS_USEDFPU;
189 }
190 return restore_fpu_checking((__force struct i387_fxsave_struct *)buf);
191}
192
193#else /* CONFIG_X86_32 */
194
195static inline void tolerant_fwait(void)
196{
197 asm volatile("fnclex ; fwait");
198}
199
200static inline void restore_fpu(struct task_struct *tsk)
201{
202 /*
203 * The "nop" is needed to make the instructions the same
204 * length.
205 */
206 alternative_input(
207 "nop ; frstor %1",
208 "fxrstor %1",
209 X86_FEATURE_FXSR,
210 "m" ((tsk)->thread.i387.fxsave));
211}
212
213/* We need a safe address that is cheap to find and that is already
214 in L1 during context switch. The best choices are unfortunately
215 different for UP and SMP */
216#ifdef CONFIG_SMP
217#define safe_address (__per_cpu_offset[0])
3#else 218#else
4# include "i387_64.h" 219#define safe_address (kstat_cpu(0).cpustat.user)
5#endif 220#endif
221
222/*
223 * These must be called with preempt disabled
224 */
225static inline void __save_init_fpu(struct task_struct *tsk)
226{
227 /* Use more nops than strictly needed in case the compiler
228 varies code */
229 alternative_input(
230 "fnsave %[fx] ;fwait;" GENERIC_NOP8 GENERIC_NOP4,
231 "fxsave %[fx]\n"
232 "bt $7,%[fsw] ; jnc 1f ; fnclex\n1:",
233 X86_FEATURE_FXSR,
234 [fx] "m" (tsk->thread.i387.fxsave),
235 [fsw] "m" (tsk->thread.i387.fxsave.swd) : "memory");
236 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
237 is pending. Clear the x87 state here by setting it to fixed
238 values. safe_address is a random variable that should be in L1 */
239 alternative_input(
240 GENERIC_NOP8 GENERIC_NOP2,
241 "emms\n\t" /* clear stack tags */
242 "fildl %[addr]", /* set F?P to defined value */
243 X86_FEATURE_FXSAVE_LEAK,
244 [addr] "m" (safe_address));
245 task_thread_info(tsk)->status &= ~TS_USEDFPU;
246}
247
248/*
249 * Signal frame handlers...
250 */
251extern int save_i387(struct _fpstate __user *buf);
252extern int restore_i387(struct _fpstate __user *buf);
253
254#endif /* CONFIG_X86_64 */
255
256static inline void __unlazy_fpu(struct task_struct *tsk)
257{
258 if (task_thread_info(tsk)->status & TS_USEDFPU) {
259 __save_init_fpu(tsk);
260 stts();
261 } else
262 tsk->fpu_counter = 0;
263}
264
265static inline void __clear_fpu(struct task_struct *tsk)
266{
267 if (task_thread_info(tsk)->status & TS_USEDFPU) {
268 tolerant_fwait();
269 task_thread_info(tsk)->status &= ~TS_USEDFPU;
270 stts();
271 }
272}
273
274static inline void kernel_fpu_begin(void)
275{
276 struct thread_info *me = current_thread_info();
277 preempt_disable();
278 if (me->status & TS_USEDFPU)
279 __save_init_fpu(me->task);
280 else
281 clts();
282}
283
284static inline void kernel_fpu_end(void)
285{
286 stts();
287 preempt_enable();
288}
289
290#ifdef CONFIG_X86_64
291
292static inline void save_init_fpu(struct task_struct *tsk)
293{
294 __save_init_fpu(tsk);
295 stts();
296}
297
298#define unlazy_fpu __unlazy_fpu
299#define clear_fpu __clear_fpu
300
301#else /* CONFIG_X86_32 */
302
303/*
304 * These disable preemption on their own and are safe
305 */
306static inline void save_init_fpu(struct task_struct *tsk)
307{
308 preempt_disable();
309 __save_init_fpu(tsk);
310 stts();
311 preempt_enable();
312}
313
314static inline void unlazy_fpu(struct task_struct *tsk)
315{
316 preempt_disable();
317 __unlazy_fpu(tsk);
318 preempt_enable();
319}
320
321static inline void clear_fpu(struct task_struct *tsk)
322{
323 preempt_disable();
324 __clear_fpu(tsk);
325 preempt_enable();
326}
327
328#endif /* CONFIG_X86_64 */
329
330/*
331 * i387 state interaction
332 */
333static inline unsigned short get_fpu_cwd(struct task_struct *tsk)
334{
335 if (cpu_has_fxsr) {
336 return tsk->thread.i387.fxsave.cwd;
337 } else {
338 return (unsigned short)tsk->thread.i387.fsave.cwd;
339 }
340}
341
342static inline unsigned short get_fpu_swd(struct task_struct *tsk)
343{
344 if (cpu_has_fxsr) {
345 return tsk->thread.i387.fxsave.swd;
346 } else {
347 return (unsigned short)tsk->thread.i387.fsave.swd;
348 }
349}
350
351static inline unsigned short get_fpu_mxcsr(struct task_struct *tsk)
352{
353 if (cpu_has_xmm) {
354 return tsk->thread.i387.fxsave.mxcsr;
355 } else {
356 return MXCSR_DEFAULT;
357 }
358}
359
360#endif /* _ASM_X86_I387_H */
diff --git a/include/asm-x86/i387_32.h b/include/asm-x86/i387_32.h
deleted file mode 100644
index cdd1e248e3b4..000000000000
--- a/include/asm-x86/i387_32.h
+++ /dev/null
@@ -1,151 +0,0 @@
1/*
2 * include/asm-i386/i387.h
3 *
4 * Copyright (C) 1994 Linus Torvalds
5 *
6 * Pentium III FXSR, SSE support
7 * General FPU state handling cleanups
8 * Gareth Hughes <gareth@valinux.com>, May 2000
9 */
10
11#ifndef __ASM_I386_I387_H
12#define __ASM_I386_I387_H
13
14#include <linux/sched.h>
15#include <linux/init.h>
16#include <linux/kernel_stat.h>
17#include <asm/processor.h>
18#include <asm/sigcontext.h>
19#include <asm/user.h>
20
21extern void mxcsr_feature_mask_init(void);
22extern void init_fpu(struct task_struct *);
23
24/*
25 * FPU lazy state save handling...
26 */
27
28/*
29 * The "nop" is needed to make the instructions the same
30 * length.
31 */
32#define restore_fpu(tsk) \
33 alternative_input( \
34 "nop ; frstor %1", \
35 "fxrstor %1", \
36 X86_FEATURE_FXSR, \
37 "m" ((tsk)->thread.i387.fxsave))
38
39extern void kernel_fpu_begin(void);
40#define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
41
42/* We need a safe address that is cheap to find and that is already
43 in L1 during context switch. The best choices are unfortunately
44 different for UP and SMP */
45#ifdef CONFIG_SMP
46#define safe_address (__per_cpu_offset[0])
47#else
48#define safe_address (kstat_cpu(0).cpustat.user)
49#endif
50
51/*
52 * These must be called with preempt disabled
53 */
54static inline void __save_init_fpu( struct task_struct *tsk )
55{
56 /* Use more nops than strictly needed in case the compiler
57 varies code */
58 alternative_input(
59 "fnsave %[fx] ;fwait;" GENERIC_NOP8 GENERIC_NOP4,
60 "fxsave %[fx]\n"
61 "bt $7,%[fsw] ; jnc 1f ; fnclex\n1:",
62 X86_FEATURE_FXSR,
63 [fx] "m" (tsk->thread.i387.fxsave),
64 [fsw] "m" (tsk->thread.i387.fxsave.swd) : "memory");
65 /* AMD K7/K8 CPUs don't save/restore FDP/FIP/FOP unless an exception
66 is pending. Clear the x87 state here by setting it to fixed
67 values. safe_address is a random variable that should be in L1 */
68 alternative_input(
69 GENERIC_NOP8 GENERIC_NOP2,
70 "emms\n\t" /* clear stack tags */
71 "fildl %[addr]", /* set F?P to defined value */
72 X86_FEATURE_FXSAVE_LEAK,
73 [addr] "m" (safe_address));
74 task_thread_info(tsk)->status &= ~TS_USEDFPU;
75}
76
77#define __unlazy_fpu( tsk ) do { \
78 if (task_thread_info(tsk)->status & TS_USEDFPU) { \
79 __save_init_fpu(tsk); \
80 stts(); \
81 } else \
82 tsk->fpu_counter = 0; \
83} while (0)
84
85#define __clear_fpu( tsk ) \
86do { \
87 if (task_thread_info(tsk)->status & TS_USEDFPU) { \
88 asm volatile("fnclex ; fwait"); \
89 task_thread_info(tsk)->status &= ~TS_USEDFPU; \
90 stts(); \
91 } \
92} while (0)
93
94
95/*
96 * These disable preemption on their own and are safe
97 */
98static inline void save_init_fpu( struct task_struct *tsk )
99{
100 preempt_disable();
101 __save_init_fpu(tsk);
102 stts();
103 preempt_enable();
104}
105
106#define unlazy_fpu( tsk ) do { \
107 preempt_disable(); \
108 __unlazy_fpu(tsk); \
109 preempt_enable(); \
110} while (0)
111
112#define clear_fpu( tsk ) do { \
113 preempt_disable(); \
114 __clear_fpu( tsk ); \
115 preempt_enable(); \
116} while (0)
117
118/*
119 * FPU state interaction...
120 */
121extern unsigned short get_fpu_cwd( struct task_struct *tsk );
122extern unsigned short get_fpu_swd( struct task_struct *tsk );
123extern unsigned short get_fpu_mxcsr( struct task_struct *tsk );
124extern asmlinkage void math_state_restore(void);
125
126/*
127 * Signal frame handlers...
128 */
129extern int save_i387( struct _fpstate __user *buf );
130extern int restore_i387( struct _fpstate __user *buf );
131
132/*
133 * ptrace request handers...
134 */
135extern int get_fpregs( struct user_i387_struct __user *buf,
136 struct task_struct *tsk );
137extern int set_fpregs( struct task_struct *tsk,
138 struct user_i387_struct __user *buf );
139
140extern int get_fpxregs( struct user_fxsr_struct __user *buf,
141 struct task_struct *tsk );
142extern int set_fpxregs( struct task_struct *tsk,
143 struct user_fxsr_struct __user *buf );
144
145/*
146 * FPU state for core dumps...
147 */
148extern int dump_fpu( struct pt_regs *regs,
149 struct user_i387_struct *fpu );
150
151#endif /* __ASM_I386_I387_H */
diff --git a/include/asm-x86/i387_64.h b/include/asm-x86/i387_64.h
deleted file mode 100644
index 0217b74cc9fc..000000000000
--- a/include/asm-x86/i387_64.h
+++ /dev/null
@@ -1,209 +0,0 @@
1/*
2 * include/asm-x86_64/i387.h
3 *
4 * Copyright (C) 1994 Linus Torvalds
5 *
6 * Pentium III FXSR, SSE support
7 * General FPU state handling cleanups
8 * Gareth Hughes <gareth@valinux.com>, May 2000
9 * x86-64 work by Andi Kleen 2002
10 */
11
12#ifndef __ASM_X86_64_I387_H
13#define __ASM_X86_64_I387_H
14
15#include <linux/sched.h>
16#include <asm/processor.h>
17#include <asm/sigcontext.h>
18#include <asm/user.h>
19#include <asm/thread_info.h>
20#include <asm/uaccess.h>
21
22extern void fpu_init(void);
23extern unsigned int mxcsr_feature_mask;
24extern void mxcsr_feature_mask_init(void);
25extern void init_fpu(struct task_struct *child);
26extern int save_i387(struct _fpstate __user *buf);
27extern asmlinkage void math_state_restore(void);
28
29/*
30 * FPU lazy state save handling...
31 */
32
33#define unlazy_fpu(tsk) do { \
34 if (task_thread_info(tsk)->status & TS_USEDFPU) \
35 save_init_fpu(tsk); \
36 else \
37 tsk->fpu_counter = 0; \
38} while (0)
39
40/* Ignore delayed exceptions from user space */
41static inline void tolerant_fwait(void)
42{
43 asm volatile("1: fwait\n"
44 "2:\n"
45 " .section __ex_table,\"a\"\n"
46 " .align 8\n"
47 " .quad 1b,2b\n"
48 " .previous\n");
49}
50
51#define clear_fpu(tsk) do { \
52 if (task_thread_info(tsk)->status & TS_USEDFPU) { \
53 tolerant_fwait(); \
54 task_thread_info(tsk)->status &= ~TS_USEDFPU; \
55 stts(); \
56 } \
57} while (0)
58
59/*
60 * ptrace request handers...
61 */
62extern int get_fpregs(struct user_i387_struct __user *buf,
63 struct task_struct *tsk);
64extern int set_fpregs(struct task_struct *tsk,
65 struct user_i387_struct __user *buf);
66
67/*
68 * i387 state interaction
69 */
70#define get_fpu_mxcsr(t) ((t)->thread.i387.fxsave.mxcsr)
71#define get_fpu_cwd(t) ((t)->thread.i387.fxsave.cwd)
72#define get_fpu_fxsr_twd(t) ((t)->thread.i387.fxsave.twd)
73#define get_fpu_swd(t) ((t)->thread.i387.fxsave.swd)
74#define set_fpu_cwd(t,val) ((t)->thread.i387.fxsave.cwd = (val))
75#define set_fpu_swd(t,val) ((t)->thread.i387.fxsave.swd = (val))
76#define set_fpu_fxsr_twd(t,val) ((t)->thread.i387.fxsave.twd = (val))
77
78#define X87_FSW_ES (1 << 7) /* Exception Summary */
79
80/* AMD CPUs don't save/restore FDP/FIP/FOP unless an exception
81 is pending. Clear the x87 state here by setting it to fixed
82 values. The kernel data segment can be sometimes 0 and sometimes
83 new user value. Both should be ok.
84 Use the PDA as safe address because it should be already in L1. */
85static inline void clear_fpu_state(struct i387_fxsave_struct *fx)
86{
87 if (unlikely(fx->swd & X87_FSW_ES))
88 asm volatile("fnclex");
89 alternative_input(ASM_NOP8 ASM_NOP2,
90 " emms\n" /* clear stack tags */
91 " fildl %%gs:0", /* load to clear state */
92 X86_FEATURE_FXSAVE_LEAK);
93}
94
95static inline int restore_fpu_checking(struct i387_fxsave_struct *fx)
96{
97 int err;
98
99 asm volatile("1: rex64/fxrstor (%[fx])\n\t"
100 "2:\n"
101 ".section .fixup,\"ax\"\n"
102 "3: movl $-1,%[err]\n"
103 " jmp 2b\n"
104 ".previous\n"
105 ".section __ex_table,\"a\"\n"
106 " .align 8\n"
107 " .quad 1b,3b\n"
108 ".previous"
109 : [err] "=r" (err)
110#if 0 /* See comment in __fxsave_clear() below. */
111 : [fx] "r" (fx), "m" (*fx), "0" (0));
112#else
113 : [fx] "cdaSDb" (fx), "m" (*fx), "0" (0));
114#endif
115 if (unlikely(err))
116 init_fpu(current);
117 return err;
118}
119
120static inline int save_i387_checking(struct i387_fxsave_struct __user *fx)
121{
122 int err;
123
124 asm volatile("1: rex64/fxsave (%[fx])\n\t"
125 "2:\n"
126 ".section .fixup,\"ax\"\n"
127 "3: movl $-1,%[err]\n"
128 " jmp 2b\n"
129 ".previous\n"
130 ".section __ex_table,\"a\"\n"
131 " .align 8\n"
132 " .quad 1b,3b\n"
133 ".previous"
134 : [err] "=r" (err), "=m" (*fx)
135#if 0 /* See comment in __fxsave_clear() below. */
136 : [fx] "r" (fx), "0" (0));
137#else
138 : [fx] "cdaSDb" (fx), "0" (0));
139#endif
140 if (unlikely(err) && __clear_user(fx, sizeof(struct i387_fxsave_struct)))
141 err = -EFAULT;
142 /* No need to clear here because the caller clears USED_MATH */
143 return err;
144}
145
146static inline void __fxsave_clear(struct task_struct *tsk)
147{
148 /* Using "rex64; fxsave %0" is broken because, if the memory operand
149 uses any extended registers for addressing, a second REX prefix
150 will be generated (to the assembler, rex64 followed by semicolon
151 is a separate instruction), and hence the 64-bitness is lost. */
152#if 0
153 /* Using "fxsaveq %0" would be the ideal choice, but is only supported
154 starting with gas 2.16. */
155 __asm__ __volatile__("fxsaveq %0"
156 : "=m" (tsk->thread.i387.fxsave));
157#elif 0
158 /* Using, as a workaround, the properly prefixed form below isn't
159 accepted by any binutils version so far released, complaining that
160 the same type of prefix is used twice if an extended register is
161 needed for addressing (fix submitted to mainline 2005-11-21). */
162 __asm__ __volatile__("rex64/fxsave %0"
163 : "=m" (tsk->thread.i387.fxsave));
164#else
165 /* This, however, we can work around by forcing the compiler to select
166 an addressing mode that doesn't require extended registers. */
167 __asm__ __volatile__("rex64/fxsave %P2(%1)"
168 : "=m" (tsk->thread.i387.fxsave)
169 : "cdaSDb" (tsk),
170 "i" (offsetof(__typeof__(*tsk),
171 thread.i387.fxsave)));
172#endif
173 clear_fpu_state(&tsk->thread.i387.fxsave);
174}
175
176static inline void kernel_fpu_begin(void)
177{
178 struct thread_info *me = current_thread_info();
179 preempt_disable();
180 if (me->status & TS_USEDFPU) {
181 __fxsave_clear(me->task);
182 me->status &= ~TS_USEDFPU;
183 return;
184 }
185 clts();
186}
187
188static inline void kernel_fpu_end(void)
189{
190 stts();
191 preempt_enable();
192}
193
194static inline void save_init_fpu(struct task_struct *tsk)
195{
196 __fxsave_clear(tsk);
197 task_thread_info(tsk)->status &= ~TS_USEDFPU;
198 stts();
199}
200
201/*
202 * This restores directly out of user space. Exceptions are handled.
203 */
204static inline int restore_i387(struct _fpstate __user *buf)
205{
206 return restore_fpu_checking((__force struct i387_fxsave_struct *)buf);
207}
208
209#endif /* __ASM_X86_64_I387_H */
diff --git a/include/asm-x86/i8253.h b/include/asm-x86/i8253.h
index 747548ec5d1d..b51c0487fc41 100644
--- a/include/asm-x86/i8253.h
+++ b/include/asm-x86/i8253.h
@@ -12,4 +12,7 @@ extern struct clock_event_device *global_clock_event;
12 12
13extern void setup_pit_timer(void); 13extern void setup_pit_timer(void);
14 14
15#define inb_pit inb_p
16#define outb_pit outb_p
17
15#endif /* __ASM_I8253_H__ */ 18#endif /* __ASM_I8253_H__ */
diff --git a/include/asm-x86/i8259.h b/include/asm-x86/i8259.h
index 29d8f9a6b3fc..67c319e0efc7 100644
--- a/include/asm-x86/i8259.h
+++ b/include/asm-x86/i8259.h
@@ -3,10 +3,25 @@
3 3
4extern unsigned int cached_irq_mask; 4extern unsigned int cached_irq_mask;
5 5
6#define __byte(x,y) (((unsigned char *) &(y))[x]) 6#define __byte(x,y) (((unsigned char *) &(y))[x])
7#define cached_master_mask (__byte(0, cached_irq_mask)) 7#define cached_master_mask (__byte(0, cached_irq_mask))
8#define cached_slave_mask (__byte(1, cached_irq_mask)) 8#define cached_slave_mask (__byte(1, cached_irq_mask))
9 9
10/* i8259A PIC registers */
11#define PIC_MASTER_CMD 0x20
12#define PIC_MASTER_IMR 0x21
13#define PIC_MASTER_ISR PIC_MASTER_CMD
14#define PIC_MASTER_POLL PIC_MASTER_ISR
15#define PIC_MASTER_OCW3 PIC_MASTER_ISR
16#define PIC_SLAVE_CMD 0xa0
17#define PIC_SLAVE_IMR 0xa1
18
19/* i8259A PIC related value */
20#define PIC_CASCADE_IR 2
21#define MASTER_ICW4_DEFAULT 0x01
22#define SLAVE_ICW4_DEFAULT 0x01
23#define PIC_ICW4_AEOI 2
24
10extern spinlock_t i8259A_lock; 25extern spinlock_t i8259A_lock;
11 26
12extern void init_8259A(int auto_eoi); 27extern void init_8259A(int auto_eoi);
@@ -14,4 +29,7 @@ extern void enable_8259A_irq(unsigned int irq);
14extern void disable_8259A_irq(unsigned int irq); 29extern void disable_8259A_irq(unsigned int irq);
15extern unsigned int startup_8259A_irq(unsigned int irq); 30extern unsigned int startup_8259A_irq(unsigned int irq);
16 31
32#define inb_pic inb_p
33#define outb_pic outb_p
34
17#endif /* __ASM_I8259_H__ */ 35#endif /* __ASM_I8259_H__ */
diff --git a/include/asm-x86/ia32.h b/include/asm-x86/ia32.h
index 0190b7c4e319..aa9733206e29 100644
--- a/include/asm-x86/ia32.h
+++ b/include/asm-x86/ia32.h
@@ -159,12 +159,6 @@ struct ustat32 {
159#define IA32_STACK_TOP IA32_PAGE_OFFSET 159#define IA32_STACK_TOP IA32_PAGE_OFFSET
160 160
161#ifdef __KERNEL__ 161#ifdef __KERNEL__
162struct user_desc;
163struct siginfo_t;
164int do_get_thread_area(struct thread_struct *t, struct user_desc __user *info);
165int do_set_thread_area(struct thread_struct *t, struct user_desc __user *info);
166int ia32_child_tls(struct task_struct *p, struct pt_regs *childregs);
167
168struct linux_binprm; 162struct linux_binprm;
169extern int ia32_setup_arg_pages(struct linux_binprm *bprm, 163extern int ia32_setup_arg_pages(struct linux_binprm *bprm,
170 unsigned long stack_top, int exec_stack); 164 unsigned long stack_top, int exec_stack);
diff --git a/include/asm-x86/ia32_unistd.h b/include/asm-x86/ia32_unistd.h
index 5b52ce507338..61cea9e7c5c1 100644
--- a/include/asm-x86/ia32_unistd.h
+++ b/include/asm-x86/ia32_unistd.h
@@ -5,7 +5,7 @@
5 * This file contains the system call numbers of the ia32 port, 5 * This file contains the system call numbers of the ia32 port,
6 * this is for the kernel only. 6 * this is for the kernel only.
7 * Only add syscalls here where some part of the kernel needs to know 7 * Only add syscalls here where some part of the kernel needs to know
8 * the number. This should be otherwise in sync with asm-i386/unistd.h. -AK 8 * the number. This should be otherwise in sync with asm-x86/unistd_32.h. -AK
9 */ 9 */
10 10
11#define __NR_ia32_restart_syscall 0 11#define __NR_ia32_restart_syscall 0
diff --git a/include/asm-x86/ide.h b/include/asm-x86/ide.h
index 42130adf9c7c..c2552d8bebf7 100644
--- a/include/asm-x86/ide.h
+++ b/include/asm-x86/ide.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/include/asm-i386/ide.h
3 *
4 * Copyright (C) 1994-1996 Linus Torvalds & authors 2 * Copyright (C) 1994-1996 Linus Torvalds & authors
5 */ 3 */
6 4
diff --git a/include/asm-x86/idle.h b/include/asm-x86/idle.h
index 6bd47dcf2067..d240e5b30a45 100644
--- a/include/asm-x86/idle.h
+++ b/include/asm-x86/idle.h
@@ -6,7 +6,6 @@
6 6
7struct notifier_block; 7struct notifier_block;
8void idle_notifier_register(struct notifier_block *n); 8void idle_notifier_register(struct notifier_block *n);
9void idle_notifier_unregister(struct notifier_block *n);
10 9
11void enter_idle(void); 10void enter_idle(void);
12void exit_idle(void); 11void exit_idle(void);
diff --git a/include/asm-x86/io_32.h b/include/asm-x86/io_32.h
index fe881cd1e6f4..586d7aa54ceb 100644
--- a/include/asm-x86/io_32.h
+++ b/include/asm-x86/io_32.h
@@ -100,8 +100,6 @@ static inline void * phys_to_virt(unsigned long address)
100 */ 100 */
101#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT) 101#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
102 102
103extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsigned long flags);
104
105/** 103/**
106 * ioremap - map bus memory into CPU space 104 * ioremap - map bus memory into CPU space
107 * @offset: bus address of the memory 105 * @offset: bus address of the memory
@@ -111,32 +109,39 @@ extern void __iomem * __ioremap(unsigned long offset, unsigned long size, unsign
111 * make bus memory CPU accessible via the readb/readw/readl/writeb/ 109 * make bus memory CPU accessible via the readb/readw/readl/writeb/
112 * writew/writel functions and the other mmio helpers. The returned 110 * writew/writel functions and the other mmio helpers. The returned
113 * address is not guaranteed to be usable directly as a virtual 111 * address is not guaranteed to be usable directly as a virtual
114 * address. 112 * address.
115 * 113 *
116 * If the area you are trying to map is a PCI BAR you should have a 114 * If the area you are trying to map is a PCI BAR you should have a
117 * look at pci_iomap(). 115 * look at pci_iomap().
118 */ 116 */
117extern void __iomem *ioremap_nocache(unsigned long offset, unsigned long size);
118extern void __iomem *ioremap_cache(unsigned long offset, unsigned long size);
119 119
120static inline void __iomem * ioremap(unsigned long offset, unsigned long size) 120/*
121 * The default ioremap() behavior is non-cached:
122 */
123static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
121{ 124{
122 return __ioremap(offset, size, 0); 125 return ioremap_nocache(offset, size);
123} 126}
124 127
125extern void __iomem * ioremap_nocache(unsigned long offset, unsigned long size);
126extern void iounmap(volatile void __iomem *addr); 128extern void iounmap(volatile void __iomem *addr);
127 129
128/* 130/*
129 * bt_ioremap() and bt_iounmap() are for temporary early boot-time 131 * early_ioremap() and early_iounmap() are for temporary early boot-time
130 * mappings, before the real ioremap() is functional. 132 * mappings, before the real ioremap() is functional.
131 * A boot-time mapping is currently limited to at most 16 pages. 133 * A boot-time mapping is currently limited to at most 16 pages.
132 */ 134 */
133extern void *bt_ioremap(unsigned long offset, unsigned long size); 135extern void early_ioremap_init(void);
134extern void bt_iounmap(void *addr, unsigned long size); 136extern void early_ioremap_clear(void);
137extern void early_ioremap_reset(void);
138extern void *early_ioremap(unsigned long offset, unsigned long size);
139extern void early_iounmap(void *addr, unsigned long size);
135extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); 140extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
136 141
137/* Use early IO mappings for DMI because it's initialized early */ 142/* Use early IO mappings for DMI because it's initialized early */
138#define dmi_ioremap bt_ioremap 143#define dmi_ioremap early_ioremap
139#define dmi_iounmap bt_iounmap 144#define dmi_iounmap early_iounmap
140#define dmi_alloc alloc_bootmem 145#define dmi_alloc alloc_bootmem
141 146
142/* 147/*
@@ -250,10 +255,10 @@ static inline void flush_write_buffers(void)
250 255
251#endif /* __KERNEL__ */ 256#endif /* __KERNEL__ */
252 257
253static inline void native_io_delay(void) 258extern void native_io_delay(void);
254{ 259
255 asm volatile("outb %%al,$0x80" : : : "memory"); 260extern int io_delay_type;
256} 261extern void io_delay_init(void);
257 262
258#if defined(CONFIG_PARAVIRT) 263#if defined(CONFIG_PARAVIRT)
259#include <asm/paravirt.h> 264#include <asm/paravirt.h>
diff --git a/include/asm-x86/io_64.h b/include/asm-x86/io_64.h
index a037b0794332..f64a59cc396d 100644
--- a/include/asm-x86/io_64.h
+++ b/include/asm-x86/io_64.h
@@ -35,12 +35,24 @@
35 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br> 35 * - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
36 */ 36 */
37 37
38#define __SLOW_DOWN_IO "\noutb %%al,$0x80" 38extern void native_io_delay(void);
39 39
40#ifdef REALLY_SLOW_IO 40extern int io_delay_type;
41#define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO __SLOW_DOWN_IO 41extern void io_delay_init(void);
42
43#if defined(CONFIG_PARAVIRT)
44#include <asm/paravirt.h>
42#else 45#else
43#define __FULL_SLOW_DOWN_IO __SLOW_DOWN_IO 46
47static inline void slow_down_io(void)
48{
49 native_io_delay();
50#ifdef REALLY_SLOW_IO
51 native_io_delay();
52 native_io_delay();
53 native_io_delay();
54#endif
55}
44#endif 56#endif
45 57
46/* 58/*
@@ -52,9 +64,15 @@ static inline void out##s(unsigned x value, unsigned short port) {
52#define __OUT2(s,s1,s2) \ 64#define __OUT2(s,s1,s2) \
53__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1" 65__asm__ __volatile__ ("out" #s " %" s1 "0,%" s2 "1"
54 66
67#ifndef REALLY_SLOW_IO
68#define REALLY_SLOW_IO
69#define UNSET_REALLY_SLOW_IO
70#endif
71
55#define __OUT(s,s1,x) \ 72#define __OUT(s,s1,x) \
56__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "Nd" (port)); } \ 73__OUT1(s,x) __OUT2(s,s1,"w") : : "a" (value), "Nd" (port)); } \
57__OUT1(s##_p,x) __OUT2(s,s1,"w") __FULL_SLOW_DOWN_IO : : "a" (value), "Nd" (port));} \ 74__OUT1(s##_p, x) __OUT2(s, s1, "w") : : "a" (value), "Nd" (port)); \
75 slow_down_io(); }
58 76
59#define __IN1(s) \ 77#define __IN1(s) \
60static inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v; 78static inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v;
@@ -63,8 +81,13 @@ static inline RETURN_TYPE in##s(unsigned short port) { RETURN_TYPE _v;
63__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0" 81__asm__ __volatile__ ("in" #s " %" s2 "1,%" s1 "0"
64 82
65#define __IN(s,s1,i...) \ 83#define __IN(s,s1,i...) \
66__IN1(s) __IN2(s,s1,"w") : "=a" (_v) : "Nd" (port) ,##i ); return _v; } \ 84__IN1(s) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); return _v; } \
67__IN1(s##_p) __IN2(s,s1,"w") __FULL_SLOW_DOWN_IO : "=a" (_v) : "Nd" (port) ,##i ); return _v; } \ 85__IN1(s##_p) __IN2(s, s1, "w") : "=a" (_v) : "Nd" (port), ##i); \
86 slow_down_io(); return _v; }
87
88#ifdef UNSET_REALLY_SLOW_IO
89#undef REALLY_SLOW_IO
90#endif
68 91
69#define __INS(s) \ 92#define __INS(s) \
70static inline void ins##s(unsigned short port, void * addr, unsigned long count) \ 93static inline void ins##s(unsigned short port, void * addr, unsigned long count) \
@@ -127,13 +150,6 @@ static inline void * phys_to_virt(unsigned long address)
127 150
128#include <asm-generic/iomap.h> 151#include <asm-generic/iomap.h>
129 152
130extern void __iomem *__ioremap(unsigned long offset, unsigned long size, unsigned long flags);
131
132static inline void __iomem * ioremap (unsigned long offset, unsigned long size)
133{
134 return __ioremap(offset, size, 0);
135}
136
137extern void *early_ioremap(unsigned long addr, unsigned long size); 153extern void *early_ioremap(unsigned long addr, unsigned long size);
138extern void early_iounmap(void *addr, unsigned long size); 154extern void early_iounmap(void *addr, unsigned long size);
139 155
@@ -142,8 +158,19 @@ extern void early_iounmap(void *addr, unsigned long size);
142 * it's useful if some control registers are in such an area and write combining 158 * it's useful if some control registers are in such an area and write combining
143 * or read caching is not desirable: 159 * or read caching is not desirable:
144 */ 160 */
145extern void __iomem * ioremap_nocache (unsigned long offset, unsigned long size); 161extern void __iomem *ioremap_nocache(unsigned long offset, unsigned long size);
162extern void __iomem *ioremap_cache(unsigned long offset, unsigned long size);
163
164/*
165 * The default ioremap() behavior is non-cached:
166 */
167static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
168{
169 return ioremap_nocache(offset, size);
170}
171
146extern void iounmap(volatile void __iomem *addr); 172extern void iounmap(volatile void __iomem *addr);
173
147extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys); 174extern void __iomem *fix_ioremap(unsigned idx, unsigned long phys);
148 175
149/* 176/*
diff --git a/include/asm-x86/io_apic.h b/include/asm-x86/io_apic.h
index 88494966beeb..0f5b3fef0b08 100644
--- a/include/asm-x86/io_apic.h
+++ b/include/asm-x86/io_apic.h
@@ -1,5 +1,159 @@
1#ifndef __ASM_IO_APIC_H
2#define __ASM_IO_APIC_H
3
4#include <asm/types.h>
5#include <asm/mpspec.h>
6#include <asm/apicdef.h>
7
8/*
9 * Intel IO-APIC support for SMP and UP systems.
10 *
11 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
12 */
13
14/*
15 * The structure of the IO-APIC:
16 */
17union IO_APIC_reg_00 {
18 u32 raw;
19 struct {
20 u32 __reserved_2 : 14,
21 LTS : 1,
22 delivery_type : 1,
23 __reserved_1 : 8,
24 ID : 8;
25 } __attribute__ ((packed)) bits;
26};
27
28union IO_APIC_reg_01 {
29 u32 raw;
30 struct {
31 u32 version : 8,
32 __reserved_2 : 7,
33 PRQ : 1,
34 entries : 8,
35 __reserved_1 : 8;
36 } __attribute__ ((packed)) bits;
37};
38
39union IO_APIC_reg_02 {
40 u32 raw;
41 struct {
42 u32 __reserved_2 : 24,
43 arbitration : 4,
44 __reserved_1 : 4;
45 } __attribute__ ((packed)) bits;
46};
47
48union IO_APIC_reg_03 {
49 u32 raw;
50 struct {
51 u32 boot_DT : 1,
52 __reserved_1 : 31;
53 } __attribute__ ((packed)) bits;
54};
55
56enum ioapic_irq_destination_types {
57 dest_Fixed = 0,
58 dest_LowestPrio = 1,
59 dest_SMI = 2,
60 dest__reserved_1 = 3,
61 dest_NMI = 4,
62 dest_INIT = 5,
63 dest__reserved_2 = 6,
64 dest_ExtINT = 7
65};
66
67struct IO_APIC_route_entry {
68 __u32 vector : 8,
69 delivery_mode : 3, /* 000: FIXED
70 * 001: lowest prio
71 * 111: ExtINT
72 */
73 dest_mode : 1, /* 0: physical, 1: logical */
74 delivery_status : 1,
75 polarity : 1,
76 irr : 1,
77 trigger : 1, /* 0: edge, 1: level */
78 mask : 1, /* 0: enabled, 1: disabled */
79 __reserved_2 : 15;
80
1#ifdef CONFIG_X86_32 81#ifdef CONFIG_X86_32
2# include "io_apic_32.h" 82 union {
83 struct {
84 __u32 __reserved_1 : 24,
85 physical_dest : 4,
86 __reserved_2 : 4;
87 } physical;
88
89 struct {
90 __u32 __reserved_1 : 24,
91 logical_dest : 8;
92 } logical;
93 } dest;
3#else 94#else
4# include "io_apic_64.h" 95 __u32 __reserved_3 : 24,
96 dest : 8;
97#endif
98
99} __attribute__ ((packed));
100
101#ifdef CONFIG_X86_IO_APIC
102
103/*
104 * # of IO-APICs and # of IRQ routing registers
105 */
106extern int nr_ioapics;
107extern int nr_ioapic_registers[MAX_IO_APICS];
108
109/*
110 * MP-BIOS irq configuration table structures:
111 */
112
113/* I/O APIC entries */
114extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
115
116/* # of MP IRQ source entries */
117extern int mp_irq_entries;
118
119/* MP IRQ source entries */
120extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
121
122/* non-0 if default (table-less) MP configuration */
123extern int mpc_default_type;
124
125/* Older SiS APIC requires we rewrite the index register */
126extern int sis_apic_bug;
127
128/* 1 if "noapic" boot option passed */
129extern int skip_ioapic_setup;
130
131static inline void disable_ioapic_setup(void)
132{
133 skip_ioapic_setup = 1;
134}
135
136/*
137 * If we use the IO-APIC for IRQ routing, disable automatic
138 * assignment of PCI IRQ's.
139 */
140#define io_apic_assign_pci_irqs \
141 (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
142
143#ifdef CONFIG_ACPI
144extern int io_apic_get_unique_id(int ioapic, int apic_id);
145extern int io_apic_get_version(int ioapic);
146extern int io_apic_get_redir_entries(int ioapic);
147extern int io_apic_set_pci_routing(int ioapic, int pin, int irq,
148 int edge_level, int active_high_low);
149extern int timer_uses_ioapic_pin_0;
150#endif /* CONFIG_ACPI */
151
152extern int (*ioapic_renumber_irq)(int ioapic, int irq);
153extern void ioapic_init_mappings(void);
154
155#else /* !CONFIG_X86_IO_APIC */
156#define io_apic_assign_pci_irqs 0
157#endif
158
5#endif 159#endif
diff --git a/include/asm-x86/io_apic_32.h b/include/asm-x86/io_apic_32.h
deleted file mode 100644
index 3f087883ea48..000000000000
--- a/include/asm-x86/io_apic_32.h
+++ /dev/null
@@ -1,155 +0,0 @@
1#ifndef __ASM_IO_APIC_H
2#define __ASM_IO_APIC_H
3
4#include <asm/types.h>
5#include <asm/mpspec.h>
6#include <asm/apicdef.h>
7
8/*
9 * Intel IO-APIC support for SMP and UP systems.
10 *
11 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
12 */
13
14/*
15 * The structure of the IO-APIC:
16 */
17union IO_APIC_reg_00 {
18 u32 raw;
19 struct {
20 u32 __reserved_2 : 14,
21 LTS : 1,
22 delivery_type : 1,
23 __reserved_1 : 8,
24 ID : 8;
25 } __attribute__ ((packed)) bits;
26};
27
28union IO_APIC_reg_01 {
29 u32 raw;
30 struct {
31 u32 version : 8,
32 __reserved_2 : 7,
33 PRQ : 1,
34 entries : 8,
35 __reserved_1 : 8;
36 } __attribute__ ((packed)) bits;
37};
38
39union IO_APIC_reg_02 {
40 u32 raw;
41 struct {
42 u32 __reserved_2 : 24,
43 arbitration : 4,
44 __reserved_1 : 4;
45 } __attribute__ ((packed)) bits;
46};
47
48union IO_APIC_reg_03 {
49 u32 raw;
50 struct {
51 u32 boot_DT : 1,
52 __reserved_1 : 31;
53 } __attribute__ ((packed)) bits;
54};
55
56enum ioapic_irq_destination_types {
57 dest_Fixed = 0,
58 dest_LowestPrio = 1,
59 dest_SMI = 2,
60 dest__reserved_1 = 3,
61 dest_NMI = 4,
62 dest_INIT = 5,
63 dest__reserved_2 = 6,
64 dest_ExtINT = 7
65};
66
67struct IO_APIC_route_entry {
68 __u32 vector : 8,
69 delivery_mode : 3, /* 000: FIXED
70 * 001: lowest prio
71 * 111: ExtINT
72 */
73 dest_mode : 1, /* 0: physical, 1: logical */
74 delivery_status : 1,
75 polarity : 1,
76 irr : 1,
77 trigger : 1, /* 0: edge, 1: level */
78 mask : 1, /* 0: enabled, 1: disabled */
79 __reserved_2 : 15;
80
81 union { struct { __u32
82 __reserved_1 : 24,
83 physical_dest : 4,
84 __reserved_2 : 4;
85 } physical;
86
87 struct { __u32
88 __reserved_1 : 24,
89 logical_dest : 8;
90 } logical;
91 } dest;
92
93} __attribute__ ((packed));
94
95#ifdef CONFIG_X86_IO_APIC
96
97/*
98 * # of IO-APICs and # of IRQ routing registers
99 */
100extern int nr_ioapics;
101extern int nr_ioapic_registers[MAX_IO_APICS];
102
103/*
104 * MP-BIOS irq configuration table structures:
105 */
106
107/* I/O APIC entries */
108extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
109
110/* # of MP IRQ source entries */
111extern int mp_irq_entries;
112
113/* MP IRQ source entries */
114extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
115
116/* non-0 if default (table-less) MP configuration */
117extern int mpc_default_type;
118
119/* Older SiS APIC requires we rewrite the index register */
120extern int sis_apic_bug;
121
122/* 1 if "noapic" boot option passed */
123extern int skip_ioapic_setup;
124
125static inline void disable_ioapic_setup(void)
126{
127 skip_ioapic_setup = 1;
128}
129
130static inline int ioapic_setup_disabled(void)
131{
132 return skip_ioapic_setup;
133}
134
135/*
136 * If we use the IO-APIC for IRQ routing, disable automatic
137 * assignment of PCI IRQ's.
138 */
139#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
140
141#ifdef CONFIG_ACPI
142extern int io_apic_get_unique_id (int ioapic, int apic_id);
143extern int io_apic_get_version (int ioapic);
144extern int io_apic_get_redir_entries (int ioapic);
145extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low);
146extern int timer_uses_ioapic_pin_0;
147#endif /* CONFIG_ACPI */
148
149extern int (*ioapic_renumber_irq)(int ioapic, int irq);
150
151#else /* !CONFIG_X86_IO_APIC */
152#define io_apic_assign_pci_irqs 0
153#endif
154
155#endif
diff --git a/include/asm-x86/io_apic_64.h b/include/asm-x86/io_apic_64.h
deleted file mode 100644
index e2c13675ee4e..000000000000
--- a/include/asm-x86/io_apic_64.h
+++ /dev/null
@@ -1,138 +0,0 @@
1#ifndef __ASM_IO_APIC_H
2#define __ASM_IO_APIC_H
3
4#include <asm/types.h>
5#include <asm/mpspec.h>
6#include <asm/apicdef.h>
7
8/*
9 * Intel IO-APIC support for SMP and UP systems.
10 *
11 * Copyright (C) 1997, 1998, 1999, 2000 Ingo Molnar
12 */
13
14#define APIC_MISMATCH_DEBUG
15
16/*
17 * The structure of the IO-APIC:
18 */
19union IO_APIC_reg_00 {
20 u32 raw;
21 struct {
22 u32 __reserved_2 : 14,
23 LTS : 1,
24 delivery_type : 1,
25 __reserved_1 : 8,
26 ID : 8;
27 } __attribute__ ((packed)) bits;
28};
29
30union IO_APIC_reg_01 {
31 u32 raw;
32 struct {
33 u32 version : 8,
34 __reserved_2 : 7,
35 PRQ : 1,
36 entries : 8,
37 __reserved_1 : 8;
38 } __attribute__ ((packed)) bits;
39};
40
41union IO_APIC_reg_02 {
42 u32 raw;
43 struct {
44 u32 __reserved_2 : 24,
45 arbitration : 4,
46 __reserved_1 : 4;
47 } __attribute__ ((packed)) bits;
48};
49
50union IO_APIC_reg_03 {
51 u32 raw;
52 struct {
53 u32 boot_DT : 1,
54 __reserved_1 : 31;
55 } __attribute__ ((packed)) bits;
56};
57
58/*
59 * # of IO-APICs and # of IRQ routing registers
60 */
61extern int nr_ioapics;
62extern int nr_ioapic_registers[MAX_IO_APICS];
63
64enum ioapic_irq_destination_types {
65 dest_Fixed = 0,
66 dest_LowestPrio = 1,
67 dest_SMI = 2,
68 dest__reserved_1 = 3,
69 dest_NMI = 4,
70 dest_INIT = 5,
71 dest__reserved_2 = 6,
72 dest_ExtINT = 7
73};
74
75struct IO_APIC_route_entry {
76 __u32 vector : 8,
77 delivery_mode : 3, /* 000: FIXED
78 * 001: lowest prio
79 * 111: ExtINT
80 */
81 dest_mode : 1, /* 0: physical, 1: logical */
82 delivery_status : 1,
83 polarity : 1,
84 irr : 1,
85 trigger : 1, /* 0: edge, 1: level */
86 mask : 1, /* 0: enabled, 1: disabled */
87 __reserved_2 : 15;
88
89 __u32 __reserved_3 : 24,
90 dest : 8;
91} __attribute__ ((packed));
92
93/*
94 * MP-BIOS irq configuration table structures:
95 */
96
97/* I/O APIC entries */
98extern struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
99
100/* # of MP IRQ source entries */
101extern int mp_irq_entries;
102
103/* MP IRQ source entries */
104extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
105
106/* non-0 if default (table-less) MP configuration */
107extern int mpc_default_type;
108
109/* 1 if "noapic" boot option passed */
110extern int skip_ioapic_setup;
111
112static inline void disable_ioapic_setup(void)
113{
114 skip_ioapic_setup = 1;
115}
116
117
118/*
119 * If we use the IO-APIC for IRQ routing, disable automatic
120 * assignment of PCI IRQ's.
121 */
122#define io_apic_assign_pci_irqs (mp_irq_entries && !skip_ioapic_setup && io_apic_irqs)
123
124#ifdef CONFIG_ACPI
125extern int io_apic_get_version (int ioapic);
126extern int io_apic_get_redir_entries (int ioapic);
127extern int io_apic_set_pci_routing (int ioapic, int pin, int irq, int, int);
128#endif
129
130extern int sis_apic_bug; /* dummy */
131
132void enable_NMI_through_LVT0 (void * dummy);
133
134extern spinlock_t i8259A_lock;
135
136extern int timer_over_8254;
137
138#endif
diff --git a/include/asm-x86/iommu.h b/include/asm-x86/iommu.h
index 5af471f228ee..07862fdd23c0 100644
--- a/include/asm-x86/iommu.h
+++ b/include/asm-x86/iommu.h
@@ -1,5 +1,5 @@
1#ifndef _ASM_X8664_IOMMU_H 1#ifndef _ASM_X8664_GART_H
2#define _ASM_X8664_IOMMU_H 1 2#define _ASM_X8664_GART_H 1
3 3
4extern void pci_iommu_shutdown(void); 4extern void pci_iommu_shutdown(void);
5extern void no_iommu_init(void); 5extern void no_iommu_init(void);
diff --git a/include/asm-x86/irqflags.h b/include/asm-x86/irqflags.h
index 1b695ff52687..92021c1ffa3a 100644
--- a/include/asm-x86/irqflags.h
+++ b/include/asm-x86/irqflags.h
@@ -1,5 +1,245 @@
1#ifdef CONFIG_X86_32 1#ifndef _X86_IRQFLAGS_H_
2# include "irqflags_32.h" 2#define _X86_IRQFLAGS_H_
3
4#include <asm/processor-flags.h>
5
6#ifndef __ASSEMBLY__
7/*
8 * Interrupt control:
9 */
10
11static inline unsigned long native_save_fl(void)
12{
13 unsigned long flags;
14
15 __asm__ __volatile__(
16 "# __raw_save_flags\n\t"
17 "pushf ; pop %0"
18 : "=g" (flags)
19 : /* no input */
20 : "memory"
21 );
22
23 return flags;
24}
25
26static inline void native_restore_fl(unsigned long flags)
27{
28 __asm__ __volatile__(
29 "push %0 ; popf"
30 : /* no output */
31 :"g" (flags)
32 :"memory", "cc"
33 );
34}
35
36static inline void native_irq_disable(void)
37{
38 asm volatile("cli": : :"memory");
39}
40
41static inline void native_irq_enable(void)
42{
43 asm volatile("sti": : :"memory");
44}
45
46static inline void native_safe_halt(void)
47{
48 asm volatile("sti; hlt": : :"memory");
49}
50
51static inline void native_halt(void)
52{
53 asm volatile("hlt": : :"memory");
54}
55
56#endif
57
58#ifdef CONFIG_PARAVIRT
59#include <asm/paravirt.h>
60#else
61#ifndef __ASSEMBLY__
62
63static inline unsigned long __raw_local_save_flags(void)
64{
65 return native_save_fl();
66}
67
68static inline void raw_local_irq_restore(unsigned long flags)
69{
70 native_restore_fl(flags);
71}
72
73static inline void raw_local_irq_disable(void)
74{
75 native_irq_disable();
76}
77
78static inline void raw_local_irq_enable(void)
79{
80 native_irq_enable();
81}
82
83/*
84 * Used in the idle loop; sti takes one instruction cycle
85 * to complete:
86 */
87static inline void raw_safe_halt(void)
88{
89 native_safe_halt();
90}
91
92/*
93 * Used when interrupts are already enabled or to
94 * shutdown the processor:
95 */
96static inline void halt(void)
97{
98 native_halt();
99}
100
101/*
102 * For spinlocks, etc:
103 */
104static inline unsigned long __raw_local_irq_save(void)
105{
106 unsigned long flags = __raw_local_save_flags();
107
108 raw_local_irq_disable();
109
110 return flags;
111}
112#else
113
114#define ENABLE_INTERRUPTS(x) sti
115#define DISABLE_INTERRUPTS(x) cli
116
117#ifdef CONFIG_X86_64
118#define INTERRUPT_RETURN iretq
119#define ENABLE_INTERRUPTS_SYSCALL_RET \
120 movq %gs:pda_oldrsp, %rsp; \
121 swapgs; \
122 sysretq;
123#else
124#define INTERRUPT_RETURN iret
125#define ENABLE_INTERRUPTS_SYSCALL_RET sti; sysexit
126#define GET_CR0_INTO_EAX movl %cr0, %eax
127#endif
128
129
130#endif /* __ASSEMBLY__ */
131#endif /* CONFIG_PARAVIRT */
132
133#ifndef __ASSEMBLY__
134#define raw_local_save_flags(flags) \
135 do { (flags) = __raw_local_save_flags(); } while (0)
136
137#define raw_local_irq_save(flags) \
138 do { (flags) = __raw_local_irq_save(); } while (0)
139
140static inline int raw_irqs_disabled_flags(unsigned long flags)
141{
142 return !(flags & X86_EFLAGS_IF);
143}
144
145static inline int raw_irqs_disabled(void)
146{
147 unsigned long flags = __raw_local_save_flags();
148
149 return raw_irqs_disabled_flags(flags);
150}
151
152/*
153 * makes the traced hardirq state match with the machine state
154 *
155 * should be a rarely used function, only in places where its
156 * otherwise impossible to know the irq state, like in traps.
157 */
158static inline void trace_hardirqs_fixup_flags(unsigned long flags)
159{
160 if (raw_irqs_disabled_flags(flags))
161 trace_hardirqs_off();
162 else
163 trace_hardirqs_on();
164}
165
166static inline void trace_hardirqs_fixup(void)
167{
168 unsigned long flags = __raw_local_save_flags();
169
170 trace_hardirqs_fixup_flags(flags);
171}
172
3#else 173#else
4# include "irqflags_64.h" 174
175#ifdef CONFIG_X86_64
176/*
177 * Currently paravirt can't handle swapgs nicely when we
178 * don't have a stack we can rely on (such as a user space
179 * stack). So we either find a way around these or just fault
180 * and emulate if a guest tries to call swapgs directly.
181 *
182 * Either way, this is a good way to document that we don't
183 * have a reliable stack. x86_64 only.
184 */
185#define SWAPGS_UNSAFE_STACK swapgs
186#define ARCH_TRACE_IRQS_ON call trace_hardirqs_on_thunk
187#define ARCH_TRACE_IRQS_OFF call trace_hardirqs_off_thunk
188#define ARCH_LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
189#define ARCH_LOCKDEP_SYS_EXIT_IRQ \
190 TRACE_IRQS_ON; \
191 sti; \
192 SAVE_REST; \
193 LOCKDEP_SYS_EXIT; \
194 RESTORE_REST; \
195 cli; \
196 TRACE_IRQS_OFF;
197
198#else
199#define ARCH_TRACE_IRQS_ON \
200 pushl %eax; \
201 pushl %ecx; \
202 pushl %edx; \
203 call trace_hardirqs_on; \
204 popl %edx; \
205 popl %ecx; \
206 popl %eax;
207
208#define ARCH_TRACE_IRQS_OFF \
209 pushl %eax; \
210 pushl %ecx; \
211 pushl %edx; \
212 call trace_hardirqs_off; \
213 popl %edx; \
214 popl %ecx; \
215 popl %eax;
216
217#define ARCH_LOCKDEP_SYS_EXIT \
218 pushl %eax; \
219 pushl %ecx; \
220 pushl %edx; \
221 call lockdep_sys_exit; \
222 popl %edx; \
223 popl %ecx; \
224 popl %eax;
225
226#define ARCH_LOCKDEP_SYS_EXIT_IRQ
227#endif
228
229#ifdef CONFIG_TRACE_IRQFLAGS
230# define TRACE_IRQS_ON ARCH_TRACE_IRQS_ON
231# define TRACE_IRQS_OFF ARCH_TRACE_IRQS_OFF
232#else
233# define TRACE_IRQS_ON
234# define TRACE_IRQS_OFF
235#endif
236#ifdef CONFIG_DEBUG_LOCK_ALLOC
237# define LOCKDEP_SYS_EXIT ARCH_LOCKDEP_SYS_EXIT
238# define LOCKDEP_SYS_EXIT_IRQ ARCH_LOCKDEP_SYS_EXIT_IRQ
239# else
240# define LOCKDEP_SYS_EXIT
241# define LOCKDEP_SYS_EXIT_IRQ
242# endif
243
244#endif /* __ASSEMBLY__ */
5#endif 245#endif
diff --git a/include/asm-x86/irqflags_32.h b/include/asm-x86/irqflags_32.h
deleted file mode 100644
index d058b04e0083..000000000000
--- a/include/asm-x86/irqflags_32.h
+++ /dev/null
@@ -1,176 +0,0 @@
1/*
2 * include/asm-i386/irqflags.h
3 *
4 * IRQ flags handling
5 *
6 * This file gets included from lowlevel asm headers too, to provide
7 * wrapped versions of the local_irq_*() APIs, based on the
8 * raw_local_irq_*() functions from the lowlevel headers.
9 */
10#ifndef _ASM_IRQFLAGS_H
11#define _ASM_IRQFLAGS_H
12#include <asm/processor-flags.h>
13
14#ifndef __ASSEMBLY__
15static inline unsigned long native_save_fl(void)
16{
17 unsigned long f;
18 asm volatile("pushfl ; popl %0":"=g" (f): /* no input */);
19 return f;
20}
21
22static inline void native_restore_fl(unsigned long f)
23{
24 asm volatile("pushl %0 ; popfl": /* no output */
25 :"g" (f)
26 :"memory", "cc");
27}
28
29static inline void native_irq_disable(void)
30{
31 asm volatile("cli": : :"memory");
32}
33
34static inline void native_irq_enable(void)
35{
36 asm volatile("sti": : :"memory");
37}
38
39static inline void native_safe_halt(void)
40{
41 asm volatile("sti; hlt": : :"memory");
42}
43
44static inline void native_halt(void)
45{
46 asm volatile("hlt": : :"memory");
47}
48#endif /* __ASSEMBLY__ */
49
50#ifdef CONFIG_PARAVIRT
51#include <asm/paravirt.h>
52#else
53#ifndef __ASSEMBLY__
54
55static inline unsigned long __raw_local_save_flags(void)
56{
57 return native_save_fl();
58}
59
60static inline void raw_local_irq_restore(unsigned long flags)
61{
62 native_restore_fl(flags);
63}
64
65static inline void raw_local_irq_disable(void)
66{
67 native_irq_disable();
68}
69
70static inline void raw_local_irq_enable(void)
71{
72 native_irq_enable();
73}
74
75/*
76 * Used in the idle loop; sti takes one instruction cycle
77 * to complete:
78 */
79static inline void raw_safe_halt(void)
80{
81 native_safe_halt();
82}
83
84/*
85 * Used when interrupts are already enabled or to
86 * shutdown the processor:
87 */
88static inline void halt(void)
89{
90 native_halt();
91}
92
93/*
94 * For spinlocks, etc:
95 */
96static inline unsigned long __raw_local_irq_save(void)
97{
98 unsigned long flags = __raw_local_save_flags();
99
100 raw_local_irq_disable();
101
102 return flags;
103}
104
105#else
106#define DISABLE_INTERRUPTS(clobbers) cli
107#define ENABLE_INTERRUPTS(clobbers) sti
108#define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
109#define INTERRUPT_RETURN iret
110#define GET_CR0_INTO_EAX movl %cr0, %eax
111#endif /* __ASSEMBLY__ */
112#endif /* CONFIG_PARAVIRT */
113
114#ifndef __ASSEMBLY__
115#define raw_local_save_flags(flags) \
116 do { (flags) = __raw_local_save_flags(); } while (0)
117
118#define raw_local_irq_save(flags) \
119 do { (flags) = __raw_local_irq_save(); } while (0)
120
121static inline int raw_irqs_disabled_flags(unsigned long flags)
122{
123 return !(flags & X86_EFLAGS_IF);
124}
125
126static inline int raw_irqs_disabled(void)
127{
128 unsigned long flags = __raw_local_save_flags();
129
130 return raw_irqs_disabled_flags(flags);
131}
132#endif /* __ASSEMBLY__ */
133
134/*
135 * Do the CPU's IRQ-state tracing from assembly code. We call a
136 * C function, so save all the C-clobbered registers:
137 */
138#ifdef CONFIG_TRACE_IRQFLAGS
139
140# define TRACE_IRQS_ON \
141 pushl %eax; \
142 pushl %ecx; \
143 pushl %edx; \
144 call trace_hardirqs_on; \
145 popl %edx; \
146 popl %ecx; \
147 popl %eax;
148
149# define TRACE_IRQS_OFF \
150 pushl %eax; \
151 pushl %ecx; \
152 pushl %edx; \
153 call trace_hardirqs_off; \
154 popl %edx; \
155 popl %ecx; \
156 popl %eax;
157
158#else
159# define TRACE_IRQS_ON
160# define TRACE_IRQS_OFF
161#endif
162
163#ifdef CONFIG_DEBUG_LOCK_ALLOC
164# define LOCKDEP_SYS_EXIT \
165 pushl %eax; \
166 pushl %ecx; \
167 pushl %edx; \
168 call lockdep_sys_exit; \
169 popl %edx; \
170 popl %ecx; \
171 popl %eax;
172#else
173# define LOCKDEP_SYS_EXIT
174#endif
175
176#endif
diff --git a/include/asm-x86/irqflags_64.h b/include/asm-x86/irqflags_64.h
deleted file mode 100644
index 5341ea1f815a..000000000000
--- a/include/asm-x86/irqflags_64.h
+++ /dev/null
@@ -1,156 +0,0 @@
1/*
2 * include/asm-x86_64/irqflags.h
3 *
4 * IRQ flags handling
5 *
6 * This file gets included from lowlevel asm headers too, to provide
7 * wrapped versions of the local_irq_*() APIs, based on the
8 * raw_local_irq_*() functions from the lowlevel headers.
9 */
10#ifndef _ASM_IRQFLAGS_H
11#define _ASM_IRQFLAGS_H
12#include <asm/processor-flags.h>
13
14#ifndef __ASSEMBLY__
15/*
16 * Interrupt control:
17 */
18
19static inline unsigned long __raw_local_save_flags(void)
20{
21 unsigned long flags;
22
23 __asm__ __volatile__(
24 "# __raw_save_flags\n\t"
25 "pushfq ; popq %q0"
26 : "=g" (flags)
27 : /* no input */
28 : "memory"
29 );
30
31 return flags;
32}
33
34#define raw_local_save_flags(flags) \
35 do { (flags) = __raw_local_save_flags(); } while (0)
36
37static inline void raw_local_irq_restore(unsigned long flags)
38{
39 __asm__ __volatile__(
40 "pushq %0 ; popfq"
41 : /* no output */
42 :"g" (flags)
43 :"memory", "cc"
44 );
45}
46
47#ifdef CONFIG_X86_VSMP
48
49/*
50 * Interrupt control for the VSMP architecture:
51 */
52
53static inline void raw_local_irq_disable(void)
54{
55 unsigned long flags = __raw_local_save_flags();
56
57 raw_local_irq_restore((flags & ~X86_EFLAGS_IF) | X86_EFLAGS_AC);
58}
59
60static inline void raw_local_irq_enable(void)
61{
62 unsigned long flags = __raw_local_save_flags();
63
64 raw_local_irq_restore((flags | X86_EFLAGS_IF) & (~X86_EFLAGS_AC));
65}
66
67static inline int raw_irqs_disabled_flags(unsigned long flags)
68{
69 return !(flags & X86_EFLAGS_IF) || (flags & X86_EFLAGS_AC);
70}
71
72#else /* CONFIG_X86_VSMP */
73
74static inline void raw_local_irq_disable(void)
75{
76 __asm__ __volatile__("cli" : : : "memory");
77}
78
79static inline void raw_local_irq_enable(void)
80{
81 __asm__ __volatile__("sti" : : : "memory");
82}
83
84static inline int raw_irqs_disabled_flags(unsigned long flags)
85{
86 return !(flags & X86_EFLAGS_IF);
87}
88
89#endif
90
91/*
92 * For spinlocks, etc.:
93 */
94
95static inline unsigned long __raw_local_irq_save(void)
96{
97 unsigned long flags = __raw_local_save_flags();
98
99 raw_local_irq_disable();
100
101 return flags;
102}
103
104#define raw_local_irq_save(flags) \
105 do { (flags) = __raw_local_irq_save(); } while (0)
106
107static inline int raw_irqs_disabled(void)
108{
109 unsigned long flags = __raw_local_save_flags();
110
111 return raw_irqs_disabled_flags(flags);
112}
113
114/*
115 * Used in the idle loop; sti takes one instruction cycle
116 * to complete:
117 */
118static inline void raw_safe_halt(void)
119{
120 __asm__ __volatile__("sti; hlt" : : : "memory");
121}
122
123/*
124 * Used when interrupts are already enabled or to
125 * shutdown the processor:
126 */
127static inline void halt(void)
128{
129 __asm__ __volatile__("hlt": : :"memory");
130}
131
132#else /* __ASSEMBLY__: */
133# ifdef CONFIG_TRACE_IRQFLAGS
134# define TRACE_IRQS_ON call trace_hardirqs_on_thunk
135# define TRACE_IRQS_OFF call trace_hardirqs_off_thunk
136# else
137# define TRACE_IRQS_ON
138# define TRACE_IRQS_OFF
139# endif
140# ifdef CONFIG_DEBUG_LOCK_ALLOC
141# define LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
142# define LOCKDEP_SYS_EXIT_IRQ \
143 TRACE_IRQS_ON; \
144 sti; \
145 SAVE_REST; \
146 LOCKDEP_SYS_EXIT; \
147 RESTORE_REST; \
148 cli; \
149 TRACE_IRQS_OFF;
150# else
151# define LOCKDEP_SYS_EXIT
152# define LOCKDEP_SYS_EXIT_IRQ
153# endif
154#endif
155
156#endif
diff --git a/include/asm-x86/k8.h b/include/asm-x86/k8.h
index 699dd6961eda..452e2b696ff4 100644
--- a/include/asm-x86/k8.h
+++ b/include/asm-x86/k8.h
@@ -10,5 +10,6 @@ extern struct pci_dev **k8_northbridges;
10extern int num_k8_northbridges; 10extern int num_k8_northbridges;
11extern int cache_k8_northbridges(void); 11extern int cache_k8_northbridges(void);
12extern void k8_flush_garts(void); 12extern void k8_flush_garts(void);
13extern int k8_scan_nodes(unsigned long start, unsigned long end);
13 14
14#endif 15#endif
diff --git a/include/asm-x86/kdebug.h b/include/asm-x86/kdebug.h
index e2f9b62e535e..dd442a1632c0 100644
--- a/include/asm-x86/kdebug.h
+++ b/include/asm-x86/kdebug.h
@@ -22,12 +22,17 @@ enum die_val {
22 DIE_PAGE_FAULT, 22 DIE_PAGE_FAULT,
23}; 23};
24 24
25extern void printk_address(unsigned long address); 25extern void printk_address(unsigned long address, int reliable);
26extern void die(const char *,struct pt_regs *,long); 26extern void die(const char *,struct pt_regs *,long);
27extern void __die(const char *,struct pt_regs *,long); 27extern int __must_check __die(const char *, struct pt_regs *, long);
28extern void show_registers(struct pt_regs *regs); 28extern void show_registers(struct pt_regs *regs);
29extern void __show_registers(struct pt_regs *, int all);
30extern void show_trace(struct task_struct *t, struct pt_regs *regs,
31 unsigned long *sp, unsigned long bp);
32extern void __show_regs(struct pt_regs *regs);
33extern void show_regs(struct pt_regs *regs);
29extern void dump_pagetable(unsigned long); 34extern void dump_pagetable(unsigned long);
30extern unsigned long oops_begin(void); 35extern unsigned long oops_begin(void);
31extern void oops_end(unsigned long); 36extern void oops_end(unsigned long, struct pt_regs *, int signr);
32 37
33#endif 38#endif
diff --git a/include/asm-x86/kexec.h b/include/asm-x86/kexec.h
index 718ddbfb9516..c90d3c77afc2 100644
--- a/include/asm-x86/kexec.h
+++ b/include/asm-x86/kexec.h
@@ -1,5 +1,170 @@
1#ifndef _KEXEC_H
2#define _KEXEC_H
3
1#ifdef CONFIG_X86_32 4#ifdef CONFIG_X86_32
2# include "kexec_32.h" 5# define PA_CONTROL_PAGE 0
6# define VA_CONTROL_PAGE 1
7# define PA_PGD 2
8# define VA_PGD 3
9# define PA_PTE_0 4
10# define VA_PTE_0 5
11# define PA_PTE_1 6
12# define VA_PTE_1 7
13# ifdef CONFIG_X86_PAE
14# define PA_PMD_0 8
15# define VA_PMD_0 9
16# define PA_PMD_1 10
17# define VA_PMD_1 11
18# define PAGES_NR 12
19# else
20# define PAGES_NR 8
21# endif
3#else 22#else
4# include "kexec_64.h" 23# define PA_CONTROL_PAGE 0
24# define VA_CONTROL_PAGE 1
25# define PA_PGD 2
26# define VA_PGD 3
27# define PA_PUD_0 4
28# define VA_PUD_0 5
29# define PA_PMD_0 6
30# define VA_PMD_0 7
31# define PA_PTE_0 8
32# define VA_PTE_0 9
33# define PA_PUD_1 10
34# define VA_PUD_1 11
35# define PA_PMD_1 12
36# define VA_PMD_1 13
37# define PA_PTE_1 14
38# define VA_PTE_1 15
39# define PA_TABLE_PAGE 16
40# define PAGES_NR 17
5#endif 41#endif
42
43#ifndef __ASSEMBLY__
44
45#include <linux/string.h>
46
47#include <asm/page.h>
48#include <asm/ptrace.h>
49
50/*
51 * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
52 * I.e. Maximum page that is mapped directly into kernel memory,
53 * and kmap is not required.
54 *
55 * So far x86_64 is limited to 40 physical address bits.
56 */
57#ifdef CONFIG_X86_32
58/* Maximum physical address we can use pages from */
59# define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
60/* Maximum address we can reach in physical address mode */
61# define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
62/* Maximum address we can use for the control code buffer */
63# define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
64
65# define KEXEC_CONTROL_CODE_SIZE 4096
66
67/* The native architecture */
68# define KEXEC_ARCH KEXEC_ARCH_386
69
70/* We can also handle crash dumps from 64 bit kernel. */
71# define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64)
72#else
73/* Maximum physical address we can use pages from */
74# define KEXEC_SOURCE_MEMORY_LIMIT (0xFFFFFFFFFFUL)
75/* Maximum address we can reach in physical address mode */
76# define KEXEC_DESTINATION_MEMORY_LIMIT (0xFFFFFFFFFFUL)
77/* Maximum address we can use for the control pages */
78# define KEXEC_CONTROL_MEMORY_LIMIT (0xFFFFFFFFFFUL)
79
80/* Allocate one page for the pdp and the second for the code */
81# define KEXEC_CONTROL_CODE_SIZE (4096UL + 4096UL)
82
83/* The native architecture */
84# define KEXEC_ARCH KEXEC_ARCH_X86_64
85#endif
86
87/*
88 * CPU does not save ss and sp on stack if execution is already
89 * running in kernel mode at the time of NMI occurrence. This code
90 * fixes it.
91 */
92static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
93 struct pt_regs *oldregs)
94{
95#ifdef CONFIG_X86_32
96 newregs->sp = (unsigned long)&(oldregs->sp);
97 __asm__ __volatile__(
98 "xorl %%eax, %%eax\n\t"
99 "movw %%ss, %%ax\n\t"
100 :"=a"(newregs->ss));
101#endif
102}
103
104/*
105 * This function is responsible for capturing register states if coming
106 * via panic otherwise just fix up the ss and sp if coming via kernel
107 * mode exception.
108 */
109static inline void crash_setup_regs(struct pt_regs *newregs,
110 struct pt_regs *oldregs)
111{
112 if (oldregs) {
113 memcpy(newregs, oldregs, sizeof(*newregs));
114 crash_fixup_ss_esp(newregs, oldregs);
115 } else {
116#ifdef CONFIG_X86_32
117 __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->bx));
118 __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->cx));
119 __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->dx));
120 __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->si));
121 __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->di));
122 __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->bp));
123 __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->ax));
124 __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->sp));
125 __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss));
126 __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs));
127 __asm__ __volatile__("movl %%ds, %%eax;" :"=a"(newregs->ds));
128 __asm__ __volatile__("movl %%es, %%eax;" :"=a"(newregs->es));
129 __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->flags));
130#else
131 __asm__ __volatile__("movq %%rbx,%0" : "=m"(newregs->bx));
132 __asm__ __volatile__("movq %%rcx,%0" : "=m"(newregs->cx));
133 __asm__ __volatile__("movq %%rdx,%0" : "=m"(newregs->dx));
134 __asm__ __volatile__("movq %%rsi,%0" : "=m"(newregs->si));
135 __asm__ __volatile__("movq %%rdi,%0" : "=m"(newregs->di));
136 __asm__ __volatile__("movq %%rbp,%0" : "=m"(newregs->bp));
137 __asm__ __volatile__("movq %%rax,%0" : "=m"(newregs->ax));
138 __asm__ __volatile__("movq %%rsp,%0" : "=m"(newregs->sp));
139 __asm__ __volatile__("movq %%r8,%0" : "=m"(newregs->r8));
140 __asm__ __volatile__("movq %%r9,%0" : "=m"(newregs->r9));
141 __asm__ __volatile__("movq %%r10,%0" : "=m"(newregs->r10));
142 __asm__ __volatile__("movq %%r11,%0" : "=m"(newregs->r11));
143 __asm__ __volatile__("movq %%r12,%0" : "=m"(newregs->r12));
144 __asm__ __volatile__("movq %%r13,%0" : "=m"(newregs->r13));
145 __asm__ __volatile__("movq %%r14,%0" : "=m"(newregs->r14));
146 __asm__ __volatile__("movq %%r15,%0" : "=m"(newregs->r15));
147 __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss));
148 __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs));
149 __asm__ __volatile__("pushfq; popq %0" :"=m"(newregs->flags));
150#endif
151 newregs->ip = (unsigned long)current_text_addr();
152 }
153}
154
155#ifdef CONFIG_X86_32
156asmlinkage NORET_TYPE void
157relocate_kernel(unsigned long indirection_page,
158 unsigned long control_page,
159 unsigned long start_address,
160 unsigned int has_pae) ATTRIB_NORET;
161#else
162NORET_TYPE void
163relocate_kernel(unsigned long indirection_page,
164 unsigned long page_list,
165 unsigned long start_address) ATTRIB_NORET;
166#endif
167
168#endif /* __ASSEMBLY__ */
169
170#endif /* _KEXEC_H */
diff --git a/include/asm-x86/kexec_32.h b/include/asm-x86/kexec_32.h
deleted file mode 100644
index 4b9dc9e6b701..000000000000
--- a/include/asm-x86/kexec_32.h
+++ /dev/null
@@ -1,99 +0,0 @@
1#ifndef _I386_KEXEC_H
2#define _I386_KEXEC_H
3
4#define PA_CONTROL_PAGE 0
5#define VA_CONTROL_PAGE 1
6#define PA_PGD 2
7#define VA_PGD 3
8#define PA_PTE_0 4
9#define VA_PTE_0 5
10#define PA_PTE_1 6
11#define VA_PTE_1 7
12#ifdef CONFIG_X86_PAE
13#define PA_PMD_0 8
14#define VA_PMD_0 9
15#define PA_PMD_1 10
16#define VA_PMD_1 11
17#define PAGES_NR 12
18#else
19#define PAGES_NR 8
20#endif
21
22#ifndef __ASSEMBLY__
23
24#include <asm/ptrace.h>
25#include <asm/string.h>
26
27/*
28 * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
29 * I.e. Maximum page that is mapped directly into kernel memory,
30 * and kmap is not required.
31 */
32
33/* Maximum physical address we can use pages from */
34#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
35/* Maximum address we can reach in physical address mode */
36#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
37/* Maximum address we can use for the control code buffer */
38#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
39
40#define KEXEC_CONTROL_CODE_SIZE 4096
41
42/* The native architecture */
43#define KEXEC_ARCH KEXEC_ARCH_386
44
45/* We can also handle crash dumps from 64 bit kernel. */
46#define vmcore_elf_check_arch_cross(x) ((x)->e_machine == EM_X86_64)
47
48/* CPU does not save ss and esp on stack if execution is already
49 * running in kernel mode at the time of NMI occurrence. This code
50 * fixes it.
51 */
52static inline void crash_fixup_ss_esp(struct pt_regs *newregs,
53 struct pt_regs *oldregs)
54{
55 memcpy(newregs, oldregs, sizeof(*newregs));
56 newregs->esp = (unsigned long)&(oldregs->esp);
57 __asm__ __volatile__(
58 "xorl %%eax, %%eax\n\t"
59 "movw %%ss, %%ax\n\t"
60 :"=a"(newregs->xss));
61}
62
63/*
64 * This function is responsible for capturing register states if coming
65 * via panic otherwise just fix up the ss and esp if coming via kernel
66 * mode exception.
67 */
68static inline void crash_setup_regs(struct pt_regs *newregs,
69 struct pt_regs *oldregs)
70{
71 if (oldregs)
72 crash_fixup_ss_esp(newregs, oldregs);
73 else {
74 __asm__ __volatile__("movl %%ebx,%0" : "=m"(newregs->ebx));
75 __asm__ __volatile__("movl %%ecx,%0" : "=m"(newregs->ecx));
76 __asm__ __volatile__("movl %%edx,%0" : "=m"(newregs->edx));
77 __asm__ __volatile__("movl %%esi,%0" : "=m"(newregs->esi));
78 __asm__ __volatile__("movl %%edi,%0" : "=m"(newregs->edi));
79 __asm__ __volatile__("movl %%ebp,%0" : "=m"(newregs->ebp));
80 __asm__ __volatile__("movl %%eax,%0" : "=m"(newregs->eax));
81 __asm__ __volatile__("movl %%esp,%0" : "=m"(newregs->esp));
82 __asm__ __volatile__("movw %%ss, %%ax;" :"=a"(newregs->xss));
83 __asm__ __volatile__("movw %%cs, %%ax;" :"=a"(newregs->xcs));
84 __asm__ __volatile__("movw %%ds, %%ax;" :"=a"(newregs->xds));
85 __asm__ __volatile__("movw %%es, %%ax;" :"=a"(newregs->xes));
86 __asm__ __volatile__("pushfl; popl %0" :"=m"(newregs->eflags));
87
88 newregs->eip = (unsigned long)current_text_addr();
89 }
90}
91asmlinkage NORET_TYPE void
92relocate_kernel(unsigned long indirection_page,
93 unsigned long control_page,
94 unsigned long start_address,
95 unsigned int has_pae) ATTRIB_NORET;
96
97#endif /* __ASSEMBLY__ */
98
99#endif /* _I386_KEXEC_H */
diff --git a/include/asm-x86/kexec_64.h b/include/asm-x86/kexec_64.h
deleted file mode 100644
index 738e581b67f8..000000000000
--- a/include/asm-x86/kexec_64.h
+++ /dev/null
@@ -1,94 +0,0 @@
1#ifndef _X86_64_KEXEC_H
2#define _X86_64_KEXEC_H
3
4#define PA_CONTROL_PAGE 0
5#define VA_CONTROL_PAGE 1
6#define PA_PGD 2
7#define VA_PGD 3
8#define PA_PUD_0 4
9#define VA_PUD_0 5
10#define PA_PMD_0 6
11#define VA_PMD_0 7
12#define PA_PTE_0 8
13#define VA_PTE_0 9
14#define PA_PUD_1 10
15#define VA_PUD_1 11
16#define PA_PMD_1 12
17#define VA_PMD_1 13
18#define PA_PTE_1 14
19#define VA_PTE_1 15
20#define PA_TABLE_PAGE 16
21#define PAGES_NR 17
22
23#ifndef __ASSEMBLY__
24
25#include <linux/string.h>
26
27#include <asm/page.h>
28#include <asm/ptrace.h>
29
30/*
31 * KEXEC_SOURCE_MEMORY_LIMIT maximum page get_free_page can return.
32 * I.e. Maximum page that is mapped directly into kernel memory,
33 * and kmap is not required.
34 *
35 * So far x86_64 is limited to 40 physical address bits.
36 */
37
38/* Maximum physical address we can use pages from */
39#define KEXEC_SOURCE_MEMORY_LIMIT (0xFFFFFFFFFFUL)
40/* Maximum address we can reach in physical address mode */
41#define KEXEC_DESTINATION_MEMORY_LIMIT (0xFFFFFFFFFFUL)
42/* Maximum address we can use for the control pages */
43#define KEXEC_CONTROL_MEMORY_LIMIT (0xFFFFFFFFFFUL)
44
45/* Allocate one page for the pdp and the second for the code */
46#define KEXEC_CONTROL_CODE_SIZE (4096UL + 4096UL)
47
48/* The native architecture */
49#define KEXEC_ARCH KEXEC_ARCH_X86_64
50
51/*
52 * Saving the registers of the cpu on which panic occured in
53 * crash_kexec to save a valid sp. The registers of other cpus
54 * will be saved in machine_crash_shutdown while shooting down them.
55 */
56
57static inline void crash_setup_regs(struct pt_regs *newregs,
58 struct pt_regs *oldregs)
59{
60 if (oldregs)
61 memcpy(newregs, oldregs, sizeof(*newregs));
62 else {
63 __asm__ __volatile__("movq %%rbx,%0" : "=m"(newregs->rbx));
64 __asm__ __volatile__("movq %%rcx,%0" : "=m"(newregs->rcx));
65 __asm__ __volatile__("movq %%rdx,%0" : "=m"(newregs->rdx));
66 __asm__ __volatile__("movq %%rsi,%0" : "=m"(newregs->rsi));
67 __asm__ __volatile__("movq %%rdi,%0" : "=m"(newregs->rdi));
68 __asm__ __volatile__("movq %%rbp,%0" : "=m"(newregs->rbp));
69 __asm__ __volatile__("movq %%rax,%0" : "=m"(newregs->rax));
70 __asm__ __volatile__("movq %%rsp,%0" : "=m"(newregs->rsp));
71 __asm__ __volatile__("movq %%r8,%0" : "=m"(newregs->r8));
72 __asm__ __volatile__("movq %%r9,%0" : "=m"(newregs->r9));
73 __asm__ __volatile__("movq %%r10,%0" : "=m"(newregs->r10));
74 __asm__ __volatile__("movq %%r11,%0" : "=m"(newregs->r11));
75 __asm__ __volatile__("movq %%r12,%0" : "=m"(newregs->r12));
76 __asm__ __volatile__("movq %%r13,%0" : "=m"(newregs->r13));
77 __asm__ __volatile__("movq %%r14,%0" : "=m"(newregs->r14));
78 __asm__ __volatile__("movq %%r15,%0" : "=m"(newregs->r15));
79 __asm__ __volatile__("movl %%ss, %%eax;" :"=a"(newregs->ss));
80 __asm__ __volatile__("movl %%cs, %%eax;" :"=a"(newregs->cs));
81 __asm__ __volatile__("pushfq; popq %0" :"=m"(newregs->eflags));
82
83 newregs->rip = (unsigned long)current_text_addr();
84 }
85}
86
87NORET_TYPE void
88relocate_kernel(unsigned long indirection_page,
89 unsigned long page_list,
90 unsigned long start_address) ATTRIB_NORET;
91
92#endif /* __ASSEMBLY__ */
93
94#endif /* _X86_64_KEXEC_H */
diff --git a/include/asm-x86/kprobes.h b/include/asm-x86/kprobes.h
index b7bbd25ba2a6..143476a3cb52 100644
--- a/include/asm-x86/kprobes.h
+++ b/include/asm-x86/kprobes.h
@@ -1,5 +1,98 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_KPROBES_H
2# include "kprobes_32.h" 2#define _ASM_KPROBES_H
3#else 3/*
4# include "kprobes_64.h" 4 * Kernel Probes (KProbes)
5#endif 5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 *
20 * Copyright (C) IBM Corporation, 2002, 2004
21 *
22 * See arch/x86/kernel/kprobes.c for x86 kprobes history.
23 */
24#include <linux/types.h>
25#include <linux/ptrace.h>
26#include <linux/percpu.h>
27
28#define __ARCH_WANT_KPROBES_INSN_SLOT
29
30struct pt_regs;
31struct kprobe;
32
33typedef u8 kprobe_opcode_t;
34#define BREAKPOINT_INSTRUCTION 0xcc
35#define RELATIVEJUMP_INSTRUCTION 0xe9
36#define MAX_INSN_SIZE 16
37#define MAX_STACK_SIZE 64
38#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
39 (((unsigned long)current_thread_info()) + THREAD_SIZE \
40 - (unsigned long)(ADDR))) \
41 ? (MAX_STACK_SIZE) \
42 : (((unsigned long)current_thread_info()) + THREAD_SIZE \
43 - (unsigned long)(ADDR)))
44
45#define ARCH_SUPPORTS_KRETPROBES
46#define flush_insn_slot(p) do { } while (0)
47
48extern const int kretprobe_blacklist_size;
49
50void arch_remove_kprobe(struct kprobe *p);
51void kretprobe_trampoline(void);
52
53/* Architecture specific copy of original instruction*/
54struct arch_specific_insn {
55 /* copy of the original instruction */
56 kprobe_opcode_t *insn;
57 /*
58 * boostable = -1: This instruction type is not boostable.
59 * boostable = 0: This instruction type is boostable.
60 * boostable = 1: This instruction has been boosted: we have
61 * added a relative jump after the instruction copy in insn,
62 * so no single-step and fixup are needed (unless there's
63 * a post_handler or break_handler).
64 */
65 int boostable;
66};
67
68struct prev_kprobe {
69 struct kprobe *kp;
70 unsigned long status;
71 unsigned long old_flags;
72 unsigned long saved_flags;
73};
74
75/* per-cpu kprobe control block */
76struct kprobe_ctlblk {
77 unsigned long kprobe_status;
78 unsigned long kprobe_old_flags;
79 unsigned long kprobe_saved_flags;
80 unsigned long *jprobe_saved_sp;
81 struct pt_regs jprobe_saved_regs;
82 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
83 struct prev_kprobe prev_kprobe;
84};
85
86/* trap3/1 are intr gates for kprobes. So, restore the status of IF,
87 * if necessary, before executing the original int3/1 (trap) handler.
88 */
89static inline void restore_interrupts(struct pt_regs *regs)
90{
91 if (regs->flags & X86_EFLAGS_IF)
92 local_irq_enable();
93}
94
95extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
96extern int kprobe_exceptions_notify(struct notifier_block *self,
97 unsigned long val, void *data);
98#endif /* _ASM_KPROBES_H */
diff --git a/include/asm-x86/kprobes_32.h b/include/asm-x86/kprobes_32.h
deleted file mode 100644
index b772d5b38685..000000000000
--- a/include/asm-x86/kprobes_32.h
+++ /dev/null
@@ -1,94 +0,0 @@
1#ifndef _ASM_KPROBES_H
2#define _ASM_KPROBES_H
3/*
4 * Kernel Probes (KProbes)
5 * include/asm-i386/kprobes.h
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * Copyright (C) IBM Corporation, 2002, 2004
22 *
23 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
24 * Probes initial implementation ( includes suggestions from
25 * Rusty Russell).
26 */
27#include <linux/types.h>
28#include <linux/ptrace.h>
29
30#define __ARCH_WANT_KPROBES_INSN_SLOT
31
32struct kprobe;
33struct pt_regs;
34
35typedef u8 kprobe_opcode_t;
36#define BREAKPOINT_INSTRUCTION 0xcc
37#define RELATIVEJUMP_INSTRUCTION 0xe9
38#define MAX_INSN_SIZE 16
39#define MAX_STACK_SIZE 64
40#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
41 (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
42 ? (MAX_STACK_SIZE) \
43 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
44
45#define ARCH_SUPPORTS_KRETPROBES
46#define flush_insn_slot(p) do { } while (0)
47
48extern const int kretprobe_blacklist_size;
49
50void arch_remove_kprobe(struct kprobe *p);
51void kretprobe_trampoline(void);
52
53/* Architecture specific copy of original instruction*/
54struct arch_specific_insn {
55 /* copy of the original instruction */
56 kprobe_opcode_t *insn;
57 /*
58 * If this flag is not 0, this kprobe can be boost when its
59 * post_handler and break_handler is not set.
60 */
61 int boostable;
62};
63
64struct prev_kprobe {
65 struct kprobe *kp;
66 unsigned long status;
67 unsigned long old_eflags;
68 unsigned long saved_eflags;
69};
70
71/* per-cpu kprobe control block */
72struct kprobe_ctlblk {
73 unsigned long kprobe_status;
74 unsigned long kprobe_old_eflags;
75 unsigned long kprobe_saved_eflags;
76 long *jprobe_saved_esp;
77 struct pt_regs jprobe_saved_regs;
78 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
79 struct prev_kprobe prev_kprobe;
80};
81
82/* trap3/1 are intr gates for kprobes. So, restore the status of IF,
83 * if necessary, before executing the original int3/1 (trap) handler.
84 */
85static inline void restore_interrupts(struct pt_regs *regs)
86{
87 if (regs->eflags & IF_MASK)
88 local_irq_enable();
89}
90
91extern int kprobe_exceptions_notify(struct notifier_block *self,
92 unsigned long val, void *data);
93extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
94#endif /* _ASM_KPROBES_H */
diff --git a/include/asm-x86/kprobes_64.h b/include/asm-x86/kprobes_64.h
deleted file mode 100644
index 53f4d8507354..000000000000
--- a/include/asm-x86/kprobes_64.h
+++ /dev/null
@@ -1,90 +0,0 @@
1#ifndef _ASM_KPROBES_H
2#define _ASM_KPROBES_H
3/*
4 * Kernel Probes (KProbes)
5 * include/asm-x86_64/kprobes.h
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 *
21 * Copyright (C) IBM Corporation, 2002, 2004
22 *
23 * 2004-Oct Prasanna S Panchamukhi <prasanna@in.ibm.com> and Jim Keniston
24 * kenistoj@us.ibm.com adopted from i386.
25 */
26#include <linux/types.h>
27#include <linux/ptrace.h>
28#include <linux/percpu.h>
29
30#define __ARCH_WANT_KPROBES_INSN_SLOT
31
32struct pt_regs;
33struct kprobe;
34
35typedef u8 kprobe_opcode_t;
36#define BREAKPOINT_INSTRUCTION 0xcc
37#define MAX_INSN_SIZE 15
38#define MAX_STACK_SIZE 64
39#define MIN_STACK_SIZE(ADDR) (((MAX_STACK_SIZE) < \
40 (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR))) \
41 ? (MAX_STACK_SIZE) \
42 : (((unsigned long)current_thread_info()) + THREAD_SIZE - (ADDR)))
43
44#define ARCH_SUPPORTS_KRETPROBES
45extern const int kretprobe_blacklist_size;
46
47void kretprobe_trampoline(void);
48extern void arch_remove_kprobe(struct kprobe *p);
49#define flush_insn_slot(p) do { } while (0)
50
51/* Architecture specific copy of original instruction*/
52struct arch_specific_insn {
53 /* copy of the original instruction */
54 kprobe_opcode_t *insn;
55};
56
57struct prev_kprobe {
58 struct kprobe *kp;
59 unsigned long status;
60 unsigned long old_rflags;
61 unsigned long saved_rflags;
62};
63
64/* per-cpu kprobe control block */
65struct kprobe_ctlblk {
66 unsigned long kprobe_status;
67 unsigned long kprobe_old_rflags;
68 unsigned long kprobe_saved_rflags;
69 long *jprobe_saved_rsp;
70 struct pt_regs jprobe_saved_regs;
71 kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
72 struct prev_kprobe prev_kprobe;
73};
74
75/* trap3/1 are intr gates for kprobes. So, restore the status of IF,
76 * if necessary, before executing the original int3/1 (trap) handler.
77 */
78static inline void restore_interrupts(struct pt_regs *regs)
79{
80 if (regs->eflags & IF_MASK)
81 local_irq_enable();
82}
83
84extern int post_kprobe_handler(struct pt_regs *regs);
85extern int kprobe_fault_handler(struct pt_regs *regs, int trapnr);
86extern int kprobe_handler(struct pt_regs *regs);
87
88extern int kprobe_exceptions_notify(struct notifier_block *self,
89 unsigned long val, void *data);
90#endif /* _ASM_KPROBES_H */
diff --git a/include/asm-x86/kvm.h b/include/asm-x86/kvm.h
new file mode 100644
index 000000000000..7a71120426a3
--- /dev/null
+++ b/include/asm-x86/kvm.h
@@ -0,0 +1,191 @@
1#ifndef __LINUX_KVM_X86_H
2#define __LINUX_KVM_X86_H
3
4/*
5 * KVM x86 specific structures and definitions
6 *
7 */
8
9#include <asm/types.h>
10#include <linux/ioctl.h>
11
12/* Architectural interrupt line count. */
13#define KVM_NR_INTERRUPTS 256
14
15struct kvm_memory_alias {
16 __u32 slot; /* this has a different namespace than memory slots */
17 __u32 flags;
18 __u64 guest_phys_addr;
19 __u64 memory_size;
20 __u64 target_phys_addr;
21};
22
23/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
24struct kvm_pic_state {
25 __u8 last_irr; /* edge detection */
26 __u8 irr; /* interrupt request register */
27 __u8 imr; /* interrupt mask register */
28 __u8 isr; /* interrupt service register */
29 __u8 priority_add; /* highest irq priority */
30 __u8 irq_base;
31 __u8 read_reg_select;
32 __u8 poll;
33 __u8 special_mask;
34 __u8 init_state;
35 __u8 auto_eoi;
36 __u8 rotate_on_auto_eoi;
37 __u8 special_fully_nested_mode;
38 __u8 init4; /* true if 4 byte init */
39 __u8 elcr; /* PIIX edge/trigger selection */
40 __u8 elcr_mask;
41};
42
43#define KVM_IOAPIC_NUM_PINS 24
44struct kvm_ioapic_state {
45 __u64 base_address;
46 __u32 ioregsel;
47 __u32 id;
48 __u32 irr;
49 __u32 pad;
50 union {
51 __u64 bits;
52 struct {
53 __u8 vector;
54 __u8 delivery_mode:3;
55 __u8 dest_mode:1;
56 __u8 delivery_status:1;
57 __u8 polarity:1;
58 __u8 remote_irr:1;
59 __u8 trig_mode:1;
60 __u8 mask:1;
61 __u8 reserve:7;
62 __u8 reserved[4];
63 __u8 dest_id;
64 } fields;
65 } redirtbl[KVM_IOAPIC_NUM_PINS];
66};
67
68#define KVM_IRQCHIP_PIC_MASTER 0
69#define KVM_IRQCHIP_PIC_SLAVE 1
70#define KVM_IRQCHIP_IOAPIC 2
71
72/* for KVM_GET_REGS and KVM_SET_REGS */
73struct kvm_regs {
74 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
75 __u64 rax, rbx, rcx, rdx;
76 __u64 rsi, rdi, rsp, rbp;
77 __u64 r8, r9, r10, r11;
78 __u64 r12, r13, r14, r15;
79 __u64 rip, rflags;
80};
81
82/* for KVM_GET_LAPIC and KVM_SET_LAPIC */
83#define KVM_APIC_REG_SIZE 0x400
84struct kvm_lapic_state {
85 char regs[KVM_APIC_REG_SIZE];
86};
87
88struct kvm_segment {
89 __u64 base;
90 __u32 limit;
91 __u16 selector;
92 __u8 type;
93 __u8 present, dpl, db, s, l, g, avl;
94 __u8 unusable;
95 __u8 padding;
96};
97
98struct kvm_dtable {
99 __u64 base;
100 __u16 limit;
101 __u16 padding[3];
102};
103
104
105/* for KVM_GET_SREGS and KVM_SET_SREGS */
106struct kvm_sregs {
107 /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
108 struct kvm_segment cs, ds, es, fs, gs, ss;
109 struct kvm_segment tr, ldt;
110 struct kvm_dtable gdt, idt;
111 __u64 cr0, cr2, cr3, cr4, cr8;
112 __u64 efer;
113 __u64 apic_base;
114 __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
115};
116
117/* for KVM_GET_FPU and KVM_SET_FPU */
118struct kvm_fpu {
119 __u8 fpr[8][16];
120 __u16 fcw;
121 __u16 fsw;
122 __u8 ftwx; /* in fxsave format */
123 __u8 pad1;
124 __u16 last_opcode;
125 __u64 last_ip;
126 __u64 last_dp;
127 __u8 xmm[16][16];
128 __u32 mxcsr;
129 __u32 pad2;
130};
131
132struct kvm_msr_entry {
133 __u32 index;
134 __u32 reserved;
135 __u64 data;
136};
137
138/* for KVM_GET_MSRS and KVM_SET_MSRS */
139struct kvm_msrs {
140 __u32 nmsrs; /* number of msrs in entries */
141 __u32 pad;
142
143 struct kvm_msr_entry entries[0];
144};
145
146/* for KVM_GET_MSR_INDEX_LIST */
147struct kvm_msr_list {
148 __u32 nmsrs; /* number of msrs in entries */
149 __u32 indices[0];
150};
151
152
153struct kvm_cpuid_entry {
154 __u32 function;
155 __u32 eax;
156 __u32 ebx;
157 __u32 ecx;
158 __u32 edx;
159 __u32 padding;
160};
161
162/* for KVM_SET_CPUID */
163struct kvm_cpuid {
164 __u32 nent;
165 __u32 padding;
166 struct kvm_cpuid_entry entries[0];
167};
168
169struct kvm_cpuid_entry2 {
170 __u32 function;
171 __u32 index;
172 __u32 flags;
173 __u32 eax;
174 __u32 ebx;
175 __u32 ecx;
176 __u32 edx;
177 __u32 padding[3];
178};
179
180#define KVM_CPUID_FLAG_SIGNIFCANT_INDEX 1
181#define KVM_CPUID_FLAG_STATEFUL_FUNC 2
182#define KVM_CPUID_FLAG_STATE_READ_NEXT 4
183
184/* for KVM_SET_CPUID2 */
185struct kvm_cpuid2 {
186 __u32 nent;
187 __u32 padding;
188 struct kvm_cpuid_entry2 entries[0];
189};
190
191#endif
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h
new file mode 100644
index 000000000000..4702b04b979a
--- /dev/null
+++ b/include/asm-x86/kvm_host.h
@@ -0,0 +1,611 @@
1#/*
2 * Kernel-based Virtual Machine driver for Linux
3 *
4 * This header defines architecture specific interfaces, x86 version
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2. See
7 * the COPYING file in the top-level directory.
8 *
9 */
10
11#ifndef ASM_KVM_HOST_H
12#define ASM_KVM_HOST_H
13
14#include <linux/types.h>
15#include <linux/mm.h>
16
17#include <linux/kvm.h>
18#include <linux/kvm_para.h>
19#include <linux/kvm_types.h>
20
21#include <asm/desc.h>
22
23#define CR3_PAE_RESERVED_BITS ((X86_CR3_PWT | X86_CR3_PCD) - 1)
24#define CR3_NONPAE_RESERVED_BITS ((PAGE_SIZE-1) & ~(X86_CR3_PWT | X86_CR3_PCD))
25#define CR3_L_MODE_RESERVED_BITS (CR3_NONPAE_RESERVED_BITS|0xFFFFFF0000000000ULL)
26
27#define KVM_GUEST_CR0_MASK \
28 (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE \
29 | X86_CR0_NW | X86_CR0_CD)
30#define KVM_VM_CR0_ALWAYS_ON \
31 (X86_CR0_PG | X86_CR0_PE | X86_CR0_WP | X86_CR0_NE | X86_CR0_TS \
32 | X86_CR0_MP)
33#define KVM_GUEST_CR4_MASK \
34 (X86_CR4_VME | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE | X86_CR4_VMXE)
35#define KVM_PMODE_VM_CR4_ALWAYS_ON (X86_CR4_PAE | X86_CR4_VMXE)
36#define KVM_RMODE_VM_CR4_ALWAYS_ON (X86_CR4_VME | X86_CR4_PAE | X86_CR4_VMXE)
37
38#define INVALID_PAGE (~(hpa_t)0)
39#define UNMAPPED_GVA (~(gpa_t)0)
40
41#define DE_VECTOR 0
42#define UD_VECTOR 6
43#define NM_VECTOR 7
44#define DF_VECTOR 8
45#define TS_VECTOR 10
46#define NP_VECTOR 11
47#define SS_VECTOR 12
48#define GP_VECTOR 13
49#define PF_VECTOR 14
50
51#define SELECTOR_TI_MASK (1 << 2)
52#define SELECTOR_RPL_MASK 0x03
53
54#define IOPL_SHIFT 12
55
56#define KVM_ALIAS_SLOTS 4
57
58#define KVM_PERMILLE_MMU_PAGES 20
59#define KVM_MIN_ALLOC_MMU_PAGES 64
60#define KVM_NUM_MMU_PAGES 1024
61#define KVM_MIN_FREE_MMU_PAGES 5
62#define KVM_REFILL_PAGES 25
63#define KVM_MAX_CPUID_ENTRIES 40
64
65extern spinlock_t kvm_lock;
66extern struct list_head vm_list;
67
68struct kvm_vcpu;
69struct kvm;
70
71enum {
72 VCPU_REGS_RAX = 0,
73 VCPU_REGS_RCX = 1,
74 VCPU_REGS_RDX = 2,
75 VCPU_REGS_RBX = 3,
76 VCPU_REGS_RSP = 4,
77 VCPU_REGS_RBP = 5,
78 VCPU_REGS_RSI = 6,
79 VCPU_REGS_RDI = 7,
80#ifdef CONFIG_X86_64
81 VCPU_REGS_R8 = 8,
82 VCPU_REGS_R9 = 9,
83 VCPU_REGS_R10 = 10,
84 VCPU_REGS_R11 = 11,
85 VCPU_REGS_R12 = 12,
86 VCPU_REGS_R13 = 13,
87 VCPU_REGS_R14 = 14,
88 VCPU_REGS_R15 = 15,
89#endif
90 NR_VCPU_REGS
91};
92
93enum {
94 VCPU_SREG_CS,
95 VCPU_SREG_DS,
96 VCPU_SREG_ES,
97 VCPU_SREG_FS,
98 VCPU_SREG_GS,
99 VCPU_SREG_SS,
100 VCPU_SREG_TR,
101 VCPU_SREG_LDTR,
102};
103
104#include <asm/kvm_x86_emulate.h>
105
106#define KVM_NR_MEM_OBJS 40
107
108/*
109 * We don't want allocation failures within the mmu code, so we preallocate
110 * enough memory for a single page fault in a cache.
111 */
112struct kvm_mmu_memory_cache {
113 int nobjs;
114 void *objects[KVM_NR_MEM_OBJS];
115};
116
117#define NR_PTE_CHAIN_ENTRIES 5
118
119struct kvm_pte_chain {
120 u64 *parent_ptes[NR_PTE_CHAIN_ENTRIES];
121 struct hlist_node link;
122};
123
124/*
125 * kvm_mmu_page_role, below, is defined as:
126 *
127 * bits 0:3 - total guest paging levels (2-4, or zero for real mode)
128 * bits 4:7 - page table level for this shadow (1-4)
129 * bits 8:9 - page table quadrant for 2-level guests
130 * bit 16 - "metaphysical" - gfn is not a real page (huge page/real mode)
131 * bits 17:19 - common access permissions for all ptes in this shadow page
132 */
133union kvm_mmu_page_role {
134 unsigned word;
135 struct {
136 unsigned glevels : 4;
137 unsigned level : 4;
138 unsigned quadrant : 2;
139 unsigned pad_for_nice_hex_output : 6;
140 unsigned metaphysical : 1;
141 unsigned access : 3;
142 };
143};
144
145struct kvm_mmu_page {
146 struct list_head link;
147 struct hlist_node hash_link;
148
149 /*
150 * The following two entries are used to key the shadow page in the
151 * hash table.
152 */
153 gfn_t gfn;
154 union kvm_mmu_page_role role;
155
156 u64 *spt;
157 /* hold the gfn of each spte inside spt */
158 gfn_t *gfns;
159 unsigned long slot_bitmap; /* One bit set per slot which has memory
160 * in this shadow page.
161 */
162 int multimapped; /* More than one parent_pte? */
163 int root_count; /* Currently serving as active root */
164 union {
165 u64 *parent_pte; /* !multimapped */
166 struct hlist_head parent_ptes; /* multimapped, kvm_pte_chain */
167 };
168};
169
170/*
171 * x86 supports 3 paging modes (4-level 64-bit, 3-level 64-bit, and 2-level
172 * 32-bit). The kvm_mmu structure abstracts the details of the current mmu
173 * mode.
174 */
175struct kvm_mmu {
176 void (*new_cr3)(struct kvm_vcpu *vcpu);
177 int (*page_fault)(struct kvm_vcpu *vcpu, gva_t gva, u32 err);
178 void (*free)(struct kvm_vcpu *vcpu);
179 gpa_t (*gva_to_gpa)(struct kvm_vcpu *vcpu, gva_t gva);
180 void (*prefetch_page)(struct kvm_vcpu *vcpu,
181 struct kvm_mmu_page *page);
182 hpa_t root_hpa;
183 int root_level;
184 int shadow_root_level;
185
186 u64 *pae_root;
187};
188
189struct kvm_vcpu_arch {
190 u64 host_tsc;
191 int interrupt_window_open;
192 unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
193 DECLARE_BITMAP(irq_pending, KVM_NR_INTERRUPTS);
194 unsigned long regs[NR_VCPU_REGS]; /* for rsp: vcpu_load_rsp_rip() */
195 unsigned long rip; /* needs vcpu_load_rsp_rip() */
196
197 unsigned long cr0;
198 unsigned long cr2;
199 unsigned long cr3;
200 unsigned long cr4;
201 unsigned long cr8;
202 u64 pdptrs[4]; /* pae */
203 u64 shadow_efer;
204 u64 apic_base;
205 struct kvm_lapic *apic; /* kernel irqchip context */
206#define VCPU_MP_STATE_RUNNABLE 0
207#define VCPU_MP_STATE_UNINITIALIZED 1
208#define VCPU_MP_STATE_INIT_RECEIVED 2
209#define VCPU_MP_STATE_SIPI_RECEIVED 3
210#define VCPU_MP_STATE_HALTED 4
211 int mp_state;
212 int sipi_vector;
213 u64 ia32_misc_enable_msr;
214 bool tpr_access_reporting;
215
216 struct kvm_mmu mmu;
217
218 struct kvm_mmu_memory_cache mmu_pte_chain_cache;
219 struct kvm_mmu_memory_cache mmu_rmap_desc_cache;
220 struct kvm_mmu_memory_cache mmu_page_cache;
221 struct kvm_mmu_memory_cache mmu_page_header_cache;
222
223 gfn_t last_pt_write_gfn;
224 int last_pt_write_count;
225 u64 *last_pte_updated;
226
227 struct {
228 gfn_t gfn; /* presumed gfn during guest pte update */
229 struct page *page; /* page corresponding to that gfn */
230 } update_pte;
231
232 struct i387_fxsave_struct host_fx_image;
233 struct i387_fxsave_struct guest_fx_image;
234
235 gva_t mmio_fault_cr2;
236 struct kvm_pio_request pio;
237 void *pio_data;
238
239 struct kvm_queued_exception {
240 bool pending;
241 bool has_error_code;
242 u8 nr;
243 u32 error_code;
244 } exception;
245
246 struct {
247 int active;
248 u8 save_iopl;
249 struct kvm_save_segment {
250 u16 selector;
251 unsigned long base;
252 u32 limit;
253 u32 ar;
254 } tr, es, ds, fs, gs;
255 } rmode;
256 int halt_request; /* real mode on Intel only */
257
258 int cpuid_nent;
259 struct kvm_cpuid_entry2 cpuid_entries[KVM_MAX_CPUID_ENTRIES];
260 /* emulate context */
261
262 struct x86_emulate_ctxt emulate_ctxt;
263};
264
265struct kvm_mem_alias {
266 gfn_t base_gfn;
267 unsigned long npages;
268 gfn_t target_gfn;
269};
270
271struct kvm_arch{
272 int naliases;
273 struct kvm_mem_alias aliases[KVM_ALIAS_SLOTS];
274
275 unsigned int n_free_mmu_pages;
276 unsigned int n_requested_mmu_pages;
277 unsigned int n_alloc_mmu_pages;
278 struct hlist_head mmu_page_hash[KVM_NUM_MMU_PAGES];
279 /*
280 * Hash table of struct kvm_mmu_page.
281 */
282 struct list_head active_mmu_pages;
283 struct kvm_pic *vpic;
284 struct kvm_ioapic *vioapic;
285
286 int round_robin_prev_vcpu;
287 unsigned int tss_addr;
288 struct page *apic_access_page;
289};
290
291struct kvm_vm_stat {
292 u32 mmu_shadow_zapped;
293 u32 mmu_pte_write;
294 u32 mmu_pte_updated;
295 u32 mmu_pde_zapped;
296 u32 mmu_flooded;
297 u32 mmu_recycled;
298 u32 mmu_cache_miss;
299 u32 remote_tlb_flush;
300};
301
302struct kvm_vcpu_stat {
303 u32 pf_fixed;
304 u32 pf_guest;
305 u32 tlb_flush;
306 u32 invlpg;
307
308 u32 exits;
309 u32 io_exits;
310 u32 mmio_exits;
311 u32 signal_exits;
312 u32 irq_window_exits;
313 u32 halt_exits;
314 u32 halt_wakeup;
315 u32 request_irq_exits;
316 u32 irq_exits;
317 u32 host_state_reload;
318 u32 efer_reload;
319 u32 fpu_reload;
320 u32 insn_emulation;
321 u32 insn_emulation_fail;
322};
323
324struct descriptor_table {
325 u16 limit;
326 unsigned long base;
327} __attribute__((packed));
328
329struct kvm_x86_ops {
330 int (*cpu_has_kvm_support)(void); /* __init */
331 int (*disabled_by_bios)(void); /* __init */
332 void (*hardware_enable)(void *dummy); /* __init */
333 void (*hardware_disable)(void *dummy);
334 void (*check_processor_compatibility)(void *rtn);
335 int (*hardware_setup)(void); /* __init */
336 void (*hardware_unsetup)(void); /* __exit */
337 bool (*cpu_has_accelerated_tpr)(void);
338
339 /* Create, but do not attach this VCPU */
340 struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
341 void (*vcpu_free)(struct kvm_vcpu *vcpu);
342 int (*vcpu_reset)(struct kvm_vcpu *vcpu);
343
344 void (*prepare_guest_switch)(struct kvm_vcpu *vcpu);
345 void (*vcpu_load)(struct kvm_vcpu *vcpu, int cpu);
346 void (*vcpu_put)(struct kvm_vcpu *vcpu);
347 void (*vcpu_decache)(struct kvm_vcpu *vcpu);
348
349 int (*set_guest_debug)(struct kvm_vcpu *vcpu,
350 struct kvm_debug_guest *dbg);
351 void (*guest_debug_pre)(struct kvm_vcpu *vcpu);
352 int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata);
353 int (*set_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 data);
354 u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg);
355 void (*get_segment)(struct kvm_vcpu *vcpu,
356 struct kvm_segment *var, int seg);
357 void (*set_segment)(struct kvm_vcpu *vcpu,
358 struct kvm_segment *var, int seg);
359 void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l);
360 void (*decache_cr4_guest_bits)(struct kvm_vcpu *vcpu);
361 void (*set_cr0)(struct kvm_vcpu *vcpu, unsigned long cr0);
362 void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
363 void (*set_cr4)(struct kvm_vcpu *vcpu, unsigned long cr4);
364 void (*set_efer)(struct kvm_vcpu *vcpu, u64 efer);
365 void (*get_idt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
366 void (*set_idt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
367 void (*get_gdt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
368 void (*set_gdt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
369 unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr);
370 void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value,
371 int *exception);
372 void (*cache_regs)(struct kvm_vcpu *vcpu);
373 void (*decache_regs)(struct kvm_vcpu *vcpu);
374 unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
375 void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
376
377 void (*tlb_flush)(struct kvm_vcpu *vcpu);
378
379 void (*run)(struct kvm_vcpu *vcpu, struct kvm_run *run);
380 int (*handle_exit)(struct kvm_run *run, struct kvm_vcpu *vcpu);
381 void (*skip_emulated_instruction)(struct kvm_vcpu *vcpu);
382 void (*patch_hypercall)(struct kvm_vcpu *vcpu,
383 unsigned char *hypercall_addr);
384 int (*get_irq)(struct kvm_vcpu *vcpu);
385 void (*set_irq)(struct kvm_vcpu *vcpu, int vec);
386 void (*queue_exception)(struct kvm_vcpu *vcpu, unsigned nr,
387 bool has_error_code, u32 error_code);
388 bool (*exception_injected)(struct kvm_vcpu *vcpu);
389 void (*inject_pending_irq)(struct kvm_vcpu *vcpu);
390 void (*inject_pending_vectors)(struct kvm_vcpu *vcpu,
391 struct kvm_run *run);
392
393 int (*set_tss_addr)(struct kvm *kvm, unsigned int addr);
394};
395
396extern struct kvm_x86_ops *kvm_x86_ops;
397
398int kvm_mmu_module_init(void);
399void kvm_mmu_module_exit(void);
400
401void kvm_mmu_destroy(struct kvm_vcpu *vcpu);
402int kvm_mmu_create(struct kvm_vcpu *vcpu);
403int kvm_mmu_setup(struct kvm_vcpu *vcpu);
404void kvm_mmu_set_nonpresent_ptes(u64 trap_pte, u64 notrap_pte);
405
406int kvm_mmu_reset_context(struct kvm_vcpu *vcpu);
407void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot);
408void kvm_mmu_zap_all(struct kvm *kvm);
409unsigned int kvm_mmu_calculate_mmu_pages(struct kvm *kvm);
410void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages);
411
412enum emulation_result {
413 EMULATE_DONE, /* no further processing */
414 EMULATE_DO_MMIO, /* kvm_run filled with mmio request */
415 EMULATE_FAIL, /* can't emulate this instruction */
416};
417
418#define EMULTYPE_NO_DECODE (1 << 0)
419#define EMULTYPE_TRAP_UD (1 << 1)
420int emulate_instruction(struct kvm_vcpu *vcpu, struct kvm_run *run,
421 unsigned long cr2, u16 error_code, int emulation_type);
422void kvm_report_emulation_failure(struct kvm_vcpu *cvpu, const char *context);
423void realmode_lgdt(struct kvm_vcpu *vcpu, u16 size, unsigned long address);
424void realmode_lidt(struct kvm_vcpu *vcpu, u16 size, unsigned long address);
425void realmode_lmsw(struct kvm_vcpu *vcpu, unsigned long msw,
426 unsigned long *rflags);
427
428unsigned long realmode_get_cr(struct kvm_vcpu *vcpu, int cr);
429void realmode_set_cr(struct kvm_vcpu *vcpu, int cr, unsigned long value,
430 unsigned long *rflags);
431int kvm_get_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 *data);
432int kvm_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data);
433
434struct x86_emulate_ctxt;
435
436int kvm_emulate_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
437 int size, unsigned port);
438int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, struct kvm_run *run, int in,
439 int size, unsigned long count, int down,
440 gva_t address, int rep, unsigned port);
441void kvm_emulate_cpuid(struct kvm_vcpu *vcpu);
442int kvm_emulate_halt(struct kvm_vcpu *vcpu);
443int emulate_invlpg(struct kvm_vcpu *vcpu, gva_t address);
444int emulate_clts(struct kvm_vcpu *vcpu);
445int emulator_get_dr(struct x86_emulate_ctxt *ctxt, int dr,
446 unsigned long *dest);
447int emulator_set_dr(struct x86_emulate_ctxt *ctxt, int dr,
448 unsigned long value);
449
450void set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0);
451void set_cr3(struct kvm_vcpu *vcpu, unsigned long cr0);
452void set_cr4(struct kvm_vcpu *vcpu, unsigned long cr0);
453void set_cr8(struct kvm_vcpu *vcpu, unsigned long cr0);
454unsigned long get_cr8(struct kvm_vcpu *vcpu);
455void lmsw(struct kvm_vcpu *vcpu, unsigned long msw);
456void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l);
457
458int kvm_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata);
459int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data);
460
461void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr);
462void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code);
463void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long cr2,
464 u32 error_code);
465
466void fx_init(struct kvm_vcpu *vcpu);
467
468int emulator_read_std(unsigned long addr,
469 void *val,
470 unsigned int bytes,
471 struct kvm_vcpu *vcpu);
472int emulator_write_emulated(unsigned long addr,
473 const void *val,
474 unsigned int bytes,
475 struct kvm_vcpu *vcpu);
476
477unsigned long segment_base(u16 selector);
478
479void kvm_mmu_flush_tlb(struct kvm_vcpu *vcpu);
480void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
481 const u8 *new, int bytes);
482int kvm_mmu_unprotect_page_virt(struct kvm_vcpu *vcpu, gva_t gva);
483void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
484int kvm_mmu_load(struct kvm_vcpu *vcpu);
485void kvm_mmu_unload(struct kvm_vcpu *vcpu);
486
487int kvm_emulate_hypercall(struct kvm_vcpu *vcpu);
488
489int kvm_fix_hypercall(struct kvm_vcpu *vcpu);
490
491int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva, u32 error_code);
492
493int load_pdptrs(struct kvm_vcpu *vcpu, unsigned long cr3);
494int complete_pio(struct kvm_vcpu *vcpu);
495
496static inline struct kvm_mmu_page *page_header(hpa_t shadow_page)
497{
498 struct page *page = pfn_to_page(shadow_page >> PAGE_SHIFT);
499
500 return (struct kvm_mmu_page *)page_private(page);
501}
502
503static inline u16 read_fs(void)
504{
505 u16 seg;
506 asm("mov %%fs, %0" : "=g"(seg));
507 return seg;
508}
509
510static inline u16 read_gs(void)
511{
512 u16 seg;
513 asm("mov %%gs, %0" : "=g"(seg));
514 return seg;
515}
516
517static inline u16 read_ldt(void)
518{
519 u16 ldt;
520 asm("sldt %0" : "=g"(ldt));
521 return ldt;
522}
523
524static inline void load_fs(u16 sel)
525{
526 asm("mov %0, %%fs" : : "rm"(sel));
527}
528
529static inline void load_gs(u16 sel)
530{
531 asm("mov %0, %%gs" : : "rm"(sel));
532}
533
534#ifndef load_ldt
535static inline void load_ldt(u16 sel)
536{
537 asm("lldt %0" : : "rm"(sel));
538}
539#endif
540
541static inline void get_idt(struct descriptor_table *table)
542{
543 asm("sidt %0" : "=m"(*table));
544}
545
546static inline void get_gdt(struct descriptor_table *table)
547{
548 asm("sgdt %0" : "=m"(*table));
549}
550
551static inline unsigned long read_tr_base(void)
552{
553 u16 tr;
554 asm("str %0" : "=g"(tr));
555 return segment_base(tr);
556}
557
558#ifdef CONFIG_X86_64
559static inline unsigned long read_msr(unsigned long msr)
560{
561 u64 value;
562
563 rdmsrl(msr, value);
564 return value;
565}
566#endif
567
568static inline void fx_save(struct i387_fxsave_struct *image)
569{
570 asm("fxsave (%0)":: "r" (image));
571}
572
573static inline void fx_restore(struct i387_fxsave_struct *image)
574{
575 asm("fxrstor (%0)":: "r" (image));
576}
577
578static inline void fpu_init(void)
579{
580 asm("finit");
581}
582
583static inline u32 get_rdx_init_val(void)
584{
585 return 0x600; /* P6 family */
586}
587
588static inline void kvm_inject_gp(struct kvm_vcpu *vcpu, u32 error_code)
589{
590 kvm_queue_exception_e(vcpu, GP_VECTOR, error_code);
591}
592
593#define ASM_VMX_VMCLEAR_RAX ".byte 0x66, 0x0f, 0xc7, 0x30"
594#define ASM_VMX_VMLAUNCH ".byte 0x0f, 0x01, 0xc2"
595#define ASM_VMX_VMRESUME ".byte 0x0f, 0x01, 0xc3"
596#define ASM_VMX_VMPTRLD_RAX ".byte 0x0f, 0xc7, 0x30"
597#define ASM_VMX_VMREAD_RDX_RAX ".byte 0x0f, 0x78, 0xd0"
598#define ASM_VMX_VMWRITE_RAX_RDX ".byte 0x0f, 0x79, 0xd0"
599#define ASM_VMX_VMWRITE_RSP_RDX ".byte 0x0f, 0x79, 0xd4"
600#define ASM_VMX_VMXOFF ".byte 0x0f, 0x01, 0xc4"
601#define ASM_VMX_VMXON_RAX ".byte 0xf3, 0x0f, 0xc7, 0x30"
602
603#define MSR_IA32_TIME_STAMP_COUNTER 0x010
604
605#define TSS_IOPB_BASE_OFFSET 0x66
606#define TSS_BASE_SIZE 0x68
607#define TSS_IOPB_SIZE (65536 / 8)
608#define TSS_REDIRECTION_SIZE (256 / 8)
609#define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
610
611#endif
diff --git a/include/asm-x86/kvm_para.h b/include/asm-x86/kvm_para.h
new file mode 100644
index 000000000000..c6f3fd8d8c53
--- /dev/null
+++ b/include/asm-x86/kvm_para.h
@@ -0,0 +1,105 @@
1#ifndef __X86_KVM_PARA_H
2#define __X86_KVM_PARA_H
3
4/* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx. It
5 * should be used to determine that a VM is running under KVM.
6 */
7#define KVM_CPUID_SIGNATURE 0x40000000
8
9/* This CPUID returns a feature bitmap in eax. Before enabling a particular
10 * paravirtualization, the appropriate feature bit should be checked.
11 */
12#define KVM_CPUID_FEATURES 0x40000001
13
14#ifdef __KERNEL__
15#include <asm/processor.h>
16
17/* This instruction is vmcall. On non-VT architectures, it will generate a
18 * trap that we will then rewrite to the appropriate instruction.
19 */
20#define KVM_HYPERCALL ".byte 0x0f,0x01,0xc1"
21
22/* For KVM hypercalls, a three-byte sequence of either the vmrun or the vmmrun
23 * instruction. The hypervisor may replace it with something else but only the
24 * instructions are guaranteed to be supported.
25 *
26 * Up to four arguments may be passed in rbx, rcx, rdx, and rsi respectively.
27 * The hypercall number should be placed in rax and the return value will be
28 * placed in rax. No other registers will be clobbered unless explicited
29 * noted by the particular hypercall.
30 */
31
32static inline long kvm_hypercall0(unsigned int nr)
33{
34 long ret;
35 asm volatile(KVM_HYPERCALL
36 : "=a"(ret)
37 : "a"(nr));
38 return ret;
39}
40
41static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
42{
43 long ret;
44 asm volatile(KVM_HYPERCALL
45 : "=a"(ret)
46 : "a"(nr), "b"(p1));
47 return ret;
48}
49
50static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
51 unsigned long p2)
52{
53 long ret;
54 asm volatile(KVM_HYPERCALL
55 : "=a"(ret)
56 : "a"(nr), "b"(p1), "c"(p2));
57 return ret;
58}
59
60static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
61 unsigned long p2, unsigned long p3)
62{
63 long ret;
64 asm volatile(KVM_HYPERCALL
65 : "=a"(ret)
66 : "a"(nr), "b"(p1), "c"(p2), "d"(p3));
67 return ret;
68}
69
70static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
71 unsigned long p2, unsigned long p3,
72 unsigned long p4)
73{
74 long ret;
75 asm volatile(KVM_HYPERCALL
76 : "=a"(ret)
77 : "a"(nr), "b"(p1), "c"(p2), "d"(p3), "S"(p4));
78 return ret;
79}
80
81static inline int kvm_para_available(void)
82{
83 unsigned int eax, ebx, ecx, edx;
84 char signature[13];
85
86 cpuid(KVM_CPUID_SIGNATURE, &eax, &ebx, &ecx, &edx);
87 memcpy(signature + 0, &ebx, 4);
88 memcpy(signature + 4, &ecx, 4);
89 memcpy(signature + 8, &edx, 4);
90 signature[12] = 0;
91
92 if (strcmp(signature, "KVMKVMKVM") == 0)
93 return 1;
94
95 return 0;
96}
97
98static inline unsigned int kvm_arch_para_features(void)
99{
100 return cpuid_eax(KVM_CPUID_FEATURES);
101}
102
103#endif
104
105#endif
diff --git a/include/asm-x86/kvm_x86_emulate.h b/include/asm-x86/kvm_x86_emulate.h
new file mode 100644
index 000000000000..7db91b9bdcd4
--- /dev/null
+++ b/include/asm-x86/kvm_x86_emulate.h
@@ -0,0 +1,186 @@
1/******************************************************************************
2 * x86_emulate.h
3 *
4 * Generic x86 (32-bit and 64-bit) instruction decoder and emulator.
5 *
6 * Copyright (c) 2005 Keir Fraser
7 *
8 * From: xen-unstable 10676:af9809f51f81a3c43f276f00c81a52ef558afda4
9 */
10
11#ifndef __X86_EMULATE_H__
12#define __X86_EMULATE_H__
13
14struct x86_emulate_ctxt;
15
16/*
17 * x86_emulate_ops:
18 *
19 * These operations represent the instruction emulator's interface to memory.
20 * There are two categories of operation: those that act on ordinary memory
21 * regions (*_std), and those that act on memory regions known to require
22 * special treatment or emulation (*_emulated).
23 *
24 * The emulator assumes that an instruction accesses only one 'emulated memory'
25 * location, that this location is the given linear faulting address (cr2), and
26 * that this is one of the instruction's data operands. Instruction fetches and
27 * stack operations are assumed never to access emulated memory. The emulator
28 * automatically deduces which operand of a string-move operation is accessing
29 * emulated memory, and assumes that the other operand accesses normal memory.
30 *
31 * NOTES:
32 * 1. The emulator isn't very smart about emulated vs. standard memory.
33 * 'Emulated memory' access addresses should be checked for sanity.
34 * 'Normal memory' accesses may fault, and the caller must arrange to
35 * detect and handle reentrancy into the emulator via recursive faults.
36 * Accesses may be unaligned and may cross page boundaries.
37 * 2. If the access fails (cannot emulate, or a standard access faults) then
38 * it is up to the memop to propagate the fault to the guest VM via
39 * some out-of-band mechanism, unknown to the emulator. The memop signals
40 * failure by returning X86EMUL_PROPAGATE_FAULT to the emulator, which will
41 * then immediately bail.
42 * 3. Valid access sizes are 1, 2, 4 and 8 bytes. On x86/32 systems only
43 * cmpxchg8b_emulated need support 8-byte accesses.
44 * 4. The emulator cannot handle 64-bit mode emulation on an x86/32 system.
45 */
46/* Access completed successfully: continue emulation as normal. */
47#define X86EMUL_CONTINUE 0
48/* Access is unhandleable: bail from emulation and return error to caller. */
49#define X86EMUL_UNHANDLEABLE 1
50/* Terminate emulation but return success to the caller. */
51#define X86EMUL_PROPAGATE_FAULT 2 /* propagate a generated fault to guest */
52#define X86EMUL_RETRY_INSTR 2 /* retry the instruction for some reason */
53#define X86EMUL_CMPXCHG_FAILED 2 /* cmpxchg did not see expected value */
54struct x86_emulate_ops {
55 /*
56 * read_std: Read bytes of standard (non-emulated/special) memory.
57 * Used for instruction fetch, stack operations, and others.
58 * @addr: [IN ] Linear address from which to read.
59 * @val: [OUT] Value read from memory, zero-extended to 'u_long'.
60 * @bytes: [IN ] Number of bytes to read from memory.
61 */
62 int (*read_std)(unsigned long addr, void *val,
63 unsigned int bytes, struct kvm_vcpu *vcpu);
64
65 /*
66 * read_emulated: Read bytes from emulated/special memory area.
67 * @addr: [IN ] Linear address from which to read.
68 * @val: [OUT] Value read from memory, zero-extended to 'u_long'.
69 * @bytes: [IN ] Number of bytes to read from memory.
70 */
71 int (*read_emulated) (unsigned long addr,
72 void *val,
73 unsigned int bytes,
74 struct kvm_vcpu *vcpu);
75
76 /*
77 * write_emulated: Read bytes from emulated/special memory area.
78 * @addr: [IN ] Linear address to which to write.
79 * @val: [IN ] Value to write to memory (low-order bytes used as
80 * required).
81 * @bytes: [IN ] Number of bytes to write to memory.
82 */
83 int (*write_emulated) (unsigned long addr,
84 const void *val,
85 unsigned int bytes,
86 struct kvm_vcpu *vcpu);
87
88 /*
89 * cmpxchg_emulated: Emulate an atomic (LOCKed) CMPXCHG operation on an
90 * emulated/special memory area.
91 * @addr: [IN ] Linear address to access.
92 * @old: [IN ] Value expected to be current at @addr.
93 * @new: [IN ] Value to write to @addr.
94 * @bytes: [IN ] Number of bytes to access using CMPXCHG.
95 */
96 int (*cmpxchg_emulated) (unsigned long addr,
97 const void *old,
98 const void *new,
99 unsigned int bytes,
100 struct kvm_vcpu *vcpu);
101
102};
103
104/* Type, address-of, and value of an instruction's operand. */
105struct operand {
106 enum { OP_REG, OP_MEM, OP_IMM, OP_NONE } type;
107 unsigned int bytes;
108 unsigned long val, orig_val, *ptr;
109};
110
111struct fetch_cache {
112 u8 data[15];
113 unsigned long start;
114 unsigned long end;
115};
116
117struct decode_cache {
118 u8 twobyte;
119 u8 b;
120 u8 lock_prefix;
121 u8 rep_prefix;
122 u8 op_bytes;
123 u8 ad_bytes;
124 u8 rex_prefix;
125 struct operand src;
126 struct operand dst;
127 unsigned long *override_base;
128 unsigned int d;
129 unsigned long regs[NR_VCPU_REGS];
130 unsigned long eip;
131 /* modrm */
132 u8 modrm;
133 u8 modrm_mod;
134 u8 modrm_reg;
135 u8 modrm_rm;
136 u8 use_modrm_ea;
137 unsigned long modrm_ea;
138 unsigned long modrm_val;
139 struct fetch_cache fetch;
140};
141
142struct x86_emulate_ctxt {
143 /* Register state before/after emulation. */
144 struct kvm_vcpu *vcpu;
145
146 /* Linear faulting address (if emulating a page-faulting instruction). */
147 unsigned long eflags;
148
149 /* Emulated execution mode, represented by an X86EMUL_MODE value. */
150 int mode;
151
152 unsigned long cs_base;
153 unsigned long ds_base;
154 unsigned long es_base;
155 unsigned long ss_base;
156 unsigned long gs_base;
157 unsigned long fs_base;
158
159 /* decode cache */
160
161 struct decode_cache decode;
162};
163
164/* Repeat String Operation Prefix */
165#define REPE_PREFIX 1
166#define REPNE_PREFIX 2
167
168/* Execution mode, passed to the emulator. */
169#define X86EMUL_MODE_REAL 0 /* Real mode. */
170#define X86EMUL_MODE_PROT16 2 /* 16-bit protected mode. */
171#define X86EMUL_MODE_PROT32 4 /* 32-bit protected mode. */
172#define X86EMUL_MODE_PROT64 8 /* 64-bit (long) mode. */
173
174/* Host execution mode. */
175#if defined(__i386__)
176#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT32
177#elif defined(CONFIG_X86_64)
178#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64
179#endif
180
181int x86_decode_insn(struct x86_emulate_ctxt *ctxt,
182 struct x86_emulate_ops *ops);
183int x86_emulate_insn(struct x86_emulate_ctxt *ctxt,
184 struct x86_emulate_ops *ops);
185
186#endif /* __X86_EMULATE_H__ */
diff --git a/include/asm-x86/lguest.h b/include/asm-x86/lguest.h
index ccd338460811..4d9367b72976 100644
--- a/include/asm-x86/lguest.h
+++ b/include/asm-x86/lguest.h
@@ -44,19 +44,19 @@ struct lguest_ro_state
44{ 44{
45 /* Host information we need to restore when we switch back. */ 45 /* Host information we need to restore when we switch back. */
46 u32 host_cr3; 46 u32 host_cr3;
47 struct Xgt_desc_struct host_idt_desc; 47 struct desc_ptr host_idt_desc;
48 struct Xgt_desc_struct host_gdt_desc; 48 struct desc_ptr host_gdt_desc;
49 u32 host_sp; 49 u32 host_sp;
50 50
51 /* Fields which are used when guest is running. */ 51 /* Fields which are used when guest is running. */
52 struct Xgt_desc_struct guest_idt_desc; 52 struct desc_ptr guest_idt_desc;
53 struct Xgt_desc_struct guest_gdt_desc; 53 struct desc_ptr guest_gdt_desc;
54 struct i386_hw_tss guest_tss; 54 struct x86_hw_tss guest_tss;
55 struct desc_struct guest_idt[IDT_ENTRIES]; 55 struct desc_struct guest_idt[IDT_ENTRIES];
56 struct desc_struct guest_gdt[GDT_ENTRIES]; 56 struct desc_struct guest_gdt[GDT_ENTRIES];
57}; 57};
58 58
59struct lguest_arch 59struct lg_cpu_arch
60{ 60{
61 /* The GDT entries copied into lguest_ro_state when running. */ 61 /* The GDT entries copied into lguest_ro_state when running. */
62 struct desc_struct gdt[GDT_ENTRIES]; 62 struct desc_struct gdt[GDT_ENTRIES];
@@ -78,8 +78,8 @@ static inline void lguest_set_ts(void)
78} 78}
79 79
80/* Full 4G segment descriptors, suitable for CS and DS. */ 80/* Full 4G segment descriptors, suitable for CS and DS. */
81#define FULL_EXEC_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9b00}) 81#define FULL_EXEC_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9b00} } })
82#define FULL_SEGMENT ((struct desc_struct){0x0000ffff, 0x00cf9300}) 82#define FULL_SEGMENT ((struct desc_struct){ { {0x0000ffff, 0x00cf9300} } })
83 83
84#endif /* __ASSEMBLY__ */ 84#endif /* __ASSEMBLY__ */
85 85
diff --git a/include/asm-x86/lguest_hcall.h b/include/asm-x86/lguest_hcall.h
index 9c5092b6aa9f..758b9a5d4539 100644
--- a/include/asm-x86/lguest_hcall.h
+++ b/include/asm-x86/lguest_hcall.h
@@ -4,7 +4,7 @@
4 4
5#define LHCALL_FLUSH_ASYNC 0 5#define LHCALL_FLUSH_ASYNC 0
6#define LHCALL_LGUEST_INIT 1 6#define LHCALL_LGUEST_INIT 1
7#define LHCALL_CRASH 2 7#define LHCALL_SHUTDOWN 2
8#define LHCALL_LOAD_GDT 3 8#define LHCALL_LOAD_GDT 3
9#define LHCALL_NEW_PGTABLE 4 9#define LHCALL_NEW_PGTABLE 4
10#define LHCALL_FLUSH_TLB 5 10#define LHCALL_FLUSH_TLB 5
@@ -20,6 +20,10 @@
20 20
21#define LGUEST_TRAP_ENTRY 0x1F 21#define LGUEST_TRAP_ENTRY 0x1F
22 22
23/* Argument number 3 to LHCALL_LGUEST_SHUTDOWN */
24#define LGUEST_SHUTDOWN_POWEROFF 1
25#define LGUEST_SHUTDOWN_RESTART 2
26
23#ifndef __ASSEMBLY__ 27#ifndef __ASSEMBLY__
24#include <asm/hw_irq.h> 28#include <asm/hw_irq.h>
25 29
@@ -54,9 +58,6 @@ hcall(unsigned long call,
54} 58}
55/*:*/ 59/*:*/
56 60
57void async_hcall(unsigned long call,
58 unsigned long arg1, unsigned long arg2, unsigned long arg3);
59
60/* Can't use our min() macro here: needs to be a constant */ 61/* Can't use our min() macro here: needs to be a constant */
61#define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32) 62#define LGUEST_IRQS (NR_IRQS < 32 ? NR_IRQS: 32)
62 63
diff --git a/include/asm-x86/linkage.h b/include/asm-x86/linkage.h
index 94b257fa8701..31739c7d66a9 100644
--- a/include/asm-x86/linkage.h
+++ b/include/asm-x86/linkage.h
@@ -1,5 +1,25 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#ifdef CONFIG_X86_64
5#define __ALIGN .p2align 4,,15
6#define __ALIGN_STR ".p2align 4,,15"
7#endif
8
1#ifdef CONFIG_X86_32 9#ifdef CONFIG_X86_32
2# include "linkage_32.h" 10#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
3#else 11#define prevent_tail_call(ret) __asm__ ("" : "=r" (ret) : "0" (ret))
4# include "linkage_64.h" 12/*
13 * For 32-bit UML - mark functions implemented in assembly that use
14 * regparm input parameters:
15 */
16#define asmregparm __attribute__((regparm(3)))
17#endif
18
19#ifdef CONFIG_X86_ALIGNMENT_16
20#define __ALIGN .align 16,0x90
21#define __ALIGN_STR ".align 16,0x90"
22#endif
23
5#endif 24#endif
25
diff --git a/include/asm-x86/linkage_32.h b/include/asm-x86/linkage_32.h
deleted file mode 100644
index f4a6ebac0247..000000000000
--- a/include/asm-x86/linkage_32.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
5#define FASTCALL(x) x __attribute__((regparm(3)))
6#define fastcall __attribute__((regparm(3)))
7
8#define prevent_tail_call(ret) __asm__ ("" : "=r" (ret) : "0" (ret))
9
10#ifdef CONFIG_X86_ALIGNMENT_16
11#define __ALIGN .align 16,0x90
12#define __ALIGN_STR ".align 16,0x90"
13#endif
14
15#endif
diff --git a/include/asm-x86/linkage_64.h b/include/asm-x86/linkage_64.h
deleted file mode 100644
index b5f39d0189ce..000000000000
--- a/include/asm-x86/linkage_64.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#define __ALIGN .p2align 4,,15
5
6#endif
diff --git a/include/asm-x86/local.h b/include/asm-x86/local.h
index c7a1b1c66c96..f852c62b3319 100644
--- a/include/asm-x86/local.h
+++ b/include/asm-x86/local.h
@@ -1,5 +1,240 @@
1#ifdef CONFIG_X86_32 1#ifndef _ARCH_LOCAL_H
2# include "local_32.h" 2#define _ARCH_LOCAL_H
3#else 3
4# include "local_64.h" 4#include <linux/percpu.h>
5
6#include <asm/system.h>
7#include <asm/atomic.h>
8#include <asm/asm.h>
9
10typedef struct {
11 atomic_long_t a;
12} local_t;
13
14#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
15
16#define local_read(l) atomic_long_read(&(l)->a)
17#define local_set(l, i) atomic_long_set(&(l)->a, (i))
18
19static inline void local_inc(local_t *l)
20{
21 __asm__ __volatile__(
22 _ASM_INC "%0"
23 :"+m" (l->a.counter));
24}
25
26static inline void local_dec(local_t *l)
27{
28 __asm__ __volatile__(
29 _ASM_DEC "%0"
30 :"+m" (l->a.counter));
31}
32
33static inline void local_add(long i, local_t *l)
34{
35 __asm__ __volatile__(
36 _ASM_ADD "%1,%0"
37 :"+m" (l->a.counter)
38 :"ir" (i));
39}
40
41static inline void local_sub(long i, local_t *l)
42{
43 __asm__ __volatile__(
44 _ASM_SUB "%1,%0"
45 :"+m" (l->a.counter)
46 :"ir" (i));
47}
48
49/**
50 * local_sub_and_test - subtract value from variable and test result
51 * @i: integer value to subtract
52 * @l: pointer to type local_t
53 *
54 * Atomically subtracts @i from @l and returns
55 * true if the result is zero, or false for all
56 * other cases.
57 */
58static inline int local_sub_and_test(long i, local_t *l)
59{
60 unsigned char c;
61
62 __asm__ __volatile__(
63 _ASM_SUB "%2,%0; sete %1"
64 :"+m" (l->a.counter), "=qm" (c)
65 :"ir" (i) : "memory");
66 return c;
67}
68
69/**
70 * local_dec_and_test - decrement and test
71 * @l: pointer to type local_t
72 *
73 * Atomically decrements @l by 1 and
74 * returns true if the result is 0, or false for all other
75 * cases.
76 */
77static inline int local_dec_and_test(local_t *l)
78{
79 unsigned char c;
80
81 __asm__ __volatile__(
82 _ASM_DEC "%0; sete %1"
83 :"+m" (l->a.counter), "=qm" (c)
84 : : "memory");
85 return c != 0;
86}
87
88/**
89 * local_inc_and_test - increment and test
90 * @l: pointer to type local_t
91 *
92 * Atomically increments @l by 1
93 * and returns true if the result is zero, or false for all
94 * other cases.
95 */
96static inline int local_inc_and_test(local_t *l)
97{
98 unsigned char c;
99
100 __asm__ __volatile__(
101 _ASM_INC "%0; sete %1"
102 :"+m" (l->a.counter), "=qm" (c)
103 : : "memory");
104 return c != 0;
105}
106
107/**
108 * local_add_negative - add and test if negative
109 * @i: integer value to add
110 * @l: pointer to type local_t
111 *
112 * Atomically adds @i to @l and returns true
113 * if the result is negative, or false when
114 * result is greater than or equal to zero.
115 */
116static inline int local_add_negative(long i, local_t *l)
117{
118 unsigned char c;
119
120 __asm__ __volatile__(
121 _ASM_ADD "%2,%0; sets %1"
122 :"+m" (l->a.counter), "=qm" (c)
123 :"ir" (i) : "memory");
124 return c;
125}
126
127/**
128 * local_add_return - add and return
129 * @i: integer value to add
130 * @l: pointer to type local_t
131 *
132 * Atomically adds @i to @l and returns @i + @l
133 */
134static inline long local_add_return(long i, local_t *l)
135{
136 long __i;
137#ifdef CONFIG_M386
138 unsigned long flags;
139 if (unlikely(boot_cpu_data.x86 <= 3))
140 goto no_xadd;
5#endif 141#endif
142 /* Modern 486+ processor */
143 __i = i;
144 __asm__ __volatile__(
145 _ASM_XADD "%0, %1;"
146 :"+r" (i), "+m" (l->a.counter)
147 : : "memory");
148 return i + __i;
149
150#ifdef CONFIG_M386
151no_xadd: /* Legacy 386 processor */
152 local_irq_save(flags);
153 __i = local_read(l);
154 local_set(l, i + __i);
155 local_irq_restore(flags);
156 return i + __i;
157#endif
158}
159
160static inline long local_sub_return(long i, local_t *l)
161{
162 return local_add_return(-i, l);
163}
164
165#define local_inc_return(l) (local_add_return(1, l))
166#define local_dec_return(l) (local_sub_return(1, l))
167
168#define local_cmpxchg(l, o, n) \
169 (cmpxchg_local(&((l)->a.counter), (o), (n)))
170/* Always has a lock prefix */
171#define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
172
173/**
174 * local_add_unless - add unless the number is a given value
175 * @l: pointer of type local_t
176 * @a: the amount to add to l...
177 * @u: ...unless l is equal to u.
178 *
179 * Atomically adds @a to @l, so long as it was not @u.
180 * Returns non-zero if @l was not @u, and zero otherwise.
181 */
182#define local_add_unless(l, a, u) \
183({ \
184 long c, old; \
185 c = local_read(l); \
186 for (;;) { \
187 if (unlikely(c == (u))) \
188 break; \
189 old = local_cmpxchg((l), c, c + (a)); \
190 if (likely(old == c)) \
191 break; \
192 c = old; \
193 } \
194 c != (u); \
195})
196#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
197
198/* On x86_32, these are no better than the atomic variants.
199 * On x86-64 these are better than the atomic variants on SMP kernels
200 * because they dont use a lock prefix.
201 */
202#define __local_inc(l) local_inc(l)
203#define __local_dec(l) local_dec(l)
204#define __local_add(i, l) local_add((i), (l))
205#define __local_sub(i, l) local_sub((i), (l))
206
207/* Use these for per-cpu local_t variables: on some archs they are
208 * much more efficient than these naive implementations. Note they take
209 * a variable, not an address.
210 *
211 * X86_64: This could be done better if we moved the per cpu data directly
212 * after GS.
213 */
214
215/* Need to disable preemption for the cpu local counters otherwise we could
216 still access a variable of a previous CPU in a non atomic way. */
217#define cpu_local_wrap_v(l) \
218 ({ local_t res__; \
219 preempt_disable(); \
220 res__ = (l); \
221 preempt_enable(); \
222 res__; })
223#define cpu_local_wrap(l) \
224 ({ preempt_disable(); \
225 l; \
226 preempt_enable(); }) \
227
228#define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
229#define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
230#define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l)))
231#define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l)))
232#define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l)))
233#define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l)))
234
235#define __cpu_local_inc(l) cpu_local_inc(l)
236#define __cpu_local_dec(l) cpu_local_dec(l)
237#define __cpu_local_add(i, l) cpu_local_add((i), (l))
238#define __cpu_local_sub(i, l) cpu_local_sub((i), (l))
239
240#endif /* _ARCH_LOCAL_H */
diff --git a/include/asm-x86/local_32.h b/include/asm-x86/local_32.h
deleted file mode 100644
index 6e85975b9ed2..000000000000
--- a/include/asm-x86/local_32.h
+++ /dev/null
@@ -1,233 +0,0 @@
1#ifndef _ARCH_I386_LOCAL_H
2#define _ARCH_I386_LOCAL_H
3
4#include <linux/percpu.h>
5#include <asm/system.h>
6#include <asm/atomic.h>
7
8typedef struct
9{
10 atomic_long_t a;
11} local_t;
12
13#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
14
15#define local_read(l) atomic_long_read(&(l)->a)
16#define local_set(l,i) atomic_long_set(&(l)->a, (i))
17
18static __inline__ void local_inc(local_t *l)
19{
20 __asm__ __volatile__(
21 "incl %0"
22 :"+m" (l->a.counter));
23}
24
25static __inline__ void local_dec(local_t *l)
26{
27 __asm__ __volatile__(
28 "decl %0"
29 :"+m" (l->a.counter));
30}
31
32static __inline__ void local_add(long i, local_t *l)
33{
34 __asm__ __volatile__(
35 "addl %1,%0"
36 :"+m" (l->a.counter)
37 :"ir" (i));
38}
39
40static __inline__ void local_sub(long i, local_t *l)
41{
42 __asm__ __volatile__(
43 "subl %1,%0"
44 :"+m" (l->a.counter)
45 :"ir" (i));
46}
47
48/**
49 * local_sub_and_test - subtract value from variable and test result
50 * @i: integer value to subtract
51 * @l: pointer of type local_t
52 *
53 * Atomically subtracts @i from @l and returns
54 * true if the result is zero, or false for all
55 * other cases.
56 */
57static __inline__ int local_sub_and_test(long i, local_t *l)
58{
59 unsigned char c;
60
61 __asm__ __volatile__(
62 "subl %2,%0; sete %1"
63 :"+m" (l->a.counter), "=qm" (c)
64 :"ir" (i) : "memory");
65 return c;
66}
67
68/**
69 * local_dec_and_test - decrement and test
70 * @l: pointer of type local_t
71 *
72 * Atomically decrements @l by 1 and
73 * returns true if the result is 0, or false for all other
74 * cases.
75 */
76static __inline__ int local_dec_and_test(local_t *l)
77{
78 unsigned char c;
79
80 __asm__ __volatile__(
81 "decl %0; sete %1"
82 :"+m" (l->a.counter), "=qm" (c)
83 : : "memory");
84 return c != 0;
85}
86
87/**
88 * local_inc_and_test - increment and test
89 * @l: pointer of type local_t
90 *
91 * Atomically increments @l by 1
92 * and returns true if the result is zero, or false for all
93 * other cases.
94 */
95static __inline__ int local_inc_and_test(local_t *l)
96{
97 unsigned char c;
98
99 __asm__ __volatile__(
100 "incl %0; sete %1"
101 :"+m" (l->a.counter), "=qm" (c)
102 : : "memory");
103 return c != 0;
104}
105
106/**
107 * local_add_negative - add and test if negative
108 * @l: pointer of type local_t
109 * @i: integer value to add
110 *
111 * Atomically adds @i to @l and returns true
112 * if the result is negative, or false when
113 * result is greater than or equal to zero.
114 */
115static __inline__ int local_add_negative(long i, local_t *l)
116{
117 unsigned char c;
118
119 __asm__ __volatile__(
120 "addl %2,%0; sets %1"
121 :"+m" (l->a.counter), "=qm" (c)
122 :"ir" (i) : "memory");
123 return c;
124}
125
126/**
127 * local_add_return - add and return
128 * @l: pointer of type local_t
129 * @i: integer value to add
130 *
131 * Atomically adds @i to @l and returns @i + @l
132 */
133static __inline__ long local_add_return(long i, local_t *l)
134{
135 long __i;
136#ifdef CONFIG_M386
137 unsigned long flags;
138 if(unlikely(boot_cpu_data.x86 <= 3))
139 goto no_xadd;
140#endif
141 /* Modern 486+ processor */
142 __i = i;
143 __asm__ __volatile__(
144 "xaddl %0, %1;"
145 :"+r" (i), "+m" (l->a.counter)
146 : : "memory");
147 return i + __i;
148
149#ifdef CONFIG_M386
150no_xadd: /* Legacy 386 processor */
151 local_irq_save(flags);
152 __i = local_read(l);
153 local_set(l, i + __i);
154 local_irq_restore(flags);
155 return i + __i;
156#endif
157}
158
159static __inline__ long local_sub_return(long i, local_t *l)
160{
161 return local_add_return(-i,l);
162}
163
164#define local_inc_return(l) (local_add_return(1,l))
165#define local_dec_return(l) (local_sub_return(1,l))
166
167#define local_cmpxchg(l, o, n) \
168 (cmpxchg_local(&((l)->a.counter), (o), (n)))
169/* Always has a lock prefix */
170#define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
171
172/**
173 * local_add_unless - add unless the number is a given value
174 * @l: pointer of type local_t
175 * @a: the amount to add to l...
176 * @u: ...unless l is equal to u.
177 *
178 * Atomically adds @a to @l, so long as it was not @u.
179 * Returns non-zero if @l was not @u, and zero otherwise.
180 */
181#define local_add_unless(l, a, u) \
182({ \
183 long c, old; \
184 c = local_read(l); \
185 for (;;) { \
186 if (unlikely(c == (u))) \
187 break; \
188 old = local_cmpxchg((l), c, c + (a)); \
189 if (likely(old == c)) \
190 break; \
191 c = old; \
192 } \
193 c != (u); \
194})
195#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
196
197/* On x86, these are no better than the atomic variants. */
198#define __local_inc(l) local_inc(l)
199#define __local_dec(l) local_dec(l)
200#define __local_add(i,l) local_add((i),(l))
201#define __local_sub(i,l) local_sub((i),(l))
202
203/* Use these for per-cpu local_t variables: on some archs they are
204 * much more efficient than these naive implementations. Note they take
205 * a variable, not an address.
206 */
207
208/* Need to disable preemption for the cpu local counters otherwise we could
209 still access a variable of a previous CPU in a non atomic way. */
210#define cpu_local_wrap_v(l) \
211 ({ local_t res__; \
212 preempt_disable(); \
213 res__ = (l); \
214 preempt_enable(); \
215 res__; })
216#define cpu_local_wrap(l) \
217 ({ preempt_disable(); \
218 l; \
219 preempt_enable(); }) \
220
221#define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
222#define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
223#define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l)))
224#define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l)))
225#define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l)))
226#define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l)))
227
228#define __cpu_local_inc(l) cpu_local_inc(l)
229#define __cpu_local_dec(l) cpu_local_dec(l)
230#define __cpu_local_add(i, l) cpu_local_add((i), (l))
231#define __cpu_local_sub(i, l) cpu_local_sub((i), (l))
232
233#endif /* _ARCH_I386_LOCAL_H */
diff --git a/include/asm-x86/local_64.h b/include/asm-x86/local_64.h
deleted file mode 100644
index e87492bb0693..000000000000
--- a/include/asm-x86/local_64.h
+++ /dev/null
@@ -1,222 +0,0 @@
1#ifndef _ARCH_X8664_LOCAL_H
2#define _ARCH_X8664_LOCAL_H
3
4#include <linux/percpu.h>
5#include <asm/atomic.h>
6
7typedef struct
8{
9 atomic_long_t a;
10} local_t;
11
12#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13
14#define local_read(l) atomic_long_read(&(l)->a)
15#define local_set(l,i) atomic_long_set(&(l)->a, (i))
16
17static inline void local_inc(local_t *l)
18{
19 __asm__ __volatile__(
20 "incq %0"
21 :"=m" (l->a.counter)
22 :"m" (l->a.counter));
23}
24
25static inline void local_dec(local_t *l)
26{
27 __asm__ __volatile__(
28 "decq %0"
29 :"=m" (l->a.counter)
30 :"m" (l->a.counter));
31}
32
33static inline void local_add(long i, local_t *l)
34{
35 __asm__ __volatile__(
36 "addq %1,%0"
37 :"=m" (l->a.counter)
38 :"ir" (i), "m" (l->a.counter));
39}
40
41static inline void local_sub(long i, local_t *l)
42{
43 __asm__ __volatile__(
44 "subq %1,%0"
45 :"=m" (l->a.counter)
46 :"ir" (i), "m" (l->a.counter));
47}
48
49/**
50 * local_sub_and_test - subtract value from variable and test result
51 * @i: integer value to subtract
52 * @l: pointer to type local_t
53 *
54 * Atomically subtracts @i from @l and returns
55 * true if the result is zero, or false for all
56 * other cases.
57 */
58static __inline__ int local_sub_and_test(long i, local_t *l)
59{
60 unsigned char c;
61
62 __asm__ __volatile__(
63 "subq %2,%0; sete %1"
64 :"=m" (l->a.counter), "=qm" (c)
65 :"ir" (i), "m" (l->a.counter) : "memory");
66 return c;
67}
68
69/**
70 * local_dec_and_test - decrement and test
71 * @l: pointer to type local_t
72 *
73 * Atomically decrements @l by 1 and
74 * returns true if the result is 0, or false for all other
75 * cases.
76 */
77static __inline__ int local_dec_and_test(local_t *l)
78{
79 unsigned char c;
80
81 __asm__ __volatile__(
82 "decq %0; sete %1"
83 :"=m" (l->a.counter), "=qm" (c)
84 :"m" (l->a.counter) : "memory");
85 return c != 0;
86}
87
88/**
89 * local_inc_and_test - increment and test
90 * @l: pointer to type local_t
91 *
92 * Atomically increments @l by 1
93 * and returns true if the result is zero, or false for all
94 * other cases.
95 */
96static __inline__ int local_inc_and_test(local_t *l)
97{
98 unsigned char c;
99
100 __asm__ __volatile__(
101 "incq %0; sete %1"
102 :"=m" (l->a.counter), "=qm" (c)
103 :"m" (l->a.counter) : "memory");
104 return c != 0;
105}
106
107/**
108 * local_add_negative - add and test if negative
109 * @i: integer value to add
110 * @l: pointer to type local_t
111 *
112 * Atomically adds @i to @l and returns true
113 * if the result is negative, or false when
114 * result is greater than or equal to zero.
115 */
116static __inline__ int local_add_negative(long i, local_t *l)
117{
118 unsigned char c;
119
120 __asm__ __volatile__(
121 "addq %2,%0; sets %1"
122 :"=m" (l->a.counter), "=qm" (c)
123 :"ir" (i), "m" (l->a.counter) : "memory");
124 return c;
125}
126
127/**
128 * local_add_return - add and return
129 * @i: integer value to add
130 * @l: pointer to type local_t
131 *
132 * Atomically adds @i to @l and returns @i + @l
133 */
134static __inline__ long local_add_return(long i, local_t *l)
135{
136 long __i = i;
137 __asm__ __volatile__(
138 "xaddq %0, %1;"
139 :"+r" (i), "+m" (l->a.counter)
140 : : "memory");
141 return i + __i;
142}
143
144static __inline__ long local_sub_return(long i, local_t *l)
145{
146 return local_add_return(-i,l);
147}
148
149#define local_inc_return(l) (local_add_return(1,l))
150#define local_dec_return(l) (local_sub_return(1,l))
151
152#define local_cmpxchg(l, o, n) \
153 (cmpxchg_local(&((l)->a.counter), (o), (n)))
154/* Always has a lock prefix */
155#define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
156
157/**
158 * atomic_up_add_unless - add unless the number is a given value
159 * @l: pointer of type local_t
160 * @a: the amount to add to l...
161 * @u: ...unless l is equal to u.
162 *
163 * Atomically adds @a to @l, so long as it was not @u.
164 * Returns non-zero if @l was not @u, and zero otherwise.
165 */
166#define local_add_unless(l, a, u) \
167({ \
168 long c, old; \
169 c = local_read(l); \
170 for (;;) { \
171 if (unlikely(c == (u))) \
172 break; \
173 old = local_cmpxchg((l), c, c + (a)); \
174 if (likely(old == c)) \
175 break; \
176 c = old; \
177 } \
178 c != (u); \
179})
180#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
181
182/* On x86-64 these are better than the atomic variants on SMP kernels
183 because they dont use a lock prefix. */
184#define __local_inc(l) local_inc(l)
185#define __local_dec(l) local_dec(l)
186#define __local_add(i,l) local_add((i),(l))
187#define __local_sub(i,l) local_sub((i),(l))
188
189/* Use these for per-cpu local_t variables: on some archs they are
190 * much more efficient than these naive implementations. Note they take
191 * a variable, not an address.
192 *
193 * This could be done better if we moved the per cpu data directly
194 * after GS.
195 */
196
197/* Need to disable preemption for the cpu local counters otherwise we could
198 still access a variable of a previous CPU in a non atomic way. */
199#define cpu_local_wrap_v(l) \
200 ({ local_t res__; \
201 preempt_disable(); \
202 res__ = (l); \
203 preempt_enable(); \
204 res__; })
205#define cpu_local_wrap(l) \
206 ({ preempt_disable(); \
207 l; \
208 preempt_enable(); }) \
209
210#define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
211#define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
212#define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l)))
213#define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l)))
214#define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l)))
215#define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l)))
216
217#define __cpu_local_inc(l) cpu_local_inc(l)
218#define __cpu_local_dec(l) cpu_local_dec(l)
219#define __cpu_local_add(i, l) cpu_local_add((i), (l))
220#define __cpu_local_sub(i, l) cpu_local_sub((i), (l))
221
222#endif /* _ARCH_X8664_LOCAL_H */
diff --git a/include/asm-x86/mach-bigsmp/mach_apic.h b/include/asm-x86/mach-bigsmp/mach_apic.h
index ebd319f838ab..6df235e8ea91 100644
--- a/include/asm-x86/mach-bigsmp/mach_apic.h
+++ b/include/asm-x86/mach-bigsmp/mach_apic.h
@@ -110,13 +110,13 @@ static inline int cpu_to_logical_apicid(int cpu)
110} 110}
111 111
112static inline int mpc_apic_id(struct mpc_config_processor *m, 112static inline int mpc_apic_id(struct mpc_config_processor *m,
113 struct mpc_config_translation *translation_record) 113 struct mpc_config_translation *translation_record)
114{ 114{
115 printk("Processor #%d %ld:%ld APIC version %d\n", 115 printk("Processor #%d %u:%u APIC version %d\n",
116 m->mpc_apicid, 116 m->mpc_apicid,
117 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, 117 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
118 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, 118 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
119 m->mpc_apicver); 119 m->mpc_apicver);
120 return m->mpc_apicid; 120 return m->mpc_apicid;
121} 121}
122 122
diff --git a/include/asm-x86/mach-default/apm.h b/include/asm-x86/mach-default/apm.h
index 1f730b8bd1fd..989f34c37d32 100644
--- a/include/asm-x86/mach-default/apm.h
+++ b/include/asm-x86/mach-default/apm.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-i386/mach-default/apm.h
3 *
4 * Machine specific APM BIOS functions for generic. 2 * Machine specific APM BIOS functions for generic.
5 * Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp> 3 * Split out from apm.c by Osamu Tomita <tomita@cinet.co.jp>
6 */ 4 */
diff --git a/include/asm-x86/mach-default/io_ports.h b/include/asm-x86/mach-default/io_ports.h
deleted file mode 100644
index 48540ba97166..000000000000
--- a/include/asm-x86/mach-default/io_ports.h
+++ /dev/null
@@ -1,25 +0,0 @@
1/*
2 * arch/i386/mach-generic/io_ports.h
3 *
4 * Machine specific IO port address definition for generic.
5 * Written by Osamu Tomita <tomita@cinet.co.jp>
6 */
7#ifndef _MACH_IO_PORTS_H
8#define _MACH_IO_PORTS_H
9
10/* i8259A PIC registers */
11#define PIC_MASTER_CMD 0x20
12#define PIC_MASTER_IMR 0x21
13#define PIC_MASTER_ISR PIC_MASTER_CMD
14#define PIC_MASTER_POLL PIC_MASTER_ISR
15#define PIC_MASTER_OCW3 PIC_MASTER_ISR
16#define PIC_SLAVE_CMD 0xa0
17#define PIC_SLAVE_IMR 0xa1
18
19/* i8259A PIC related value */
20#define PIC_CASCADE_IR 2
21#define MASTER_ICW4_DEFAULT 0x01
22#define SLAVE_ICW4_DEFAULT 0x01
23#define PIC_ICW4_AEOI 2
24
25#endif /* !_MACH_IO_PORTS_H */
diff --git a/include/asm-x86/mach-default/mach_apic.h b/include/asm-x86/mach-default/mach_apic.h
index 6db1c3babe9a..e3c2c1012c1c 100644
--- a/include/asm-x86/mach-default/mach_apic.h
+++ b/include/asm-x86/mach-default/mach_apic.h
@@ -89,15 +89,15 @@ static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
89 return physid_mask_of_physid(phys_apicid); 89 return physid_mask_of_physid(phys_apicid);
90} 90}
91 91
92static inline int mpc_apic_id(struct mpc_config_processor *m, 92static inline int mpc_apic_id(struct mpc_config_processor *m,
93 struct mpc_config_translation *translation_record) 93 struct mpc_config_translation *translation_record)
94{ 94{
95 printk("Processor #%d %ld:%ld APIC version %d\n", 95 printk("Processor #%d %u:%u APIC version %d\n",
96 m->mpc_apicid, 96 m->mpc_apicid,
97 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, 97 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
98 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, 98 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
99 m->mpc_apicver); 99 m->mpc_apicver);
100 return (m->mpc_apicid); 100 return m->mpc_apicid;
101} 101}
102 102
103static inline void setup_portio_remap(void) 103static inline void setup_portio_remap(void)
diff --git a/include/asm-x86/mach-default/mach_reboot.h b/include/asm-x86/mach-default/mach_reboot.h
index e23fd9fbebb3..6adee6a97dec 100644
--- a/include/asm-x86/mach-default/mach_reboot.h
+++ b/include/asm-x86/mach-default/mach_reboot.h
@@ -49,7 +49,7 @@ static inline void mach_reboot(void)
49 udelay(50); 49 udelay(50);
50 kb_wait(); 50 kb_wait();
51 udelay(50); 51 udelay(50);
52 outb(cmd | 0x04, 0x60); /* set "System flag" */ 52 outb(cmd | 0x14, 0x60); /* set "System flag" and "Keyboard Disabled" */
53 udelay(50); 53 udelay(50);
54 kb_wait(); 54 kb_wait();
55 udelay(50); 55 udelay(50);
diff --git a/include/asm-x86/mach-default/mach_time.h b/include/asm-x86/mach-default/mach_time.h
deleted file mode 100644
index 31eb5de6f3dc..000000000000
--- a/include/asm-x86/mach-default/mach_time.h
+++ /dev/null
@@ -1,111 +0,0 @@
1/*
2 * include/asm-i386/mach-default/mach_time.h
3 *
4 * Machine specific set RTC function for generic.
5 * Split out from time.c by Osamu Tomita <tomita@cinet.co.jp>
6 */
7#ifndef _MACH_TIME_H
8#define _MACH_TIME_H
9
10#include <linux/mc146818rtc.h>
11
12/* for check timing call set_rtc_mmss() 500ms */
13/* used in arch/i386/time.c::do_timer_interrupt() */
14#define USEC_AFTER 500000
15#define USEC_BEFORE 500000
16
17/*
18 * In order to set the CMOS clock precisely, set_rtc_mmss has to be
19 * called 500 ms after the second nowtime has started, because when
20 * nowtime is written into the registers of the CMOS clock, it will
21 * jump to the next second precisely 500 ms later. Check the Motorola
22 * MC146818A or Dallas DS12887 data sheet for details.
23 *
24 * BUG: This routine does not handle hour overflow properly; it just
25 * sets the minutes. Usually you'll only notice that after reboot!
26 */
27static inline int mach_set_rtc_mmss(unsigned long nowtime)
28{
29 int retval = 0;
30 int real_seconds, real_minutes, cmos_minutes;
31 unsigned char save_control, save_freq_select;
32
33 save_control = CMOS_READ(RTC_CONTROL); /* tell the clock it's being set */
34 CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL);
35
36 save_freq_select = CMOS_READ(RTC_FREQ_SELECT); /* stop and reset prescaler */
37 CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT);
38
39 cmos_minutes = CMOS_READ(RTC_MINUTES);
40 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD)
41 BCD_TO_BIN(cmos_minutes);
42
43 /*
44 * since we're only adjusting minutes and seconds,
45 * don't interfere with hour overflow. This avoids
46 * messing with unknown time zones but requires your
47 * RTC not to be off by more than 15 minutes
48 */
49 real_seconds = nowtime % 60;
50 real_minutes = nowtime / 60;
51 if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1)
52 real_minutes += 30; /* correct for half hour time zone */
53 real_minutes %= 60;
54
55 if (abs(real_minutes - cmos_minutes) < 30) {
56 if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
57 BIN_TO_BCD(real_seconds);
58 BIN_TO_BCD(real_minutes);
59 }
60 CMOS_WRITE(real_seconds,RTC_SECONDS);
61 CMOS_WRITE(real_minutes,RTC_MINUTES);
62 } else {
63 printk(KERN_WARNING
64 "set_rtc_mmss: can't update from %d to %d\n",
65 cmos_minutes, real_minutes);
66 retval = -1;
67 }
68
69 /* The following flags have to be released exactly in this order,
70 * otherwise the DS12887 (popular MC146818A clone with integrated
71 * battery and quartz) will not reset the oscillator and will not
72 * update precisely 500 ms later. You won't find this mentioned in
73 * the Dallas Semiconductor data sheets, but who believes data
74 * sheets anyway ... -- Markus Kuhn
75 */
76 CMOS_WRITE(save_control, RTC_CONTROL);
77 CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
78
79 return retval;
80}
81
82static inline unsigned long mach_get_cmos_time(void)
83{
84 unsigned int year, mon, day, hour, min, sec;
85
86 do {
87 sec = CMOS_READ(RTC_SECONDS);
88 min = CMOS_READ(RTC_MINUTES);
89 hour = CMOS_READ(RTC_HOURS);
90 day = CMOS_READ(RTC_DAY_OF_MONTH);
91 mon = CMOS_READ(RTC_MONTH);
92 year = CMOS_READ(RTC_YEAR);
93 } while (sec != CMOS_READ(RTC_SECONDS));
94
95 if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) {
96 BCD_TO_BIN(sec);
97 BCD_TO_BIN(min);
98 BCD_TO_BIN(hour);
99 BCD_TO_BIN(day);
100 BCD_TO_BIN(mon);
101 BCD_TO_BIN(year);
102 }
103
104 year += 1900;
105 if (year < 1970)
106 year += 100;
107
108 return mktime(year, mon, day, hour, min, sec);
109}
110
111#endif /* !_MACH_TIME_H */
diff --git a/include/asm-x86/mach-default/mach_timer.h b/include/asm-x86/mach-default/mach_timer.h
index 807992fd4171..4b76e536cd98 100644
--- a/include/asm-x86/mach-default/mach_timer.h
+++ b/include/asm-x86/mach-default/mach_timer.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-i386/mach-default/mach_timer.h
3 *
4 * Machine specific calibrate_tsc() for generic. 2 * Machine specific calibrate_tsc() for generic.
5 * Split out from timer_tsc.c by Osamu Tomita <tomita@cinet.co.jp> 3 * Split out from timer_tsc.c by Osamu Tomita <tomita@cinet.co.jp>
6 */ 4 */
diff --git a/include/asm-x86/mach-default/mach_traps.h b/include/asm-x86/mach-default/mach_traps.h
index 625438b8a6eb..2fe7705c0484 100644
--- a/include/asm-x86/mach-default/mach_traps.h
+++ b/include/asm-x86/mach-default/mach_traps.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-i386/mach-default/mach_traps.h
3 *
4 * Machine specific NMI handling for generic. 2 * Machine specific NMI handling for generic.
5 * Split out from traps.c by Osamu Tomita <tomita@cinet.co.jp> 3 * Split out from traps.c by Osamu Tomita <tomita@cinet.co.jp>
6 */ 4 */
diff --git a/include/asm-x86/mach-es7000/mach_apic.h b/include/asm-x86/mach-es7000/mach_apic.h
index caec64be516d..d23011fdf454 100644
--- a/include/asm-x86/mach-es7000/mach_apic.h
+++ b/include/asm-x86/mach-es7000/mach_apic.h
@@ -131,11 +131,11 @@ static inline int cpu_to_logical_apicid(int cpu)
131 131
132static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *unused) 132static inline int mpc_apic_id(struct mpc_config_processor *m, struct mpc_config_translation *unused)
133{ 133{
134 printk("Processor #%d %ld:%ld APIC version %d\n", 134 printk("Processor #%d %u:%u APIC version %d\n",
135 m->mpc_apicid, 135 m->mpc_apicid,
136 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, 136 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
137 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, 137 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
138 m->mpc_apicver); 138 m->mpc_apicver);
139 return (m->mpc_apicid); 139 return (m->mpc_apicid);
140} 140}
141 141
diff --git a/include/asm-x86/mach-es7000/mach_mpparse.h b/include/asm-x86/mach-es7000/mach_mpparse.h
index 8aa10547b4b1..52ee75cd0fe1 100644
--- a/include/asm-x86/mach-es7000/mach_mpparse.h
+++ b/include/asm-x86/mach-es7000/mach_mpparse.h
@@ -29,9 +29,9 @@ extern int mps_oem_check(struct mp_config_table *mpc, char *oem,
29static inline int es7000_check_dsdt(void) 29static inline int es7000_check_dsdt(void)
30{ 30{
31 struct acpi_table_header header; 31 struct acpi_table_header header;
32 memcpy(&header, 0, sizeof(struct acpi_table_header)); 32
33 acpi_get_table_header(ACPI_SIG_DSDT, 0, &header); 33 if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) &&
34 if (!strncmp(header.oem_id, "UNISYS", 6)) 34 !strncmp(header.oem_id, "UNISYS", 6))
35 return 1; 35 return 1;
36 return 0; 36 return 0;
37} 37}
diff --git a/include/asm-x86/mach-generic/gpio.h b/include/asm-x86/mach-generic/gpio.h
new file mode 100644
index 000000000000..5305dcb96df2
--- /dev/null
+++ b/include/asm-x86/mach-generic/gpio.h
@@ -0,0 +1,15 @@
1#ifndef __ASM_MACH_GENERIC_GPIO_H
2#define __ASM_MACH_GENERIC_GPIO_H
3
4int gpio_request(unsigned gpio, const char *label);
5void gpio_free(unsigned gpio);
6int gpio_direction_input(unsigned gpio);
7int gpio_direction_output(unsigned gpio, int value);
8int gpio_get_value(unsigned gpio);
9void gpio_set_value(unsigned gpio, int value);
10int gpio_to_irq(unsigned gpio);
11int irq_to_gpio(unsigned irq);
12
13#include <asm-generic/gpio.h> /* cansleep wrappers */
14
15#endif /* __ASM_MACH_GENERIC_GPIO_H */
diff --git a/include/asm-x86/mach-numaq/mach_apic.h b/include/asm-x86/mach-numaq/mach_apic.h
index 5e5e7dd2692e..17e183bd39c1 100644
--- a/include/asm-x86/mach-numaq/mach_apic.h
+++ b/include/asm-x86/mach-numaq/mach_apic.h
@@ -101,11 +101,11 @@ static inline int mpc_apic_id(struct mpc_config_processor *m,
101 int quad = translation_record->trans_quad; 101 int quad = translation_record->trans_quad;
102 int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid); 102 int logical_apicid = generate_logical_apicid(quad, m->mpc_apicid);
103 103
104 printk("Processor #%d %ld:%ld APIC version %d (quad %d, apic %d)\n", 104 printk("Processor #%d %u:%u APIC version %d (quad %d, apic %d)\n",
105 m->mpc_apicid, 105 m->mpc_apicid,
106 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, 106 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
107 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, 107 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
108 m->mpc_apicver, quad, logical_apicid); 108 m->mpc_apicver, quad, logical_apicid);
109 return logical_apicid; 109 return logical_apicid;
110} 110}
111 111
diff --git a/include/asm-x86/mach-rdc321x/gpio.h b/include/asm-x86/mach-rdc321x/gpio.h
new file mode 100644
index 000000000000..db31b929b990
--- /dev/null
+++ b/include/asm-x86/mach-rdc321x/gpio.h
@@ -0,0 +1,56 @@
1#ifndef _RDC321X_GPIO_H
2#define _RDC321X_GPIO_H
3
4extern int rdc_gpio_get_value(unsigned gpio);
5extern void rdc_gpio_set_value(unsigned gpio, int value);
6extern int rdc_gpio_direction_input(unsigned gpio);
7extern int rdc_gpio_direction_output(unsigned gpio, int value);
8
9
10/* Wrappers for the arch-neutral GPIO API */
11
12static inline int gpio_request(unsigned gpio, const char *label)
13{
14 /* Not yet implemented */
15 return 0;
16}
17
18static inline void gpio_free(unsigned gpio)
19{
20 /* Not yet implemented */
21}
22
23static inline int gpio_direction_input(unsigned gpio)
24{
25 return rdc_gpio_direction_input(gpio);
26}
27
28static inline int gpio_direction_output(unsigned gpio, int value)
29{
30 return rdc_gpio_direction_output(gpio, value);
31}
32
33static inline int gpio_get_value(unsigned gpio)
34{
35 return rdc_gpio_get_value(gpio);
36}
37
38static inline void gpio_set_value(unsigned gpio, int value)
39{
40 rdc_gpio_set_value(gpio, value);
41}
42
43static inline int gpio_to_irq(unsigned gpio)
44{
45 return gpio;
46}
47
48static inline int irq_to_gpio(unsigned irq)
49{
50 return irq;
51}
52
53/* For cansleep */
54#include <asm-generic/gpio.h>
55
56#endif /* _RDC321X_GPIO_H_ */
diff --git a/include/asm-x86/mach-rdc321x/rdc321x_defs.h b/include/asm-x86/mach-rdc321x/rdc321x_defs.h
new file mode 100644
index 000000000000..838ba8f64fd3
--- /dev/null
+++ b/include/asm-x86/mach-rdc321x/rdc321x_defs.h
@@ -0,0 +1,6 @@
1#define PFX "rdc321x: "
2
3/* General purpose configuration and data registers */
4#define RDC3210_CFGREG_ADDR 0x0CF8
5#define RDC3210_CFGREG_DATA 0x0CFC
6#define RDC_MAX_GPIO 0x3A
diff --git a/include/asm-x86/mach-summit/mach_apic.h b/include/asm-x86/mach-summit/mach_apic.h
index 732f776aab8e..062c97f6100b 100644
--- a/include/asm-x86/mach-summit/mach_apic.h
+++ b/include/asm-x86/mach-summit/mach_apic.h
@@ -126,15 +126,15 @@ static inline physid_mask_t apicid_to_cpu_present(int apicid)
126 return physid_mask_of_physid(0); 126 return physid_mask_of_physid(0);
127} 127}
128 128
129static inline int mpc_apic_id(struct mpc_config_processor *m, 129static inline int mpc_apic_id(struct mpc_config_processor *m,
130 struct mpc_config_translation *translation_record) 130 struct mpc_config_translation *translation_record)
131{ 131{
132 printk("Processor #%d %ld:%ld APIC version %d\n", 132 printk("Processor #%d %u:%u APIC version %d\n",
133 m->mpc_apicid, 133 m->mpc_apicid,
134 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8, 134 (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
135 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4, 135 (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
136 m->mpc_apicver); 136 m->mpc_apicver);
137 return (m->mpc_apicid); 137 return m->mpc_apicid;
138} 138}
139 139
140static inline void setup_portio_remap(void) 140static inline void setup_portio_remap(void)
diff --git a/include/asm-x86/mach-voyager/setup_arch.h b/include/asm-x86/mach-voyager/setup_arch.h
index 84d01ad33459..71729ca05cd7 100644
--- a/include/asm-x86/mach-voyager/setup_arch.h
+++ b/include/asm-x86/mach-voyager/setup_arch.h
@@ -1,5 +1,7 @@
1#include <asm/voyager.h> 1#include <asm/voyager.h>
2#define VOYAGER_BIOS_INFO ((struct voyager_bios_info *)(PARAM+0x40)) 2#include <asm/setup.h>
3#define VOYAGER_BIOS_INFO ((struct voyager_bios_info *) \
4 (&boot_params.apm_bios_info))
3 5
4/* Hook to call BIOS initialisation function */ 6/* Hook to call BIOS initialisation function */
5 7
diff --git a/include/asm-x86/math_emu.h b/include/asm-x86/math_emu.h
index a4b0aa3320e6..9bf4ae93ab10 100644
--- a/include/asm-x86/math_emu.h
+++ b/include/asm-x86/math_emu.h
@@ -1,11 +1,6 @@
1#ifndef _I386_MATH_EMU_H 1#ifndef _I386_MATH_EMU_H
2#define _I386_MATH_EMU_H 2#define _I386_MATH_EMU_H
3 3
4#include <asm/sigcontext.h>
5
6int restore_i387_soft(void *s387, struct _fpstate __user *buf);
7int save_i387_soft(void *s387, struct _fpstate __user *buf);
8
9/* This structure matches the layout of the data saved to the stack 4/* This structure matches the layout of the data saved to the stack
10 following a device-not-present interrupt, part of it saved 5 following a device-not-present interrupt, part of it saved
11 automatically by the 80386/80486. 6 automatically by the 80386/80486.
diff --git a/include/asm-x86/mc146818rtc.h b/include/asm-x86/mc146818rtc.h
index 5c2bb66caf17..cdd9f965835a 100644
--- a/include/asm-x86/mc146818rtc.h
+++ b/include/asm-x86/mc146818rtc.h
@@ -1,5 +1,100 @@
1#ifdef CONFIG_X86_32 1/*
2# include "mc146818rtc_32.h" 2 * Machine dependent access functions for RTC registers.
3 */
4#ifndef _ASM_MC146818RTC_H
5#define _ASM_MC146818RTC_H
6
7#include <asm/io.h>
8#include <asm/system.h>
9#include <asm/processor.h>
10#include <linux/mc146818rtc.h>
11
12#ifndef RTC_PORT
13#define RTC_PORT(x) (0x70 + (x))
14#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
15#endif
16
17#if defined(CONFIG_X86_32) && defined(__HAVE_ARCH_CMPXCHG)
18/*
19 * This lock provides nmi access to the CMOS/RTC registers. It has some
20 * special properties. It is owned by a CPU and stores the index register
21 * currently being accessed (if owned). The idea here is that it works
22 * like a normal lock (normally). However, in an NMI, the NMI code will
23 * first check to see if its CPU owns the lock, meaning that the NMI
24 * interrupted during the read/write of the device. If it does, it goes ahead
25 * and performs the access and then restores the index register. If it does
26 * not, it locks normally.
27 *
28 * Note that since we are working with NMIs, we need this lock even in
29 * a non-SMP machine just to mark that the lock is owned.
30 *
31 * This only works with compare-and-swap. There is no other way to
32 * atomically claim the lock and set the owner.
33 */
34#include <linux/smp.h>
35extern volatile unsigned long cmos_lock;
36
37/*
38 * All of these below must be called with interrupts off, preempt
39 * disabled, etc.
40 */
41
42static inline void lock_cmos(unsigned char reg)
43{
44 unsigned long new;
45 new = ((smp_processor_id()+1) << 8) | reg;
46 for (;;) {
47 if (cmos_lock) {
48 cpu_relax();
49 continue;
50 }
51 if (__cmpxchg(&cmos_lock, 0, new, sizeof(cmos_lock)) == 0)
52 return;
53 }
54}
55
56static inline void unlock_cmos(void)
57{
58 cmos_lock = 0;
59}
60static inline int do_i_have_lock_cmos(void)
61{
62 return (cmos_lock >> 8) == (smp_processor_id()+1);
63}
64static inline unsigned char current_lock_cmos_reg(void)
65{
66 return cmos_lock & 0xff;
67}
68#define lock_cmos_prefix(reg) \
69 do { \
70 unsigned long cmos_flags; \
71 local_irq_save(cmos_flags); \
72 lock_cmos(reg)
73#define lock_cmos_suffix(reg) \
74 unlock_cmos(); \
75 local_irq_restore(cmos_flags); \
76 } while (0)
3#else 77#else
4# include "mc146818rtc_64.h" 78#define lock_cmos_prefix(reg) do {} while (0)
79#define lock_cmos_suffix(reg) do {} while (0)
80#define lock_cmos(reg)
81#define unlock_cmos()
82#define do_i_have_lock_cmos() 0
83#define current_lock_cmos_reg() 0
5#endif 84#endif
85
86/*
87 * The yet supported machines all access the RTC index register via
88 * an ISA port access but the way to access the date register differs ...
89 */
90#define CMOS_READ(addr) rtc_cmos_read(addr)
91#define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr)
92unsigned char rtc_cmos_read(unsigned char addr);
93void rtc_cmos_write(unsigned char val, unsigned char addr);
94
95extern int mach_set_rtc_mmss(unsigned long nowtime);
96extern unsigned long mach_get_cmos_time(void);
97
98#define RTC_IRQ 8
99
100#endif /* _ASM_MC146818RTC_H */
diff --git a/include/asm-x86/mc146818rtc_32.h b/include/asm-x86/mc146818rtc_32.h
deleted file mode 100644
index 1613b42eaf58..000000000000
--- a/include/asm-x86/mc146818rtc_32.h
+++ /dev/null
@@ -1,97 +0,0 @@
1/*
2 * Machine dependent access functions for RTC registers.
3 */
4#ifndef _ASM_MC146818RTC_H
5#define _ASM_MC146818RTC_H
6
7#include <asm/io.h>
8#include <asm/system.h>
9#include <asm/processor.h>
10#include <linux/mc146818rtc.h>
11
12#ifndef RTC_PORT
13#define RTC_PORT(x) (0x70 + (x))
14#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
15#endif
16
17#ifdef __HAVE_ARCH_CMPXCHG
18/*
19 * This lock provides nmi access to the CMOS/RTC registers. It has some
20 * special properties. It is owned by a CPU and stores the index register
21 * currently being accessed (if owned). The idea here is that it works
22 * like a normal lock (normally). However, in an NMI, the NMI code will
23 * first check to see if its CPU owns the lock, meaning that the NMI
24 * interrupted during the read/write of the device. If it does, it goes ahead
25 * and performs the access and then restores the index register. If it does
26 * not, it locks normally.
27 *
28 * Note that since we are working with NMIs, we need this lock even in
29 * a non-SMP machine just to mark that the lock is owned.
30 *
31 * This only works with compare-and-swap. There is no other way to
32 * atomically claim the lock and set the owner.
33 */
34#include <linux/smp.h>
35extern volatile unsigned long cmos_lock;
36
37/*
38 * All of these below must be called with interrupts off, preempt
39 * disabled, etc.
40 */
41
42static inline void lock_cmos(unsigned char reg)
43{
44 unsigned long new;
45 new = ((smp_processor_id()+1) << 8) | reg;
46 for (;;) {
47 if (cmos_lock) {
48 cpu_relax();
49 continue;
50 }
51 if (__cmpxchg(&cmos_lock, 0, new, sizeof(cmos_lock)) == 0)
52 return;
53 }
54}
55
56static inline void unlock_cmos(void)
57{
58 cmos_lock = 0;
59}
60static inline int do_i_have_lock_cmos(void)
61{
62 return (cmos_lock >> 8) == (smp_processor_id()+1);
63}
64static inline unsigned char current_lock_cmos_reg(void)
65{
66 return cmos_lock & 0xff;
67}
68#define lock_cmos_prefix(reg) \
69 do { \
70 unsigned long cmos_flags; \
71 local_irq_save(cmos_flags); \
72 lock_cmos(reg)
73#define lock_cmos_suffix(reg) \
74 unlock_cmos(); \
75 local_irq_restore(cmos_flags); \
76 } while (0)
77#else
78#define lock_cmos_prefix(reg) do {} while (0)
79#define lock_cmos_suffix(reg) do {} while (0)
80#define lock_cmos(reg)
81#define unlock_cmos()
82#define do_i_have_lock_cmos() 0
83#define current_lock_cmos_reg() 0
84#endif
85
86/*
87 * The yet supported machines all access the RTC index register via
88 * an ISA port access but the way to access the date register differs ...
89 */
90#define CMOS_READ(addr) rtc_cmos_read(addr)
91#define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr)
92unsigned char rtc_cmos_read(unsigned char addr);
93void rtc_cmos_write(unsigned char val, unsigned char addr);
94
95#define RTC_IRQ 8
96
97#endif /* _ASM_MC146818RTC_H */
diff --git a/include/asm-x86/mc146818rtc_64.h b/include/asm-x86/mc146818rtc_64.h
deleted file mode 100644
index d6e3009430c1..000000000000
--- a/include/asm-x86/mc146818rtc_64.h
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Machine dependent access functions for RTC registers.
3 */
4#ifndef _ASM_MC146818RTC_H
5#define _ASM_MC146818RTC_H
6
7#include <asm/io.h>
8
9#ifndef RTC_PORT
10#define RTC_PORT(x) (0x70 + (x))
11#define RTC_ALWAYS_BCD 1 /* RTC operates in binary mode */
12#endif
13
14/*
15 * The yet supported machines all access the RTC index register via
16 * an ISA port access but the way to access the date register differs ...
17 */
18#define CMOS_READ(addr) ({ \
19outb_p((addr),RTC_PORT(0)); \
20inb_p(RTC_PORT(1)); \
21})
22#define CMOS_WRITE(val, addr) ({ \
23outb_p((addr),RTC_PORT(0)); \
24outb_p((val),RTC_PORT(1)); \
25})
26
27#define RTC_IRQ 8
28
29#endif /* _ASM_MC146818RTC_H */
diff --git a/include/asm-x86/mce.h b/include/asm-x86/mce.h
index df304fd89c27..94f1fd79e22a 100644
--- a/include/asm-x86/mce.h
+++ b/include/asm-x86/mce.h
@@ -13,7 +13,7 @@
13#define MCG_CTL_P (1UL<<8) /* MCG_CAP register available */ 13#define MCG_CTL_P (1UL<<8) /* MCG_CAP register available */
14 14
15#define MCG_STATUS_RIPV (1UL<<0) /* restart ip valid */ 15#define MCG_STATUS_RIPV (1UL<<0) /* restart ip valid */
16#define MCG_STATUS_EIPV (1UL<<1) /* eip points to correct instruction */ 16#define MCG_STATUS_EIPV (1UL<<1) /* ip points to correct instruction */
17#define MCG_STATUS_MCIP (1UL<<2) /* machine check in progress */ 17#define MCG_STATUS_MCIP (1UL<<2) /* machine check in progress */
18 18
19#define MCI_STATUS_VAL (1UL<<63) /* valid error */ 19#define MCI_STATUS_VAL (1UL<<63) /* valid error */
@@ -30,7 +30,7 @@ struct mce {
30 __u64 misc; 30 __u64 misc;
31 __u64 addr; 31 __u64 addr;
32 __u64 mcgstatus; 32 __u64 mcgstatus;
33 __u64 rip; 33 __u64 ip;
34 __u64 tsc; /* cpu time stamp counter */ 34 __u64 tsc; /* cpu time stamp counter */
35 __u64 res1; /* for future extension */ 35 __u64 res1; /* for future extension */
36 __u64 res2; /* dito. */ 36 __u64 res2; /* dito. */
@@ -85,14 +85,7 @@ struct mce_log {
85#ifdef __KERNEL__ 85#ifdef __KERNEL__
86 86
87#ifdef CONFIG_X86_32 87#ifdef CONFIG_X86_32
88#ifdef CONFIG_X86_MCE
89extern void mcheck_init(struct cpuinfo_x86 *c);
90#else
91#define mcheck_init(c) do {} while(0)
92#endif
93
94extern int mce_disabled; 88extern int mce_disabled;
95
96#else /* CONFIG_X86_32 */ 89#else /* CONFIG_X86_32 */
97 90
98#include <asm/atomic.h> 91#include <asm/atomic.h>
@@ -121,6 +114,13 @@ extern int mce_notify_user(void);
121 114
122#endif /* !CONFIG_X86_32 */ 115#endif /* !CONFIG_X86_32 */
123 116
117
118
119#ifdef CONFIG_X86_MCE
120extern void mcheck_init(struct cpuinfo_x86 *c);
121#else
122#define mcheck_init(c) do { } while (0)
123#endif
124extern void stop_mce(void); 124extern void stop_mce(void);
125extern void restart_mce(void); 125extern void restart_mce(void);
126 126
diff --git a/include/asm-x86/mmsegment.h b/include/asm-x86/mmsegment.h
deleted file mode 100644
index d3f80c996330..000000000000
--- a/include/asm-x86/mmsegment.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef _ASM_MMSEGMENT_H
2#define _ASM_MMSEGMENT_H 1
3
4typedef struct {
5 unsigned long seg;
6} mm_segment_t;
7
8#endif
diff --git a/include/asm-x86/mmu.h b/include/asm-x86/mmu.h
index 3f922c8e1c88..efa962c38897 100644
--- a/include/asm-x86/mmu.h
+++ b/include/asm-x86/mmu.h
@@ -20,4 +20,12 @@ typedef struct {
20 void *vdso; 20 void *vdso;
21} mm_context_t; 21} mm_context_t;
22 22
23#ifdef CONFIG_SMP
24void leave_mm(int cpu);
25#else
26static inline void leave_mm(int cpu)
27{
28}
29#endif
30
23#endif /* _ASM_X86_MMU_H */ 31#endif /* _ASM_X86_MMU_H */
diff --git a/include/asm-x86/mmu_context_32.h b/include/asm-x86/mmu_context_32.h
index 7eb0b0b1fb3c..8198d1cca1f3 100644
--- a/include/asm-x86/mmu_context_32.h
+++ b/include/asm-x86/mmu_context_32.h
@@ -32,8 +32,6 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
32#endif 32#endif
33} 33}
34 34
35void leave_mm(unsigned long cpu);
36
37static inline void switch_mm(struct mm_struct *prev, 35static inline void switch_mm(struct mm_struct *prev,
38 struct mm_struct *next, 36 struct mm_struct *next,
39 struct task_struct *tsk) 37 struct task_struct *tsk)
diff --git a/include/asm-x86/mmu_context_64.h b/include/asm-x86/mmu_context_64.h
index 0cce83a78378..ad6dc821ef9e 100644
--- a/include/asm-x86/mmu_context_64.h
+++ b/include/asm-x86/mmu_context_64.h
@@ -7,7 +7,9 @@
7#include <asm/pda.h> 7#include <asm/pda.h>
8#include <asm/pgtable.h> 8#include <asm/pgtable.h>
9#include <asm/tlbflush.h> 9#include <asm/tlbflush.h>
10#ifndef CONFIG_PARAVIRT
10#include <asm-generic/mm_hooks.h> 11#include <asm-generic/mm_hooks.h>
12#endif
11 13
12/* 14/*
13 * possibly do the LDT unload here? 15 * possibly do the LDT unload here?
@@ -23,11 +25,6 @@ static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
23#endif 25#endif
24} 26}
25 27
26static inline void load_cr3(pgd_t *pgd)
27{
28 asm volatile("movq %0,%%cr3" :: "r" (__pa(pgd)) : "memory");
29}
30
31static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 28static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
32 struct task_struct *tsk) 29 struct task_struct *tsk)
33{ 30{
@@ -43,20 +40,20 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
43 load_cr3(next->pgd); 40 load_cr3(next->pgd);
44 41
45 if (unlikely(next->context.ldt != prev->context.ldt)) 42 if (unlikely(next->context.ldt != prev->context.ldt))
46 load_LDT_nolock(&next->context, cpu); 43 load_LDT_nolock(&next->context);
47 } 44 }
48#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
49 else { 46 else {
50 write_pda(mmu_state, TLBSTATE_OK); 47 write_pda(mmu_state, TLBSTATE_OK);
51 if (read_pda(active_mm) != next) 48 if (read_pda(active_mm) != next)
52 out_of_line_bug(); 49 BUG();
53 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) { 50 if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
54 /* We were in lazy tlb mode and leave_mm disabled 51 /* We were in lazy tlb mode and leave_mm disabled
55 * tlb flush IPI delivery. We must reload CR3 52 * tlb flush IPI delivery. We must reload CR3
56 * to make sure to use no freed page tables. 53 * to make sure to use no freed page tables.
57 */ 54 */
58 load_cr3(next->pgd); 55 load_cr3(next->pgd);
59 load_LDT_nolock(&next->context, cpu); 56 load_LDT_nolock(&next->context);
60 } 57 }
61 } 58 }
62#endif 59#endif
diff --git a/include/asm-x86/mmzone_32.h b/include/asm-x86/mmzone_32.h
index 118e9812778f..5d6f4ce6e6d6 100644
--- a/include/asm-x86/mmzone_32.h
+++ b/include/asm-x86/mmzone_32.h
@@ -87,9 +87,6 @@ static inline int pfn_to_nid(unsigned long pfn)
87 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \ 87 __pgdat->node_start_pfn + __pgdat->node_spanned_pages; \
88}) 88})
89 89
90/* XXX: FIXME -- wli */
91#define kern_addr_valid(kaddr) (0)
92
93#ifdef CONFIG_X86_NUMAQ /* we have contiguous memory on NUMA-Q */ 90#ifdef CONFIG_X86_NUMAQ /* we have contiguous memory on NUMA-Q */
94#define pfn_valid(pfn) ((pfn) < num_physpages) 91#define pfn_valid(pfn) ((pfn) < num_physpages)
95#else 92#else
diff --git a/include/asm-x86/mmzone_64.h b/include/asm-x86/mmzone_64.h
index 19a89377b123..ebaf9663aa8a 100644
--- a/include/asm-x86/mmzone_64.h
+++ b/include/asm-x86/mmzone_64.h
@@ -15,9 +15,9 @@
15struct memnode { 15struct memnode {
16 int shift; 16 int shift;
17 unsigned int mapsize; 17 unsigned int mapsize;
18 u8 *map; 18 s16 *map;
19 u8 embedded_map[64-16]; 19 s16 embedded_map[64-8];
20} ____cacheline_aligned; /* total size = 64 bytes */ 20} ____cacheline_aligned; /* total size = 128 bytes */
21extern struct memnode memnode; 21extern struct memnode memnode;
22#define memnode_shift memnode.shift 22#define memnode_shift memnode.shift
23#define memnodemap memnode.map 23#define memnodemap memnode.map
@@ -41,11 +41,7 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
41#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \ 41#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
42 NODE_DATA(nid)->node_spanned_pages) 42 NODE_DATA(nid)->node_spanned_pages)
43 43
44#ifdef CONFIG_DISCONTIGMEM 44extern int early_pfn_to_nid(unsigned long pfn);
45#define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
46
47extern int pfn_valid(unsigned long pfn);
48#endif
49 45
50#ifdef CONFIG_NUMA_EMU 46#ifdef CONFIG_NUMA_EMU
51#define FAKE_NODE_MIN_SIZE (64*1024*1024) 47#define FAKE_NODE_MIN_SIZE (64*1024*1024)
diff --git a/include/asm-x86/module.h b/include/asm-x86/module.h
index 2b2f18d8a531..bfedb247871c 100644
--- a/include/asm-x86/module.h
+++ b/include/asm-x86/module.h
@@ -1,5 +1,82 @@
1#ifndef _ASM_MODULE_H
2#define _ASM_MODULE_H
3
4/* x86_32/64 are simple */
5struct mod_arch_specific {};
6
1#ifdef CONFIG_X86_32 7#ifdef CONFIG_X86_32
2# include "module_32.h" 8# define Elf_Shdr Elf32_Shdr
9# define Elf_Sym Elf32_Sym
10# define Elf_Ehdr Elf32_Ehdr
3#else 11#else
4# include "module_64.h" 12# define Elf_Shdr Elf64_Shdr
13# define Elf_Sym Elf64_Sym
14# define Elf_Ehdr Elf64_Ehdr
5#endif 15#endif
16
17#ifdef CONFIG_X86_64
18/* X86_64 does not define MODULE_PROC_FAMILY */
19#elif defined CONFIG_M386
20#define MODULE_PROC_FAMILY "386 "
21#elif defined CONFIG_M486
22#define MODULE_PROC_FAMILY "486 "
23#elif defined CONFIG_M586
24#define MODULE_PROC_FAMILY "586 "
25#elif defined CONFIG_M586TSC
26#define MODULE_PROC_FAMILY "586TSC "
27#elif defined CONFIG_M586MMX
28#define MODULE_PROC_FAMILY "586MMX "
29#elif defined CONFIG_MCORE2
30#define MODULE_PROC_FAMILY "CORE2 "
31#elif defined CONFIG_M686
32#define MODULE_PROC_FAMILY "686 "
33#elif defined CONFIG_MPENTIUMII
34#define MODULE_PROC_FAMILY "PENTIUMII "
35#elif defined CONFIG_MPENTIUMIII
36#define MODULE_PROC_FAMILY "PENTIUMIII "
37#elif defined CONFIG_MPENTIUMM
38#define MODULE_PROC_FAMILY "PENTIUMM "
39#elif defined CONFIG_MPENTIUM4
40#define MODULE_PROC_FAMILY "PENTIUM4 "
41#elif defined CONFIG_MK6
42#define MODULE_PROC_FAMILY "K6 "
43#elif defined CONFIG_MK7
44#define MODULE_PROC_FAMILY "K7 "
45#elif defined CONFIG_MK8
46#define MODULE_PROC_FAMILY "K8 "
47#elif defined CONFIG_X86_ELAN
48#define MODULE_PROC_FAMILY "ELAN "
49#elif defined CONFIG_MCRUSOE
50#define MODULE_PROC_FAMILY "CRUSOE "
51#elif defined CONFIG_MEFFICEON
52#define MODULE_PROC_FAMILY "EFFICEON "
53#elif defined CONFIG_MWINCHIPC6
54#define MODULE_PROC_FAMILY "WINCHIPC6 "
55#elif defined CONFIG_MWINCHIP2
56#define MODULE_PROC_FAMILY "WINCHIP2 "
57#elif defined CONFIG_MWINCHIP3D
58#define MODULE_PROC_FAMILY "WINCHIP3D "
59#elif defined CONFIG_MCYRIXIII
60#define MODULE_PROC_FAMILY "CYRIXIII "
61#elif defined CONFIG_MVIAC3_2
62#define MODULE_PROC_FAMILY "VIAC3-2 "
63#elif defined CONFIG_MVIAC7
64#define MODULE_PROC_FAMILY "VIAC7 "
65#elif defined CONFIG_MGEODEGX1
66#define MODULE_PROC_FAMILY "GEODEGX1 "
67#elif defined CONFIG_MGEODE_LX
68#define MODULE_PROC_FAMILY "GEODE "
69#else
70#error unknown processor family
71#endif
72
73#ifdef CONFIG_X86_32
74# ifdef CONFIG_4KSTACKS
75# define MODULE_STACKSIZE "4KSTACKS "
76# else
77# define MODULE_STACKSIZE ""
78# endif
79# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
80#endif
81
82#endif /* _ASM_MODULE_H */
diff --git a/include/asm-x86/module_32.h b/include/asm-x86/module_32.h
deleted file mode 100644
index 7e5fda6c3976..000000000000
--- a/include/asm-x86/module_32.h
+++ /dev/null
@@ -1,75 +0,0 @@
1#ifndef _ASM_I386_MODULE_H
2#define _ASM_I386_MODULE_H
3
4/* x86 is simple */
5struct mod_arch_specific
6{
7};
8
9#define Elf_Shdr Elf32_Shdr
10#define Elf_Sym Elf32_Sym
11#define Elf_Ehdr Elf32_Ehdr
12
13#ifdef CONFIG_M386
14#define MODULE_PROC_FAMILY "386 "
15#elif defined CONFIG_M486
16#define MODULE_PROC_FAMILY "486 "
17#elif defined CONFIG_M586
18#define MODULE_PROC_FAMILY "586 "
19#elif defined CONFIG_M586TSC
20#define MODULE_PROC_FAMILY "586TSC "
21#elif defined CONFIG_M586MMX
22#define MODULE_PROC_FAMILY "586MMX "
23#elif defined CONFIG_MCORE2
24#define MODULE_PROC_FAMILY "CORE2 "
25#elif defined CONFIG_M686
26#define MODULE_PROC_FAMILY "686 "
27#elif defined CONFIG_MPENTIUMII
28#define MODULE_PROC_FAMILY "PENTIUMII "
29#elif defined CONFIG_MPENTIUMIII
30#define MODULE_PROC_FAMILY "PENTIUMIII "
31#elif defined CONFIG_MPENTIUMM
32#define MODULE_PROC_FAMILY "PENTIUMM "
33#elif defined CONFIG_MPENTIUM4
34#define MODULE_PROC_FAMILY "PENTIUM4 "
35#elif defined CONFIG_MK6
36#define MODULE_PROC_FAMILY "K6 "
37#elif defined CONFIG_MK7
38#define MODULE_PROC_FAMILY "K7 "
39#elif defined CONFIG_MK8
40#define MODULE_PROC_FAMILY "K8 "
41#elif defined CONFIG_X86_ELAN
42#define MODULE_PROC_FAMILY "ELAN "
43#elif defined CONFIG_MCRUSOE
44#define MODULE_PROC_FAMILY "CRUSOE "
45#elif defined CONFIG_MEFFICEON
46#define MODULE_PROC_FAMILY "EFFICEON "
47#elif defined CONFIG_MWINCHIPC6
48#define MODULE_PROC_FAMILY "WINCHIPC6 "
49#elif defined CONFIG_MWINCHIP2
50#define MODULE_PROC_FAMILY "WINCHIP2 "
51#elif defined CONFIG_MWINCHIP3D
52#define MODULE_PROC_FAMILY "WINCHIP3D "
53#elif defined CONFIG_MCYRIXIII
54#define MODULE_PROC_FAMILY "CYRIXIII "
55#elif defined CONFIG_MVIAC3_2
56#define MODULE_PROC_FAMILY "VIAC3-2 "
57#elif defined CONFIG_MVIAC7
58#define MODULE_PROC_FAMILY "VIAC7 "
59#elif defined CONFIG_MGEODEGX1
60#define MODULE_PROC_FAMILY "GEODEGX1 "
61#elif defined CONFIG_MGEODE_LX
62#define MODULE_PROC_FAMILY "GEODE "
63#else
64#error unknown processor family
65#endif
66
67#ifdef CONFIG_4KSTACKS
68#define MODULE_STACKSIZE "4KSTACKS "
69#else
70#define MODULE_STACKSIZE ""
71#endif
72
73#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
74
75#endif /* _ASM_I386_MODULE_H */
diff --git a/include/asm-x86/module_64.h b/include/asm-x86/module_64.h
deleted file mode 100644
index 67f8f69fa7b1..000000000000
--- a/include/asm-x86/module_64.h
+++ /dev/null
@@ -1,10 +0,0 @@
1#ifndef _ASM_X8664_MODULE_H
2#define _ASM_X8664_MODULE_H
3
4struct mod_arch_specific {};
5
6#define Elf_Shdr Elf64_Shdr
7#define Elf_Sym Elf64_Sym
8#define Elf_Ehdr Elf64_Ehdr
9
10#endif
diff --git a/include/asm-x86/mpspec.h b/include/asm-x86/mpspec.h
index 8f268e8fd2e9..781ad74ab9e9 100644
--- a/include/asm-x86/mpspec.h
+++ b/include/asm-x86/mpspec.h
@@ -1,5 +1,117 @@
1#ifndef _AM_X86_MPSPEC_H
2#define _AM_X86_MPSPEC_H
3
4#include <asm/mpspec_def.h>
5
1#ifdef CONFIG_X86_32 6#ifdef CONFIG_X86_32
2# include "mpspec_32.h" 7#include <mach_mpspec.h>
8
9extern int mp_bus_id_to_type[MAX_MP_BUSSES];
10extern int mp_bus_id_to_node[MAX_MP_BUSSES];
11extern int mp_bus_id_to_local[MAX_MP_BUSSES];
12extern int quad_local_to_mp_bus_id[NR_CPUS/4][4];
13
14extern unsigned int def_to_bigsmp;
15extern int apic_version[MAX_APICS];
16extern u8 apicid_2_node[];
17extern int pic_mode;
18
19#define MAX_APICID 256
20
3#else 21#else
4# include "mpspec_64.h" 22
23#define MAX_MP_BUSSES 256
24/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */
25#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4)
26
27extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
28
29#endif
30
31extern int mp_bus_id_to_pci_bus[MAX_MP_BUSSES];
32
33extern unsigned int boot_cpu_physical_apicid;
34extern int smp_found_config;
35extern int nr_ioapics;
36extern int mp_irq_entries;
37extern struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
38extern int mpc_default_type;
39extern unsigned long mp_lapic_addr;
40
41extern void find_smp_config(void);
42extern void get_smp_config(void);
43
44#ifdef CONFIG_ACPI
45extern void mp_register_lapic(u8 id, u8 enabled);
46extern void mp_register_lapic_address(u64 address);
47extern void mp_register_ioapic(u8 id, u32 address, u32 gsi_base);
48extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
49 u32 gsi);
50extern void mp_config_acpi_legacy_irqs(void);
51extern int mp_register_gsi(u32 gsi, int edge_level, int active_high_low);
52#endif /* CONFIG_ACPI */
53
54#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
55
56struct physid_mask
57{
58 unsigned long mask[PHYSID_ARRAY_SIZE];
59};
60
61typedef struct physid_mask physid_mask_t;
62
63#define physid_set(physid, map) set_bit(physid, (map).mask)
64#define physid_clear(physid, map) clear_bit(physid, (map).mask)
65#define physid_isset(physid, map) test_bit(physid, (map).mask)
66#define physid_test_and_set(physid, map) \
67 test_and_set_bit(physid, (map).mask)
68
69#define physids_and(dst, src1, src2) \
70 bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
71
72#define physids_or(dst, src1, src2) \
73 bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
74
75#define physids_clear(map) \
76 bitmap_zero((map).mask, MAX_APICS)
77
78#define physids_complement(dst, src) \
79 bitmap_complement((dst).mask, (src).mask, MAX_APICS)
80
81#define physids_empty(map) \
82 bitmap_empty((map).mask, MAX_APICS)
83
84#define physids_equal(map1, map2) \
85 bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
86
87#define physids_weight(map) \
88 bitmap_weight((map).mask, MAX_APICS)
89
90#define physids_shift_right(d, s, n) \
91 bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
92
93#define physids_shift_left(d, s, n) \
94 bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
95
96#define physids_coerce(map) ((map).mask[0])
97
98#define physids_promote(physids) \
99 ({ \
100 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
101 __physid_mask.mask[0] = physids; \
102 __physid_mask; \
103 })
104
105#define physid_mask_of_physid(physid) \
106 ({ \
107 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
108 physid_set(physid, __physid_mask); \
109 __physid_mask; \
110 })
111
112#define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
113#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
114
115extern physid_mask_t phys_cpu_present_map;
116
5#endif 117#endif
diff --git a/include/asm-x86/mpspec_32.h b/include/asm-x86/mpspec_32.h
deleted file mode 100644
index f21349399d14..000000000000
--- a/include/asm-x86/mpspec_32.h
+++ /dev/null
@@ -1,81 +0,0 @@
1#ifndef __ASM_MPSPEC_H
2#define __ASM_MPSPEC_H
3
4#include <linux/cpumask.h>
5#include <asm/mpspec_def.h>
6#include <mach_mpspec.h>
7
8extern int mp_bus_id_to_type [MAX_MP_BUSSES];
9extern int mp_bus_id_to_node [MAX_MP_BUSSES];
10extern int mp_bus_id_to_local [MAX_MP_BUSSES];
11extern int quad_local_to_mp_bus_id [NR_CPUS/4][4];
12extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES];
13
14extern unsigned int def_to_bigsmp;
15extern unsigned int boot_cpu_physical_apicid;
16extern int smp_found_config;
17extern void find_smp_config (void);
18extern void get_smp_config (void);
19extern int nr_ioapics;
20extern int apic_version [MAX_APICS];
21extern int mp_irq_entries;
22extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES];
23extern int mpc_default_type;
24extern unsigned long mp_lapic_addr;
25extern int pic_mode;
26
27#ifdef CONFIG_ACPI
28extern void mp_register_lapic (u8 id, u8 enabled);
29extern void mp_register_lapic_address (u64 address);
30extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base);
31extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);
32extern void mp_config_acpi_legacy_irqs (void);
33extern int mp_register_gsi (u32 gsi, int edge_level, int active_high_low);
34#endif /* CONFIG_ACPI */
35
36#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
37
38struct physid_mask
39{
40 unsigned long mask[PHYSID_ARRAY_SIZE];
41};
42
43typedef struct physid_mask physid_mask_t;
44
45#define physid_set(physid, map) set_bit(physid, (map).mask)
46#define physid_clear(physid, map) clear_bit(physid, (map).mask)
47#define physid_isset(physid, map) test_bit(physid, (map).mask)
48#define physid_test_and_set(physid, map) test_and_set_bit(physid, (map).mask)
49
50#define physids_and(dst, src1, src2) bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
51#define physids_or(dst, src1, src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
52#define physids_clear(map) bitmap_zero((map).mask, MAX_APICS)
53#define physids_complement(dst, src) bitmap_complement((dst).mask,(src).mask, MAX_APICS)
54#define physids_empty(map) bitmap_empty((map).mask, MAX_APICS)
55#define physids_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
56#define physids_weight(map) bitmap_weight((map).mask, MAX_APICS)
57#define physids_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
58#define physids_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
59#define physids_coerce(map) ((map).mask[0])
60
61#define physids_promote(physids) \
62 ({ \
63 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
64 __physid_mask.mask[0] = physids; \
65 __physid_mask; \
66 })
67
68#define physid_mask_of_physid(physid) \
69 ({ \
70 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
71 physid_set(physid, __physid_mask); \
72 __physid_mask; \
73 })
74
75#define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
76#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
77
78extern physid_mask_t phys_cpu_present_map;
79
80#endif
81
diff --git a/include/asm-x86/mpspec_64.h b/include/asm-x86/mpspec_64.h
deleted file mode 100644
index 017fddb61dc5..000000000000
--- a/include/asm-x86/mpspec_64.h
+++ /dev/null
@@ -1,233 +0,0 @@
1#ifndef __ASM_MPSPEC_H
2#define __ASM_MPSPEC_H
3
4/*
5 * Structure definitions for SMP machines following the
6 * Intel Multiprocessing Specification 1.1 and 1.4.
7 */
8
9/*
10 * This tag identifies where the SMP configuration
11 * information is.
12 */
13
14#define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_')
15
16/*
17 * A maximum of 255 APICs with the current APIC ID architecture.
18 */
19#define MAX_APICS 255
20
21struct intel_mp_floating
22{
23 char mpf_signature[4]; /* "_MP_" */
24 unsigned int mpf_physptr; /* Configuration table address */
25 unsigned char mpf_length; /* Our length (paragraphs) */
26 unsigned char mpf_specification;/* Specification version */
27 unsigned char mpf_checksum; /* Checksum (makes sum 0) */
28 unsigned char mpf_feature1; /* Standard or configuration ? */
29 unsigned char mpf_feature2; /* Bit7 set for IMCR|PIC */
30 unsigned char mpf_feature3; /* Unused (0) */
31 unsigned char mpf_feature4; /* Unused (0) */
32 unsigned char mpf_feature5; /* Unused (0) */
33};
34
35struct mp_config_table
36{
37 char mpc_signature[4];
38#define MPC_SIGNATURE "PCMP"
39 unsigned short mpc_length; /* Size of table */
40 char mpc_spec; /* 0x01 */
41 char mpc_checksum;
42 char mpc_oem[8];
43 char mpc_productid[12];
44 unsigned int mpc_oemptr; /* 0 if not present */
45 unsigned short mpc_oemsize; /* 0 if not present */
46 unsigned short mpc_oemcount;
47 unsigned int mpc_lapic; /* APIC address */
48 unsigned int reserved;
49};
50
51/* Followed by entries */
52
53#define MP_PROCESSOR 0
54#define MP_BUS 1
55#define MP_IOAPIC 2
56#define MP_INTSRC 3
57#define MP_LINTSRC 4
58
59struct mpc_config_processor
60{
61 unsigned char mpc_type;
62 unsigned char mpc_apicid; /* Local APIC number */
63 unsigned char mpc_apicver; /* Its versions */
64 unsigned char mpc_cpuflag;
65#define CPU_ENABLED 1 /* Processor is available */
66#define CPU_BOOTPROCESSOR 2 /* Processor is the BP */
67 unsigned int mpc_cpufeature;
68#define CPU_STEPPING_MASK 0x0F
69#define CPU_MODEL_MASK 0xF0
70#define CPU_FAMILY_MASK 0xF00
71 unsigned int mpc_featureflag; /* CPUID feature value */
72 unsigned int mpc_reserved[2];
73};
74
75struct mpc_config_bus
76{
77 unsigned char mpc_type;
78 unsigned char mpc_busid;
79 unsigned char mpc_bustype[6];
80};
81
82/* List of Bus Type string values, Intel MP Spec. */
83#define BUSTYPE_EISA "EISA"
84#define BUSTYPE_ISA "ISA"
85#define BUSTYPE_INTERN "INTERN" /* Internal BUS */
86#define BUSTYPE_MCA "MCA"
87#define BUSTYPE_VL "VL" /* Local bus */
88#define BUSTYPE_PCI "PCI"
89#define BUSTYPE_PCMCIA "PCMCIA"
90#define BUSTYPE_CBUS "CBUS"
91#define BUSTYPE_CBUSII "CBUSII"
92#define BUSTYPE_FUTURE "FUTURE"
93#define BUSTYPE_MBI "MBI"
94#define BUSTYPE_MBII "MBII"
95#define BUSTYPE_MPI "MPI"
96#define BUSTYPE_MPSA "MPSA"
97#define BUSTYPE_NUBUS "NUBUS"
98#define BUSTYPE_TC "TC"
99#define BUSTYPE_VME "VME"
100#define BUSTYPE_XPRESS "XPRESS"
101
102struct mpc_config_ioapic
103{
104 unsigned char mpc_type;
105 unsigned char mpc_apicid;
106 unsigned char mpc_apicver;
107 unsigned char mpc_flags;
108#define MPC_APIC_USABLE 0x01
109 unsigned int mpc_apicaddr;
110};
111
112struct mpc_config_intsrc
113{
114 unsigned char mpc_type;
115 unsigned char mpc_irqtype;
116 unsigned short mpc_irqflag;
117 unsigned char mpc_srcbus;
118 unsigned char mpc_srcbusirq;
119 unsigned char mpc_dstapic;
120 unsigned char mpc_dstirq;
121};
122
123enum mp_irq_source_types {
124 mp_INT = 0,
125 mp_NMI = 1,
126 mp_SMI = 2,
127 mp_ExtINT = 3
128};
129
130#define MP_IRQDIR_DEFAULT 0
131#define MP_IRQDIR_HIGH 1
132#define MP_IRQDIR_LOW 3
133
134
135struct mpc_config_lintsrc
136{
137 unsigned char mpc_type;
138 unsigned char mpc_irqtype;
139 unsigned short mpc_irqflag;
140 unsigned char mpc_srcbusid;
141 unsigned char mpc_srcbusirq;
142 unsigned char mpc_destapic;
143#define MP_APIC_ALL 0xFF
144 unsigned char mpc_destapiclint;
145};
146
147/*
148 * Default configurations
149 *
150 * 1 2 CPU ISA 82489DX
151 * 2 2 CPU EISA 82489DX neither IRQ 0 timer nor IRQ 13 DMA chaining
152 * 3 2 CPU EISA 82489DX
153 * 4 2 CPU MCA 82489DX
154 * 5 2 CPU ISA+PCI
155 * 6 2 CPU EISA+PCI
156 * 7 2 CPU MCA+PCI
157 */
158
159#define MAX_MP_BUSSES 256
160/* Each PCI slot may be a combo card with its own bus. 4 IRQ pins per slot. */
161#define MAX_IRQ_SOURCES (MAX_MP_BUSSES * 4)
162extern DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
163extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES];
164
165extern unsigned int boot_cpu_physical_apicid;
166extern int smp_found_config;
167extern void find_smp_config (void);
168extern void get_smp_config (void);
169extern int nr_ioapics;
170extern unsigned char apic_version [MAX_APICS];
171extern int mp_irq_entries;
172extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES];
173extern int mpc_default_type;
174extern unsigned long mp_lapic_addr;
175
176#ifdef CONFIG_ACPI
177extern void mp_register_lapic (u8 id, u8 enabled);
178extern void mp_register_lapic_address (u64 address);
179
180extern void mp_register_ioapic (u8 id, u32 address, u32 gsi_base);
181extern void mp_override_legacy_irq (u8 bus_irq, u8 polarity, u8 trigger, u32 gsi);
182extern void mp_config_acpi_legacy_irqs (void);
183extern int mp_register_gsi (u32 gsi, int triggering, int polarity);
184#endif
185
186extern int using_apic_timer;
187
188#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
189
190struct physid_mask
191{
192 unsigned long mask[PHYSID_ARRAY_SIZE];
193};
194
195typedef struct physid_mask physid_mask_t;
196
197#define physid_set(physid, map) set_bit(physid, (map).mask)
198#define physid_clear(physid, map) clear_bit(physid, (map).mask)
199#define physid_isset(physid, map) test_bit(physid, (map).mask)
200#define physid_test_and_set(physid, map) test_and_set_bit(physid, (map).mask)
201
202#define physids_and(dst, src1, src2) bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
203#define physids_or(dst, src1, src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
204#define physids_clear(map) bitmap_zero((map).mask, MAX_APICS)
205#define physids_complement(dst, src) bitmap_complement((dst).mask, (src).mask, MAX_APICS)
206#define physids_empty(map) bitmap_empty((map).mask, MAX_APICS)
207#define physids_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
208#define physids_weight(map) bitmap_weight((map).mask, MAX_APICS)
209#define physids_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
210#define physids_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
211#define physids_coerce(map) ((map).mask[0])
212
213#define physids_promote(physids) \
214 ({ \
215 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
216 __physid_mask.mask[0] = physids; \
217 __physid_mask; \
218 })
219
220#define physid_mask_of_physid(physid) \
221 ({ \
222 physid_mask_t __physid_mask = PHYSID_MASK_NONE; \
223 physid_set(physid, __physid_mask); \
224 __physid_mask; \
225 })
226
227#define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
228#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
229
230extern physid_mask_t phys_cpu_present_map;
231
232#endif
233
diff --git a/include/asm-x86/mpspec_def.h b/include/asm-x86/mpspec_def.h
index 13bafb16e7af..3504617fe648 100644
--- a/include/asm-x86/mpspec_def.h
+++ b/include/asm-x86/mpspec_def.h
@@ -8,52 +8,68 @@
8 8
9/* 9/*
10 * This tag identifies where the SMP configuration 10 * This tag identifies where the SMP configuration
11 * information is. 11 * information is.
12 */ 12 */
13 13
14#define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_') 14#define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_')
15 15
16#define MAX_MPC_ENTRY 1024 16#ifdef CONFIG_X86_32
17#define MAX_APICS 256 17# define MAX_MPC_ENTRY 1024
18# define MAX_APICS 256
19#else
20/*
21 * A maximum of 255 APICs with the current APIC ID architecture.
22 */
23# define MAX_APICS 255
24#endif
18 25
19struct intel_mp_floating 26struct intel_mp_floating
20{ 27{
21 char mpf_signature[4]; /* "_MP_" */ 28 char mpf_signature[4]; /* "_MP_" */
22 unsigned long mpf_physptr; /* Configuration table address */ 29 unsigned int mpf_physptr; /* Configuration table address */
23 unsigned char mpf_length; /* Our length (paragraphs) */ 30 unsigned char mpf_length; /* Our length (paragraphs) */
24 unsigned char mpf_specification;/* Specification version */ 31 unsigned char mpf_specification;/* Specification version */
25 unsigned char mpf_checksum; /* Checksum (makes sum 0) */ 32 unsigned char mpf_checksum; /* Checksum (makes sum 0) */
26 unsigned char mpf_feature1; /* Standard or configuration ? */ 33 unsigned char mpf_feature1; /* Standard or configuration ? */
27 unsigned char mpf_feature2; /* Bit7 set for IMCR|PIC */ 34 unsigned char mpf_feature2; /* Bit7 set for IMCR|PIC */
28 unsigned char mpf_feature3; /* Unused (0) */ 35 unsigned char mpf_feature3; /* Unused (0) */
29 unsigned char mpf_feature4; /* Unused (0) */ 36 unsigned char mpf_feature4; /* Unused (0) */
30 unsigned char mpf_feature5; /* Unused (0) */ 37 unsigned char mpf_feature5; /* Unused (0) */
31}; 38};
32 39
40#define MPC_SIGNATURE "PCMP"
41
33struct mp_config_table 42struct mp_config_table
34{ 43{
35 char mpc_signature[4]; 44 char mpc_signature[4];
36#define MPC_SIGNATURE "PCMP"
37 unsigned short mpc_length; /* Size of table */ 45 unsigned short mpc_length; /* Size of table */
38 char mpc_spec; /* 0x01 */ 46 char mpc_spec; /* 0x01 */
39 char mpc_checksum; 47 char mpc_checksum;
40 char mpc_oem[8]; 48 char mpc_oem[8];
41 char mpc_productid[12]; 49 char mpc_productid[12];
42 unsigned long mpc_oemptr; /* 0 if not present */ 50 unsigned int mpc_oemptr; /* 0 if not present */
43 unsigned short mpc_oemsize; /* 0 if not present */ 51 unsigned short mpc_oemsize; /* 0 if not present */
44 unsigned short mpc_oemcount; 52 unsigned short mpc_oemcount;
45 unsigned long mpc_lapic; /* APIC address */ 53 unsigned int mpc_lapic; /* APIC address */
46 unsigned long reserved; 54 unsigned int reserved;
47}; 55};
48 56
49/* Followed by entries */ 57/* Followed by entries */
50 58
51#define MP_PROCESSOR 0 59#define MP_PROCESSOR 0
52#define MP_BUS 1 60#define MP_BUS 1
53#define MP_IOAPIC 2 61#define MP_IOAPIC 2
54#define MP_INTSRC 3 62#define MP_INTSRC 3
55#define MP_LINTSRC 4 63#define MP_LINTSRC 4
56#define MP_TRANSLATION 192 /* Used by IBM NUMA-Q to describe node locality */ 64/* Used by IBM NUMA-Q to describe node locality */
65#define MP_TRANSLATION 192
66
67#define CPU_ENABLED 1 /* Processor is available */
68#define CPU_BOOTPROCESSOR 2 /* Processor is the BP */
69
70#define CPU_STEPPING_MASK 0x000F
71#define CPU_MODEL_MASK 0x00F0
72#define CPU_FAMILY_MASK 0x0F00
57 73
58struct mpc_config_processor 74struct mpc_config_processor
59{ 75{
@@ -61,14 +77,9 @@ struct mpc_config_processor
61 unsigned char mpc_apicid; /* Local APIC number */ 77 unsigned char mpc_apicid; /* Local APIC number */
62 unsigned char mpc_apicver; /* Its versions */ 78 unsigned char mpc_apicver; /* Its versions */
63 unsigned char mpc_cpuflag; 79 unsigned char mpc_cpuflag;
64#define CPU_ENABLED 1 /* Processor is available */ 80 unsigned int mpc_cpufeature;
65#define CPU_BOOTPROCESSOR 2 /* Processor is the BP */ 81 unsigned int mpc_featureflag; /* CPUID feature value */
66 unsigned long mpc_cpufeature; 82 unsigned int mpc_reserved[2];
67#define CPU_STEPPING_MASK 0x0F
68#define CPU_MODEL_MASK 0xF0
69#define CPU_FAMILY_MASK 0xF00
70 unsigned long mpc_featureflag; /* CPUID feature value */
71 unsigned long mpc_reserved[2];
72}; 83};
73 84
74struct mpc_config_bus 85struct mpc_config_bus
@@ -98,14 +109,15 @@ struct mpc_config_bus
98#define BUSTYPE_VME "VME" 109#define BUSTYPE_VME "VME"
99#define BUSTYPE_XPRESS "XPRESS" 110#define BUSTYPE_XPRESS "XPRESS"
100 111
112#define MPC_APIC_USABLE 0x01
113
101struct mpc_config_ioapic 114struct mpc_config_ioapic
102{ 115{
103 unsigned char mpc_type; 116 unsigned char mpc_type;
104 unsigned char mpc_apicid; 117 unsigned char mpc_apicid;
105 unsigned char mpc_apicver; 118 unsigned char mpc_apicver;
106 unsigned char mpc_flags; 119 unsigned char mpc_flags;
107#define MPC_APIC_USABLE 0x01 120 unsigned int mpc_apicaddr;
108 unsigned long mpc_apicaddr;
109}; 121};
110 122
111struct mpc_config_intsrc 123struct mpc_config_intsrc
@@ -130,6 +142,7 @@ enum mp_irq_source_types {
130#define MP_IRQDIR_HIGH 1 142#define MP_IRQDIR_HIGH 1
131#define MP_IRQDIR_LOW 3 143#define MP_IRQDIR_LOW 3
132 144
145#define MP_APIC_ALL 0xFF
133 146
134struct mpc_config_lintsrc 147struct mpc_config_lintsrc
135{ 148{
@@ -138,15 +151,15 @@ struct mpc_config_lintsrc
138 unsigned short mpc_irqflag; 151 unsigned short mpc_irqflag;
139 unsigned char mpc_srcbusid; 152 unsigned char mpc_srcbusid;
140 unsigned char mpc_srcbusirq; 153 unsigned char mpc_srcbusirq;
141 unsigned char mpc_destapic; 154 unsigned char mpc_destapic;
142#define MP_APIC_ALL 0xFF
143 unsigned char mpc_destapiclint; 155 unsigned char mpc_destapiclint;
144}; 156};
145 157
158#define MPC_OEM_SIGNATURE "_OEM"
159
146struct mp_config_oemtable 160struct mp_config_oemtable
147{ 161{
148 char oem_signature[4]; 162 char oem_signature[4];
149#define MPC_OEM_SIGNATURE "_OEM"
150 unsigned short oem_length; /* Size of table */ 163 unsigned short oem_length; /* Size of table */
151 char oem_rev; /* 0x01 */ 164 char oem_rev; /* 0x01 */
152 char oem_checksum; 165 char oem_checksum;
@@ -155,13 +168,13 @@ struct mp_config_oemtable
155 168
156struct mpc_config_translation 169struct mpc_config_translation
157{ 170{
158 unsigned char mpc_type; 171 unsigned char mpc_type;
159 unsigned char trans_len; 172 unsigned char trans_len;
160 unsigned char trans_type; 173 unsigned char trans_type;
161 unsigned char trans_quad; 174 unsigned char trans_quad;
162 unsigned char trans_global; 175 unsigned char trans_global;
163 unsigned char trans_local; 176 unsigned char trans_local;
164 unsigned short trans_reserved; 177 unsigned short trans_reserved;
165}; 178};
166 179
167/* 180/*
diff --git a/include/asm-x86/msr-index.h b/include/asm-x86/msr-index.h
index a4944732be04..fae118a25278 100644
--- a/include/asm-x86/msr-index.h
+++ b/include/asm-x86/msr-index.h
@@ -63,6 +63,13 @@
63#define MSR_IA32_LASTINTFROMIP 0x000001dd 63#define MSR_IA32_LASTINTFROMIP 0x000001dd
64#define MSR_IA32_LASTINTTOIP 0x000001de 64#define MSR_IA32_LASTINTTOIP 0x000001de
65 65
66/* DEBUGCTLMSR bits (others vary by model): */
67#define _DEBUGCTLMSR_LBR 0 /* last branch recording */
68#define _DEBUGCTLMSR_BTF 1 /* single-step on branches */
69
70#define DEBUGCTLMSR_LBR (1UL << _DEBUGCTLMSR_LBR)
71#define DEBUGCTLMSR_BTF (1UL << _DEBUGCTLMSR_BTF)
72
66#define MSR_IA32_MC0_CTL 0x00000400 73#define MSR_IA32_MC0_CTL 0x00000400
67#define MSR_IA32_MC0_STATUS 0x00000401 74#define MSR_IA32_MC0_STATUS 0x00000401
68#define MSR_IA32_MC0_ADDR 0x00000402 75#define MSR_IA32_MC0_ADDR 0x00000402
@@ -88,6 +95,14 @@
88#define MSR_AMD64_IBSDCPHYSAD 0xc0011039 95#define MSR_AMD64_IBSDCPHYSAD 0xc0011039
89#define MSR_AMD64_IBSCTL 0xc001103a 96#define MSR_AMD64_IBSCTL 0xc001103a
90 97
98/* Fam 10h MSRs */
99#define MSR_FAM10H_MMIO_CONF_BASE 0xc0010058
100#define FAM10H_MMIO_CONF_ENABLE (1<<0)
101#define FAM10H_MMIO_CONF_BUSRANGE_MASK 0xf
102#define FAM10H_MMIO_CONF_BUSRANGE_SHIFT 2
103#define FAM10H_MMIO_CONF_BASE_MASK 0xfffffff
104#define FAM10H_MMIO_CONF_BASE_SHIFT 20
105
91/* K8 MSRs */ 106/* K8 MSRs */
92#define MSR_K8_TOP_MEM1 0xc001001a 107#define MSR_K8_TOP_MEM1 0xc001001a
93#define MSR_K8_TOP_MEM2 0xc001001d 108#define MSR_K8_TOP_MEM2 0xc001001d
diff --git a/include/asm-x86/msr.h b/include/asm-x86/msr.h
index ba4b31432120..204a8a30fecf 100644
--- a/include/asm-x86/msr.h
+++ b/include/asm-x86/msr.h
@@ -3,77 +3,113 @@
3 3
4#include <asm/msr-index.h> 4#include <asm/msr-index.h>
5 5
6#ifdef __i386__ 6#ifndef __ASSEMBLY__
7# include <linux/types.h>
8#endif
7 9
8#ifdef __KERNEL__ 10#ifdef __KERNEL__
9#ifndef __ASSEMBLY__ 11#ifndef __ASSEMBLY__
10 12
13#include <asm/asm.h>
11#include <asm/errno.h> 14#include <asm/errno.h>
12 15
16static inline unsigned long long native_read_tscp(unsigned int *aux)
17{
18 unsigned long low, high;
19 asm volatile (".byte 0x0f,0x01,0xf9"
20 : "=a" (low), "=d" (high), "=c" (*aux));
21 return low | ((u64)high >> 32);
22}
23
24/*
25 * i386 calling convention returns 64-bit value in edx:eax, while
26 * x86_64 returns at rax. Also, the "A" constraint does not really
27 * mean rdx:rax in x86_64, so we need specialized behaviour for each
28 * architecture
29 */
30#ifdef CONFIG_X86_64
31#define DECLARE_ARGS(val, low, high) unsigned low, high
32#define EAX_EDX_VAL(val, low, high) (low | ((u64)(high) << 32))
33#define EAX_EDX_ARGS(val, low, high) "a" (low), "d" (high)
34#define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high)
35#else
36#define DECLARE_ARGS(val, low, high) unsigned long long val
37#define EAX_EDX_VAL(val, low, high) (val)
38#define EAX_EDX_ARGS(val, low, high) "A" (val)
39#define EAX_EDX_RET(val, low, high) "=A" (val)
40#endif
41
13static inline unsigned long long native_read_msr(unsigned int msr) 42static inline unsigned long long native_read_msr(unsigned int msr)
14{ 43{
15 unsigned long long val; 44 DECLARE_ARGS(val, low, high);
16 45
17 asm volatile("rdmsr" : "=A" (val) : "c" (msr)); 46 asm volatile("rdmsr" : EAX_EDX_RET(val, low, high) : "c" (msr));
18 return val; 47 return EAX_EDX_VAL(val, low, high);
19} 48}
20 49
21static inline unsigned long long native_read_msr_safe(unsigned int msr, 50static inline unsigned long long native_read_msr_safe(unsigned int msr,
22 int *err) 51 int *err)
23{ 52{
24 unsigned long long val; 53 DECLARE_ARGS(val, low, high);
25 54
26 asm volatile("2: rdmsr ; xorl %0,%0\n" 55 asm volatile("2: rdmsr ; xor %0,%0\n"
27 "1:\n\t" 56 "1:\n\t"
28 ".section .fixup,\"ax\"\n\t" 57 ".section .fixup,\"ax\"\n\t"
29 "3: movl %3,%0 ; jmp 1b\n\t" 58 "3: mov %3,%0 ; jmp 1b\n\t"
30 ".previous\n\t" 59 ".previous\n\t"
31 ".section __ex_table,\"a\"\n" 60 ".section __ex_table,\"a\"\n"
32 " .align 4\n\t" 61 _ASM_ALIGN "\n\t"
33 " .long 2b,3b\n\t" 62 _ASM_PTR " 2b,3b\n\t"
34 ".previous" 63 ".previous"
35 : "=r" (*err), "=A" (val) 64 : "=r" (*err), EAX_EDX_RET(val, low, high)
36 : "c" (msr), "i" (-EFAULT)); 65 : "c" (msr), "i" (-EFAULT));
37 66 return EAX_EDX_VAL(val, low, high);
38 return val;
39} 67}
40 68
41static inline void native_write_msr(unsigned int msr, unsigned long long val) 69static inline void native_write_msr(unsigned int msr,
70 unsigned low, unsigned high)
42{ 71{
43 asm volatile("wrmsr" : : "c" (msr), "A"(val)); 72 asm volatile("wrmsr" : : "c" (msr), "a"(low), "d" (high));
44} 73}
45 74
46static inline int native_write_msr_safe(unsigned int msr, 75static inline int native_write_msr_safe(unsigned int msr,
47 unsigned long long val) 76 unsigned low, unsigned high)
48{ 77{
49 int err; 78 int err;
50 asm volatile("2: wrmsr ; xorl %0,%0\n" 79 asm volatile("2: wrmsr ; xor %0,%0\n"
51 "1:\n\t" 80 "1:\n\t"
52 ".section .fixup,\"ax\"\n\t" 81 ".section .fixup,\"ax\"\n\t"
53 "3: movl %4,%0 ; jmp 1b\n\t" 82 "3: mov %4,%0 ; jmp 1b\n\t"
54 ".previous\n\t" 83 ".previous\n\t"
55 ".section __ex_table,\"a\"\n" 84 ".section __ex_table,\"a\"\n"
56 " .align 4\n\t" 85 _ASM_ALIGN "\n\t"
57 " .long 2b,3b\n\t" 86 _ASM_PTR " 2b,3b\n\t"
58 ".previous" 87 ".previous"
59 : "=a" (err) 88 : "=a" (err)
60 : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)), 89 : "c" (msr), "0" (low), "d" (high),
61 "i" (-EFAULT)); 90 "i" (-EFAULT));
62 return err; 91 return err;
63} 92}
64 93
65static inline unsigned long long native_read_tsc(void) 94extern unsigned long long native_read_tsc(void);
95
96static __always_inline unsigned long long __native_read_tsc(void)
66{ 97{
67 unsigned long long val; 98 DECLARE_ARGS(val, low, high);
68 asm volatile("rdtsc" : "=A" (val)); 99
69 return val; 100 rdtsc_barrier();
101 asm volatile("rdtsc" : EAX_EDX_RET(val, low, high));
102 rdtsc_barrier();
103
104 return EAX_EDX_VAL(val, low, high);
70} 105}
71 106
72static inline unsigned long long native_read_pmc(void) 107static inline unsigned long long native_read_pmc(int counter)
73{ 108{
74 unsigned long long val; 109 DECLARE_ARGS(val, low, high);
75 asm volatile("rdpmc" : "=A" (val)); 110
76 return val; 111 asm volatile("rdpmc" : EAX_EDX_RET(val, low, high) : "c" (counter));
112 return EAX_EDX_VAL(val, low, high);
77} 113}
78 114
79#ifdef CONFIG_PARAVIRT 115#ifdef CONFIG_PARAVIRT
@@ -93,20 +129,21 @@ static inline unsigned long long native_read_pmc(void)
93 (val2) = (u32)(__val >> 32); \ 129 (val2) = (u32)(__val >> 32); \
94 } while(0) 130 } while(0)
95 131
96static inline void wrmsr(u32 __msr, u32 __low, u32 __high) 132static inline void wrmsr(unsigned msr, unsigned low, unsigned high)
97{ 133{
98 native_write_msr(__msr, ((u64)__high << 32) | __low); 134 native_write_msr(msr, low, high);
99} 135}
100 136
101#define rdmsrl(msr,val) \ 137#define rdmsrl(msr,val) \
102 ((val) = native_read_msr(msr)) 138 ((val) = native_read_msr(msr))
103 139
104#define wrmsrl(msr,val) native_write_msr(msr, val) 140#define wrmsrl(msr, val) \
141 native_write_msr(msr, (u32)((u64)(val)), (u32)((u64)(val) >> 32))
105 142
106/* wrmsr with exception handling */ 143/* wrmsr with exception handling */
107static inline int wrmsr_safe(u32 __msr, u32 __low, u32 __high) 144static inline int wrmsr_safe(unsigned msr, unsigned low, unsigned high)
108{ 145{
109 return native_write_msr_safe(__msr, ((u64)__high << 32) | __low); 146 return native_write_msr_safe(msr, low, high);
110} 147}
111 148
112/* rdmsr with exception handling */ 149/* rdmsr with exception handling */
@@ -125,201 +162,31 @@ static inline int wrmsr_safe(u32 __msr, u32 __low, u32 __high)
125#define rdtscll(val) \ 162#define rdtscll(val) \
126 ((val) = native_read_tsc()) 163 ((val) = native_read_tsc())
127 164
128#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
129
130#define rdpmc(counter,low,high) \ 165#define rdpmc(counter,low,high) \
131 do { \ 166 do { \
132 u64 _l = native_read_pmc(); \ 167 u64 _l = native_read_pmc(counter); \
133 (low) = (u32)_l; \ 168 (low) = (u32)_l; \
134 (high) = (u32)(_l >> 32); \ 169 (high) = (u32)(_l >> 32); \
135 } while(0) 170 } while(0)
136#endif /* !CONFIG_PARAVIRT */
137 171
138#ifdef CONFIG_SMP 172#define rdtscp(low, high, aux) \
139void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); 173 do { \
140void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); 174 unsigned long long _val = native_read_tscp(&(aux)); \
141int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); 175 (low) = (u32)_val; \
142int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); 176 (high) = (u32)(_val >> 32); \
143#else /* CONFIG_SMP */ 177 } while (0)
144static inline void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
145{
146 rdmsr(msr_no, *l, *h);
147}
148static inline void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
149{
150 wrmsr(msr_no, l, h);
151}
152static inline int rdmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h)
153{
154 return rdmsr_safe(msr_no, l, h);
155}
156static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
157{
158 return wrmsr_safe(msr_no, l, h);
159}
160#endif /* CONFIG_SMP */
161#endif /* ! __ASSEMBLY__ */
162#endif /* __KERNEL__ */
163
164#else /* __i386__ */
165
166#ifndef __ASSEMBLY__
167#include <linux/errno.h>
168/*
169 * Access to machine-specific registers (available on 586 and better only)
170 * Note: the rd* operations modify the parameters directly (without using
171 * pointer indirection), this allows gcc to optimize better
172 */
173 178
174#define rdmsr(msr,val1,val2) \ 179#define rdtscpll(val, aux) (val) = native_read_tscp(&(aux))
175 __asm__ __volatile__("rdmsr" \
176 : "=a" (val1), "=d" (val2) \
177 : "c" (msr))
178 180
181#endif /* !CONFIG_PARAVIRT */
179 182
180#define rdmsrl(msr,val) do { unsigned long a__,b__; \
181 __asm__ __volatile__("rdmsr" \
182 : "=a" (a__), "=d" (b__) \
183 : "c" (msr)); \
184 val = a__ | (b__<<32); \
185} while(0)
186
187#define wrmsr(msr,val1,val2) \
188 __asm__ __volatile__("wrmsr" \
189 : /* no outputs */ \
190 : "c" (msr), "a" (val1), "d" (val2))
191
192#define wrmsrl(msr,val) wrmsr(msr,(__u32)((__u64)(val)),((__u64)(val))>>32)
193
194/* wrmsr with exception handling */
195#define wrmsr_safe(msr,a,b) ({ int ret__; \
196 asm volatile("2: wrmsr ; xorl %0,%0\n" \
197 "1:\n\t" \
198 ".section .fixup,\"ax\"\n\t" \
199 "3: movl %4,%0 ; jmp 1b\n\t" \
200 ".previous\n\t" \
201 ".section __ex_table,\"a\"\n" \
202 " .align 8\n\t" \
203 " .quad 2b,3b\n\t" \
204 ".previous" \
205 : "=a" (ret__) \
206 : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT)); \
207 ret__; })
208 183
209#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32)) 184#define checking_wrmsrl(msr,val) wrmsr_safe(msr,(u32)(val),(u32)((val)>>32))
210 185
211#define rdmsr_safe(msr,a,b) \
212 ({ int ret__; \
213 asm volatile ("1: rdmsr\n" \
214 "2:\n" \
215 ".section .fixup,\"ax\"\n" \
216 "3: movl %4,%0\n" \
217 " jmp 2b\n" \
218 ".previous\n" \
219 ".section __ex_table,\"a\"\n" \
220 " .align 8\n" \
221 " .quad 1b,3b\n" \
222 ".previous":"=&bDS" (ret__), "=a"(*(a)), "=d"(*(b)) \
223 :"c"(msr), "i"(-EIO), "0"(0)); \
224 ret__; })
225
226#define rdtsc(low,high) \
227 __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))
228
229#define rdtscl(low) \
230 __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
231
232#define rdtscp(low,high,aux) \
233 asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (low), "=d" (high), "=c" (aux))
234
235#define rdtscll(val) do { \
236 unsigned int __a,__d; \
237 asm volatile("rdtsc" : "=a" (__a), "=d" (__d)); \
238 (val) = ((unsigned long)__a) | (((unsigned long)__d)<<32); \
239} while(0)
240
241#define rdtscpll(val, aux) do { \
242 unsigned long __a, __d; \
243 asm volatile (".byte 0x0f,0x01,0xf9" : "=a" (__a), "=d" (__d), "=c" (aux)); \
244 (val) = (__d << 32) | __a; \
245} while (0)
246
247#define write_tsc(val1,val2) wrmsr(0x10, val1, val2) 186#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
248 187
249#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0) 188#define write_rdtscp_aux(val) wrmsr(0xc0000103, val, 0)
250 189
251#define rdpmc(counter,low,high) \
252 __asm__ __volatile__("rdpmc" \
253 : "=a" (low), "=d" (high) \
254 : "c" (counter))
255
256static inline void cpuid(int op, unsigned int *eax, unsigned int *ebx,
257 unsigned int *ecx, unsigned int *edx)
258{
259 __asm__("cpuid"
260 : "=a" (*eax),
261 "=b" (*ebx),
262 "=c" (*ecx),
263 "=d" (*edx)
264 : "0" (op));
265}
266
267/* Some CPUID calls want 'count' to be placed in ecx */
268static inline void cpuid_count(int op, int count, int *eax, int *ebx, int *ecx,
269 int *edx)
270{
271 __asm__("cpuid"
272 : "=a" (*eax),
273 "=b" (*ebx),
274 "=c" (*ecx),
275 "=d" (*edx)
276 : "0" (op), "c" (count));
277}
278
279/*
280 * CPUID functions returning a single datum
281 */
282static inline unsigned int cpuid_eax(unsigned int op)
283{
284 unsigned int eax;
285
286 __asm__("cpuid"
287 : "=a" (eax)
288 : "0" (op)
289 : "bx", "cx", "dx");
290 return eax;
291}
292static inline unsigned int cpuid_ebx(unsigned int op)
293{
294 unsigned int eax, ebx;
295
296 __asm__("cpuid"
297 : "=a" (eax), "=b" (ebx)
298 : "0" (op)
299 : "cx", "dx" );
300 return ebx;
301}
302static inline unsigned int cpuid_ecx(unsigned int op)
303{
304 unsigned int eax, ecx;
305
306 __asm__("cpuid"
307 : "=a" (eax), "=c" (ecx)
308 : "0" (op)
309 : "bx", "dx" );
310 return ecx;
311}
312static inline unsigned int cpuid_edx(unsigned int op)
313{
314 unsigned int eax, edx;
315
316 __asm__("cpuid"
317 : "=a" (eax), "=d" (edx)
318 : "0" (op)
319 : "bx", "cx");
320 return edx;
321}
322
323#ifdef CONFIG_SMP 190#ifdef CONFIG_SMP
324void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); 191void rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h);
325void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h); 192void wrmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h);
@@ -343,8 +210,8 @@ static inline int wrmsr_safe_on_cpu(unsigned int cpu, u32 msr_no, u32 l, u32 h)
343 return wrmsr_safe(msr_no, l, h); 210 return wrmsr_safe(msr_no, l, h);
344} 211}
345#endif /* CONFIG_SMP */ 212#endif /* CONFIG_SMP */
346#endif /* __ASSEMBLY__ */ 213#endif /* __ASSEMBLY__ */
214#endif /* __KERNEL__ */
347 215
348#endif /* !__i386__ */
349 216
350#endif 217#endif
diff --git a/include/asm-x86/mtrr.h b/include/asm-x86/mtrr.h
index e8320e4e6ca2..319d065800be 100644
--- a/include/asm-x86/mtrr.h
+++ b/include/asm-x86/mtrr.h
@@ -89,24 +89,25 @@ struct mtrr_gentry
89extern void mtrr_save_fixed_ranges(void *); 89extern void mtrr_save_fixed_ranges(void *);
90extern void mtrr_save_state(void); 90extern void mtrr_save_state(void);
91extern int mtrr_add (unsigned long base, unsigned long size, 91extern int mtrr_add (unsigned long base, unsigned long size,
92 unsigned int type, char increment); 92 unsigned int type, bool increment);
93extern int mtrr_add_page (unsigned long base, unsigned long size, 93extern int mtrr_add_page (unsigned long base, unsigned long size,
94 unsigned int type, char increment); 94 unsigned int type, bool increment);
95extern int mtrr_del (int reg, unsigned long base, unsigned long size); 95extern int mtrr_del (int reg, unsigned long base, unsigned long size);
96extern int mtrr_del_page (int reg, unsigned long base, unsigned long size); 96extern int mtrr_del_page (int reg, unsigned long base, unsigned long size);
97extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi); 97extern void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi);
98extern void mtrr_ap_init(void); 98extern void mtrr_ap_init(void);
99extern void mtrr_bp_init(void); 99extern void mtrr_bp_init(void);
100extern int mtrr_trim_uncached_memory(unsigned long end_pfn);
100# else 101# else
101#define mtrr_save_fixed_ranges(arg) do {} while (0) 102#define mtrr_save_fixed_ranges(arg) do {} while (0)
102#define mtrr_save_state() do {} while (0) 103#define mtrr_save_state() do {} while (0)
103static __inline__ int mtrr_add (unsigned long base, unsigned long size, 104static __inline__ int mtrr_add (unsigned long base, unsigned long size,
104 unsigned int type, char increment) 105 unsigned int type, bool increment)
105{ 106{
106 return -ENODEV; 107 return -ENODEV;
107} 108}
108static __inline__ int mtrr_add_page (unsigned long base, unsigned long size, 109static __inline__ int mtrr_add_page (unsigned long base, unsigned long size,
109 unsigned int type, char increment) 110 unsigned int type, bool increment)
110{ 111{
111 return -ENODEV; 112 return -ENODEV;
112} 113}
@@ -120,7 +121,10 @@ static __inline__ int mtrr_del_page (int reg, unsigned long base,
120{ 121{
121 return -ENODEV; 122 return -ENODEV;
122} 123}
123 124static inline int mtrr_trim_uncached_memory(unsigned long end_pfn)
125{
126 return 0;
127}
124static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;} 128static __inline__ void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) {;}
125 129
126#define mtrr_ap_init() do {} while (0) 130#define mtrr_ap_init() do {} while (0)
diff --git a/include/asm-x86/mutex_32.h b/include/asm-x86/mutex_32.h
index 7a17d9e58ad6..bbeefb96ddfd 100644
--- a/include/asm-x86/mutex_32.h
+++ b/include/asm-x86/mutex_32.h
@@ -26,7 +26,7 @@ do { \
26 unsigned int dummy; \ 26 unsigned int dummy; \
27 \ 27 \
28 typecheck(atomic_t *, count); \ 28 typecheck(atomic_t *, count); \
29 typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \ 29 typecheck_fn(void (*)(atomic_t *), fail_fn); \
30 \ 30 \
31 __asm__ __volatile__( \ 31 __asm__ __volatile__( \
32 LOCK_PREFIX " decl (%%eax) \n" \ 32 LOCK_PREFIX " decl (%%eax) \n" \
@@ -51,8 +51,7 @@ do { \
51 * or anything the slow path function returns 51 * or anything the slow path function returns
52 */ 52 */
53static inline int 53static inline int
54__mutex_fastpath_lock_retval(atomic_t *count, 54__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
55 int fastcall (*fail_fn)(atomic_t *))
56{ 55{
57 if (unlikely(atomic_dec_return(count) < 0)) 56 if (unlikely(atomic_dec_return(count) < 0))
58 return fail_fn(count); 57 return fail_fn(count);
@@ -78,7 +77,7 @@ do { \
78 unsigned int dummy; \ 77 unsigned int dummy; \
79 \ 78 \
80 typecheck(atomic_t *, count); \ 79 typecheck(atomic_t *, count); \
81 typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \ 80 typecheck_fn(void (*)(atomic_t *), fail_fn); \
82 \ 81 \
83 __asm__ __volatile__( \ 82 __asm__ __volatile__( \
84 LOCK_PREFIX " incl (%%eax) \n" \ 83 LOCK_PREFIX " incl (%%eax) \n" \
diff --git a/include/asm-x86/nmi_32.h b/include/asm-x86/nmi_32.h
index 70a958a8e381..7206c7e8a388 100644
--- a/include/asm-x86/nmi_32.h
+++ b/include/asm-x86/nmi_32.h
@@ -1,6 +1,3 @@
1/*
2 * linux/include/asm-i386/nmi.h
3 */
4#ifndef ASM_NMI_H 1#ifndef ASM_NMI_H
5#define ASM_NMI_H 2#define ASM_NMI_H
6 3
diff --git a/include/asm-x86/nmi_64.h b/include/asm-x86/nmi_64.h
index 65b6acf3bb59..2eeb74e5f3ff 100644
--- a/include/asm-x86/nmi_64.h
+++ b/include/asm-x86/nmi_64.h
@@ -1,6 +1,3 @@
1/*
2 * linux/include/asm-i386/nmi.h
3 */
4#ifndef ASM_NMI_H 1#ifndef ASM_NMI_H
5#define ASM_NMI_H 2#define ASM_NMI_H
6 3
@@ -41,7 +38,6 @@ extern void die_nmi(char *str, struct pt_regs *regs, int do_panic);
41 38
42#define get_nmi_reason() inb(0x61) 39#define get_nmi_reason() inb(0x61)
43 40
44extern int panic_on_timeout;
45extern int unknown_nmi_panic; 41extern int unknown_nmi_panic;
46extern int nmi_watchdog_enabled; 42extern int nmi_watchdog_enabled;
47 43
@@ -60,7 +56,6 @@ extern void enable_timer_nmi_watchdog(void);
60extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason); 56extern int nmi_watchdog_tick (struct pt_regs * regs, unsigned reason);
61 57
62extern void nmi_watchdog_default(void); 58extern void nmi_watchdog_default(void);
63extern int setup_nmi_watchdog(char *);
64 59
65extern atomic_t nmi_active; 60extern atomic_t nmi_active;
66extern unsigned int nmi_watchdog; 61extern unsigned int nmi_watchdog;
diff --git a/include/asm-x86/nops.h b/include/asm-x86/nops.h
new file mode 100644
index 000000000000..fec025c7f58c
--- /dev/null
+++ b/include/asm-x86/nops.h
@@ -0,0 +1,90 @@
1#ifndef _ASM_NOPS_H
2#define _ASM_NOPS_H 1
3
4/* Define nops for use with alternative() */
5
6/* generic versions from gas */
7#define GENERIC_NOP1 ".byte 0x90\n"
8#define GENERIC_NOP2 ".byte 0x89,0xf6\n"
9#define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n"
10#define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n"
11#define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4
12#define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
13#define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
14#define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7
15
16/* Opteron 64bit nops */
17#define K8_NOP1 GENERIC_NOP1
18#define K8_NOP2 ".byte 0x66,0x90\n"
19#define K8_NOP3 ".byte 0x66,0x66,0x90\n"
20#define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n"
21#define K8_NOP5 K8_NOP3 K8_NOP2
22#define K8_NOP6 K8_NOP3 K8_NOP3
23#define K8_NOP7 K8_NOP4 K8_NOP3
24#define K8_NOP8 K8_NOP4 K8_NOP4
25
26/* K7 nops */
27/* uses eax dependencies (arbitary choice) */
28#define K7_NOP1 GENERIC_NOP1
29#define K7_NOP2 ".byte 0x8b,0xc0\n"
30#define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
31#define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
32#define K7_NOP5 K7_NOP4 ASM_NOP1
33#define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n"
34#define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n"
35#define K7_NOP8 K7_NOP7 ASM_NOP1
36
37/* P6 nops */
38/* uses eax dependencies (Intel-recommended choice) */
39#define P6_NOP1 GENERIC_NOP1
40#define P6_NOP2 ".byte 0x66,0x90\n"
41#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
42#define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
43#define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
44#define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
45#define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
46#define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
47
48#if defined(CONFIG_MK8)
49#define ASM_NOP1 K8_NOP1
50#define ASM_NOP2 K8_NOP2
51#define ASM_NOP3 K8_NOP3
52#define ASM_NOP4 K8_NOP4
53#define ASM_NOP5 K8_NOP5
54#define ASM_NOP6 K8_NOP6
55#define ASM_NOP7 K8_NOP7
56#define ASM_NOP8 K8_NOP8
57#elif defined(CONFIG_MK7)
58#define ASM_NOP1 K7_NOP1
59#define ASM_NOP2 K7_NOP2
60#define ASM_NOP3 K7_NOP3
61#define ASM_NOP4 K7_NOP4
62#define ASM_NOP5 K7_NOP5
63#define ASM_NOP6 K7_NOP6
64#define ASM_NOP7 K7_NOP7
65#define ASM_NOP8 K7_NOP8
66#elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \
67 defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
68 defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4)
69#define ASM_NOP1 P6_NOP1
70#define ASM_NOP2 P6_NOP2
71#define ASM_NOP3 P6_NOP3
72#define ASM_NOP4 P6_NOP4
73#define ASM_NOP5 P6_NOP5
74#define ASM_NOP6 P6_NOP6
75#define ASM_NOP7 P6_NOP7
76#define ASM_NOP8 P6_NOP8
77#else
78#define ASM_NOP1 GENERIC_NOP1
79#define ASM_NOP2 GENERIC_NOP2
80#define ASM_NOP3 GENERIC_NOP3
81#define ASM_NOP4 GENERIC_NOP4
82#define ASM_NOP5 GENERIC_NOP5
83#define ASM_NOP6 GENERIC_NOP6
84#define ASM_NOP7 GENERIC_NOP7
85#define ASM_NOP8 GENERIC_NOP8
86#endif
87
88#define ASM_NOP_MAX 8
89
90#endif
diff --git a/include/asm-x86/numa_32.h b/include/asm-x86/numa_32.h
index 96fcb157db1d..03d0f7a9bf02 100644
--- a/include/asm-x86/numa_32.h
+++ b/include/asm-x86/numa_32.h
@@ -1,3 +1,15 @@
1#ifndef _ASM_X86_32_NUMA_H
2#define _ASM_X86_32_NUMA_H 1
1 3
2int pxm_to_nid(int pxm); 4extern int pxm_to_nid(int pxm);
3 5
6#ifdef CONFIG_NUMA
7extern void __init remap_numa_kva(void);
8extern void set_highmem_pages_init(int);
9#else
10static inline void remap_numa_kva(void)
11{
12}
13#endif
14
15#endif /* _ASM_X86_32_NUMA_H */
diff --git a/include/asm-x86/numa_64.h b/include/asm-x86/numa_64.h
index 0cc5c97a7fc9..15fe07cde586 100644
--- a/include/asm-x86/numa_64.h
+++ b/include/asm-x86/numa_64.h
@@ -20,13 +20,19 @@ extern void numa_set_node(int cpu, int node);
20extern void srat_reserve_add_area(int nodeid); 20extern void srat_reserve_add_area(int nodeid);
21extern int hotadd_percent; 21extern int hotadd_percent;
22 22
23extern unsigned char apicid_to_node[MAX_LOCAL_APIC]; 23extern s16 apicid_to_node[MAX_LOCAL_APIC];
24
25extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
26extern unsigned long numa_free_all_bootmem(void);
27extern void setup_node_bootmem(int nodeid, unsigned long start,
28 unsigned long end);
29
24#ifdef CONFIG_NUMA 30#ifdef CONFIG_NUMA
25extern void __init init_cpu_to_node(void); 31extern void __init init_cpu_to_node(void);
26 32
27static inline void clear_node_cpumask(int cpu) 33static inline void clear_node_cpumask(int cpu)
28{ 34{
29 clear_bit(cpu, &node_to_cpumask[cpu_to_node(cpu)]); 35 clear_bit(cpu, (unsigned long *)&node_to_cpumask_map[cpu_to_node(cpu)]);
30} 36}
31 37
32#else 38#else
@@ -34,6 +40,4 @@ static inline void clear_node_cpumask(int cpu)
34#define clear_node_cpumask(cpu) do {} while (0) 40#define clear_node_cpumask(cpu) do {} while (0)
35#endif 41#endif
36 42
37#define NUMA_NO_NODE 0xff
38
39#endif 43#endif
diff --git a/include/asm-x86/page.h b/include/asm-x86/page.h
index a757eb26141d..c8b30efeed85 100644
--- a/include/asm-x86/page.h
+++ b/include/asm-x86/page.h
@@ -1,13 +1,183 @@
1#ifndef _ASM_X86_PAGE_H
2#define _ASM_X86_PAGE_H
3
4#include <linux/const.h>
5
6/* PAGE_SHIFT determines the page size */
7#define PAGE_SHIFT 12
8#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
9#define PAGE_MASK (~(PAGE_SIZE-1))
10
1#ifdef __KERNEL__ 11#ifdef __KERNEL__
2# ifdef CONFIG_X86_32 12
3# include "page_32.h" 13#define PHYSICAL_PAGE_MASK (PAGE_MASK & __PHYSICAL_MASK)
4# else 14#define PTE_MASK (_AT(long, PHYSICAL_PAGE_MASK))
5# include "page_64.h" 15
6# endif 16#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT)
17#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
18
19#define HPAGE_SHIFT PMD_SHIFT
20#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
21#define HPAGE_MASK (~(HPAGE_SIZE - 1))
22#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
23
24/* to align the pointer to the (next) page boundary */
25#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
26
27#define __PHYSICAL_MASK _AT(phys_addr_t, (_AC(1,ULL) << __PHYSICAL_MASK_SHIFT) - 1)
28#define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
29
30#ifndef __ASSEMBLY__
31#include <linux/types.h>
32#endif
33
34#ifdef CONFIG_X86_64
35#include <asm/page_64.h>
36#define max_pfn_mapped end_pfn_map
7#else 37#else
8# ifdef __i386__ 38#include <asm/page_32.h>
9# include "page_32.h" 39#define max_pfn_mapped max_low_pfn
10# else 40#endif /* CONFIG_X86_64 */
11# include "page_64.h" 41
12# endif 42#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
43
44#define VM_DATA_DEFAULT_FLAGS \
45 (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
46 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
47
48
49#ifndef __ASSEMBLY__
50
51extern int page_is_ram(unsigned long pagenr);
52
53struct page;
54
55static void inline clear_user_page(void *page, unsigned long vaddr,
56 struct page *pg)
57{
58 clear_page(page);
59}
60
61static void inline copy_user_page(void *to, void *from, unsigned long vaddr,
62 struct page *topage)
63{
64 copy_page(to, from);
65}
66
67#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
68 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
69#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
70
71typedef struct { pgdval_t pgd; } pgd_t;
72typedef struct { pgprotval_t pgprot; } pgprot_t;
73
74static inline pgd_t native_make_pgd(pgdval_t val)
75{
76 return (pgd_t) { val };
77}
78
79static inline pgdval_t native_pgd_val(pgd_t pgd)
80{
81 return pgd.pgd;
82}
83
84#if PAGETABLE_LEVELS >= 3
85#if PAGETABLE_LEVELS == 4
86typedef struct { pudval_t pud; } pud_t;
87
88static inline pud_t native_make_pud(pmdval_t val)
89{
90 return (pud_t) { val };
91}
92
93static inline pudval_t native_pud_val(pud_t pud)
94{
95 return pud.pud;
96}
97#else /* PAGETABLE_LEVELS == 3 */
98#include <asm-generic/pgtable-nopud.h>
99
100static inline pudval_t native_pud_val(pud_t pud)
101{
102 return native_pgd_val(pud.pgd);
103}
104#endif /* PAGETABLE_LEVELS == 4 */
105
106typedef struct { pmdval_t pmd; } pmd_t;
107
108static inline pmd_t native_make_pmd(pmdval_t val)
109{
110 return (pmd_t) { val };
111}
112
113static inline pmdval_t native_pmd_val(pmd_t pmd)
114{
115 return pmd.pmd;
116}
117#else /* PAGETABLE_LEVELS == 2 */
118#include <asm-generic/pgtable-nopmd.h>
119
120static inline pmdval_t native_pmd_val(pmd_t pmd)
121{
122 return native_pgd_val(pmd.pud.pgd);
123}
124#endif /* PAGETABLE_LEVELS >= 3 */
125
126static inline pte_t native_make_pte(pteval_t val)
127{
128 return (pte_t) { .pte = val };
129}
130
131static inline pteval_t native_pte_val(pte_t pte)
132{
133 return pte.pte;
134}
135
136#define pgprot_val(x) ((x).pgprot)
137#define __pgprot(x) ((pgprot_t) { (x) } )
138
139#ifdef CONFIG_PARAVIRT
140#include <asm/paravirt.h>
141#else /* !CONFIG_PARAVIRT */
142
143#define pgd_val(x) native_pgd_val(x)
144#define __pgd(x) native_make_pgd(x)
145
146#ifndef __PAGETABLE_PUD_FOLDED
147#define pud_val(x) native_pud_val(x)
148#define __pud(x) native_make_pud(x)
149#endif
150
151#ifndef __PAGETABLE_PMD_FOLDED
152#define pmd_val(x) native_pmd_val(x)
153#define __pmd(x) native_make_pmd(x)
13#endif 154#endif
155
156#define pte_val(x) native_pte_val(x)
157#define __pte(x) native_make_pte(x)
158
159#endif /* CONFIG_PARAVIRT */
160
161#define __pa(x) __phys_addr((unsigned long)(x))
162/* __pa_symbol should be used for C visible symbols.
163 This seems to be the official gcc blessed way to do such arithmetic. */
164#define __pa_symbol(x) __pa(__phys_reloc_hide((unsigned long)(x)))
165
166#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
167
168#define __boot_va(x) __va(x)
169#define __boot_pa(x) __pa(x)
170
171#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
172#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
173#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
174
175#endif /* __ASSEMBLY__ */
176
177#include <asm-generic/memory_model.h>
178#include <asm-generic/page.h>
179
180#define __HAVE_ARCH_GATE_AREA 1
181
182#endif /* __KERNEL__ */
183#endif /* _ASM_X86_PAGE_H */
diff --git a/include/asm-x86/page_32.h b/include/asm-x86/page_32.h
index 80ecc66b6d86..a6fd10f230d2 100644
--- a/include/asm-x86/page_32.h
+++ b/include/asm-x86/page_32.h
@@ -1,206 +1,107 @@
1#ifndef _I386_PAGE_H 1#ifndef _ASM_X86_PAGE_32_H
2#define _I386_PAGE_H 2#define _ASM_X86_PAGE_32_H
3
4/* PAGE_SHIFT determines the page size */
5#define PAGE_SHIFT 12
6#define PAGE_SIZE (1UL << PAGE_SHIFT)
7#define PAGE_MASK (~(PAGE_SIZE-1))
8
9#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
10#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
11
12#ifdef __KERNEL__
13#ifndef __ASSEMBLY__
14
15#ifdef CONFIG_X86_USE_3DNOW
16
17#include <asm/mmx.h>
18
19#define clear_page(page) mmx_clear_page((void *)(page))
20#define copy_page(to,from) mmx_copy_page(to,from)
21
22#else
23 3
24/* 4/*
25 * On older X86 processors it's not a win to use MMX here it seems. 5 * This handles the memory map.
26 * Maybe the K6-III ? 6 *
27 */ 7 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
28 8 * a virtual address space of one gigabyte, which limits the
29#define clear_page(page) memset((void *)(page), 0, PAGE_SIZE) 9 * amount of physical memory you can use to about 950MB.
30#define copy_page(to,from) memcpy((void *)(to), (void *)(from), PAGE_SIZE) 10 *
31 11 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
32#endif 12 * and CONFIG_HIGHMEM64G options in the kernel configuration.
33
34#define clear_user_page(page, vaddr, pg) clear_page(page)
35#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
36
37#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
38 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
39#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
40
41/*
42 * These are used to make use of C type-checking..
43 */ 13 */
44extern int nx_enabled; 14#define __PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)
45 15
46#ifdef CONFIG_X86_PAE 16#ifdef CONFIG_X86_PAE
47typedef struct { unsigned long pte_low, pte_high; } pte_t; 17#define __PHYSICAL_MASK_SHIFT 36
48typedef struct { unsigned long long pmd; } pmd_t; 18#define __VIRTUAL_MASK_SHIFT 32
49typedef struct { unsigned long long pgd; } pgd_t; 19#define PAGETABLE_LEVELS 3
50typedef struct { unsigned long long pgprot; } pgprot_t;
51 20
52static inline unsigned long long native_pgd_val(pgd_t pgd) 21#ifndef __ASSEMBLY__
53{ 22typedef u64 pteval_t;
54 return pgd.pgd; 23typedef u64 pmdval_t;
55} 24typedef u64 pudval_t;
56 25typedef u64 pgdval_t;
57static inline unsigned long long native_pmd_val(pmd_t pmd) 26typedef u64 pgprotval_t;
58{ 27typedef u64 phys_addr_t;
59 return pmd.pmd; 28
60} 29typedef union {
61 30 struct {
62static inline unsigned long long native_pte_val(pte_t pte) 31 unsigned long pte_low, pte_high;
63{ 32 };
64 return pte.pte_low | ((unsigned long long)pte.pte_high << 32); 33 pteval_t pte;
65} 34} pte_t;
66 35#endif /* __ASSEMBLY__
67static inline pgd_t native_make_pgd(unsigned long long val) 36 */
68{
69 return (pgd_t) { val };
70}
71
72static inline pmd_t native_make_pmd(unsigned long long val)
73{
74 return (pmd_t) { val };
75}
76
77static inline pte_t native_make_pte(unsigned long long val)
78{
79 return (pte_t) { .pte_low = val, .pte_high = (val >> 32) } ;
80}
81
82#ifndef CONFIG_PARAVIRT
83#define pmd_val(x) native_pmd_val(x)
84#define __pmd(x) native_make_pmd(x)
85#endif
86
87#define HPAGE_SHIFT 21
88#include <asm-generic/pgtable-nopud.h>
89#else /* !CONFIG_X86_PAE */ 37#else /* !CONFIG_X86_PAE */
90typedef struct { unsigned long pte_low; } pte_t; 38#define __PHYSICAL_MASK_SHIFT 32
91typedef struct { unsigned long pgd; } pgd_t; 39#define __VIRTUAL_MASK_SHIFT 32
92typedef struct { unsigned long pgprot; } pgprot_t; 40#define PAGETABLE_LEVELS 2
93#define boot_pte_t pte_t /* or would you rather have a typedef */
94
95static inline unsigned long native_pgd_val(pgd_t pgd)
96{
97 return pgd.pgd;
98}
99 41
100static inline unsigned long native_pte_val(pte_t pte) 42#ifndef __ASSEMBLY__
101{ 43typedef unsigned long pteval_t;
102 return pte.pte_low; 44typedef unsigned long pmdval_t;
103} 45typedef unsigned long pudval_t;
104 46typedef unsigned long pgdval_t;
105static inline pgd_t native_make_pgd(unsigned long val) 47typedef unsigned long pgprotval_t;
106{ 48typedef unsigned long phys_addr_t;
107 return (pgd_t) { val };
108}
109 49
110static inline pte_t native_make_pte(unsigned long val) 50typedef union { pteval_t pte, pte_low; } pte_t;
111{ 51typedef pte_t boot_pte_t;
112 return (pte_t) { .pte_low = val };
113}
114 52
115#define HPAGE_SHIFT 22 53#endif /* __ASSEMBLY__ */
116#include <asm-generic/pgtable-nopmd.h>
117#endif /* CONFIG_X86_PAE */ 54#endif /* CONFIG_X86_PAE */
118 55
119#define PTE_MASK PAGE_MASK
120
121#ifdef CONFIG_HUGETLB_PAGE 56#ifdef CONFIG_HUGETLB_PAGE
122#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
123#define HPAGE_MASK (~(HPAGE_SIZE - 1))
124#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
125#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA 57#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
126#endif 58#endif
127 59
128#define pgprot_val(x) ((x).pgprot)
129#define __pgprot(x) ((pgprot_t) { (x) } )
130
131#ifndef CONFIG_PARAVIRT
132#define pgd_val(x) native_pgd_val(x)
133#define __pgd(x) native_make_pgd(x)
134#define pte_val(x) native_pte_val(x)
135#define __pte(x) native_make_pte(x)
136#endif
137
138#endif /* !__ASSEMBLY__ */
139
140/* to align the pointer to the (next) page boundary */
141#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
142
143/*
144 * This handles the memory map.. We could make this a config
145 * option, but too many people screw it up, and too few need
146 * it.
147 *
148 * A __PAGE_OFFSET of 0xC0000000 means that the kernel has
149 * a virtual address space of one gigabyte, which limits the
150 * amount of physical memory you can use to about 950MB.
151 *
152 * If you want more physical memory than this then see the CONFIG_HIGHMEM4G
153 * and CONFIG_HIGHMEM64G options in the kernel configuration.
154 */
155
156#ifndef __ASSEMBLY__ 60#ifndef __ASSEMBLY__
61#define __phys_addr(x) ((x)-PAGE_OFFSET)
62#define __phys_reloc_hide(x) RELOC_HIDE((x), 0)
63
64#ifdef CONFIG_FLATMEM
65#define pfn_valid(pfn) ((pfn) < max_mapnr)
66#endif /* CONFIG_FLATMEM */
157 67
158struct vm_area_struct; 68extern int nx_enabled;
159 69
160/* 70/*
161 * This much address space is reserved for vmalloc() and iomap() 71 * This much address space is reserved for vmalloc() and iomap()
162 * as well as fixmap mappings. 72 * as well as fixmap mappings.
163 */ 73 */
164extern unsigned int __VMALLOC_RESERVE; 74extern unsigned int __VMALLOC_RESERVE;
165
166extern int sysctl_legacy_va_layout; 75extern int sysctl_legacy_va_layout;
167 76
168extern int page_is_ram(unsigned long pagenr);
169
170#endif /* __ASSEMBLY__ */
171
172#ifdef __ASSEMBLY__
173#define __PAGE_OFFSET CONFIG_PAGE_OFFSET
174#else
175#define __PAGE_OFFSET ((unsigned long)CONFIG_PAGE_OFFSET)
176#endif
177
178
179#define PAGE_OFFSET ((unsigned long)__PAGE_OFFSET)
180#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE) 77#define VMALLOC_RESERVE ((unsigned long)__VMALLOC_RESERVE)
181#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE) 78#define MAXMEM (-__PAGE_OFFSET-__VMALLOC_RESERVE)
182#define __pa(x) ((unsigned long)(x)-PAGE_OFFSET)
183/* __pa_symbol should be used for C visible symbols.
184 This seems to be the official gcc blessed way to do such arithmetic. */
185#define __pa_symbol(x) __pa(RELOC_HIDE((unsigned long)(x),0))
186#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
187#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
188#ifdef CONFIG_FLATMEM
189#define pfn_valid(pfn) ((pfn) < max_mapnr)
190#endif /* CONFIG_FLATMEM */
191#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
192 79
193#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) 80#ifdef CONFIG_X86_USE_3DNOW
81#include <asm/mmx.h>
82
83static inline void clear_page(void *page)
84{
85 mmx_clear_page(page);
86}
194 87
195#define VM_DATA_DEFAULT_FLAGS \ 88static inline void copy_page(void *to, void *from)
196 (VM_READ | VM_WRITE | \ 89{
197 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \ 90 mmx_copy_page(to, from);
198 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 91}
92#else /* !CONFIG_X86_USE_3DNOW */
93#include <linux/string.h>
199 94
200#include <asm-generic/memory_model.h> 95static inline void clear_page(void *page)
201#include <asm-generic/page.h> 96{
97 memset(page, 0, PAGE_SIZE);
98}
202 99
203#define __HAVE_ARCH_GATE_AREA 1 100static inline void copy_page(void *to, void *from)
204#endif /* __KERNEL__ */ 101{
102 memcpy(to, from, PAGE_SIZE);
103}
104#endif /* CONFIG_X86_3DNOW */
105#endif /* !__ASSEMBLY__ */
205 106
206#endif /* _I386_PAGE_H */ 107#endif /* _ASM_X86_PAGE_32_H */
diff --git a/include/asm-x86/page_64.h b/include/asm-x86/page_64.h
index c3b52bcb171e..c1ac42d8707f 100644
--- a/include/asm-x86/page_64.h
+++ b/include/asm-x86/page_64.h
@@ -1,15 +1,9 @@
1#ifndef _X86_64_PAGE_H 1#ifndef _X86_64_PAGE_H
2#define _X86_64_PAGE_H 2#define _X86_64_PAGE_H
3 3
4#include <linux/const.h> 4#define PAGETABLE_LEVELS 4
5 5
6/* PAGE_SHIFT determines the page size */ 6#define THREAD_ORDER 1
7#define PAGE_SHIFT 12
8#define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
9#define PAGE_MASK (~(PAGE_SIZE-1))
10#define PHYSICAL_PAGE_MASK (~(PAGE_SIZE-1) & __PHYSICAL_MASK)
11
12#define THREAD_ORDER 1
13#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER) 7#define THREAD_SIZE (PAGE_SIZE << THREAD_ORDER)
14#define CURRENT_MASK (~(THREAD_SIZE-1)) 8#define CURRENT_MASK (~(THREAD_SIZE-1))
15 9
@@ -29,54 +23,7 @@
29#define MCE_STACK 5 23#define MCE_STACK 5
30#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */ 24#define N_EXCEPTION_STACKS 5 /* hw limit: 7 */
31 25
32#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1)) 26#define __PAGE_OFFSET _AC(0xffff810000000000, UL)
33#define LARGE_PAGE_SIZE (_AC(1,UL) << PMD_SHIFT)
34
35#define HPAGE_SHIFT PMD_SHIFT
36#define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
37#define HPAGE_MASK (~(HPAGE_SIZE - 1))
38#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
39
40#ifdef __KERNEL__
41#ifndef __ASSEMBLY__
42
43extern unsigned long end_pfn;
44
45void clear_page(void *);
46void copy_page(void *, void *);
47
48#define clear_user_page(page, vaddr, pg) clear_page(page)
49#define copy_user_page(to, from, vaddr, pg) copy_page(to, from)
50
51#define __alloc_zeroed_user_highpage(movableflags, vma, vaddr) \
52 alloc_page_vma(GFP_HIGHUSER | __GFP_ZERO | movableflags, vma, vaddr)
53#define __HAVE_ARCH_ALLOC_ZEROED_USER_HIGHPAGE
54/*
55 * These are used to make use of C type-checking..
56 */
57typedef struct { unsigned long pte; } pte_t;
58typedef struct { unsigned long pmd; } pmd_t;
59typedef struct { unsigned long pud; } pud_t;
60typedef struct { unsigned long pgd; } pgd_t;
61#define PTE_MASK PHYSICAL_PAGE_MASK
62
63typedef struct { unsigned long pgprot; } pgprot_t;
64
65extern unsigned long phys_base;
66
67#define pte_val(x) ((x).pte)
68#define pmd_val(x) ((x).pmd)
69#define pud_val(x) ((x).pud)
70#define pgd_val(x) ((x).pgd)
71#define pgprot_val(x) ((x).pgprot)
72
73#define __pte(x) ((pte_t) { (x) } )
74#define __pmd(x) ((pmd_t) { (x) } )
75#define __pud(x) ((pud_t) { (x) } )
76#define __pgd(x) ((pgd_t) { (x) } )
77#define __pgprot(x) ((pgprot_t) { (x) } )
78
79#endif /* !__ASSEMBLY__ */
80 27
81#define __PHYSICAL_START CONFIG_PHYSICAL_START 28#define __PHYSICAL_START CONFIG_PHYSICAL_START
82#define __KERNEL_ALIGN 0x200000 29#define __KERNEL_ALIGN 0x200000
@@ -92,53 +39,44 @@ extern unsigned long phys_base;
92 39
93#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START) 40#define __START_KERNEL (__START_KERNEL_map + __PHYSICAL_START)
94#define __START_KERNEL_map _AC(0xffffffff80000000, UL) 41#define __START_KERNEL_map _AC(0xffffffff80000000, UL)
95#define __PAGE_OFFSET _AC(0xffff810000000000, UL)
96
97/* to align the pointer to the (next) page boundary */
98#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
99 42
100/* See Documentation/x86_64/mm.txt for a description of the memory map. */ 43/* See Documentation/x86_64/mm.txt for a description of the memory map. */
101#define __PHYSICAL_MASK_SHIFT 46 44#define __PHYSICAL_MASK_SHIFT 46
102#define __PHYSICAL_MASK ((_AC(1,UL) << __PHYSICAL_MASK_SHIFT) - 1)
103#define __VIRTUAL_MASK_SHIFT 48 45#define __VIRTUAL_MASK_SHIFT 48
104#define __VIRTUAL_MASK ((_AC(1,UL) << __VIRTUAL_MASK_SHIFT) - 1)
105 46
106#define KERNEL_TEXT_SIZE (40*1024*1024) 47#define KERNEL_TEXT_SIZE (40*1024*1024)
107#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL) 48#define KERNEL_TEXT_START _AC(0xffffffff80000000, UL)
108#define PAGE_OFFSET __PAGE_OFFSET
109 49
110#ifndef __ASSEMBLY__ 50#ifndef __ASSEMBLY__
51void clear_page(void *page);
52void copy_page(void *to, void *from);
111 53
112#include <asm/bug.h> 54extern unsigned long end_pfn;
55extern unsigned long end_pfn_map;
56extern unsigned long phys_base;
113 57
114extern unsigned long __phys_addr(unsigned long); 58extern unsigned long __phys_addr(unsigned long);
59#define __phys_reloc_hide(x) (x)
115 60
116#endif /* __ASSEMBLY__ */ 61/*
117 62 * These are used to make use of C type-checking..
118#define __pa(x) __phys_addr((unsigned long)(x)) 63 */
119#define __pa_symbol(x) __phys_addr((unsigned long)(x)) 64typedef unsigned long pteval_t;
120 65typedef unsigned long pmdval_t;
121#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 66typedef unsigned long pudval_t;
122#define __boot_va(x) __va(x) 67typedef unsigned long pgdval_t;
123#define __boot_pa(x) __pa(x) 68typedef unsigned long pgprotval_t;
124#ifdef CONFIG_FLATMEM 69typedef unsigned long phys_addr_t;
125#define pfn_valid(pfn) ((pfn) < end_pfn)
126#endif
127
128#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
129#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
130#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
131 70
132#define VM_DATA_DEFAULT_FLAGS \ 71typedef struct { pteval_t pte; } pte_t;
133 (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0 ) | \
134 VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
135 72
136#define __HAVE_ARCH_GATE_AREA 1
137#define vmemmap ((struct page *)VMEMMAP_START) 73#define vmemmap ((struct page *)VMEMMAP_START)
138 74
139#include <asm-generic/memory_model.h> 75#endif /* !__ASSEMBLY__ */
140#include <asm-generic/page.h> 76
77#ifdef CONFIG_FLATMEM
78#define pfn_valid(pfn) ((pfn) < end_pfn)
79#endif
141 80
142#endif /* __KERNEL__ */
143 81
144#endif /* _X86_64_PAGE_H */ 82#endif /* _X86_64_PAGE_H */
diff --git a/include/asm-x86/paravirt.h b/include/asm-x86/paravirt.h
index f59d370c5df4..d6236eb46466 100644
--- a/include/asm-x86/paravirt.h
+++ b/include/asm-x86/paravirt.h
@@ -5,22 +5,37 @@
5 5
6#ifdef CONFIG_PARAVIRT 6#ifdef CONFIG_PARAVIRT
7#include <asm/page.h> 7#include <asm/page.h>
8#include <asm/asm.h>
8 9
9/* Bitmask of what can be clobbered: usually at least eax. */ 10/* Bitmask of what can be clobbered: usually at least eax. */
10#define CLBR_NONE 0x0 11#define CLBR_NONE 0
11#define CLBR_EAX 0x1 12#define CLBR_EAX (1 << 0)
12#define CLBR_ECX 0x2 13#define CLBR_ECX (1 << 1)
13#define CLBR_EDX 0x4 14#define CLBR_EDX (1 << 2)
14#define CLBR_ANY 0x7 15
16#ifdef CONFIG_X86_64
17#define CLBR_RSI (1 << 3)
18#define CLBR_RDI (1 << 4)
19#define CLBR_R8 (1 << 5)
20#define CLBR_R9 (1 << 6)
21#define CLBR_R10 (1 << 7)
22#define CLBR_R11 (1 << 8)
23#define CLBR_ANY ((1 << 9) - 1)
24#include <asm/desc_defs.h>
25#else
26/* CLBR_ANY should match all regs platform has. For i386, that's just it */
27#define CLBR_ANY ((1 << 3) - 1)
28#endif /* X86_64 */
15 29
16#ifndef __ASSEMBLY__ 30#ifndef __ASSEMBLY__
17#include <linux/types.h> 31#include <linux/types.h>
18#include <linux/cpumask.h> 32#include <linux/cpumask.h>
19#include <asm/kmap_types.h> 33#include <asm/kmap_types.h>
34#include <asm/desc_defs.h>
20 35
21struct page; 36struct page;
22struct thread_struct; 37struct thread_struct;
23struct Xgt_desc_struct; 38struct desc_ptr;
24struct tss_struct; 39struct tss_struct;
25struct mm_struct; 40struct mm_struct;
26struct desc_struct; 41struct desc_struct;
@@ -86,22 +101,27 @@ struct pv_cpu_ops {
86 unsigned long (*read_cr4)(void); 101 unsigned long (*read_cr4)(void);
87 void (*write_cr4)(unsigned long); 102 void (*write_cr4)(unsigned long);
88 103
104#ifdef CONFIG_X86_64
105 unsigned long (*read_cr8)(void);
106 void (*write_cr8)(unsigned long);
107#endif
108
89 /* Segment descriptor handling */ 109 /* Segment descriptor handling */
90 void (*load_tr_desc)(void); 110 void (*load_tr_desc)(void);
91 void (*load_gdt)(const struct Xgt_desc_struct *); 111 void (*load_gdt)(const struct desc_ptr *);
92 void (*load_idt)(const struct Xgt_desc_struct *); 112 void (*load_idt)(const struct desc_ptr *);
93 void (*store_gdt)(struct Xgt_desc_struct *); 113 void (*store_gdt)(struct desc_ptr *);
94 void (*store_idt)(struct Xgt_desc_struct *); 114 void (*store_idt)(struct desc_ptr *);
95 void (*set_ldt)(const void *desc, unsigned entries); 115 void (*set_ldt)(const void *desc, unsigned entries);
96 unsigned long (*store_tr)(void); 116 unsigned long (*store_tr)(void);
97 void (*load_tls)(struct thread_struct *t, unsigned int cpu); 117 void (*load_tls)(struct thread_struct *t, unsigned int cpu);
98 void (*write_ldt_entry)(struct desc_struct *, 118 void (*write_ldt_entry)(struct desc_struct *ldt, int entrynum,
99 int entrynum, u32 low, u32 high); 119 const void *desc);
100 void (*write_gdt_entry)(struct desc_struct *, 120 void (*write_gdt_entry)(struct desc_struct *,
101 int entrynum, u32 low, u32 high); 121 int entrynum, const void *desc, int size);
102 void (*write_idt_entry)(struct desc_struct *, 122 void (*write_idt_entry)(gate_desc *,
103 int entrynum, u32 low, u32 high); 123 int entrynum, const gate_desc *gate);
104 void (*load_esp0)(struct tss_struct *tss, struct thread_struct *t); 124 void (*load_sp0)(struct tss_struct *tss, struct thread_struct *t);
105 125
106 void (*set_iopl_mask)(unsigned mask); 126 void (*set_iopl_mask)(unsigned mask);
107 127
@@ -115,15 +135,18 @@ struct pv_cpu_ops {
115 /* MSR, PMC and TSR operations. 135 /* MSR, PMC and TSR operations.
116 err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */ 136 err = 0/-EFAULT. wrmsr returns 0/-EFAULT. */
117 u64 (*read_msr)(unsigned int msr, int *err); 137 u64 (*read_msr)(unsigned int msr, int *err);
118 int (*write_msr)(unsigned int msr, u64 val); 138 int (*write_msr)(unsigned int msr, unsigned low, unsigned high);
119 139
120 u64 (*read_tsc)(void); 140 u64 (*read_tsc)(void);
121 u64 (*read_pmc)(void); 141 u64 (*read_pmc)(int counter);
142 unsigned long long (*read_tscp)(unsigned int *aux);
122 143
123 /* These two are jmp to, not actually called. */ 144 /* These two are jmp to, not actually called. */
124 void (*irq_enable_sysexit)(void); 145 void (*irq_enable_syscall_ret)(void);
125 void (*iret)(void); 146 void (*iret)(void);
126 147
148 void (*swapgs)(void);
149
127 struct pv_lazy_ops lazy_mode; 150 struct pv_lazy_ops lazy_mode;
128}; 151};
129 152
@@ -150,9 +173,9 @@ struct pv_apic_ops {
150 * Direct APIC operations, principally for VMI. Ideally 173 * Direct APIC operations, principally for VMI. Ideally
151 * these shouldn't be in this interface. 174 * these shouldn't be in this interface.
152 */ 175 */
153 void (*apic_write)(unsigned long reg, unsigned long v); 176 void (*apic_write)(unsigned long reg, u32 v);
154 void (*apic_write_atomic)(unsigned long reg, unsigned long v); 177 void (*apic_write_atomic)(unsigned long reg, u32 v);
155 unsigned long (*apic_read)(unsigned long reg); 178 u32 (*apic_read)(unsigned long reg);
156 void (*setup_boot_clock)(void); 179 void (*setup_boot_clock)(void);
157 void (*setup_secondary_clock)(void); 180 void (*setup_secondary_clock)(void);
158 181
@@ -198,7 +221,7 @@ struct pv_mmu_ops {
198 221
199 /* Hooks for allocating/releasing pagetable pages */ 222 /* Hooks for allocating/releasing pagetable pages */
200 void (*alloc_pt)(struct mm_struct *mm, u32 pfn); 223 void (*alloc_pt)(struct mm_struct *mm, u32 pfn);
201 void (*alloc_pd)(u32 pfn); 224 void (*alloc_pd)(struct mm_struct *mm, u32 pfn);
202 void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count); 225 void (*alloc_pd_clone)(u32 pfn, u32 clonepfn, u32 start, u32 count);
203 void (*release_pt)(u32 pfn); 226 void (*release_pt)(u32 pfn);
204 void (*release_pd)(u32 pfn); 227 void (*release_pd)(u32 pfn);
@@ -212,28 +235,34 @@ struct pv_mmu_ops {
212 void (*pte_update_defer)(struct mm_struct *mm, 235 void (*pte_update_defer)(struct mm_struct *mm,
213 unsigned long addr, pte_t *ptep); 236 unsigned long addr, pte_t *ptep);
214 237
238 pteval_t (*pte_val)(pte_t);
239 pte_t (*make_pte)(pteval_t pte);
240
241 pgdval_t (*pgd_val)(pgd_t);
242 pgd_t (*make_pgd)(pgdval_t pgd);
243
244#if PAGETABLE_LEVELS >= 3
215#ifdef CONFIG_X86_PAE 245#ifdef CONFIG_X86_PAE
216 void (*set_pte_atomic)(pte_t *ptep, pte_t pteval); 246 void (*set_pte_atomic)(pte_t *ptep, pte_t pteval);
217 void (*set_pte_present)(struct mm_struct *mm, unsigned long addr, 247 void (*set_pte_present)(struct mm_struct *mm, unsigned long addr,
218 pte_t *ptep, pte_t pte); 248 pte_t *ptep, pte_t pte);
219 void (*set_pud)(pud_t *pudp, pud_t pudval);
220 void (*pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 249 void (*pte_clear)(struct mm_struct *mm, unsigned long addr, pte_t *ptep);
221 void (*pmd_clear)(pmd_t *pmdp); 250 void (*pmd_clear)(pmd_t *pmdp);
222 251
223 unsigned long long (*pte_val)(pte_t); 252#endif /* CONFIG_X86_PAE */
224 unsigned long long (*pmd_val)(pmd_t);
225 unsigned long long (*pgd_val)(pgd_t);
226 253
227 pte_t (*make_pte)(unsigned long long pte); 254 void (*set_pud)(pud_t *pudp, pud_t pudval);
228 pmd_t (*make_pmd)(unsigned long long pmd);
229 pgd_t (*make_pgd)(unsigned long long pgd);
230#else
231 unsigned long (*pte_val)(pte_t);
232 unsigned long (*pgd_val)(pgd_t);
233 255
234 pte_t (*make_pte)(unsigned long pte); 256 pmdval_t (*pmd_val)(pmd_t);
235 pgd_t (*make_pgd)(unsigned long pgd); 257 pmd_t (*make_pmd)(pmdval_t pmd);
236#endif 258
259#if PAGETABLE_LEVELS == 4
260 pudval_t (*pud_val)(pud_t);
261 pud_t (*make_pud)(pudval_t pud);
262
263 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
264#endif /* PAGETABLE_LEVELS == 4 */
265#endif /* PAGETABLE_LEVELS >= 3 */
237 266
238#ifdef CONFIG_HIGHPTE 267#ifdef CONFIG_HIGHPTE
239 void *(*kmap_atomic_pte)(struct page *page, enum km_type type); 268 void *(*kmap_atomic_pte)(struct page *page, enum km_type type);
@@ -279,7 +308,8 @@ extern struct pv_mmu_ops pv_mmu_ops;
279#define _paravirt_alt(insn_string, type, clobber) \ 308#define _paravirt_alt(insn_string, type, clobber) \
280 "771:\n\t" insn_string "\n" "772:\n" \ 309 "771:\n\t" insn_string "\n" "772:\n" \
281 ".pushsection .parainstructions,\"a\"\n" \ 310 ".pushsection .parainstructions,\"a\"\n" \
282 " .long 771b\n" \ 311 _ASM_ALIGN "\n" \
312 _ASM_PTR " 771b\n" \
283 " .byte " type "\n" \ 313 " .byte " type "\n" \
284 " .byte 772b-771b\n" \ 314 " .byte 772b-771b\n" \
285 " .short " clobber "\n" \ 315 " .short " clobber "\n" \
@@ -289,6 +319,11 @@ extern struct pv_mmu_ops pv_mmu_ops;
289#define paravirt_alt(insn_string) \ 319#define paravirt_alt(insn_string) \
290 _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]") 320 _paravirt_alt(insn_string, "%c[paravirt_typenum]", "%c[paravirt_clobber]")
291 321
322/* Simple instruction patching code. */
323#define DEF_NATIVE(ops, name, code) \
324 extern const char start_##ops##_##name[], end_##ops##_##name[]; \
325 asm("start_" #ops "_" #name ": " code "; end_" #ops "_" #name ":")
326
292unsigned paravirt_patch_nop(void); 327unsigned paravirt_patch_nop(void);
293unsigned paravirt_patch_ignore(unsigned len); 328unsigned paravirt_patch_ignore(unsigned len);
294unsigned paravirt_patch_call(void *insnbuf, 329unsigned paravirt_patch_call(void *insnbuf,
@@ -303,6 +338,9 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
303unsigned paravirt_patch_insns(void *insnbuf, unsigned len, 338unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
304 const char *start, const char *end); 339 const char *start, const char *end);
305 340
341unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
342 unsigned long addr, unsigned len);
343
306int paravirt_disable_iospace(void); 344int paravirt_disable_iospace(void);
307 345
308/* 346/*
@@ -319,7 +357,7 @@ int paravirt_disable_iospace(void);
319 * runtime. 357 * runtime.
320 * 358 *
321 * Normally, a call to a pv_op function is a simple indirect call: 359 * Normally, a call to a pv_op function is a simple indirect call:
322 * (paravirt_ops.operations)(args...). 360 * (pv_op_struct.operations)(args...).
323 * 361 *
324 * Unfortunately, this is a relatively slow operation for modern CPUs, 362 * Unfortunately, this is a relatively slow operation for modern CPUs,
325 * because it cannot necessarily determine what the destination 363 * because it cannot necessarily determine what the destination
@@ -329,11 +367,17 @@ int paravirt_disable_iospace(void);
329 * calls are essentially free, because the call and return addresses 367 * calls are essentially free, because the call and return addresses
330 * are completely predictable.) 368 * are completely predictable.)
331 * 369 *
332 * These macros rely on the standard gcc "regparm(3)" calling 370 * For i386, these macros rely on the standard gcc "regparm(3)" calling
333 * convention, in which the first three arguments are placed in %eax, 371 * convention, in which the first three arguments are placed in %eax,
334 * %edx, %ecx (in that order), and the remaining arguments are placed 372 * %edx, %ecx (in that order), and the remaining arguments are placed
335 * on the stack. All caller-save registers (eax,edx,ecx) are expected 373 * on the stack. All caller-save registers (eax,edx,ecx) are expected
336 * to be modified (either clobbered or used for return values). 374 * to be modified (either clobbered or used for return values).
375 * X86_64, on the other hand, already specifies a register-based calling
376 * conventions, returning at %rax, with parameteres going on %rdi, %rsi,
377 * %rdx, and %rcx. Note that for this reason, x86_64 does not need any
378 * special handling for dealing with 4 arguments, unlike i386.
379 * However, x86_64 also have to clobber all caller saved registers, which
380 * unfortunately, are quite a bit (r8 - r11)
337 * 381 *
338 * The call instruction itself is marked by placing its start address 382 * The call instruction itself is marked by placing its start address
339 * and size into the .parainstructions section, so that 383 * and size into the .parainstructions section, so that
@@ -356,10 +400,12 @@ int paravirt_disable_iospace(void);
356 * the return type. The macro then uses sizeof() on that type to 400 * the return type. The macro then uses sizeof() on that type to
357 * determine whether its a 32 or 64 bit value, and places the return 401 * determine whether its a 32 or 64 bit value, and places the return
358 * in the right register(s) (just %eax for 32-bit, and %edx:%eax for 402 * in the right register(s) (just %eax for 32-bit, and %edx:%eax for
359 * 64-bit). 403 * 64-bit). For x86_64 machines, it just returns at %rax regardless of
404 * the return value size.
360 * 405 *
361 * 64-bit arguments are passed as a pair of adjacent 32-bit arguments 406 * 64-bit arguments are passed as a pair of adjacent 32-bit arguments
362 * in low,high order. 407 * i386 also passes 64-bit arguments as a pair of adjacent 32-bit arguments
408 * in low,high order
363 * 409 *
364 * Small structures are passed and returned in registers. The macro 410 * Small structures are passed and returned in registers. The macro
365 * calling convention can't directly deal with this, so the wrapper 411 * calling convention can't directly deal with this, so the wrapper
@@ -369,46 +415,67 @@ int paravirt_disable_iospace(void);
369 * means that all uses must be wrapped in inline functions. This also 415 * means that all uses must be wrapped in inline functions. This also
370 * makes sure the incoming and outgoing types are always correct. 416 * makes sure the incoming and outgoing types are always correct.
371 */ 417 */
418#ifdef CONFIG_X86_32
419#define PVOP_VCALL_ARGS unsigned long __eax, __edx, __ecx
420#define PVOP_CALL_ARGS PVOP_VCALL_ARGS
421#define PVOP_VCALL_CLOBBERS "=a" (__eax), "=d" (__edx), \
422 "=c" (__ecx)
423#define PVOP_CALL_CLOBBERS PVOP_VCALL_CLOBBERS
424#define EXTRA_CLOBBERS
425#define VEXTRA_CLOBBERS
426#else
427#define PVOP_VCALL_ARGS unsigned long __edi, __esi, __edx, __ecx
428#define PVOP_CALL_ARGS PVOP_VCALL_ARGS, __eax
429#define PVOP_VCALL_CLOBBERS "=D" (__edi), \
430 "=S" (__esi), "=d" (__edx), \
431 "=c" (__ecx)
432
433#define PVOP_CALL_CLOBBERS PVOP_VCALL_CLOBBERS, "=a" (__eax)
434
435#define EXTRA_CLOBBERS , "r8", "r9", "r10", "r11"
436#define VEXTRA_CLOBBERS , "rax", "r8", "r9", "r10", "r11"
437#endif
438
372#define __PVOP_CALL(rettype, op, pre, post, ...) \ 439#define __PVOP_CALL(rettype, op, pre, post, ...) \
373 ({ \ 440 ({ \
374 rettype __ret; \ 441 rettype __ret; \
375 unsigned long __eax, __edx, __ecx; \ 442 PVOP_CALL_ARGS; \
443 /* This is 32-bit specific, but is okay in 64-bit */ \
444 /* since this condition will never hold */ \
376 if (sizeof(rettype) > sizeof(unsigned long)) { \ 445 if (sizeof(rettype) > sizeof(unsigned long)) { \
377 asm volatile(pre \ 446 asm volatile(pre \
378 paravirt_alt(PARAVIRT_CALL) \ 447 paravirt_alt(PARAVIRT_CALL) \
379 post \ 448 post \
380 : "=a" (__eax), "=d" (__edx), \ 449 : PVOP_CALL_CLOBBERS \
381 "=c" (__ecx) \
382 : paravirt_type(op), \ 450 : paravirt_type(op), \
383 paravirt_clobber(CLBR_ANY), \ 451 paravirt_clobber(CLBR_ANY), \
384 ##__VA_ARGS__ \ 452 ##__VA_ARGS__ \
385 : "memory", "cc"); \ 453 : "memory", "cc" EXTRA_CLOBBERS); \
386 __ret = (rettype)((((u64)__edx) << 32) | __eax); \ 454 __ret = (rettype)((((u64)__edx) << 32) | __eax); \
387 } else { \ 455 } else { \
388 asm volatile(pre \ 456 asm volatile(pre \
389 paravirt_alt(PARAVIRT_CALL) \ 457 paravirt_alt(PARAVIRT_CALL) \
390 post \ 458 post \
391 : "=a" (__eax), "=d" (__edx), \ 459 : PVOP_CALL_CLOBBERS \
392 "=c" (__ecx) \
393 : paravirt_type(op), \ 460 : paravirt_type(op), \
394 paravirt_clobber(CLBR_ANY), \ 461 paravirt_clobber(CLBR_ANY), \
395 ##__VA_ARGS__ \ 462 ##__VA_ARGS__ \
396 : "memory", "cc"); \ 463 : "memory", "cc" EXTRA_CLOBBERS); \
397 __ret = (rettype)__eax; \ 464 __ret = (rettype)__eax; \
398 } \ 465 } \
399 __ret; \ 466 __ret; \
400 }) 467 })
401#define __PVOP_VCALL(op, pre, post, ...) \ 468#define __PVOP_VCALL(op, pre, post, ...) \
402 ({ \ 469 ({ \
403 unsigned long __eax, __edx, __ecx; \ 470 PVOP_VCALL_ARGS; \
404 asm volatile(pre \ 471 asm volatile(pre \
405 paravirt_alt(PARAVIRT_CALL) \ 472 paravirt_alt(PARAVIRT_CALL) \
406 post \ 473 post \
407 : "=a" (__eax), "=d" (__edx), "=c" (__ecx) \ 474 : PVOP_VCALL_CLOBBERS \
408 : paravirt_type(op), \ 475 : paravirt_type(op), \
409 paravirt_clobber(CLBR_ANY), \ 476 paravirt_clobber(CLBR_ANY), \
410 ##__VA_ARGS__ \ 477 ##__VA_ARGS__ \
411 : "memory", "cc"); \ 478 : "memory", "cc" VEXTRA_CLOBBERS); \
412 }) 479 })
413 480
414#define PVOP_CALL0(rettype, op) \ 481#define PVOP_CALL0(rettype, op) \
@@ -417,22 +484,26 @@ int paravirt_disable_iospace(void);
417 __PVOP_VCALL(op, "", "") 484 __PVOP_VCALL(op, "", "")
418 485
419#define PVOP_CALL1(rettype, op, arg1) \ 486#define PVOP_CALL1(rettype, op, arg1) \
420 __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1))) 487 __PVOP_CALL(rettype, op, "", "", "0" ((unsigned long)(arg1)))
421#define PVOP_VCALL1(op, arg1) \ 488#define PVOP_VCALL1(op, arg1) \
422 __PVOP_VCALL(op, "", "", "0" ((u32)(arg1))) 489 __PVOP_VCALL(op, "", "", "0" ((unsigned long)(arg1)))
423 490
424#define PVOP_CALL2(rettype, op, arg1, arg2) \ 491#define PVOP_CALL2(rettype, op, arg1, arg2) \
425 __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2))) 492 __PVOP_CALL(rettype, op, "", "", "0" ((unsigned long)(arg1)), \
493 "1" ((unsigned long)(arg2)))
426#define PVOP_VCALL2(op, arg1, arg2) \ 494#define PVOP_VCALL2(op, arg1, arg2) \
427 __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1" ((u32)(arg2))) 495 __PVOP_VCALL(op, "", "", "0" ((unsigned long)(arg1)), \
496 "1" ((unsigned long)(arg2)))
428 497
429#define PVOP_CALL3(rettype, op, arg1, arg2, arg3) \ 498#define PVOP_CALL3(rettype, op, arg1, arg2, arg3) \
430 __PVOP_CALL(rettype, op, "", "", "0" ((u32)(arg1)), \ 499 __PVOP_CALL(rettype, op, "", "", "0" ((unsigned long)(arg1)), \
431 "1"((u32)(arg2)), "2"((u32)(arg3))) 500 "1"((unsigned long)(arg2)), "2"((unsigned long)(arg3)))
432#define PVOP_VCALL3(op, arg1, arg2, arg3) \ 501#define PVOP_VCALL3(op, arg1, arg2, arg3) \
433 __PVOP_VCALL(op, "", "", "0" ((u32)(arg1)), "1"((u32)(arg2)), \ 502 __PVOP_VCALL(op, "", "", "0" ((unsigned long)(arg1)), \
434 "2"((u32)(arg3))) 503 "1"((unsigned long)(arg2)), "2"((unsigned long)(arg3)))
435 504
505/* This is the only difference in x86_64. We can make it much simpler */
506#ifdef CONFIG_X86_32
436#define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \ 507#define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \
437 __PVOP_CALL(rettype, op, \ 508 __PVOP_CALL(rettype, op, \
438 "push %[_arg4];", "lea 4(%%esp),%%esp;", \ 509 "push %[_arg4];", "lea 4(%%esp),%%esp;", \
@@ -443,16 +514,26 @@ int paravirt_disable_iospace(void);
443 "push %[_arg4];", "lea 4(%%esp),%%esp;", \ 514 "push %[_arg4];", "lea 4(%%esp),%%esp;", \
444 "0" ((u32)(arg1)), "1" ((u32)(arg2)), \ 515 "0" ((u32)(arg1)), "1" ((u32)(arg2)), \
445 "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4))) 516 "2" ((u32)(arg3)), [_arg4] "mr" ((u32)(arg4)))
517#else
518#define PVOP_CALL4(rettype, op, arg1, arg2, arg3, arg4) \
519 __PVOP_CALL(rettype, op, "", "", "0" ((unsigned long)(arg1)), \
520 "1"((unsigned long)(arg2)), "2"((unsigned long)(arg3)), \
521 "3"((unsigned long)(arg4)))
522#define PVOP_VCALL4(op, arg1, arg2, arg3, arg4) \
523 __PVOP_VCALL(op, "", "", "0" ((unsigned long)(arg1)), \
524 "1"((unsigned long)(arg2)), "2"((unsigned long)(arg3)), \
525 "3"((unsigned long)(arg4)))
526#endif
446 527
447static inline int paravirt_enabled(void) 528static inline int paravirt_enabled(void)
448{ 529{
449 return pv_info.paravirt_enabled; 530 return pv_info.paravirt_enabled;
450} 531}
451 532
452static inline void load_esp0(struct tss_struct *tss, 533static inline void load_sp0(struct tss_struct *tss,
453 struct thread_struct *thread) 534 struct thread_struct *thread)
454{ 535{
455 PVOP_VCALL2(pv_cpu_ops.load_esp0, tss, thread); 536 PVOP_VCALL2(pv_cpu_ops.load_sp0, tss, thread);
456} 537}
457 538
458#define ARCH_SETUP pv_init_ops.arch_setup(); 539#define ARCH_SETUP pv_init_ops.arch_setup();
@@ -540,6 +621,18 @@ static inline void write_cr4(unsigned long x)
540 PVOP_VCALL1(pv_cpu_ops.write_cr4, x); 621 PVOP_VCALL1(pv_cpu_ops.write_cr4, x);
541} 622}
542 623
624#ifdef CONFIG_X86_64
625static inline unsigned long read_cr8(void)
626{
627 return PVOP_CALL0(unsigned long, pv_cpu_ops.read_cr8);
628}
629
630static inline void write_cr8(unsigned long x)
631{
632 PVOP_VCALL1(pv_cpu_ops.write_cr8, x);
633}
634#endif
635
543static inline void raw_safe_halt(void) 636static inline void raw_safe_halt(void)
544{ 637{
545 PVOP_VCALL0(pv_irq_ops.safe_halt); 638 PVOP_VCALL0(pv_irq_ops.safe_halt);
@@ -613,8 +706,6 @@ static inline unsigned long long paravirt_sched_clock(void)
613} 706}
614#define calculate_cpu_khz() (pv_time_ops.get_cpu_khz()) 707#define calculate_cpu_khz() (pv_time_ops.get_cpu_khz())
615 708
616#define write_tsc(val1,val2) wrmsr(0x10, val1, val2)
617
618static inline unsigned long long paravirt_read_pmc(int counter) 709static inline unsigned long long paravirt_read_pmc(int counter)
619{ 710{
620 return PVOP_CALL1(u64, pv_cpu_ops.read_pmc, counter); 711 return PVOP_CALL1(u64, pv_cpu_ops.read_pmc, counter);
@@ -626,15 +717,36 @@ static inline unsigned long long paravirt_read_pmc(int counter)
626 high = _l >> 32; \ 717 high = _l >> 32; \
627} while(0) 718} while(0)
628 719
720static inline unsigned long long paravirt_rdtscp(unsigned int *aux)
721{
722 return PVOP_CALL1(u64, pv_cpu_ops.read_tscp, aux);
723}
724
725#define rdtscp(low, high, aux) \
726do { \
727 int __aux; \
728 unsigned long __val = paravirt_rdtscp(&__aux); \
729 (low) = (u32)__val; \
730 (high) = (u32)(__val >> 32); \
731 (aux) = __aux; \
732} while (0)
733
734#define rdtscpll(val, aux) \
735do { \
736 unsigned long __aux; \
737 val = paravirt_rdtscp(&__aux); \
738 (aux) = __aux; \
739} while (0)
740
629static inline void load_TR_desc(void) 741static inline void load_TR_desc(void)
630{ 742{
631 PVOP_VCALL0(pv_cpu_ops.load_tr_desc); 743 PVOP_VCALL0(pv_cpu_ops.load_tr_desc);
632} 744}
633static inline void load_gdt(const struct Xgt_desc_struct *dtr) 745static inline void load_gdt(const struct desc_ptr *dtr)
634{ 746{
635 PVOP_VCALL1(pv_cpu_ops.load_gdt, dtr); 747 PVOP_VCALL1(pv_cpu_ops.load_gdt, dtr);
636} 748}
637static inline void load_idt(const struct Xgt_desc_struct *dtr) 749static inline void load_idt(const struct desc_ptr *dtr)
638{ 750{
639 PVOP_VCALL1(pv_cpu_ops.load_idt, dtr); 751 PVOP_VCALL1(pv_cpu_ops.load_idt, dtr);
640} 752}
@@ -642,11 +754,11 @@ static inline void set_ldt(const void *addr, unsigned entries)
642{ 754{
643 PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries); 755 PVOP_VCALL2(pv_cpu_ops.set_ldt, addr, entries);
644} 756}
645static inline void store_gdt(struct Xgt_desc_struct *dtr) 757static inline void store_gdt(struct desc_ptr *dtr)
646{ 758{
647 PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr); 759 PVOP_VCALL1(pv_cpu_ops.store_gdt, dtr);
648} 760}
649static inline void store_idt(struct Xgt_desc_struct *dtr) 761static inline void store_idt(struct desc_ptr *dtr)
650{ 762{
651 PVOP_VCALL1(pv_cpu_ops.store_idt, dtr); 763 PVOP_VCALL1(pv_cpu_ops.store_idt, dtr);
652} 764}
@@ -659,17 +771,22 @@ static inline void load_TLS(struct thread_struct *t, unsigned cpu)
659{ 771{
660 PVOP_VCALL2(pv_cpu_ops.load_tls, t, cpu); 772 PVOP_VCALL2(pv_cpu_ops.load_tls, t, cpu);
661} 773}
662static inline void write_ldt_entry(void *dt, int entry, u32 low, u32 high) 774
775static inline void write_ldt_entry(struct desc_struct *dt, int entry,
776 const void *desc)
663{ 777{
664 PVOP_VCALL4(pv_cpu_ops.write_ldt_entry, dt, entry, low, high); 778 PVOP_VCALL3(pv_cpu_ops.write_ldt_entry, dt, entry, desc);
665} 779}
666static inline void write_gdt_entry(void *dt, int entry, u32 low, u32 high) 780
781static inline void write_gdt_entry(struct desc_struct *dt, int entry,
782 void *desc, int type)
667{ 783{
668 PVOP_VCALL4(pv_cpu_ops.write_gdt_entry, dt, entry, low, high); 784 PVOP_VCALL4(pv_cpu_ops.write_gdt_entry, dt, entry, desc, type);
669} 785}
670static inline void write_idt_entry(void *dt, int entry, u32 low, u32 high) 786
787static inline void write_idt_entry(gate_desc *dt, int entry, const gate_desc *g)
671{ 788{
672 PVOP_VCALL4(pv_cpu_ops.write_idt_entry, dt, entry, low, high); 789 PVOP_VCALL3(pv_cpu_ops.write_idt_entry, dt, entry, g);
673} 790}
674static inline void set_iopl_mask(unsigned mask) 791static inline void set_iopl_mask(unsigned mask)
675{ 792{
@@ -690,17 +807,17 @@ static inline void slow_down_io(void) {
690/* 807/*
691 * Basic functions accessing APICs. 808 * Basic functions accessing APICs.
692 */ 809 */
693static inline void apic_write(unsigned long reg, unsigned long v) 810static inline void apic_write(unsigned long reg, u32 v)
694{ 811{
695 PVOP_VCALL2(pv_apic_ops.apic_write, reg, v); 812 PVOP_VCALL2(pv_apic_ops.apic_write, reg, v);
696} 813}
697 814
698static inline void apic_write_atomic(unsigned long reg, unsigned long v) 815static inline void apic_write_atomic(unsigned long reg, u32 v)
699{ 816{
700 PVOP_VCALL2(pv_apic_ops.apic_write_atomic, reg, v); 817 PVOP_VCALL2(pv_apic_ops.apic_write_atomic, reg, v);
701} 818}
702 819
703static inline unsigned long apic_read(unsigned long reg) 820static inline u32 apic_read(unsigned long reg)
704{ 821{
705 return PVOP_CALL1(unsigned long, pv_apic_ops.apic_read, reg); 822 return PVOP_CALL1(unsigned long, pv_apic_ops.apic_read, reg);
706} 823}
@@ -786,9 +903,9 @@ static inline void paravirt_release_pt(unsigned pfn)
786 PVOP_VCALL1(pv_mmu_ops.release_pt, pfn); 903 PVOP_VCALL1(pv_mmu_ops.release_pt, pfn);
787} 904}
788 905
789static inline void paravirt_alloc_pd(unsigned pfn) 906static inline void paravirt_alloc_pd(struct mm_struct *mm, unsigned pfn)
790{ 907{
791 PVOP_VCALL1(pv_mmu_ops.alloc_pd, pfn); 908 PVOP_VCALL2(pv_mmu_ops.alloc_pd, mm, pfn);
792} 909}
793 910
794static inline void paravirt_alloc_pd_clone(unsigned pfn, unsigned clonepfn, 911static inline void paravirt_alloc_pd_clone(unsigned pfn, unsigned clonepfn,
@@ -822,128 +939,236 @@ static inline void pte_update_defer(struct mm_struct *mm, unsigned long addr,
822 PVOP_VCALL3(pv_mmu_ops.pte_update_defer, mm, addr, ptep); 939 PVOP_VCALL3(pv_mmu_ops.pte_update_defer, mm, addr, ptep);
823} 940}
824 941
825#ifdef CONFIG_X86_PAE 942static inline pte_t __pte(pteval_t val)
826static inline pte_t __pte(unsigned long long val)
827{ 943{
828 unsigned long long ret = PVOP_CALL2(unsigned long long, 944 pteval_t ret;
829 pv_mmu_ops.make_pte, 945
830 val, val >> 32); 946 if (sizeof(pteval_t) > sizeof(long))
831 return (pte_t) { ret, ret >> 32 }; 947 ret = PVOP_CALL2(pteval_t,
948 pv_mmu_ops.make_pte,
949 val, (u64)val >> 32);
950 else
951 ret = PVOP_CALL1(pteval_t,
952 pv_mmu_ops.make_pte,
953 val);
954
955 return (pte_t) { .pte = ret };
832} 956}
833 957
834static inline pmd_t __pmd(unsigned long long val) 958static inline pteval_t pte_val(pte_t pte)
835{ 959{
836 return (pmd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pmd, 960 pteval_t ret;
837 val, val >> 32) }; 961
962 if (sizeof(pteval_t) > sizeof(long))
963 ret = PVOP_CALL2(pteval_t, pv_mmu_ops.pte_val,
964 pte.pte, (u64)pte.pte >> 32);
965 else
966 ret = PVOP_CALL1(pteval_t, pv_mmu_ops.pte_val,
967 pte.pte);
968
969 return ret;
838} 970}
839 971
840static inline pgd_t __pgd(unsigned long long val) 972static inline pgd_t __pgd(pgdval_t val)
841{ 973{
842 return (pgd_t) { PVOP_CALL2(unsigned long long, pv_mmu_ops.make_pgd, 974 pgdval_t ret;
843 val, val >> 32) }; 975
976 if (sizeof(pgdval_t) > sizeof(long))
977 ret = PVOP_CALL2(pgdval_t, pv_mmu_ops.make_pgd,
978 val, (u64)val >> 32);
979 else
980 ret = PVOP_CALL1(pgdval_t, pv_mmu_ops.make_pgd,
981 val);
982
983 return (pgd_t) { ret };
844} 984}
845 985
846static inline unsigned long long pte_val(pte_t x) 986static inline pgdval_t pgd_val(pgd_t pgd)
847{ 987{
848 return PVOP_CALL2(unsigned long long, pv_mmu_ops.pte_val, 988 pgdval_t ret;
849 x.pte_low, x.pte_high); 989
990 if (sizeof(pgdval_t) > sizeof(long))
991 ret = PVOP_CALL2(pgdval_t, pv_mmu_ops.pgd_val,
992 pgd.pgd, (u64)pgd.pgd >> 32);
993 else
994 ret = PVOP_CALL1(pgdval_t, pv_mmu_ops.pgd_val,
995 pgd.pgd);
996
997 return ret;
850} 998}
851 999
852static inline unsigned long long pmd_val(pmd_t x) 1000static inline void set_pte(pte_t *ptep, pte_t pte)
853{ 1001{
854 return PVOP_CALL2(unsigned long long, pv_mmu_ops.pmd_val, 1002 if (sizeof(pteval_t) > sizeof(long))
855 x.pmd, x.pmd >> 32); 1003 PVOP_VCALL3(pv_mmu_ops.set_pte, ptep,
1004 pte.pte, (u64)pte.pte >> 32);
1005 else
1006 PVOP_VCALL2(pv_mmu_ops.set_pte, ptep,
1007 pte.pte);
856} 1008}
857 1009
858static inline unsigned long long pgd_val(pgd_t x) 1010static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
1011 pte_t *ptep, pte_t pte)
859{ 1012{
860 return PVOP_CALL2(unsigned long long, pv_mmu_ops.pgd_val, 1013 if (sizeof(pteval_t) > sizeof(long))
861 x.pgd, x.pgd >> 32); 1014 /* 5 arg words */
1015 pv_mmu_ops.set_pte_at(mm, addr, ptep, pte);
1016 else
1017 PVOP_VCALL4(pv_mmu_ops.set_pte_at, mm, addr, ptep, pte.pte);
862} 1018}
863 1019
864static inline void set_pte(pte_t *ptep, pte_t pteval) 1020static inline void set_pmd(pmd_t *pmdp, pmd_t pmd)
865{ 1021{
866 PVOP_VCALL3(pv_mmu_ops.set_pte, ptep, pteval.pte_low, pteval.pte_high); 1022 pmdval_t val = native_pmd_val(pmd);
1023
1024 if (sizeof(pmdval_t) > sizeof(long))
1025 PVOP_VCALL3(pv_mmu_ops.set_pmd, pmdp, val, (u64)val >> 32);
1026 else
1027 PVOP_VCALL2(pv_mmu_ops.set_pmd, pmdp, val);
867} 1028}
868 1029
869static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 1030#if PAGETABLE_LEVELS >= 3
870 pte_t *ptep, pte_t pteval) 1031static inline pmd_t __pmd(pmdval_t val)
871{ 1032{
872 /* 5 arg words */ 1033 pmdval_t ret;
873 pv_mmu_ops.set_pte_at(mm, addr, ptep, pteval); 1034
1035 if (sizeof(pmdval_t) > sizeof(long))
1036 ret = PVOP_CALL2(pmdval_t, pv_mmu_ops.make_pmd,
1037 val, (u64)val >> 32);
1038 else
1039 ret = PVOP_CALL1(pmdval_t, pv_mmu_ops.make_pmd,
1040 val);
1041
1042 return (pmd_t) { ret };
874} 1043}
875 1044
876static inline void set_pte_atomic(pte_t *ptep, pte_t pteval) 1045static inline pmdval_t pmd_val(pmd_t pmd)
877{ 1046{
878 PVOP_VCALL3(pv_mmu_ops.set_pte_atomic, ptep, 1047 pmdval_t ret;
879 pteval.pte_low, pteval.pte_high); 1048
1049 if (sizeof(pmdval_t) > sizeof(long))
1050 ret = PVOP_CALL2(pmdval_t, pv_mmu_ops.pmd_val,
1051 pmd.pmd, (u64)pmd.pmd >> 32);
1052 else
1053 ret = PVOP_CALL1(pmdval_t, pv_mmu_ops.pmd_val,
1054 pmd.pmd);
1055
1056 return ret;
880} 1057}
881 1058
882static inline void set_pte_present(struct mm_struct *mm, unsigned long addr, 1059static inline void set_pud(pud_t *pudp, pud_t pud)
883 pte_t *ptep, pte_t pte)
884{ 1060{
885 /* 5 arg words */ 1061 pudval_t val = native_pud_val(pud);
886 pv_mmu_ops.set_pte_present(mm, addr, ptep, pte); 1062
1063 if (sizeof(pudval_t) > sizeof(long))
1064 PVOP_VCALL3(pv_mmu_ops.set_pud, pudp,
1065 val, (u64)val >> 32);
1066 else
1067 PVOP_VCALL2(pv_mmu_ops.set_pud, pudp,
1068 val);
1069}
1070#if PAGETABLE_LEVELS == 4
1071static inline pud_t __pud(pudval_t val)
1072{
1073 pudval_t ret;
1074
1075 if (sizeof(pudval_t) > sizeof(long))
1076 ret = PVOP_CALL2(pudval_t, pv_mmu_ops.make_pud,
1077 val, (u64)val >> 32);
1078 else
1079 ret = PVOP_CALL1(pudval_t, pv_mmu_ops.make_pud,
1080 val);
1081
1082 return (pud_t) { ret };
887} 1083}
888 1084
889static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval) 1085static inline pudval_t pud_val(pud_t pud)
890{ 1086{
891 PVOP_VCALL3(pv_mmu_ops.set_pmd, pmdp, 1087 pudval_t ret;
892 pmdval.pmd, pmdval.pmd >> 32); 1088
1089 if (sizeof(pudval_t) > sizeof(long))
1090 ret = PVOP_CALL2(pudval_t, pv_mmu_ops.pud_val,
1091 pud.pud, (u64)pud.pud >> 32);
1092 else
1093 ret = PVOP_CALL1(pudval_t, pv_mmu_ops.pud_val,
1094 pud.pud);
1095
1096 return ret;
893} 1097}
894 1098
895static inline void set_pud(pud_t *pudp, pud_t pudval) 1099static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
896{ 1100{
897 PVOP_VCALL3(pv_mmu_ops.set_pud, pudp, 1101 pgdval_t val = native_pgd_val(pgd);
898 pudval.pgd.pgd, pudval.pgd.pgd >> 32); 1102
1103 if (sizeof(pgdval_t) > sizeof(long))
1104 PVOP_VCALL3(pv_mmu_ops.set_pgd, pgdp,
1105 val, (u64)val >> 32);
1106 else
1107 PVOP_VCALL2(pv_mmu_ops.set_pgd, pgdp,
1108 val);
899} 1109}
900 1110
901static inline void pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 1111static inline void pgd_clear(pgd_t *pgdp)
902{ 1112{
903 PVOP_VCALL3(pv_mmu_ops.pte_clear, mm, addr, ptep); 1113 set_pgd(pgdp, __pgd(0));
904} 1114}
905 1115
906static inline void pmd_clear(pmd_t *pmdp) 1116static inline void pud_clear(pud_t *pudp)
907{ 1117{
908 PVOP_VCALL1(pv_mmu_ops.pmd_clear, pmdp); 1118 set_pud(pudp, __pud(0));
909} 1119}
910 1120
911#else /* !CONFIG_X86_PAE */ 1121#endif /* PAGETABLE_LEVELS == 4 */
912 1122
913static inline pte_t __pte(unsigned long val) 1123#endif /* PAGETABLE_LEVELS >= 3 */
1124
1125#ifdef CONFIG_X86_PAE
1126/* Special-case pte-setting operations for PAE, which can't update a
1127 64-bit pte atomically */
1128static inline void set_pte_atomic(pte_t *ptep, pte_t pte)
914{ 1129{
915 return (pte_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pte, val) }; 1130 PVOP_VCALL3(pv_mmu_ops.set_pte_atomic, ptep,
1131 pte.pte, pte.pte >> 32);
916} 1132}
917 1133
918static inline pgd_t __pgd(unsigned long val) 1134static inline void set_pte_present(struct mm_struct *mm, unsigned long addr,
1135 pte_t *ptep, pte_t pte)
919{ 1136{
920 return (pgd_t) { PVOP_CALL1(unsigned long, pv_mmu_ops.make_pgd, val) }; 1137 /* 5 arg words */
1138 pv_mmu_ops.set_pte_present(mm, addr, ptep, pte);
921} 1139}
922 1140
923static inline unsigned long pte_val(pte_t x) 1141static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
1142 pte_t *ptep)
924{ 1143{
925 return PVOP_CALL1(unsigned long, pv_mmu_ops.pte_val, x.pte_low); 1144 PVOP_VCALL3(pv_mmu_ops.pte_clear, mm, addr, ptep);
926} 1145}
927 1146
928static inline unsigned long pgd_val(pgd_t x) 1147static inline void pmd_clear(pmd_t *pmdp)
1148{
1149 PVOP_VCALL1(pv_mmu_ops.pmd_clear, pmdp);
1150}
1151#else /* !CONFIG_X86_PAE */
1152static inline void set_pte_atomic(pte_t *ptep, pte_t pte)
929{ 1153{
930 return PVOP_CALL1(unsigned long, pv_mmu_ops.pgd_val, x.pgd); 1154 set_pte(ptep, pte);
931} 1155}
932 1156
933static inline void set_pte(pte_t *ptep, pte_t pteval) 1157static inline void set_pte_present(struct mm_struct *mm, unsigned long addr,
1158 pte_t *ptep, pte_t pte)
934{ 1159{
935 PVOP_VCALL2(pv_mmu_ops.set_pte, ptep, pteval.pte_low); 1160 set_pte(ptep, pte);
936} 1161}
937 1162
938static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 1163static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
939 pte_t *ptep, pte_t pteval) 1164 pte_t *ptep)
940{ 1165{
941 PVOP_VCALL4(pv_mmu_ops.set_pte_at, mm, addr, ptep, pteval.pte_low); 1166 set_pte_at(mm, addr, ptep, __pte(0));
942} 1167}
943 1168
944static inline void set_pmd(pmd_t *pmdp, pmd_t pmdval) 1169static inline void pmd_clear(pmd_t *pmdp)
945{ 1170{
946 PVOP_VCALL2(pv_mmu_ops.set_pmd, pmdp, pmdval.pud.pgd.pgd); 1171 set_pmd(pmdp, __pmd(0));
947} 1172}
948#endif /* CONFIG_X86_PAE */ 1173#endif /* CONFIG_X86_PAE */
949 1174
@@ -1014,52 +1239,68 @@ struct paravirt_patch_site {
1014extern struct paravirt_patch_site __parainstructions[], 1239extern struct paravirt_patch_site __parainstructions[],
1015 __parainstructions_end[]; 1240 __parainstructions_end[];
1016 1241
1242#ifdef CONFIG_X86_32
1243#define PV_SAVE_REGS "pushl %%ecx; pushl %%edx;"
1244#define PV_RESTORE_REGS "popl %%edx; popl %%ecx"
1245#define PV_FLAGS_ARG "0"
1246#define PV_EXTRA_CLOBBERS
1247#define PV_VEXTRA_CLOBBERS
1248#else
1249/* We save some registers, but all of them, that's too much. We clobber all
1250 * caller saved registers but the argument parameter */
1251#define PV_SAVE_REGS "pushq %%rdi;"
1252#define PV_RESTORE_REGS "popq %%rdi;"
1253#define PV_EXTRA_CLOBBERS EXTRA_CLOBBERS, "rcx" , "rdx"
1254#define PV_VEXTRA_CLOBBERS EXTRA_CLOBBERS, "rdi", "rcx" , "rdx"
1255#define PV_FLAGS_ARG "D"
1256#endif
1257
1017static inline unsigned long __raw_local_save_flags(void) 1258static inline unsigned long __raw_local_save_flags(void)
1018{ 1259{
1019 unsigned long f; 1260 unsigned long f;
1020 1261
1021 asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" 1262 asm volatile(paravirt_alt(PV_SAVE_REGS
1022 PARAVIRT_CALL 1263 PARAVIRT_CALL
1023 "popl %%edx; popl %%ecx") 1264 PV_RESTORE_REGS)
1024 : "=a"(f) 1265 : "=a"(f)
1025 : paravirt_type(pv_irq_ops.save_fl), 1266 : paravirt_type(pv_irq_ops.save_fl),
1026 paravirt_clobber(CLBR_EAX) 1267 paravirt_clobber(CLBR_EAX)
1027 : "memory", "cc"); 1268 : "memory", "cc" PV_VEXTRA_CLOBBERS);
1028 return f; 1269 return f;
1029} 1270}
1030 1271
1031static inline void raw_local_irq_restore(unsigned long f) 1272static inline void raw_local_irq_restore(unsigned long f)
1032{ 1273{
1033 asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" 1274 asm volatile(paravirt_alt(PV_SAVE_REGS
1034 PARAVIRT_CALL 1275 PARAVIRT_CALL
1035 "popl %%edx; popl %%ecx") 1276 PV_RESTORE_REGS)
1036 : "=a"(f) 1277 : "=a"(f)
1037 : "0"(f), 1278 : PV_FLAGS_ARG(f),
1038 paravirt_type(pv_irq_ops.restore_fl), 1279 paravirt_type(pv_irq_ops.restore_fl),
1039 paravirt_clobber(CLBR_EAX) 1280 paravirt_clobber(CLBR_EAX)
1040 : "memory", "cc"); 1281 : "memory", "cc" PV_EXTRA_CLOBBERS);
1041} 1282}
1042 1283
1043static inline void raw_local_irq_disable(void) 1284static inline void raw_local_irq_disable(void)
1044{ 1285{
1045 asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" 1286 asm volatile(paravirt_alt(PV_SAVE_REGS
1046 PARAVIRT_CALL 1287 PARAVIRT_CALL
1047 "popl %%edx; popl %%ecx") 1288 PV_RESTORE_REGS)
1048 : 1289 :
1049 : paravirt_type(pv_irq_ops.irq_disable), 1290 : paravirt_type(pv_irq_ops.irq_disable),
1050 paravirt_clobber(CLBR_EAX) 1291 paravirt_clobber(CLBR_EAX)
1051 : "memory", "eax", "cc"); 1292 : "memory", "eax", "cc" PV_EXTRA_CLOBBERS);
1052} 1293}
1053 1294
1054static inline void raw_local_irq_enable(void) 1295static inline void raw_local_irq_enable(void)
1055{ 1296{
1056 asm volatile(paravirt_alt("pushl %%ecx; pushl %%edx;" 1297 asm volatile(paravirt_alt(PV_SAVE_REGS
1057 PARAVIRT_CALL 1298 PARAVIRT_CALL
1058 "popl %%edx; popl %%ecx") 1299 PV_RESTORE_REGS)
1059 : 1300 :
1060 : paravirt_type(pv_irq_ops.irq_enable), 1301 : paravirt_type(pv_irq_ops.irq_enable),
1061 paravirt_clobber(CLBR_EAX) 1302 paravirt_clobber(CLBR_EAX)
1062 : "memory", "eax", "cc"); 1303 : "memory", "eax", "cc" PV_EXTRA_CLOBBERS);
1063} 1304}
1064 1305
1065static inline unsigned long __raw_local_irq_save(void) 1306static inline unsigned long __raw_local_irq_save(void)
@@ -1071,27 +1312,6 @@ static inline unsigned long __raw_local_irq_save(void)
1071 return f; 1312 return f;
1072} 1313}
1073 1314
1074#define CLI_STRING \
1075 _paravirt_alt("pushl %%ecx; pushl %%edx;" \
1076 "call *%[paravirt_cli_opptr];" \
1077 "popl %%edx; popl %%ecx", \
1078 "%c[paravirt_cli_type]", "%c[paravirt_clobber]")
1079
1080#define STI_STRING \
1081 _paravirt_alt("pushl %%ecx; pushl %%edx;" \
1082 "call *%[paravirt_sti_opptr];" \
1083 "popl %%edx; popl %%ecx", \
1084 "%c[paravirt_sti_type]", "%c[paravirt_clobber]")
1085
1086#define CLI_STI_CLOBBERS , "%eax"
1087#define CLI_STI_INPUT_ARGS \
1088 , \
1089 [paravirt_cli_type] "i" (PARAVIRT_PATCH(pv_irq_ops.irq_disable)), \
1090 [paravirt_cli_opptr] "m" (pv_irq_ops.irq_disable), \
1091 [paravirt_sti_type] "i" (PARAVIRT_PATCH(pv_irq_ops.irq_enable)), \
1092 [paravirt_sti_opptr] "m" (pv_irq_ops.irq_enable), \
1093 paravirt_clobber(CLBR_EAX)
1094
1095/* Make sure as little as possible of this mess escapes. */ 1315/* Make sure as little as possible of this mess escapes. */
1096#undef PARAVIRT_CALL 1316#undef PARAVIRT_CALL
1097#undef __PVOP_CALL 1317#undef __PVOP_CALL
@@ -1109,43 +1329,72 @@ static inline unsigned long __raw_local_irq_save(void)
1109 1329
1110#else /* __ASSEMBLY__ */ 1330#else /* __ASSEMBLY__ */
1111 1331
1112#define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4) 1332#define _PVSITE(ptype, clobbers, ops, word, algn) \
1113
1114#define PARA_SITE(ptype, clobbers, ops) \
1115771:; \ 1333771:; \
1116 ops; \ 1334 ops; \
1117772:; \ 1335772:; \
1118 .pushsection .parainstructions,"a"; \ 1336 .pushsection .parainstructions,"a"; \
1119 .long 771b; \ 1337 .align algn; \
1338 word 771b; \
1120 .byte ptype; \ 1339 .byte ptype; \
1121 .byte 772b-771b; \ 1340 .byte 772b-771b; \
1122 .short clobbers; \ 1341 .short clobbers; \
1123 .popsection 1342 .popsection
1124 1343
1344
1345#ifdef CONFIG_X86_64
1346#define PV_SAVE_REGS pushq %rax; pushq %rdi; pushq %rcx; pushq %rdx
1347#define PV_RESTORE_REGS popq %rdx; popq %rcx; popq %rdi; popq %rax
1348#define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 8)
1349#define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .quad, 8)
1350#else
1351#define PV_SAVE_REGS pushl %eax; pushl %edi; pushl %ecx; pushl %edx
1352#define PV_RESTORE_REGS popl %edx; popl %ecx; popl %edi; popl %eax
1353#define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
1354#define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
1355#endif
1356
1125#define INTERRUPT_RETURN \ 1357#define INTERRUPT_RETURN \
1126 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_iret), CLBR_NONE, \ 1358 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_iret), CLBR_NONE, \
1127 jmp *%cs:pv_cpu_ops+PV_CPU_iret) 1359 jmp *%cs:pv_cpu_ops+PV_CPU_iret)
1128 1360
1129#define DISABLE_INTERRUPTS(clobbers) \ 1361#define DISABLE_INTERRUPTS(clobbers) \
1130 PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_disable), clobbers, \ 1362 PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_disable), clobbers, \
1131 pushl %eax; pushl %ecx; pushl %edx; \ 1363 PV_SAVE_REGS; \
1132 call *%cs:pv_irq_ops+PV_IRQ_irq_disable; \ 1364 call *%cs:pv_irq_ops+PV_IRQ_irq_disable; \
1133 popl %edx; popl %ecx; popl %eax) \ 1365 PV_RESTORE_REGS;) \
1134 1366
1135#define ENABLE_INTERRUPTS(clobbers) \ 1367#define ENABLE_INTERRUPTS(clobbers) \
1136 PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_enable), clobbers, \ 1368 PARA_SITE(PARA_PATCH(pv_irq_ops, PV_IRQ_irq_enable), clobbers, \
1137 pushl %eax; pushl %ecx; pushl %edx; \ 1369 PV_SAVE_REGS; \
1138 call *%cs:pv_irq_ops+PV_IRQ_irq_enable; \ 1370 call *%cs:pv_irq_ops+PV_IRQ_irq_enable; \
1139 popl %edx; popl %ecx; popl %eax) 1371 PV_RESTORE_REGS;)
1372
1373#define ENABLE_INTERRUPTS_SYSCALL_RET \
1374 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_syscall_ret),\
1375 CLBR_NONE, \
1376 jmp *%cs:pv_cpu_ops+PV_CPU_irq_enable_syscall_ret)
1140 1377
1141#define ENABLE_INTERRUPTS_SYSEXIT \
1142 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), CLBR_NONE,\
1143 jmp *%cs:pv_cpu_ops+PV_CPU_irq_enable_sysexit)
1144 1378
1379#ifdef CONFIG_X86_32
1145#define GET_CR0_INTO_EAX \ 1380#define GET_CR0_INTO_EAX \
1146 push %ecx; push %edx; \ 1381 push %ecx; push %edx; \
1147 call *pv_cpu_ops+PV_CPU_read_cr0; \ 1382 call *pv_cpu_ops+PV_CPU_read_cr0; \
1148 pop %edx; pop %ecx 1383 pop %edx; pop %ecx
1384#else
1385#define SWAPGS \
1386 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_swapgs), CLBR_NONE, \
1387 PV_SAVE_REGS; \
1388 call *pv_cpu_ops+PV_CPU_swapgs; \
1389 PV_RESTORE_REGS \
1390 )
1391
1392#define GET_CR2_INTO_RCX \
1393 call *pv_mmu_ops+PV_MMU_read_cr2; \
1394 movq %rax, %rcx; \
1395 xorq %rax, %rax;
1396
1397#endif
1149 1398
1150#endif /* __ASSEMBLY__ */ 1399#endif /* __ASSEMBLY__ */
1151#endif /* CONFIG_PARAVIRT */ 1400#endif /* CONFIG_PARAVIRT */
diff --git a/include/asm-x86/pci.h b/include/asm-x86/pci.h
index e88361966347..c61190cb9e12 100644
--- a/include/asm-x86/pci.h
+++ b/include/asm-x86/pci.h
@@ -66,6 +66,7 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
66 66
67 67
68#ifdef CONFIG_PCI 68#ifdef CONFIG_PCI
69extern void early_quirks(void);
69static inline void pci_dma_burst_advice(struct pci_dev *pdev, 70static inline void pci_dma_burst_advice(struct pci_dev *pdev,
70 enum pci_dma_burst_strategy *strat, 71 enum pci_dma_burst_strategy *strat,
71 unsigned long *strategy_parameter) 72 unsigned long *strategy_parameter)
@@ -73,9 +74,10 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
73 *strat = PCI_DMA_BURST_INFINITY; 74 *strat = PCI_DMA_BURST_INFINITY;
74 *strategy_parameter = ~0UL; 75 *strategy_parameter = ~0UL;
75} 76}
77#else
78static inline void early_quirks(void) { }
76#endif 79#endif
77 80
78
79#endif /* __KERNEL__ */ 81#endif /* __KERNEL__ */
80 82
81#ifdef CONFIG_X86_32 83#ifdef CONFIG_X86_32
@@ -90,6 +92,19 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
90/* generic pci stuff */ 92/* generic pci stuff */
91#include <asm-generic/pci.h> 93#include <asm-generic/pci.h>
92 94
95#ifdef CONFIG_NUMA
96/* Returns the node based on pci bus */
97static inline int __pcibus_to_node(struct pci_bus *bus)
98{
99 struct pci_sysdata *sd = bus->sysdata;
93 100
101 return sd->node;
102}
103
104static inline cpumask_t __pcibus_to_cpumask(struct pci_bus *bus)
105{
106 return node_to_cpumask(__pcibus_to_node(bus));
107}
108#endif
94 109
95#endif 110#endif
diff --git a/include/asm-x86/pci_64.h b/include/asm-x86/pci_64.h
index 9baa46d9f594..374690314539 100644
--- a/include/asm-x86/pci_64.h
+++ b/include/asm-x86/pci_64.h
@@ -26,7 +26,6 @@ extern int (*pci_config_write)(int seg, int bus, int dev, int fn, int reg, int l
26 26
27 27
28extern void pci_iommu_alloc(void); 28extern void pci_iommu_alloc(void);
29extern int iommu_setup(char *opt);
30 29
31/* The PCI address space does equal the physical memory 30/* The PCI address space does equal the physical memory
32 * address space. The networking and block device layers use 31 * address space. The networking and block device layers use
@@ -37,7 +36,7 @@ extern int iommu_setup(char *opt);
37 */ 36 */
38#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys) 37#define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
39 38
40#if defined(CONFIG_IOMMU) || defined(CONFIG_CALGARY_IOMMU) 39#if defined(CONFIG_GART_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
41 40
42#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \ 41#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
43 dma_addr_t ADDR_NAME; 42 dma_addr_t ADDR_NAME;
diff --git a/include/asm-x86/pda.h b/include/asm-x86/pda.h
index 35962bbe5e72..c0305bff0f19 100644
--- a/include/asm-x86/pda.h
+++ b/include/asm-x86/pda.h
@@ -7,22 +7,22 @@
7#include <linux/cache.h> 7#include <linux/cache.h>
8#include <asm/page.h> 8#include <asm/page.h>
9 9
10/* Per processor datastructure. %gs points to it while the kernel runs */ 10/* Per processor datastructure. %gs points to it while the kernel runs */
11struct x8664_pda { 11struct x8664_pda {
12 struct task_struct *pcurrent; /* 0 Current process */ 12 struct task_struct *pcurrent; /* 0 Current process */
13 unsigned long data_offset; /* 8 Per cpu data offset from linker 13 unsigned long data_offset; /* 8 Per cpu data offset from linker
14 address */ 14 address */
15 unsigned long kernelstack; /* 16 top of kernel stack for current */ 15 unsigned long kernelstack; /* 16 top of kernel stack for current */
16 unsigned long oldrsp; /* 24 user rsp for system call */ 16 unsigned long oldrsp; /* 24 user rsp for system call */
17 int irqcount; /* 32 Irq nesting counter. Starts with -1 */ 17 int irqcount; /* 32 Irq nesting counter. Starts -1 */
18 int cpunumber; /* 36 Logical CPU number */ 18 unsigned int cpunumber; /* 36 Logical CPU number */
19#ifdef CONFIG_CC_STACKPROTECTOR 19#ifdef CONFIG_CC_STACKPROTECTOR
20 unsigned long stack_canary; /* 40 stack canary value */ 20 unsigned long stack_canary; /* 40 stack canary value */
21 /* gcc-ABI: this canary MUST be at 21 /* gcc-ABI: this canary MUST be at
22 offset 40!!! */ 22 offset 40!!! */
23#endif 23#endif
24 char *irqstackptr; 24 char *irqstackptr;
25 int nodenumber; /* number of current node */ 25 unsigned int nodenumber; /* number of current node */
26 unsigned int __softirq_pending; 26 unsigned int __softirq_pending;
27 unsigned int __nmi_count; /* number of NMI on this CPUs */ 27 unsigned int __nmi_count; /* number of NMI on this CPUs */
28 short mmu_state; 28 short mmu_state;
@@ -40,13 +40,14 @@ struct x8664_pda {
40 40
41extern struct x8664_pda *_cpu_pda[]; 41extern struct x8664_pda *_cpu_pda[];
42extern struct x8664_pda boot_cpu_pda[]; 42extern struct x8664_pda boot_cpu_pda[];
43extern void pda_init(int);
43 44
44#define cpu_pda(i) (_cpu_pda[i]) 45#define cpu_pda(i) (_cpu_pda[i])
45 46
46/* 47/*
47 * There is no fast way to get the base address of the PDA, all the accesses 48 * There is no fast way to get the base address of the PDA, all the accesses
48 * have to mention %fs/%gs. So it needs to be done this Torvaldian way. 49 * have to mention %fs/%gs. So it needs to be done this Torvaldian way.
49 */ 50 */
50extern void __bad_pda_field(void) __attribute__((noreturn)); 51extern void __bad_pda_field(void) __attribute__((noreturn));
51 52
52/* 53/*
@@ -57,70 +58,70 @@ extern struct x8664_pda _proxy_pda;
57 58
58#define pda_offset(field) offsetof(struct x8664_pda, field) 59#define pda_offset(field) offsetof(struct x8664_pda, field)
59 60
60#define pda_to_op(op,field,val) do { \ 61#define pda_to_op(op, field, val) do { \
61 typedef typeof(_proxy_pda.field) T__; \ 62 typedef typeof(_proxy_pda.field) T__; \
62 if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \ 63 if (0) { T__ tmp__; tmp__ = (val); } /* type checking */ \
63 switch (sizeof(_proxy_pda.field)) { \ 64 switch (sizeof(_proxy_pda.field)) { \
64 case 2: \ 65 case 2: \
65 asm(op "w %1,%%gs:%c2" : \ 66 asm(op "w %1,%%gs:%c2" : \
66 "+m" (_proxy_pda.field) : \ 67 "+m" (_proxy_pda.field) : \
67 "ri" ((T__)val), \ 68 "ri" ((T__)val), \
68 "i"(pda_offset(field))); \ 69 "i"(pda_offset(field))); \
69 break; \ 70 break; \
70 case 4: \ 71 case 4: \
71 asm(op "l %1,%%gs:%c2" : \ 72 asm(op "l %1,%%gs:%c2" : \
72 "+m" (_proxy_pda.field) : \ 73 "+m" (_proxy_pda.field) : \
73 "ri" ((T__)val), \ 74 "ri" ((T__)val), \
74 "i" (pda_offset(field))); \ 75 "i" (pda_offset(field))); \
75 break; \ 76 break; \
76 case 8: \ 77 case 8: \
77 asm(op "q %1,%%gs:%c2": \ 78 asm(op "q %1,%%gs:%c2": \
78 "+m" (_proxy_pda.field) : \ 79 "+m" (_proxy_pda.field) : \
79 "ri" ((T__)val), \ 80 "ri" ((T__)val), \
80 "i"(pda_offset(field))); \ 81 "i"(pda_offset(field))); \
81 break; \ 82 break; \
82 default: \ 83 default: \
83 __bad_pda_field(); \ 84 __bad_pda_field(); \
84 } \ 85 } \
85 } while (0) 86 } while (0)
86 87
87#define pda_from_op(op,field) ({ \ 88#define pda_from_op(op,field) ({ \
88 typeof(_proxy_pda.field) ret__; \ 89 typeof(_proxy_pda.field) ret__; \
89 switch (sizeof(_proxy_pda.field)) { \ 90 switch (sizeof(_proxy_pda.field)) { \
90 case 2: \ 91 case 2: \
91 asm(op "w %%gs:%c1,%0" : \ 92 asm(op "w %%gs:%c1,%0" : \
92 "=r" (ret__) : \ 93 "=r" (ret__) : \
93 "i" (pda_offset(field)), \ 94 "i" (pda_offset(field)), \
94 "m" (_proxy_pda.field)); \ 95 "m" (_proxy_pda.field)); \
95 break; \ 96 break; \
96 case 4: \ 97 case 4: \
97 asm(op "l %%gs:%c1,%0": \ 98 asm(op "l %%gs:%c1,%0": \
98 "=r" (ret__): \ 99 "=r" (ret__): \
99 "i" (pda_offset(field)), \ 100 "i" (pda_offset(field)), \
100 "m" (_proxy_pda.field)); \ 101 "m" (_proxy_pda.field)); \
101 break; \ 102 break; \
102 case 8: \ 103 case 8: \
103 asm(op "q %%gs:%c1,%0": \ 104 asm(op "q %%gs:%c1,%0": \
104 "=r" (ret__) : \ 105 "=r" (ret__) : \
105 "i" (pda_offset(field)), \ 106 "i" (pda_offset(field)), \
106 "m" (_proxy_pda.field)); \ 107 "m" (_proxy_pda.field)); \
107 break; \ 108 break; \
108 default: \ 109 default: \
109 __bad_pda_field(); \ 110 __bad_pda_field(); \
110 } \ 111 } \
111 ret__; }) 112 ret__; })
112 113
113#define read_pda(field) pda_from_op("mov",field) 114#define read_pda(field) pda_from_op("mov", field)
114#define write_pda(field,val) pda_to_op("mov",field,val) 115#define write_pda(field, val) pda_to_op("mov", field, val)
115#define add_pda(field,val) pda_to_op("add",field,val) 116#define add_pda(field, val) pda_to_op("add", field, val)
116#define sub_pda(field,val) pda_to_op("sub",field,val) 117#define sub_pda(field, val) pda_to_op("sub", field, val)
117#define or_pda(field,val) pda_to_op("or",field,val) 118#define or_pda(field, val) pda_to_op("or", field, val)
118 119
119/* This is not atomic against other CPUs -- CPU preemption needs to be off */ 120/* This is not atomic against other CPUs -- CPU preemption needs to be off */
120#define test_and_clear_bit_pda(bit,field) ({ \ 121#define test_and_clear_bit_pda(bit, field) ({ \
121 int old__; \ 122 int old__; \
122 asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \ 123 asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" \
123 : "=r" (old__), "+m" (_proxy_pda.field) \ 124 : "=r" (old__), "+m" (_proxy_pda.field) \
124 : "dIr" (bit), "i" (pda_offset(field)) : "memory"); \ 125 : "dIr" (bit), "i" (pda_offset(field)) : "memory"); \
125 old__; \ 126 old__; \
126}) 127})
diff --git a/include/asm-x86/percpu.h b/include/asm-x86/percpu.h
index a1aaad274cca..0dec00f27eb4 100644
--- a/include/asm-x86/percpu.h
+++ b/include/asm-x86/percpu.h
@@ -1,5 +1,142 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_PERCPU_H_
2# include "percpu_32.h" 2#define _ASM_X86_PERCPU_H_
3#else 3
4# include "percpu_64.h" 4#ifdef CONFIG_X86_64
5#include <linux/compiler.h>
6
7/* Same as asm-generic/percpu.h, except that we store the per cpu offset
8 in the PDA. Longer term the PDA and every per cpu variable
9 should be just put into a single section and referenced directly
10 from %gs */
11
12#ifdef CONFIG_SMP
13#include <asm/pda.h>
14
15#define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset)
16#define __my_cpu_offset read_pda(data_offset)
17
18#define per_cpu_offset(x) (__per_cpu_offset(x))
19
5#endif 20#endif
21#include <asm-generic/percpu.h>
22
23DECLARE_PER_CPU(struct x8664_pda, pda);
24
25#else /* CONFIG_X86_64 */
26
27#ifdef __ASSEMBLY__
28
29/*
30 * PER_CPU finds an address of a per-cpu variable.
31 *
32 * Args:
33 * var - variable name
34 * reg - 32bit register
35 *
36 * The resulting address is stored in the "reg" argument.
37 *
38 * Example:
39 * PER_CPU(cpu_gdt_descr, %ebx)
40 */
41#ifdef CONFIG_SMP
42#define PER_CPU(var, reg) \
43 movl %fs:per_cpu__##this_cpu_off, reg; \
44 lea per_cpu__##var(reg), reg
45#define PER_CPU_VAR(var) %fs:per_cpu__##var
46#else /* ! SMP */
47#define PER_CPU(var, reg) \
48 movl $per_cpu__##var, reg
49#define PER_CPU_VAR(var) per_cpu__##var
50#endif /* SMP */
51
52#else /* ...!ASSEMBLY */
53
54/*
55 * PER_CPU finds an address of a per-cpu variable.
56 *
57 * Args:
58 * var - variable name
59 * cpu - 32bit register containing the current CPU number
60 *
61 * The resulting address is stored in the "cpu" argument.
62 *
63 * Example:
64 * PER_CPU(cpu_gdt_descr, %ebx)
65 */
66#ifdef CONFIG_SMP
67
68#define __my_cpu_offset x86_read_percpu(this_cpu_off)
69
70/* fs segment starts at (positive) offset == __per_cpu_offset[cpu] */
71#define __percpu_seg "%%fs:"
72
73#else /* !SMP */
74
75#define __percpu_seg ""
76
77#endif /* SMP */
78
79#include <asm-generic/percpu.h>
80
81/* We can use this directly for local CPU (faster). */
82DECLARE_PER_CPU(unsigned long, this_cpu_off);
83
84/* For arch-specific code, we can use direct single-insn ops (they
85 * don't give an lvalue though). */
86extern void __bad_percpu_size(void);
87
88#define percpu_to_op(op,var,val) \
89 do { \
90 typedef typeof(var) T__; \
91 if (0) { T__ tmp__; tmp__ = (val); } \
92 switch (sizeof(var)) { \
93 case 1: \
94 asm(op "b %1,"__percpu_seg"%0" \
95 : "+m" (var) \
96 :"ri" ((T__)val)); \
97 break; \
98 case 2: \
99 asm(op "w %1,"__percpu_seg"%0" \
100 : "+m" (var) \
101 :"ri" ((T__)val)); \
102 break; \
103 case 4: \
104 asm(op "l %1,"__percpu_seg"%0" \
105 : "+m" (var) \
106 :"ri" ((T__)val)); \
107 break; \
108 default: __bad_percpu_size(); \
109 } \
110 } while (0)
111
112#define percpu_from_op(op,var) \
113 ({ \
114 typeof(var) ret__; \
115 switch (sizeof(var)) { \
116 case 1: \
117 asm(op "b "__percpu_seg"%1,%0" \
118 : "=r" (ret__) \
119 : "m" (var)); \
120 break; \
121 case 2: \
122 asm(op "w "__percpu_seg"%1,%0" \
123 : "=r" (ret__) \
124 : "m" (var)); \
125 break; \
126 case 4: \
127 asm(op "l "__percpu_seg"%1,%0" \
128 : "=r" (ret__) \
129 : "m" (var)); \
130 break; \
131 default: __bad_percpu_size(); \
132 } \
133 ret__; })
134
135#define x86_read_percpu(var) percpu_from_op("mov", per_cpu__##var)
136#define x86_write_percpu(var,val) percpu_to_op("mov", per_cpu__##var, val)
137#define x86_add_percpu(var,val) percpu_to_op("add", per_cpu__##var, val)
138#define x86_sub_percpu(var,val) percpu_to_op("sub", per_cpu__##var, val)
139#define x86_or_percpu(var,val) percpu_to_op("or", per_cpu__##var, val)
140#endif /* !__ASSEMBLY__ */
141#endif /* !CONFIG_X86_64 */
142#endif /* _ASM_X86_PERCPU_H_ */
diff --git a/include/asm-x86/percpu_32.h b/include/asm-x86/percpu_32.h
deleted file mode 100644
index a7ebd436f3cc..000000000000
--- a/include/asm-x86/percpu_32.h
+++ /dev/null
@@ -1,154 +0,0 @@
1#ifndef __ARCH_I386_PERCPU__
2#define __ARCH_I386_PERCPU__
3
4#ifdef __ASSEMBLY__
5
6/*
7 * PER_CPU finds an address of a per-cpu variable.
8 *
9 * Args:
10 * var - variable name
11 * reg - 32bit register
12 *
13 * The resulting address is stored in the "reg" argument.
14 *
15 * Example:
16 * PER_CPU(cpu_gdt_descr, %ebx)
17 */
18#ifdef CONFIG_SMP
19#define PER_CPU(var, reg) \
20 movl %fs:per_cpu__##this_cpu_off, reg; \
21 lea per_cpu__##var(reg), reg
22#define PER_CPU_VAR(var) %fs:per_cpu__##var
23#else /* ! SMP */
24#define PER_CPU(var, reg) \
25 movl $per_cpu__##var, reg
26#define PER_CPU_VAR(var) per_cpu__##var
27#endif /* SMP */
28
29#else /* ...!ASSEMBLY */
30
31/*
32 * PER_CPU finds an address of a per-cpu variable.
33 *
34 * Args:
35 * var - variable name
36 * cpu - 32bit register containing the current CPU number
37 *
38 * The resulting address is stored in the "cpu" argument.
39 *
40 * Example:
41 * PER_CPU(cpu_gdt_descr, %ebx)
42 */
43#ifdef CONFIG_SMP
44/* Same as generic implementation except for optimized local access. */
45#define __GENERIC_PER_CPU
46
47/* This is used for other cpus to find our section. */
48extern unsigned long __per_cpu_offset[];
49
50#define per_cpu_offset(x) (__per_cpu_offset[x])
51
52/* Separate out the type, so (int[3], foo) works. */
53#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
54#define DEFINE_PER_CPU(type, name) \
55 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
56
57#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
58 __attribute__((__section__(".data.percpu.shared_aligned"))) \
59 __typeof__(type) per_cpu__##name \
60 ____cacheline_aligned_in_smp
61
62/* We can use this directly for local CPU (faster). */
63DECLARE_PER_CPU(unsigned long, this_cpu_off);
64
65/* var is in discarded region: offset to particular copy we want */
66#define per_cpu(var, cpu) (*({ \
67 extern int simple_indentifier_##var(void); \
68 RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]); }))
69
70#define __raw_get_cpu_var(var) (*({ \
71 extern int simple_indentifier_##var(void); \
72 RELOC_HIDE(&per_cpu__##var, x86_read_percpu(this_cpu_off)); \
73}))
74
75#define __get_cpu_var(var) __raw_get_cpu_var(var)
76
77/* A macro to avoid #include hell... */
78#define percpu_modcopy(pcpudst, src, size) \
79do { \
80 unsigned int __i; \
81 for_each_possible_cpu(__i) \
82 memcpy((pcpudst)+__per_cpu_offset[__i], \
83 (src), (size)); \
84} while (0)
85
86#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
87#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
88
89/* fs segment starts at (positive) offset == __per_cpu_offset[cpu] */
90#define __percpu_seg "%%fs:"
91#else /* !SMP */
92#include <asm-generic/percpu.h>
93#define __percpu_seg ""
94#endif /* SMP */
95
96/* For arch-specific code, we can use direct single-insn ops (they
97 * don't give an lvalue though). */
98extern void __bad_percpu_size(void);
99
100#define percpu_to_op(op,var,val) \
101 do { \
102 typedef typeof(var) T__; \
103 if (0) { T__ tmp__; tmp__ = (val); } \
104 switch (sizeof(var)) { \
105 case 1: \
106 asm(op "b %1,"__percpu_seg"%0" \
107 : "+m" (var) \
108 :"ri" ((T__)val)); \
109 break; \
110 case 2: \
111 asm(op "w %1,"__percpu_seg"%0" \
112 : "+m" (var) \
113 :"ri" ((T__)val)); \
114 break; \
115 case 4: \
116 asm(op "l %1,"__percpu_seg"%0" \
117 : "+m" (var) \
118 :"ri" ((T__)val)); \
119 break; \
120 default: __bad_percpu_size(); \
121 } \
122 } while (0)
123
124#define percpu_from_op(op,var) \
125 ({ \
126 typeof(var) ret__; \
127 switch (sizeof(var)) { \
128 case 1: \
129 asm(op "b "__percpu_seg"%1,%0" \
130 : "=r" (ret__) \
131 : "m" (var)); \
132 break; \
133 case 2: \
134 asm(op "w "__percpu_seg"%1,%0" \
135 : "=r" (ret__) \
136 : "m" (var)); \
137 break; \
138 case 4: \
139 asm(op "l "__percpu_seg"%1,%0" \
140 : "=r" (ret__) \
141 : "m" (var)); \
142 break; \
143 default: __bad_percpu_size(); \
144 } \
145 ret__; })
146
147#define x86_read_percpu(var) percpu_from_op("mov", per_cpu__##var)
148#define x86_write_percpu(var,val) percpu_to_op("mov", per_cpu__##var, val)
149#define x86_add_percpu(var,val) percpu_to_op("add", per_cpu__##var, val)
150#define x86_sub_percpu(var,val) percpu_to_op("sub", per_cpu__##var, val)
151#define x86_or_percpu(var,val) percpu_to_op("or", per_cpu__##var, val)
152#endif /* !__ASSEMBLY__ */
153
154#endif /* __ARCH_I386_PERCPU__ */
diff --git a/include/asm-x86/percpu_64.h b/include/asm-x86/percpu_64.h
deleted file mode 100644
index 5abd48270101..000000000000
--- a/include/asm-x86/percpu_64.h
+++ /dev/null
@@ -1,68 +0,0 @@
1#ifndef _ASM_X8664_PERCPU_H_
2#define _ASM_X8664_PERCPU_H_
3#include <linux/compiler.h>
4
5/* Same as asm-generic/percpu.h, except that we store the per cpu offset
6 in the PDA. Longer term the PDA and every per cpu variable
7 should be just put into a single section and referenced directly
8 from %gs */
9
10#ifdef CONFIG_SMP
11
12#include <asm/pda.h>
13
14#define __per_cpu_offset(cpu) (cpu_pda(cpu)->data_offset)
15#define __my_cpu_offset() read_pda(data_offset)
16
17#define per_cpu_offset(x) (__per_cpu_offset(x))
18
19/* Separate out the type, so (int[3], foo) works. */
20#define DEFINE_PER_CPU(type, name) \
21 __attribute__((__section__(".data.percpu"))) __typeof__(type) per_cpu__##name
22
23#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
24 __attribute__((__section__(".data.percpu.shared_aligned"))) \
25 __typeof__(type) per_cpu__##name \
26 ____cacheline_internodealigned_in_smp
27
28/* var is in discarded region: offset to particular copy we want */
29#define per_cpu(var, cpu) (*({ \
30 extern int simple_identifier_##var(void); \
31 RELOC_HIDE(&per_cpu__##var, __per_cpu_offset(cpu)); }))
32#define __get_cpu_var(var) (*({ \
33 extern int simple_identifier_##var(void); \
34 RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); }))
35#define __raw_get_cpu_var(var) (*({ \
36 extern int simple_identifier_##var(void); \
37 RELOC_HIDE(&per_cpu__##var, __my_cpu_offset()); }))
38
39/* A macro to avoid #include hell... */
40#define percpu_modcopy(pcpudst, src, size) \
41do { \
42 unsigned int __i; \
43 for_each_possible_cpu(__i) \
44 memcpy((pcpudst)+__per_cpu_offset(__i), \
45 (src), (size)); \
46} while (0)
47
48extern void setup_per_cpu_areas(void);
49
50#else /* ! SMP */
51
52#define DEFINE_PER_CPU(type, name) \
53 __typeof__(type) per_cpu__##name
54#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
55 DEFINE_PER_CPU(type, name)
56
57#define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
58#define __get_cpu_var(var) per_cpu__##var
59#define __raw_get_cpu_var(var) per_cpu__##var
60
61#endif /* SMP */
62
63#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name
64
65#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
66#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
67
68#endif /* _ASM_X8664_PERCPU_H_ */
diff --git a/include/asm-x86/pgalloc_32.h b/include/asm-x86/pgalloc_32.h
index f2fc33ceb9f2..7641e7b5d931 100644
--- a/include/asm-x86/pgalloc_32.h
+++ b/include/asm-x86/pgalloc_32.h
@@ -3,31 +3,34 @@
3 3
4#include <linux/threads.h> 4#include <linux/threads.h>
5#include <linux/mm.h> /* for struct page */ 5#include <linux/mm.h> /* for struct page */
6#include <linux/pagemap.h>
7#include <asm/tlb.h>
8#include <asm-generic/tlb.h>
6 9
7#ifdef CONFIG_PARAVIRT 10#ifdef CONFIG_PARAVIRT
8#include <asm/paravirt.h> 11#include <asm/paravirt.h>
9#else 12#else
10#define paravirt_alloc_pt(mm, pfn) do { } while (0) 13#define paravirt_alloc_pt(mm, pfn) do { } while (0)
11#define paravirt_alloc_pd(pfn) do { } while (0) 14#define paravirt_alloc_pd(mm, pfn) do { } while (0)
12#define paravirt_alloc_pd(pfn) do { } while (0)
13#define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0) 15#define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0)
14#define paravirt_release_pt(pfn) do { } while (0) 16#define paravirt_release_pt(pfn) do { } while (0)
15#define paravirt_release_pd(pfn) do { } while (0) 17#define paravirt_release_pd(pfn) do { } while (0)
16#endif 18#endif
17 19
18#define pmd_populate_kernel(mm, pmd, pte) \ 20static inline void pmd_populate_kernel(struct mm_struct *mm,
19do { \ 21 pmd_t *pmd, pte_t *pte)
20 paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT); \ 22{
21 set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))); \ 23 paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT);
22} while (0) 24 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
25}
23 26
24#define pmd_populate(mm, pmd, pte) \ 27static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *pte)
25do { \ 28{
26 paravirt_alloc_pt(mm, page_to_pfn(pte)); \ 29 unsigned long pfn = page_to_pfn(pte);
27 set_pmd(pmd, __pmd(_PAGE_TABLE + \ 30
28 ((unsigned long long)page_to_pfn(pte) << \ 31 paravirt_alloc_pt(mm, pfn);
29 (unsigned long long) PAGE_SHIFT))); \ 32 set_pmd(pmd, __pmd(((pteval_t)pfn << PAGE_SHIFT) | _PAGE_TABLE));
30} while (0) 33}
31 34
32/* 35/*
33 * Allocate and free page tables. 36 * Allocate and free page tables.
@@ -49,20 +52,40 @@ static inline void pte_free(struct page *pte)
49} 52}
50 53
51 54
52#define __pte_free_tlb(tlb,pte) \ 55extern void __pte_free_tlb(struct mmu_gather *tlb, struct page *pte);
53do { \
54 paravirt_release_pt(page_to_pfn(pte)); \
55 tlb_remove_page((tlb),(pte)); \
56} while (0)
57 56
58#ifdef CONFIG_X86_PAE 57#ifdef CONFIG_X86_PAE
59/* 58/*
60 * In the PAE case we free the pmds as part of the pgd. 59 * In the PAE case we free the pmds as part of the pgd.
61 */ 60 */
62#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); }) 61static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
63#define pmd_free(x) do { } while (0) 62{
64#define __pmd_free_tlb(tlb,x) do { } while (0) 63 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
65#define pud_populate(mm, pmd, pte) BUG() 64}
66#endif 65
66static inline void pmd_free(pmd_t *pmd)
67{
68 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
69 free_page((unsigned long)pmd);
70}
71
72extern void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd);
73
74static inline void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
75{
76 paravirt_alloc_pd(mm, __pa(pmd) >> PAGE_SHIFT);
77
78 /* Note: almost everything apart from _PAGE_PRESENT is
79 reserved at the pmd (PDPT) level. */
80 set_pud(pudp, __pud(__pa(pmd) | _PAGE_PRESENT));
81
82 /*
83 * Pentium-II erratum A13: in PAE mode we explicitly have to flush
84 * the TLB via cr3 if the top-level pgd is changed...
85 */
86 if (mm == current->active_mm)
87 write_cr3(read_cr3());
88}
89#endif /* CONFIG_X86_PAE */
67 90
68#endif /* _I386_PGALLOC_H */ 91#endif /* _I386_PGALLOC_H */
diff --git a/include/asm-x86/pgtable-2level.h b/include/asm-x86/pgtable-2level.h
index 84b03cf56a79..701404fab308 100644
--- a/include/asm-x86/pgtable-2level.h
+++ b/include/asm-x86/pgtable-2level.h
@@ -15,30 +15,31 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
15{ 15{
16 *ptep = pte; 16 *ptep = pte;
17} 17}
18static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr, 18
19 pte_t *ptep , pte_t pte)
20{
21 native_set_pte(ptep, pte);
22}
23static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd) 19static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
24{ 20{
25 *pmdp = pmd; 21 *pmdp = pmd;
26} 22}
27#ifndef CONFIG_PARAVIRT
28#define set_pte(pteptr, pteval) native_set_pte(pteptr, pteval)
29#define set_pte_at(mm,addr,ptep,pteval) native_set_pte_at(mm, addr, ptep, pteval)
30#define set_pmd(pmdptr, pmdval) native_set_pmd(pmdptr, pmdval)
31#endif
32 23
33#define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval) 24static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
34#define set_pte_present(mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval) 25{
26 native_set_pte(ptep, pte);
27}
35 28
36#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0) 29static inline void native_set_pte_present(struct mm_struct *mm, unsigned long addr,
37#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0) 30 pte_t *ptep, pte_t pte)
31{
32 native_set_pte(ptep, pte);
33}
34
35static inline void native_pmd_clear(pmd_t *pmdp)
36{
37 native_set_pmd(pmdp, __pmd(0));
38}
38 39
39static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *xp) 40static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr, pte_t *xp)
40{ 41{
41 *xp = __pte(0); 42 *xp = native_make_pte(0);
42} 43}
43 44
44#ifdef CONFIG_SMP 45#ifdef CONFIG_SMP
@@ -53,16 +54,6 @@ static inline pte_t native_ptep_get_and_clear(pte_t *xp)
53#define pte_page(x) pfn_to_page(pte_pfn(x)) 54#define pte_page(x) pfn_to_page(pte_pfn(x))
54#define pte_none(x) (!(x).pte_low) 55#define pte_none(x) (!(x).pte_low)
55#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT) 56#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
56#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
57#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
58
59/*
60 * All present pages are kernel-executable:
61 */
62static inline int pte_exec_kernel(pte_t pte)
63{
64 return 1;
65}
66 57
67/* 58/*
68 * Bits 0, 6 and 7 are taken, split up the 29 bits of offset 59 * Bits 0, 6 and 7 are taken, split up the 29 bits of offset
@@ -74,13 +65,13 @@ static inline int pte_exec_kernel(pte_t pte)
74 ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 )) 65 ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 ))
75 66
76#define pgoff_to_pte(off) \ 67#define pgoff_to_pte(off) \
77 ((pte_t) { (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE }) 68 ((pte_t) { .pte_low = (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE })
78 69
79/* Encode and de-code a swap entry */ 70/* Encode and de-code a swap entry */
80#define __swp_type(x) (((x).val >> 1) & 0x1f) 71#define __swp_type(x) (((x).val >> 1) & 0x1f)
81#define __swp_offset(x) ((x).val >> 8) 72#define __swp_offset(x) ((x).val >> 8)
82#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) 73#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })
83#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low }) 74#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low })
84#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 75#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val })
85 76
86#endif /* _I386_PGTABLE_2LEVEL_H */ 77#endif /* _I386_PGTABLE_2LEVEL_H */
diff --git a/include/asm-x86/pgtable-3level.h b/include/asm-x86/pgtable-3level.h
index 948a33414118..a195c3e757b9 100644
--- a/include/asm-x86/pgtable-3level.h
+++ b/include/asm-x86/pgtable-3level.h
@@ -15,16 +15,18 @@
15#define pgd_ERROR(e) \ 15#define pgd_ERROR(e) \
16 printk("%s:%d: bad pgd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pgd_val(e)) 16 printk("%s:%d: bad pgd %p(%016Lx).\n", __FILE__, __LINE__, &(e), pgd_val(e))
17 17
18#define pud_none(pud) 0
19#define pud_bad(pud) 0
20#define pud_present(pud) 1
21 18
22/* 19static inline int pud_none(pud_t pud)
23 * All present pages with !NX bit are kernel-executable: 20{
24 */ 21 return pud_val(pud) == 0;
25static inline int pte_exec_kernel(pte_t pte) 22}
23static inline int pud_bad(pud_t pud)
24{
25 return (pud_val(pud) & ~(PTE_MASK | _KERNPG_TABLE | _PAGE_USER)) != 0;
26}
27static inline int pud_present(pud_t pud)
26{ 28{
27 return !(pte_val(pte) & _PAGE_NX); 29 return pud_val(pud) & _PAGE_PRESENT;
28} 30}
29 31
30/* Rules for using set_pte: the pte being assigned *must* be 32/* Rules for using set_pte: the pte being assigned *must* be
@@ -39,11 +41,6 @@ static inline void native_set_pte(pte_t *ptep, pte_t pte)
39 smp_wmb(); 41 smp_wmb();
40 ptep->pte_low = pte.pte_low; 42 ptep->pte_low = pte.pte_low;
41} 43}
42static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
43 pte_t *ptep , pte_t pte)
44{
45 native_set_pte(ptep, pte);
46}
47 44
48/* 45/*
49 * Since this is only called on user PTEs, and the page fault handler 46 * Since this is only called on user PTEs, and the page fault handler
@@ -71,7 +68,7 @@ static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
71} 68}
72static inline void native_set_pud(pud_t *pudp, pud_t pud) 69static inline void native_set_pud(pud_t *pudp, pud_t pud)
73{ 70{
74 *pudp = pud; 71 set_64bit((unsigned long long *)(pudp),native_pud_val(pud));
75} 72}
76 73
77/* 74/*
@@ -94,24 +91,29 @@ static inline void native_pmd_clear(pmd_t *pmd)
94 *(tmp + 1) = 0; 91 *(tmp + 1) = 0;
95} 92}
96 93
97#ifndef CONFIG_PARAVIRT 94static inline void pud_clear(pud_t *pudp)
98#define set_pte(ptep, pte) native_set_pte(ptep, pte) 95{
99#define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte) 96 set_pud(pudp, __pud(0));
100#define set_pte_present(mm, addr, ptep, pte) native_set_pte_present(mm, addr, ptep, pte) 97
101#define set_pte_atomic(ptep, pte) native_set_pte_atomic(ptep, pte) 98 /*
102#define set_pmd(pmdp, pmd) native_set_pmd(pmdp, pmd) 99 * In principle we need to do a cr3 reload here to make sure
103#define set_pud(pudp, pud) native_set_pud(pudp, pud) 100 * the processor recognizes the changed pgd. In practice, all
104#define pte_clear(mm, addr, ptep) native_pte_clear(mm, addr, ptep) 101 * the places where pud_clear() gets called are followed by
105#define pmd_clear(pmd) native_pmd_clear(pmd) 102 * full tlb flushes anyway, so we can defer the cost here.
106#endif 103 *
107 104 * Specifically:
108/* 105 *
109 * Pentium-II erratum A13: in PAE mode we explicitly have to flush 106 * mm/memory.c:free_pmd_range() - immediately after the
110 * the TLB via cr3 if the top-level pgd is changed... 107 * pud_clear() it does a pmd_free_tlb(). We change the
111 * We do not let the generic code free and clear pgd entries due to 108 * mmu_gather structure to do a full tlb flush (which has the
112 * this erratum. 109 * effect of reloading cr3) when the pagetable free is
113 */ 110 * complete.
114static inline void pud_clear (pud_t * pud) { } 111 *
112 * arch/x86/mm/hugetlbpage.c:huge_pmd_unshare() - the call to
113 * this is followed by a flush_tlb_range, which on x86 does a
114 * full tlb flush.
115 */
116}
115 117
116#define pud_page(pud) \ 118#define pud_page(pud) \
117((struct page *) __va(pud_val(pud) & PAGE_MASK)) 119((struct page *) __va(pud_val(pud) & PAGE_MASK))
@@ -155,21 +157,7 @@ static inline int pte_none(pte_t pte)
155 157
156static inline unsigned long pte_pfn(pte_t pte) 158static inline unsigned long pte_pfn(pte_t pte)
157{ 159{
158 return pte_val(pte) >> PAGE_SHIFT; 160 return (pte_val(pte) & ~_PAGE_NX) >> PAGE_SHIFT;
159}
160
161extern unsigned long long __supported_pte_mask;
162
163static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
164{
165 return __pte((((unsigned long long)page_nr << PAGE_SHIFT) |
166 pgprot_val(pgprot)) & __supported_pte_mask);
167}
168
169static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
170{
171 return __pmd((((unsigned long long)page_nr << PAGE_SHIFT) |
172 pgprot_val(pgprot)) & __supported_pte_mask);
173} 161}
174 162
175/* 163/*
@@ -177,7 +165,7 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
177 * put the 32 bits of offset into the high part. 165 * put the 32 bits of offset into the high part.
178 */ 166 */
179#define pte_to_pgoff(pte) ((pte).pte_high) 167#define pte_to_pgoff(pte) ((pte).pte_high)
180#define pgoff_to_pte(off) ((pte_t) { _PAGE_FILE, (off) }) 168#define pgoff_to_pte(off) ((pte_t) { { .pte_low = _PAGE_FILE, .pte_high = (off) } })
181#define PTE_FILE_MAX_BITS 32 169#define PTE_FILE_MAX_BITS 32
182 170
183/* Encode and de-code a swap entry */ 171/* Encode and de-code a swap entry */
@@ -185,8 +173,6 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
185#define __swp_offset(x) ((x).val >> 5) 173#define __swp_offset(x) ((x).val >> 5)
186#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5}) 174#define __swp_entry(type, offset) ((swp_entry_t){(type) | (offset) << 5})
187#define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high }) 175#define __pte_to_swp_entry(pte) ((swp_entry_t){ (pte).pte_high })
188#define __swp_entry_to_pte(x) ((pte_t){ 0, (x).val }) 176#define __swp_entry_to_pte(x) ((pte_t){ { .pte_high = (x).val } })
189
190#define __pmd_free_tlb(tlb, x) do { } while (0)
191 177
192#endif /* _I386_PGTABLE_3LEVEL_H */ 178#endif /* _I386_PGTABLE_3LEVEL_H */
diff --git a/include/asm-x86/pgtable.h b/include/asm-x86/pgtable.h
index 1039140652af..cd2524f07452 100644
--- a/include/asm-x86/pgtable.h
+++ b/include/asm-x86/pgtable.h
@@ -1,5 +1,364 @@
1#ifndef _ASM_X86_PGTABLE_H
2#define _ASM_X86_PGTABLE_H
3
4#define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1)
5#define FIRST_USER_ADDRESS 0
6
7#define _PAGE_BIT_PRESENT 0
8#define _PAGE_BIT_RW 1
9#define _PAGE_BIT_USER 2
10#define _PAGE_BIT_PWT 3
11#define _PAGE_BIT_PCD 4
12#define _PAGE_BIT_ACCESSED 5
13#define _PAGE_BIT_DIRTY 6
14#define _PAGE_BIT_FILE 6
15#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
16#define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
17#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
18#define _PAGE_BIT_UNUSED2 10
19#define _PAGE_BIT_UNUSED3 11
20#define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
21
22/*
23 * Note: we use _AC(1, L) instead of _AC(1, UL) so that we get a
24 * sign-extended value on 32-bit with all 1's in the upper word,
25 * which preserves the upper pte values on 64-bit ptes:
26 */
27#define _PAGE_PRESENT (_AC(1, L)<<_PAGE_BIT_PRESENT)
28#define _PAGE_RW (_AC(1, L)<<_PAGE_BIT_RW)
29#define _PAGE_USER (_AC(1, L)<<_PAGE_BIT_USER)
30#define _PAGE_PWT (_AC(1, L)<<_PAGE_BIT_PWT)
31#define _PAGE_PCD (_AC(1, L)<<_PAGE_BIT_PCD)
32#define _PAGE_ACCESSED (_AC(1, L)<<_PAGE_BIT_ACCESSED)
33#define _PAGE_DIRTY (_AC(1, L)<<_PAGE_BIT_DIRTY)
34#define _PAGE_PSE (_AC(1, L)<<_PAGE_BIT_PSE) /* 2MB page */
35#define _PAGE_GLOBAL (_AC(1, L)<<_PAGE_BIT_GLOBAL) /* Global TLB entry */
36#define _PAGE_UNUSED1 (_AC(1, L)<<_PAGE_BIT_UNUSED1)
37#define _PAGE_UNUSED2 (_AC(1, L)<<_PAGE_BIT_UNUSED2)
38#define _PAGE_UNUSED3 (_AC(1, L)<<_PAGE_BIT_UNUSED3)
39
40#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
41#define _PAGE_NX (_AC(1, ULL) << _PAGE_BIT_NX)
42#else
43#define _PAGE_NX 0
44#endif
45
46/* If _PAGE_PRESENT is clear, we use these: */
47#define _PAGE_FILE _PAGE_DIRTY /* nonlinear file mapping, saved PTE; unset:swap */
48#define _PAGE_PROTNONE _PAGE_PSE /* if the user mapped it with PROT_NONE;
49 pte_present gives true */
50
51#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
52#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
53
54#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
55
56#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
57#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
58
59#define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
60#define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
61#define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
62#define PAGE_COPY PAGE_COPY_NOEXEC
63#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
64#define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
65
66#ifdef CONFIG_X86_32
67#define _PAGE_KERNEL_EXEC \
68 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
69#define _PAGE_KERNEL (_PAGE_KERNEL_EXEC | _PAGE_NX)
70
71#ifndef __ASSEMBLY__
72extern pteval_t __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
73#endif /* __ASSEMBLY__ */
74#else
75#define __PAGE_KERNEL_EXEC \
76 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
77#define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
78#endif
79
80#define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
81#define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
82#define __PAGE_KERNEL_EXEC_NOCACHE (__PAGE_KERNEL_EXEC | _PAGE_PCD | _PAGE_PWT)
83#define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
84#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
85#define __PAGE_KERNEL_VSYSCALL_NOCACHE (__PAGE_KERNEL_VSYSCALL | _PAGE_PCD | _PAGE_PWT)
86#define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
87#define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
88
89#ifdef CONFIG_X86_32
90# define MAKE_GLOBAL(x) __pgprot((x))
91#else
92# define MAKE_GLOBAL(x) __pgprot((x) | _PAGE_GLOBAL)
93#endif
94
95#define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL)
96#define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO)
97#define PAGE_KERNEL_EXEC MAKE_GLOBAL(__PAGE_KERNEL_EXEC)
98#define PAGE_KERNEL_RX MAKE_GLOBAL(__PAGE_KERNEL_RX)
99#define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE)
100#define PAGE_KERNEL_EXEC_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_EXEC_NOCACHE)
101#define PAGE_KERNEL_LARGE MAKE_GLOBAL(__PAGE_KERNEL_LARGE)
102#define PAGE_KERNEL_LARGE_EXEC MAKE_GLOBAL(__PAGE_KERNEL_LARGE_EXEC)
103#define PAGE_KERNEL_VSYSCALL MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL)
104#define PAGE_KERNEL_VSYSCALL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL_NOCACHE)
105
106/* xwr */
107#define __P000 PAGE_NONE
108#define __P001 PAGE_READONLY
109#define __P010 PAGE_COPY
110#define __P011 PAGE_COPY
111#define __P100 PAGE_READONLY_EXEC
112#define __P101 PAGE_READONLY_EXEC
113#define __P110 PAGE_COPY_EXEC
114#define __P111 PAGE_COPY_EXEC
115
116#define __S000 PAGE_NONE
117#define __S001 PAGE_READONLY
118#define __S010 PAGE_SHARED
119#define __S011 PAGE_SHARED
120#define __S100 PAGE_READONLY_EXEC
121#define __S101 PAGE_READONLY_EXEC
122#define __S110 PAGE_SHARED_EXEC
123#define __S111 PAGE_SHARED_EXEC
124
125#ifndef __ASSEMBLY__
126
127/*
128 * ZERO_PAGE is a global shared page that is always zero: used
129 * for zero-mapped memory areas etc..
130 */
131extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
132#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
133
134extern spinlock_t pgd_lock;
135extern struct list_head pgd_list;
136
137/*
138 * The following only work if pte_present() is true.
139 * Undefined behaviour if not..
140 */
141static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
142static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
143static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
144static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
145static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; }
146static inline int pte_global(pte_t pte) { return pte_val(pte) & _PAGE_GLOBAL; }
147static inline int pte_exec(pte_t pte) { return !(pte_val(pte) & _PAGE_NX); }
148
149static inline int pmd_large(pmd_t pte) {
150 return (pmd_val(pte) & (_PAGE_PSE|_PAGE_PRESENT)) ==
151 (_PAGE_PSE|_PAGE_PRESENT);
152}
153
154static inline pte_t pte_mkclean(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_DIRTY); }
155static inline pte_t pte_mkold(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_ACCESSED); }
156static inline pte_t pte_wrprotect(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_RW); }
157static inline pte_t pte_mkexec(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_NX); }
158static inline pte_t pte_mkdirty(pte_t pte) { return __pte(pte_val(pte) | _PAGE_DIRTY); }
159static inline pte_t pte_mkyoung(pte_t pte) { return __pte(pte_val(pte) | _PAGE_ACCESSED); }
160static inline pte_t pte_mkwrite(pte_t pte) { return __pte(pte_val(pte) | _PAGE_RW); }
161static inline pte_t pte_mkhuge(pte_t pte) { return __pte(pte_val(pte) | _PAGE_PSE); }
162static inline pte_t pte_clrhuge(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_PSE); }
163static inline pte_t pte_mkglobal(pte_t pte) { return __pte(pte_val(pte) | _PAGE_GLOBAL); }
164static inline pte_t pte_clrglobal(pte_t pte) { return __pte(pte_val(pte) & ~(pteval_t)_PAGE_GLOBAL); }
165
166extern pteval_t __supported_pte_mask;
167
168static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
169{
170 return __pte((((phys_addr_t)page_nr << PAGE_SHIFT) |
171 pgprot_val(pgprot)) & __supported_pte_mask);
172}
173
174static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
175{
176 return __pmd((((phys_addr_t)page_nr << PAGE_SHIFT) |
177 pgprot_val(pgprot)) & __supported_pte_mask);
178}
179
180static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
181{
182 pteval_t val = pte_val(pte);
183
184 /*
185 * Chop off the NX bit (if present), and add the NX portion of
186 * the newprot (if present):
187 */
188 val &= _PAGE_CHG_MASK & ~_PAGE_NX;
189 val |= pgprot_val(newprot) & __supported_pte_mask;
190
191 return __pte(val);
192}
193
194#define pte_pgprot(x) __pgprot(pte_val(x) & (0xfff | _PAGE_NX))
195
196#define canon_pgprot(p) __pgprot(pgprot_val(p) & __supported_pte_mask)
197
198#ifdef CONFIG_PARAVIRT
199#include <asm/paravirt.h>
200#else /* !CONFIG_PARAVIRT */
201#define set_pte(ptep, pte) native_set_pte(ptep, pte)
202#define set_pte_at(mm, addr, ptep, pte) native_set_pte_at(mm, addr, ptep, pte)
203
204#define set_pte_present(mm, addr, ptep, pte) \
205 native_set_pte_present(mm, addr, ptep, pte)
206#define set_pte_atomic(ptep, pte) \
207 native_set_pte_atomic(ptep, pte)
208
209#define set_pmd(pmdp, pmd) native_set_pmd(pmdp, pmd)
210
211#ifndef __PAGETABLE_PUD_FOLDED
212#define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
213#define pgd_clear(pgd) native_pgd_clear(pgd)
214#endif
215
216#ifndef set_pud
217# define set_pud(pudp, pud) native_set_pud(pudp, pud)
218#endif
219
220#ifndef __PAGETABLE_PMD_FOLDED
221#define pud_clear(pud) native_pud_clear(pud)
222#endif
223
224#define pte_clear(mm, addr, ptep) native_pte_clear(mm, addr, ptep)
225#define pmd_clear(pmd) native_pmd_clear(pmd)
226
227#define pte_update(mm, addr, ptep) do { } while (0)
228#define pte_update_defer(mm, addr, ptep) do { } while (0)
229#endif /* CONFIG_PARAVIRT */
230
231#endif /* __ASSEMBLY__ */
232
1#ifdef CONFIG_X86_32 233#ifdef CONFIG_X86_32
2# include "pgtable_32.h" 234# include "pgtable_32.h"
3#else 235#else
4# include "pgtable_64.h" 236# include "pgtable_64.h"
5#endif 237#endif
238
239#ifndef __ASSEMBLY__
240
241enum {
242 PG_LEVEL_NONE,
243 PG_LEVEL_4K,
244 PG_LEVEL_2M,
245 PG_LEVEL_1G,
246};
247
248/*
249 * Helper function that returns the kernel pagetable entry controlling
250 * the virtual address 'address'. NULL means no pagetable entry present.
251 * NOTE: the return type is pte_t but if the pmd is PSE then we return it
252 * as a pte too.
253 */
254extern pte_t *lookup_address(unsigned long address, int *level);
255
256/* local pte updates need not use xchg for locking */
257static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
258{
259 pte_t res = *ptep;
260
261 /* Pure native function needs no input for mm, addr */
262 native_pte_clear(NULL, 0, ptep);
263 return res;
264}
265
266static inline void native_set_pte_at(struct mm_struct *mm, unsigned long addr,
267 pte_t *ptep , pte_t pte)
268{
269 native_set_pte(ptep, pte);
270}
271
272#ifndef CONFIG_PARAVIRT
273/*
274 * Rules for using pte_update - it must be called after any PTE update which
275 * has not been done using the set_pte / clear_pte interfaces. It is used by
276 * shadow mode hypervisors to resynchronize the shadow page tables. Kernel PTE
277 * updates should either be sets, clears, or set_pte_atomic for P->P
278 * transitions, which means this hook should only be called for user PTEs.
279 * This hook implies a P->P protection or access change has taken place, which
280 * requires a subsequent TLB flush. The notification can optionally be delayed
281 * until the TLB flush event by using the pte_update_defer form of the
282 * interface, but care must be taken to assure that the flush happens while
283 * still holding the same page table lock so that the shadow and primary pages
284 * do not become out of sync on SMP.
285 */
286#define pte_update(mm, addr, ptep) do { } while (0)
287#define pte_update_defer(mm, addr, ptep) do { } while (0)
288#endif
289
290/*
291 * We only update the dirty/accessed state if we set
292 * the dirty bit by hand in the kernel, since the hardware
293 * will do the accessed bit for us, and we don't want to
294 * race with other CPU's that might be updating the dirty
295 * bit at the same time.
296 */
297#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
298#define ptep_set_access_flags(vma, address, ptep, entry, dirty) \
299({ \
300 int __changed = !pte_same(*(ptep), entry); \
301 if (__changed && dirty) { \
302 *ptep = entry; \
303 pte_update_defer((vma)->vm_mm, (address), (ptep)); \
304 flush_tlb_page(vma, address); \
305 } \
306 __changed; \
307})
308
309#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
310#define ptep_test_and_clear_young(vma, addr, ptep) ({ \
311 int __ret = 0; \
312 if (pte_young(*(ptep))) \
313 __ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, \
314 &(ptep)->pte); \
315 if (__ret) \
316 pte_update((vma)->vm_mm, addr, ptep); \
317 __ret; \
318})
319
320#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
321#define ptep_clear_flush_young(vma, address, ptep) \
322({ \
323 int __young; \
324 __young = ptep_test_and_clear_young((vma), (address), (ptep)); \
325 if (__young) \
326 flush_tlb_page(vma, address); \
327 __young; \
328})
329
330#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
331static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
332{
333 pte_t pte = native_ptep_get_and_clear(ptep);
334 pte_update(mm, addr, ptep);
335 return pte;
336}
337
338#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
339static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
340{
341 pte_t pte;
342 if (full) {
343 /*
344 * Full address destruction in progress; paravirt does not
345 * care about updates and native needs no locking
346 */
347 pte = native_local_ptep_get_and_clear(ptep);
348 } else {
349 pte = ptep_get_and_clear(mm, addr, ptep);
350 }
351 return pte;
352}
353
354#define __HAVE_ARCH_PTEP_SET_WRPROTECT
355static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
356{
357 clear_bit(_PAGE_BIT_RW, (unsigned long *)&ptep->pte);
358 pte_update(mm, addr, ptep);
359}
360
361#include <asm-generic/pgtable.h>
362#endif /* __ASSEMBLY__ */
363
364#endif /* _ASM_X86_PGTABLE_H */
diff --git a/include/asm-x86/pgtable_32.h b/include/asm-x86/pgtable_32.h
index ed3e70d8d04b..21e70fbf1dae 100644
--- a/include/asm-x86/pgtable_32.h
+++ b/include/asm-x86/pgtable_32.h
@@ -25,20 +25,11 @@
25struct mm_struct; 25struct mm_struct;
26struct vm_area_struct; 26struct vm_area_struct;
27 27
28/*
29 * ZERO_PAGE is a global shared page that is always zero: used
30 * for zero-mapped memory areas etc..
31 */
32#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
33extern unsigned long empty_zero_page[1024];
34extern pgd_t swapper_pg_dir[1024]; 28extern pgd_t swapper_pg_dir[1024];
35extern struct kmem_cache *pmd_cache; 29extern struct kmem_cache *pmd_cache;
36extern spinlock_t pgd_lock;
37extern struct page *pgd_list;
38void check_pgt_cache(void); 30void check_pgt_cache(void);
39 31
40void pmd_ctor(struct kmem_cache *, void *); 32static inline void pgtable_cache_init(void) {}
41void pgtable_cache_init(void);
42void paging_init(void); 33void paging_init(void);
43 34
44 35
@@ -58,9 +49,6 @@ void paging_init(void);
58#define PGDIR_SIZE (1UL << PGDIR_SHIFT) 49#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
59#define PGDIR_MASK (~(PGDIR_SIZE-1)) 50#define PGDIR_MASK (~(PGDIR_SIZE-1))
60 51
61#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
62#define FIRST_USER_ADDRESS 0
63
64#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT) 52#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
65#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS) 53#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
66 54
@@ -85,113 +73,6 @@ void paging_init(void);
85#endif 73#endif
86 74
87/* 75/*
88 * _PAGE_PSE set in the page directory entry just means that
89 * the page directory entry points directly to a 4MB-aligned block of
90 * memory.
91 */
92#define _PAGE_BIT_PRESENT 0
93#define _PAGE_BIT_RW 1
94#define _PAGE_BIT_USER 2
95#define _PAGE_BIT_PWT 3
96#define _PAGE_BIT_PCD 4
97#define _PAGE_BIT_ACCESSED 5
98#define _PAGE_BIT_DIRTY 6
99#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page, Pentium+, if present.. */
100#define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
101#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
102#define _PAGE_BIT_UNUSED2 10
103#define _PAGE_BIT_UNUSED3 11
104#define _PAGE_BIT_NX 63
105
106#define _PAGE_PRESENT 0x001
107#define _PAGE_RW 0x002
108#define _PAGE_USER 0x004
109#define _PAGE_PWT 0x008
110#define _PAGE_PCD 0x010
111#define _PAGE_ACCESSED 0x020
112#define _PAGE_DIRTY 0x040
113#define _PAGE_PSE 0x080 /* 4 MB (or 2MB) page, Pentium+, if present.. */
114#define _PAGE_GLOBAL 0x100 /* Global TLB entry PPro+ */
115#define _PAGE_UNUSED1 0x200 /* available for programmer */
116#define _PAGE_UNUSED2 0x400
117#define _PAGE_UNUSED3 0x800
118
119/* If _PAGE_PRESENT is clear, we use these: */
120#define _PAGE_FILE 0x040 /* nonlinear file mapping, saved PTE; unset:swap */
121#define _PAGE_PROTNONE 0x080 /* if the user mapped it with PROT_NONE;
122 pte_present gives true */
123#ifdef CONFIG_X86_PAE
124#define _PAGE_NX (1ULL<<_PAGE_BIT_NX)
125#else
126#define _PAGE_NX 0
127#endif
128
129#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
130#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
131#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
132
133#define PAGE_NONE \
134 __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
135#define PAGE_SHARED \
136 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
137
138#define PAGE_SHARED_EXEC \
139 __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
140#define PAGE_COPY_NOEXEC \
141 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
142#define PAGE_COPY_EXEC \
143 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
144#define PAGE_COPY \
145 PAGE_COPY_NOEXEC
146#define PAGE_READONLY \
147 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
148#define PAGE_READONLY_EXEC \
149 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
150
151#define _PAGE_KERNEL \
152 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
153#define _PAGE_KERNEL_EXEC \
154 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
155
156extern unsigned long long __PAGE_KERNEL, __PAGE_KERNEL_EXEC;
157#define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
158#define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
159#define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD)
160#define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
161#define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
162
163#define PAGE_KERNEL __pgprot(__PAGE_KERNEL)
164#define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO)
165#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC)
166#define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX)
167#define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE)
168#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE)
169#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC)
170
171/*
172 * The i386 can't do page protection for execute, and considers that
173 * the same are read. Also, write permissions imply read permissions.
174 * This is the closest we can get..
175 */
176#define __P000 PAGE_NONE
177#define __P001 PAGE_READONLY
178#define __P010 PAGE_COPY
179#define __P011 PAGE_COPY
180#define __P100 PAGE_READONLY_EXEC
181#define __P101 PAGE_READONLY_EXEC
182#define __P110 PAGE_COPY_EXEC
183#define __P111 PAGE_COPY_EXEC
184
185#define __S000 PAGE_NONE
186#define __S001 PAGE_READONLY
187#define __S010 PAGE_SHARED
188#define __S011 PAGE_SHARED
189#define __S100 PAGE_READONLY_EXEC
190#define __S101 PAGE_READONLY_EXEC
191#define __S110 PAGE_SHARED_EXEC
192#define __S111 PAGE_SHARED_EXEC
193
194/*
195 * Define this if things work differently on an i386 and an i486: 76 * Define this if things work differently on an i386 and an i486:
196 * it will (on an i486) warn about kernel memory accesses that are 77 * it will (on an i486) warn about kernel memory accesses that are
197 * done without a 'access_ok(VERIFY_WRITE,..)' 78 * done without a 'access_ok(VERIFY_WRITE,..)'
@@ -211,133 +92,12 @@ extern unsigned long pg0[];
211 92
212#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) 93#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
213 94
214/*
215 * The following only work if pte_present() is true.
216 * Undefined behaviour if not..
217 */
218static inline int pte_dirty(pte_t pte) { return (pte).pte_low & _PAGE_DIRTY; }
219static inline int pte_young(pte_t pte) { return (pte).pte_low & _PAGE_ACCESSED; }
220static inline int pte_write(pte_t pte) { return (pte).pte_low & _PAGE_RW; }
221static inline int pte_huge(pte_t pte) { return (pte).pte_low & _PAGE_PSE; }
222
223/*
224 * The following only works if pte_present() is not true.
225 */
226static inline int pte_file(pte_t pte) { return (pte).pte_low & _PAGE_FILE; }
227
228static inline pte_t pte_mkclean(pte_t pte) { (pte).pte_low &= ~_PAGE_DIRTY; return pte; }
229static inline pte_t pte_mkold(pte_t pte) { (pte).pte_low &= ~_PAGE_ACCESSED; return pte; }
230static inline pte_t pte_wrprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_RW; return pte; }
231static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte_low |= _PAGE_DIRTY; return pte; }
232static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte_low |= _PAGE_ACCESSED; return pte; }
233static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte_low |= _PAGE_RW; return pte; }
234static inline pte_t pte_mkhuge(pte_t pte) { (pte).pte_low |= _PAGE_PSE; return pte; }
235
236#ifdef CONFIG_X86_PAE 95#ifdef CONFIG_X86_PAE
237# include <asm/pgtable-3level.h> 96# include <asm/pgtable-3level.h>
238#else 97#else
239# include <asm/pgtable-2level.h> 98# include <asm/pgtable-2level.h>
240#endif 99#endif
241 100
242#ifndef CONFIG_PARAVIRT
243/*
244 * Rules for using pte_update - it must be called after any PTE update which
245 * has not been done using the set_pte / clear_pte interfaces. It is used by
246 * shadow mode hypervisors to resynchronize the shadow page tables. Kernel PTE
247 * updates should either be sets, clears, or set_pte_atomic for P->P
248 * transitions, which means this hook should only be called for user PTEs.
249 * This hook implies a P->P protection or access change has taken place, which
250 * requires a subsequent TLB flush. The notification can optionally be delayed
251 * until the TLB flush event by using the pte_update_defer form of the
252 * interface, but care must be taken to assure that the flush happens while
253 * still holding the same page table lock so that the shadow and primary pages
254 * do not become out of sync on SMP.
255 */
256#define pte_update(mm, addr, ptep) do { } while (0)
257#define pte_update_defer(mm, addr, ptep) do { } while (0)
258#endif
259
260/* local pte updates need not use xchg for locking */
261static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
262{
263 pte_t res = *ptep;
264
265 /* Pure native function needs no input for mm, addr */
266 native_pte_clear(NULL, 0, ptep);
267 return res;
268}
269
270/*
271 * We only update the dirty/accessed state if we set
272 * the dirty bit by hand in the kernel, since the hardware
273 * will do the accessed bit for us, and we don't want to
274 * race with other CPU's that might be updating the dirty
275 * bit at the same time.
276 */
277#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
278#define ptep_set_access_flags(vma, address, ptep, entry, dirty) \
279({ \
280 int __changed = !pte_same(*(ptep), entry); \
281 if (__changed && dirty) { \
282 (ptep)->pte_low = (entry).pte_low; \
283 pte_update_defer((vma)->vm_mm, (address), (ptep)); \
284 flush_tlb_page(vma, address); \
285 } \
286 __changed; \
287})
288
289#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
290#define ptep_test_and_clear_young(vma, addr, ptep) ({ \
291 int __ret = 0; \
292 if (pte_young(*(ptep))) \
293 __ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, \
294 &(ptep)->pte_low); \
295 if (__ret) \
296 pte_update((vma)->vm_mm, addr, ptep); \
297 __ret; \
298})
299
300#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
301#define ptep_clear_flush_young(vma, address, ptep) \
302({ \
303 int __young; \
304 __young = ptep_test_and_clear_young((vma), (address), (ptep)); \
305 if (__young) \
306 flush_tlb_page(vma, address); \
307 __young; \
308})
309
310#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
311static inline pte_t ptep_get_and_clear(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
312{
313 pte_t pte = native_ptep_get_and_clear(ptep);
314 pte_update(mm, addr, ptep);
315 return pte;
316}
317
318#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
319static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full)
320{
321 pte_t pte;
322 if (full) {
323 /*
324 * Full address destruction in progress; paravirt does not
325 * care about updates and native needs no locking
326 */
327 pte = native_local_ptep_get_and_clear(ptep);
328 } else {
329 pte = ptep_get_and_clear(mm, addr, ptep);
330 }
331 return pte;
332}
333
334#define __HAVE_ARCH_PTEP_SET_WRPROTECT
335static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
336{
337 clear_bit(_PAGE_BIT_RW, &ptep->pte_low);
338 pte_update(mm, addr, ptep);
339}
340
341/* 101/*
342 * clone_pgd_range(pgd_t *dst, pgd_t *src, int count); 102 * clone_pgd_range(pgd_t *dst, pgd_t *src, int count);
343 * 103 *
@@ -367,25 +127,6 @@ static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
367 127
368#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 128#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
369 129
370static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
371{
372 pte.pte_low &= _PAGE_CHG_MASK;
373 pte.pte_low |= pgprot_val(newprot);
374#ifdef CONFIG_X86_PAE
375 /*
376 * Chop off the NX bit (if present), and add the NX portion of
377 * the newprot (if present):
378 */
379 pte.pte_high &= ~(1 << (_PAGE_BIT_NX - 32));
380 pte.pte_high |= (pgprot_val(newprot) >> 32) & \
381 (__supported_pte_mask >> 32);
382#endif
383 return pte;
384}
385
386#define pmd_large(pmd) \
387((pmd_val(pmd) & (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT))
388
389/* 130/*
390 * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD] 131 * the pgd page can be thought of an array like this: pgd_t[PTRS_PER_PGD]
391 * 132 *
@@ -432,26 +173,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
432#define pmd_page_vaddr(pmd) \ 173#define pmd_page_vaddr(pmd) \
433 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK)) 174 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
434 175
435/*
436 * Helper function that returns the kernel pagetable entry controlling
437 * the virtual address 'address'. NULL means no pagetable entry present.
438 * NOTE: the return type is pte_t but if the pmd is PSE then we return it
439 * as a pte too.
440 */
441extern pte_t *lookup_address(unsigned long address);
442
443/*
444 * Make a given kernel text page executable/non-executable.
445 * Returns the previous executability setting of that page (which
446 * is used to restore the previous state). Used by the SMP bootup code.
447 * NOTE: this is an __init function for security reasons.
448 */
449#ifdef CONFIG_X86_PAE
450 extern int set_kernel_exec(unsigned long vaddr, int enable);
451#else
452 static inline int set_kernel_exec(unsigned long vaddr, int enable) { return 0;}
453#endif
454
455#if defined(CONFIG_HIGHPTE) 176#if defined(CONFIG_HIGHPTE)
456#define pte_offset_map(dir, address) \ 177#define pte_offset_map(dir, address) \
457 ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE0) + pte_index(address)) 178 ((pte_t *)kmap_atomic_pte(pmd_page(*(dir)),KM_PTE0) + pte_index(address))
@@ -497,13 +218,17 @@ static inline void paravirt_pagetable_setup_done(pgd_t *base)
497 218
498#endif /* !__ASSEMBLY__ */ 219#endif /* !__ASSEMBLY__ */
499 220
221/*
222 * kern_addr_valid() is (1) for FLATMEM and (0) for
223 * SPARSEMEM and DISCONTIGMEM
224 */
500#ifdef CONFIG_FLATMEM 225#ifdef CONFIG_FLATMEM
501#define kern_addr_valid(addr) (1) 226#define kern_addr_valid(addr) (1)
502#endif /* CONFIG_FLATMEM */ 227#else
228#define kern_addr_valid(kaddr) (0)
229#endif
503 230
504#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 231#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
505 remap_pfn_range(vma, vaddr, pfn, size, prot) 232 remap_pfn_range(vma, vaddr, pfn, size, prot)
506 233
507#include <asm-generic/pgtable.h>
508
509#endif /* _I386_PGTABLE_H */ 234#endif /* _I386_PGTABLE_H */
diff --git a/include/asm-x86/pgtable_64.h b/include/asm-x86/pgtable_64.h
index 9b0ff477b39e..6e615a103c2f 100644
--- a/include/asm-x86/pgtable_64.h
+++ b/include/asm-x86/pgtable_64.h
@@ -17,22 +17,16 @@ extern pud_t level3_kernel_pgt[512];
17extern pud_t level3_ident_pgt[512]; 17extern pud_t level3_ident_pgt[512];
18extern pmd_t level2_kernel_pgt[512]; 18extern pmd_t level2_kernel_pgt[512];
19extern pgd_t init_level4_pgt[]; 19extern pgd_t init_level4_pgt[];
20extern unsigned long __supported_pte_mask;
21 20
22#define swapper_pg_dir init_level4_pgt 21#define swapper_pg_dir init_level4_pgt
23 22
24extern void paging_init(void); 23extern void paging_init(void);
25extern void clear_kernel_mapping(unsigned long addr, unsigned long size); 24extern void clear_kernel_mapping(unsigned long addr, unsigned long size);
26 25
27/*
28 * ZERO_PAGE is a global shared page that is always zero: used
29 * for zero-mapped memory areas etc..
30 */
31extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
32#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
33
34#endif /* !__ASSEMBLY__ */ 26#endif /* !__ASSEMBLY__ */
35 27
28#define SHARED_KERNEL_PMD 1
29
36/* 30/*
37 * PGDIR_SHIFT determines what a top-level page table entry can map 31 * PGDIR_SHIFT determines what a top-level page table entry can map
38 */ 32 */
@@ -71,57 +65,68 @@ extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
71#define pgd_none(x) (!pgd_val(x)) 65#define pgd_none(x) (!pgd_val(x))
72#define pud_none(x) (!pud_val(x)) 66#define pud_none(x) (!pud_val(x))
73 67
74static inline void set_pte(pte_t *dst, pte_t val) 68struct mm_struct;
69
70static inline void native_pte_clear(struct mm_struct *mm, unsigned long addr,
71 pte_t *ptep)
72{
73 *ptep = native_make_pte(0);
74}
75
76static inline void native_set_pte(pte_t *ptep, pte_t pte)
75{ 77{
76 pte_val(*dst) = pte_val(val); 78 *ptep = pte;
77} 79}
78#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
79 80
80static inline void set_pmd(pmd_t *dst, pmd_t val) 81static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
81{ 82{
82 pmd_val(*dst) = pmd_val(val); 83 native_set_pte(ptep, pte);
83} 84}
84 85
85static inline void set_pud(pud_t *dst, pud_t val) 86static inline pte_t native_ptep_get_and_clear(pte_t *xp)
86{ 87{
87 pud_val(*dst) = pud_val(val); 88#ifdef CONFIG_SMP
89 return native_make_pte(xchg(&xp->pte, 0));
90#else
91 /* native_local_ptep_get_and_clear, but duplicated because of cyclic dependency */
92 pte_t ret = *xp;
93 native_pte_clear(NULL, 0, xp);
94 return ret;
95#endif
88} 96}
89 97
90static inline void pud_clear (pud_t *pud) 98static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
91{ 99{
92 set_pud(pud, __pud(0)); 100 *pmdp = pmd;
93} 101}
94 102
95static inline void set_pgd(pgd_t *dst, pgd_t val) 103static inline void native_pmd_clear(pmd_t *pmd)
96{ 104{
97 pgd_val(*dst) = pgd_val(val); 105 native_set_pmd(pmd, native_make_pmd(0));
98} 106}
99 107
100static inline void pgd_clear (pgd_t * pgd) 108static inline void native_set_pud(pud_t *pudp, pud_t pud)
101{ 109{
102 set_pgd(pgd, __pgd(0)); 110 *pudp = pud;
103} 111}
104 112
105#define ptep_get_and_clear(mm,addr,xp) __pte(xchg(&(xp)->pte, 0)) 113static inline void native_pud_clear(pud_t *pud)
114{
115 native_set_pud(pud, native_make_pud(0));
116}
106 117
107struct mm_struct; 118static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
119{
120 *pgdp = pgd;
121}
108 122
109static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long addr, pte_t *ptep, int full) 123static inline void native_pgd_clear(pgd_t * pgd)
110{ 124{
111 pte_t pte; 125 native_set_pgd(pgd, native_make_pgd(0));
112 if (full) {
113 pte = *ptep;
114 *ptep = __pte(0);
115 } else {
116 pte = ptep_get_and_clear(mm, addr, ptep);
117 }
118 return pte;
119} 126}
120 127
121#define pte_same(a, b) ((a).pte == (b).pte) 128#define pte_same(a, b) ((a).pte == (b).pte)
122 129
123#define pte_pgprot(a) (__pgprot((a).pte & ~PHYSICAL_PAGE_MASK))
124
125#endif /* !__ASSEMBLY__ */ 130#endif /* !__ASSEMBLY__ */
126 131
127#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT) 132#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
@@ -131,8 +136,6 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long
131#define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT) 136#define PGDIR_SIZE (_AC(1,UL) << PGDIR_SHIFT)
132#define PGDIR_MASK (~(PGDIR_SIZE-1)) 137#define PGDIR_MASK (~(PGDIR_SIZE-1))
133 138
134#define USER_PTRS_PER_PGD ((TASK_SIZE-1)/PGDIR_SIZE+1)
135#define FIRST_USER_ADDRESS 0
136 139
137#define MAXMEM _AC(0x3fffffffffff, UL) 140#define MAXMEM _AC(0x3fffffffffff, UL)
138#define VMALLOC_START _AC(0xffffc20000000000, UL) 141#define VMALLOC_START _AC(0xffffc20000000000, UL)
@@ -142,91 +145,6 @@ static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, unsigned long
142#define MODULES_END _AC(0xfffffffffff00000, UL) 145#define MODULES_END _AC(0xfffffffffff00000, UL)
143#define MODULES_LEN (MODULES_END - MODULES_VADDR) 146#define MODULES_LEN (MODULES_END - MODULES_VADDR)
144 147
145#define _PAGE_BIT_PRESENT 0
146#define _PAGE_BIT_RW 1
147#define _PAGE_BIT_USER 2
148#define _PAGE_BIT_PWT 3
149#define _PAGE_BIT_PCD 4
150#define _PAGE_BIT_ACCESSED 5
151#define _PAGE_BIT_DIRTY 6
152#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
153#define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
154#define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
155
156#define _PAGE_PRESENT 0x001
157#define _PAGE_RW 0x002
158#define _PAGE_USER 0x004
159#define _PAGE_PWT 0x008
160#define _PAGE_PCD 0x010
161#define _PAGE_ACCESSED 0x020
162#define _PAGE_DIRTY 0x040
163#define _PAGE_PSE 0x080 /* 2MB page */
164#define _PAGE_FILE 0x040 /* nonlinear file mapping, saved PTE; unset:swap */
165#define _PAGE_GLOBAL 0x100 /* Global TLB entry */
166
167#define _PAGE_PROTNONE 0x080 /* If not present */
168#define _PAGE_NX (_AC(1,UL)<<_PAGE_BIT_NX)
169
170#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
171#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
172
173#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
174
175#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
176#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
177#define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
178#define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
179#define PAGE_COPY PAGE_COPY_NOEXEC
180#define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
181#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
182#define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
183#define __PAGE_KERNEL \
184 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
185#define __PAGE_KERNEL_EXEC \
186 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
187#define __PAGE_KERNEL_NOCACHE \
188 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED | _PAGE_NX)
189#define __PAGE_KERNEL_RO \
190 (_PAGE_PRESENT | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
191#define __PAGE_KERNEL_VSYSCALL \
192 (_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
193#define __PAGE_KERNEL_VSYSCALL_NOCACHE \
194 (_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_PCD)
195#define __PAGE_KERNEL_LARGE \
196 (__PAGE_KERNEL | _PAGE_PSE)
197#define __PAGE_KERNEL_LARGE_EXEC \
198 (__PAGE_KERNEL_EXEC | _PAGE_PSE)
199
200#define MAKE_GLOBAL(x) __pgprot((x) | _PAGE_GLOBAL)
201
202#define PAGE_KERNEL MAKE_GLOBAL(__PAGE_KERNEL)
203#define PAGE_KERNEL_EXEC MAKE_GLOBAL(__PAGE_KERNEL_EXEC)
204#define PAGE_KERNEL_RO MAKE_GLOBAL(__PAGE_KERNEL_RO)
205#define PAGE_KERNEL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_NOCACHE)
206#define PAGE_KERNEL_VSYSCALL32 __pgprot(__PAGE_KERNEL_VSYSCALL)
207#define PAGE_KERNEL_VSYSCALL MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL)
208#define PAGE_KERNEL_LARGE MAKE_GLOBAL(__PAGE_KERNEL_LARGE)
209#define PAGE_KERNEL_VSYSCALL_NOCACHE MAKE_GLOBAL(__PAGE_KERNEL_VSYSCALL_NOCACHE)
210
211/* xwr */
212#define __P000 PAGE_NONE
213#define __P001 PAGE_READONLY
214#define __P010 PAGE_COPY
215#define __P011 PAGE_COPY
216#define __P100 PAGE_READONLY_EXEC
217#define __P101 PAGE_READONLY_EXEC
218#define __P110 PAGE_COPY_EXEC
219#define __P111 PAGE_COPY_EXEC
220
221#define __S000 PAGE_NONE
222#define __S001 PAGE_READONLY
223#define __S010 PAGE_SHARED
224#define __S011 PAGE_SHARED
225#define __S100 PAGE_READONLY_EXEC
226#define __S101 PAGE_READONLY_EXEC
227#define __S110 PAGE_SHARED_EXEC
228#define __S111 PAGE_SHARED_EXEC
229
230#ifndef __ASSEMBLY__ 148#ifndef __ASSEMBLY__
231 149
232static inline unsigned long pgd_bad(pgd_t pgd) 150static inline unsigned long pgd_bad(pgd_t pgd)
@@ -246,66 +164,16 @@ static inline unsigned long pmd_bad(pmd_t pmd)
246 164
247#define pte_none(x) (!pte_val(x)) 165#define pte_none(x) (!pte_val(x))
248#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE)) 166#define pte_present(x) (pte_val(x) & (_PAGE_PRESENT | _PAGE_PROTNONE))
249#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
250 167
251#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this 168#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) /* FIXME: is this right? */
252 right? */
253#define pte_page(x) pfn_to_page(pte_pfn(x)) 169#define pte_page(x) pfn_to_page(pte_pfn(x))
254#define pte_pfn(x) ((pte_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 170#define pte_pfn(x) ((pte_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
255 171
256static inline pte_t pfn_pte(unsigned long page_nr, pgprot_t pgprot)
257{
258 pte_t pte;
259 pte_val(pte) = (page_nr << PAGE_SHIFT);
260 pte_val(pte) |= pgprot_val(pgprot);
261 pte_val(pte) &= __supported_pte_mask;
262 return pte;
263}
264
265/*
266 * The following only work if pte_present() is true.
267 * Undefined behaviour if not..
268 */
269#define __LARGE_PTE (_PAGE_PSE|_PAGE_PRESENT)
270static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY; }
271static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED; }
272static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW; }
273static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE; }
274static inline int pte_huge(pte_t pte) { return pte_val(pte) & _PAGE_PSE; }
275
276static inline pte_t pte_mkclean(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_DIRTY)); return pte; }
277static inline pte_t pte_mkold(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_ACCESSED)); return pte; }
278static inline pte_t pte_wrprotect(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_RW)); return pte; }
279static inline pte_t pte_mkexec(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_NX)); return pte; }
280static inline pte_t pte_mkdirty(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_DIRTY)); return pte; }
281static inline pte_t pte_mkyoung(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_ACCESSED)); return pte; }
282static inline pte_t pte_mkwrite(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_RW)); return pte; }
283static inline pte_t pte_mkhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) | _PAGE_PSE)); return pte; }
284static inline pte_t pte_clrhuge(pte_t pte) { set_pte(&pte, __pte(pte_val(pte) & ~_PAGE_PSE)); return pte; }
285
286struct vm_area_struct;
287
288static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
289{
290 if (!pte_young(*ptep))
291 return 0;
292 return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte);
293}
294
295static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
296{
297 clear_bit(_PAGE_BIT_RW, &ptep->pte);
298}
299
300/* 172/*
301 * Macro to mark a page protection value as "uncacheable". 173 * Macro to mark a page protection value as "uncacheable".
302 */ 174 */
303#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) 175#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT))
304 176
305static inline int pmd_large(pmd_t pte) {
306 return (pmd_val(pte) & __LARGE_PTE) == __LARGE_PTE;
307}
308
309 177
310/* 178/*
311 * Conversion functions: convert a page and protection to a page entry, 179 * Conversion functions: convert a page and protection to a page entry,
@@ -340,29 +208,18 @@ static inline int pmd_large(pmd_t pte) {
340 pmd_index(address)) 208 pmd_index(address))
341#define pmd_none(x) (!pmd_val(x)) 209#define pmd_none(x) (!pmd_val(x))
342#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT) 210#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
343#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
344#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot))) 211#define pfn_pmd(nr,prot) (__pmd(((nr) << PAGE_SHIFT) | pgprot_val(prot)))
345#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT) 212#define pmd_pfn(x) ((pmd_val(x) & __PHYSICAL_MASK) >> PAGE_SHIFT)
346 213
347#define pte_to_pgoff(pte) ((pte_val(pte) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT) 214#define pte_to_pgoff(pte) ((pte_val(pte) & PHYSICAL_PAGE_MASK) >> PAGE_SHIFT)
348#define pgoff_to_pte(off) ((pte_t) { ((off) << PAGE_SHIFT) | _PAGE_FILE }) 215#define pgoff_to_pte(off) ((pte_t) { .pte = ((off) << PAGE_SHIFT) | _PAGE_FILE })
349#define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT 216#define PTE_FILE_MAX_BITS __PHYSICAL_MASK_SHIFT
350 217
351/* PTE - Level 1 access. */ 218/* PTE - Level 1 access. */
352 219
353/* page, protection -> pte */ 220/* page, protection -> pte */
354#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot)) 221#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
355#define mk_pte_huge(entry) (pte_val(entry) |= _PAGE_PRESENT | _PAGE_PSE)
356 222
357/* Change flags of a PTE */
358static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
359{
360 pte_val(pte) &= _PAGE_CHG_MASK;
361 pte_val(pte) |= pgprot_val(newprot);
362 pte_val(pte) &= __supported_pte_mask;
363 return pte;
364}
365
366#define pte_index(address) \ 223#define pte_index(address) \
367 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)) 224 (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
368#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \ 225#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + \
@@ -376,40 +233,20 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
376 233
377#define update_mmu_cache(vma,address,pte) do { } while (0) 234#define update_mmu_cache(vma,address,pte) do { } while (0)
378 235
379/* We only update the dirty/accessed state if we set
380 * the dirty bit by hand in the kernel, since the hardware
381 * will do the accessed bit for us, and we don't want to
382 * race with other CPU's that might be updating the dirty
383 * bit at the same time. */
384#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
385#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
386({ \
387 int __changed = !pte_same(*(__ptep), __entry); \
388 if (__changed && __dirty) { \
389 set_pte(__ptep, __entry); \
390 flush_tlb_page(__vma, __address); \
391 } \
392 __changed; \
393})
394
395/* Encode and de-code a swap entry */ 236/* Encode and de-code a swap entry */
396#define __swp_type(x) (((x).val >> 1) & 0x3f) 237#define __swp_type(x) (((x).val >> 1) & 0x3f)
397#define __swp_offset(x) ((x).val >> 8) 238#define __swp_offset(x) ((x).val >> 8)
398#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) }) 239#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })
399#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) }) 240#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
400#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 241#define __swp_entry_to_pte(x) ((pte_t) { .pte = (x).val })
401
402extern spinlock_t pgd_lock;
403extern struct list_head pgd_list;
404 242
405extern int kern_addr_valid(unsigned long addr); 243extern int kern_addr_valid(unsigned long addr);
406 244
407pte_t *lookup_address(unsigned long addr);
408
409#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 245#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
410 remap_pfn_range(vma, vaddr, pfn, size, prot) 246 remap_pfn_range(vma, vaddr, pfn, size, prot)
411 247
412#define HAVE_ARCH_UNMAPPED_AREA 248#define HAVE_ARCH_UNMAPPED_AREA
249#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
413 250
414#define pgtable_cache_init() do { } while (0) 251#define pgtable_cache_init() do { } while (0)
415#define check_pgt_cache() do { } while (0) 252#define check_pgt_cache() do { } while (0)
@@ -422,12 +259,7 @@ pte_t *lookup_address(unsigned long addr);
422#define kc_offset_to_vaddr(o) \ 259#define kc_offset_to_vaddr(o) \
423 (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o)) 260 (((o) & (1UL << (__VIRTUAL_MASK_SHIFT-1))) ? ((o) | (~__VIRTUAL_MASK)) : (o))
424 261
425#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
426#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
427#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
428#define __HAVE_ARCH_PTEP_SET_WRPROTECT
429#define __HAVE_ARCH_PTE_SAME 262#define __HAVE_ARCH_PTE_SAME
430#include <asm-generic/pgtable.h>
431#endif /* !__ASSEMBLY__ */ 263#endif /* !__ASSEMBLY__ */
432 264
433#endif /* _X86_64_PGTABLE_H */ 265#endif /* _X86_64_PGTABLE_H */
diff --git a/include/asm-x86/processor.h b/include/asm-x86/processor.h
index 46e1c04e309c..ab4d0c2a3f8f 100644
--- a/include/asm-x86/processor.h
+++ b/include/asm-x86/processor.h
@@ -1,5 +1,842 @@
1#ifndef __ASM_X86_PROCESSOR_H
2#define __ASM_X86_PROCESSOR_H
3
4#include <asm/processor-flags.h>
5
6/* migration helpers, for KVM - will be removed in 2.6.25: */
7#include <asm/vm86.h>
8#define Xgt_desc_struct desc_ptr
9
10/* Forward declaration, a strange C thing */
11struct task_struct;
12struct mm_struct;
13
14#include <asm/vm86.h>
15#include <asm/math_emu.h>
16#include <asm/segment.h>
17#include <asm/types.h>
18#include <asm/sigcontext.h>
19#include <asm/current.h>
20#include <asm/cpufeature.h>
21#include <asm/system.h>
22#include <asm/page.h>
23#include <asm/percpu.h>
24#include <asm/msr.h>
25#include <asm/desc_defs.h>
26#include <asm/nops.h>
27#include <linux/personality.h>
28#include <linux/cpumask.h>
29#include <linux/cache.h>
30#include <linux/threads.h>
31#include <linux/init.h>
32
33/*
34 * Default implementation of macro that returns current
35 * instruction pointer ("program counter").
36 */
37static inline void *current_text_addr(void)
38{
39 void *pc;
40 asm volatile("mov $1f,%0\n1:":"=r" (pc));
41 return pc;
42}
43
44#ifdef CONFIG_X86_VSMP
45#define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT)
46#define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT)
47#else
48#define ARCH_MIN_TASKALIGN 16
49#define ARCH_MIN_MMSTRUCT_ALIGN 0
50#endif
51
52/*
53 * CPU type and hardware bug flags. Kept separately for each CPU.
54 * Members of this structure are referenced in head.S, so think twice
55 * before touching them. [mj]
56 */
57
58struct cpuinfo_x86 {
59 __u8 x86; /* CPU family */
60 __u8 x86_vendor; /* CPU vendor */
61 __u8 x86_model;
62 __u8 x86_mask;
63#ifdef CONFIG_X86_32
64 char wp_works_ok; /* It doesn't on 386's */
65 char hlt_works_ok; /* Problems on some 486Dx4's and old 386's */
66 char hard_math;
67 char rfu;
68 char fdiv_bug;
69 char f00f_bug;
70 char coma_bug;
71 char pad0;
72#else
73 /* number of 4K pages in DTLB/ITLB combined(in pages)*/
74 int x86_tlbsize;
75 __u8 x86_virt_bits, x86_phys_bits;
76 /* cpuid returned core id bits */
77 __u8 x86_coreid_bits;
78 /* Max extended CPUID function supported */
79 __u32 extended_cpuid_level;
80#endif
81 int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
82 __u32 x86_capability[NCAPINTS];
83 char x86_vendor_id[16];
84 char x86_model_id[64];
85 int x86_cache_size; /* in KB - valid for CPUS which support this
86 call */
87 int x86_cache_alignment; /* In bytes */
88 int x86_power;
89 unsigned long loops_per_jiffy;
90#ifdef CONFIG_SMP
91 cpumask_t llc_shared_map; /* cpus sharing the last level cache */
92#endif
93 u16 x86_max_cores; /* cpuid returned max cores value */
94 u16 apicid;
95 u16 x86_clflush_size;
96#ifdef CONFIG_SMP
97 u16 booted_cores; /* number of cores as seen by OS */
98 u16 phys_proc_id; /* Physical processor id. */
99 u16 cpu_core_id; /* Core id */
100 u16 cpu_index; /* index into per_cpu list */
101#endif
102} __attribute__((__aligned__(SMP_CACHE_BYTES)));
103
104#define X86_VENDOR_INTEL 0
105#define X86_VENDOR_CYRIX 1
106#define X86_VENDOR_AMD 2
107#define X86_VENDOR_UMC 3
108#define X86_VENDOR_NEXGEN 4
109#define X86_VENDOR_CENTAUR 5
110#define X86_VENDOR_TRANSMETA 7
111#define X86_VENDOR_NSC 8
112#define X86_VENDOR_NUM 9
113#define X86_VENDOR_UNKNOWN 0xff
114
115/*
116 * capabilities of CPUs
117 */
118extern struct cpuinfo_x86 boot_cpu_data;
119extern struct cpuinfo_x86 new_cpu_data;
120extern struct tss_struct doublefault_tss;
121extern __u32 cleared_cpu_caps[NCAPINTS];
122
123#ifdef CONFIG_SMP
124DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
125#define cpu_data(cpu) per_cpu(cpu_info, cpu)
126#define current_cpu_data cpu_data(smp_processor_id())
127#else
128#define cpu_data(cpu) boot_cpu_data
129#define current_cpu_data boot_cpu_data
130#endif
131
132void cpu_detect(struct cpuinfo_x86 *c);
133
134extern void identify_cpu(struct cpuinfo_x86 *);
135extern void identify_boot_cpu(void);
136extern void identify_secondary_cpu(struct cpuinfo_x86 *);
137extern void print_cpu_info(struct cpuinfo_x86 *);
138extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
139extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
140extern unsigned short num_cache_leaves;
141
142#if defined(CONFIG_X86_HT) || defined(CONFIG_X86_64)
143extern void detect_ht(struct cpuinfo_x86 *c);
144#else
145static inline void detect_ht(struct cpuinfo_x86 *c) {}
146#endif
147
148static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
149 unsigned int *ecx, unsigned int *edx)
150{
151 /* ecx is often an input as well as an output. */
152 __asm__("cpuid"
153 : "=a" (*eax),
154 "=b" (*ebx),
155 "=c" (*ecx),
156 "=d" (*edx)
157 : "0" (*eax), "2" (*ecx));
158}
159
160static inline void load_cr3(pgd_t *pgdir)
161{
162 write_cr3(__pa(pgdir));
163}
164
165#ifdef CONFIG_X86_32
166/* This is the TSS defined by the hardware. */
167struct x86_hw_tss {
168 unsigned short back_link, __blh;
169 unsigned long sp0;
170 unsigned short ss0, __ss0h;
171 unsigned long sp1;
172 unsigned short ss1, __ss1h; /* ss1 caches MSR_IA32_SYSENTER_CS */
173 unsigned long sp2;
174 unsigned short ss2, __ss2h;
175 unsigned long __cr3;
176 unsigned long ip;
177 unsigned long flags;
178 unsigned long ax, cx, dx, bx;
179 unsigned long sp, bp, si, di;
180 unsigned short es, __esh;
181 unsigned short cs, __csh;
182 unsigned short ss, __ssh;
183 unsigned short ds, __dsh;
184 unsigned short fs, __fsh;
185 unsigned short gs, __gsh;
186 unsigned short ldt, __ldth;
187 unsigned short trace, io_bitmap_base;
188} __attribute__((packed));
189#else
190struct x86_hw_tss {
191 u32 reserved1;
192 u64 sp0;
193 u64 sp1;
194 u64 sp2;
195 u64 reserved2;
196 u64 ist[7];
197 u32 reserved3;
198 u32 reserved4;
199 u16 reserved5;
200 u16 io_bitmap_base;
201} __attribute__((packed)) ____cacheline_aligned;
202#endif
203
204/*
205 * Size of io_bitmap.
206 */
207#define IO_BITMAP_BITS 65536
208#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
209#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
210#define IO_BITMAP_OFFSET offsetof(struct tss_struct, io_bitmap)
211#define INVALID_IO_BITMAP_OFFSET 0x8000
212#define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000
213
214struct tss_struct {
215 struct x86_hw_tss x86_tss;
216
217 /*
218 * The extra 1 is there because the CPU will access an
219 * additional byte beyond the end of the IO permission
220 * bitmap. The extra byte must be all 1 bits, and must
221 * be within the limit.
222 */
223 unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
224 /*
225 * Cache the current maximum and the last task that used the bitmap:
226 */
227 unsigned long io_bitmap_max;
228 struct thread_struct *io_bitmap_owner;
229 /*
230 * pads the TSS to be cacheline-aligned (size is 0x100)
231 */
232 unsigned long __cacheline_filler[35];
233 /*
234 * .. and then another 0x100 bytes for emergency kernel stack
235 */
236 unsigned long stack[64];
237} __attribute__((packed));
238
239DECLARE_PER_CPU(struct tss_struct, init_tss);
240
241/* Save the original ist values for checking stack pointers during debugging */
242struct orig_ist {
243 unsigned long ist[7];
244};
245
246#define MXCSR_DEFAULT 0x1f80
247
248struct i387_fsave_struct {
249 u32 cwd;
250 u32 swd;
251 u32 twd;
252 u32 fip;
253 u32 fcs;
254 u32 foo;
255 u32 fos;
256 u32 st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
257 u32 status; /* software status information */
258};
259
260struct i387_fxsave_struct {
261 u16 cwd;
262 u16 swd;
263 u16 twd;
264 u16 fop;
265 union {
266 struct {
267 u64 rip;
268 u64 rdp;
269 };
270 struct {
271 u32 fip;
272 u32 fcs;
273 u32 foo;
274 u32 fos;
275 };
276 };
277 u32 mxcsr;
278 u32 mxcsr_mask;
279 u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
280 u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
281 u32 padding[24];
282} __attribute__((aligned(16)));
283
284struct i387_soft_struct {
285 u32 cwd;
286 u32 swd;
287 u32 twd;
288 u32 fip;
289 u32 fcs;
290 u32 foo;
291 u32 fos;
292 u32 st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
293 u8 ftop, changed, lookahead, no_update, rm, alimit;
294 struct info *info;
295 u32 entry_eip;
296};
297
298union i387_union {
299 struct i387_fsave_struct fsave;
300 struct i387_fxsave_struct fxsave;
301 struct i387_soft_struct soft;
302};
303
304#ifdef CONFIG_X86_32
305/*
306 * the following now lives in the per cpu area:
307 * extern int cpu_llc_id[NR_CPUS];
308 */
309DECLARE_PER_CPU(u8, cpu_llc_id);
310#else
311DECLARE_PER_CPU(struct orig_ist, orig_ist);
312#endif
313
314extern void print_cpu_info(struct cpuinfo_x86 *);
315extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
316extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
317extern unsigned short num_cache_leaves;
318
319struct thread_struct {
320/* cached TLS descriptors. */
321 struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
322 unsigned long sp0;
323 unsigned long sp;
324#ifdef CONFIG_X86_32
325 unsigned long sysenter_cs;
326#else
327 unsigned long usersp; /* Copy from PDA */
328 unsigned short es, ds, fsindex, gsindex;
329#endif
330 unsigned long ip;
331 unsigned long fs;
332 unsigned long gs;
333/* Hardware debugging registers */
334 unsigned long debugreg0;
335 unsigned long debugreg1;
336 unsigned long debugreg2;
337 unsigned long debugreg3;
338 unsigned long debugreg6;
339 unsigned long debugreg7;
340/* fault info */
341 unsigned long cr2, trap_no, error_code;
342/* floating point info */
343 union i387_union i387 __attribute__((aligned(16)));;
344#ifdef CONFIG_X86_32
345/* virtual 86 mode info */
346 struct vm86_struct __user *vm86_info;
347 unsigned long screen_bitmap;
348 unsigned long v86flags, v86mask, saved_sp0;
349 unsigned int saved_fs, saved_gs;
350#endif
351/* IO permissions */
352 unsigned long *io_bitmap_ptr;
353 unsigned long iopl;
354/* max allowed port in the bitmap, in bytes: */
355 unsigned io_bitmap_max;
356/* MSR_IA32_DEBUGCTLMSR value to switch in if TIF_DEBUGCTLMSR is set. */
357 unsigned long debugctlmsr;
358/* Debug Store - if not 0 points to a DS Save Area configuration;
359 * goes into MSR_IA32_DS_AREA */
360 unsigned long ds_area_msr;
361};
362
363static inline unsigned long native_get_debugreg(int regno)
364{
365 unsigned long val = 0; /* Damn you, gcc! */
366
367 switch (regno) {
368 case 0:
369 asm("mov %%db0, %0" :"=r" (val)); break;
370 case 1:
371 asm("mov %%db1, %0" :"=r" (val)); break;
372 case 2:
373 asm("mov %%db2, %0" :"=r" (val)); break;
374 case 3:
375 asm("mov %%db3, %0" :"=r" (val)); break;
376 case 6:
377 asm("mov %%db6, %0" :"=r" (val)); break;
378 case 7:
379 asm("mov %%db7, %0" :"=r" (val)); break;
380 default:
381 BUG();
382 }
383 return val;
384}
385
386static inline void native_set_debugreg(int regno, unsigned long value)
387{
388 switch (regno) {
389 case 0:
390 asm("mov %0,%%db0" : /* no output */ :"r" (value));
391 break;
392 case 1:
393 asm("mov %0,%%db1" : /* no output */ :"r" (value));
394 break;
395 case 2:
396 asm("mov %0,%%db2" : /* no output */ :"r" (value));
397 break;
398 case 3:
399 asm("mov %0,%%db3" : /* no output */ :"r" (value));
400 break;
401 case 6:
402 asm("mov %0,%%db6" : /* no output */ :"r" (value));
403 break;
404 case 7:
405 asm("mov %0,%%db7" : /* no output */ :"r" (value));
406 break;
407 default:
408 BUG();
409 }
410}
411
412/*
413 * Set IOPL bits in EFLAGS from given mask
414 */
415static inline void native_set_iopl_mask(unsigned mask)
416{
417#ifdef CONFIG_X86_32
418 unsigned int reg;
419 __asm__ __volatile__ ("pushfl;"
420 "popl %0;"
421 "andl %1, %0;"
422 "orl %2, %0;"
423 "pushl %0;"
424 "popfl"
425 : "=&r" (reg)
426 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
427#endif
428}
429
430static inline void native_load_sp0(struct tss_struct *tss,
431 struct thread_struct *thread)
432{
433 tss->x86_tss.sp0 = thread->sp0;
434#ifdef CONFIG_X86_32
435 /* Only happens when SEP is enabled, no need to test "SEP"arately */
436 if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
437 tss->x86_tss.ss1 = thread->sysenter_cs;
438 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
439 }
440#endif
441}
442
443static inline void native_swapgs(void)
444{
445#ifdef CONFIG_X86_64
446 asm volatile("swapgs" ::: "memory");
447#endif
448}
449
450#ifdef CONFIG_PARAVIRT
451#include <asm/paravirt.h>
452#else
453#define __cpuid native_cpuid
454#define paravirt_enabled() 0
455
456/*
457 * These special macros can be used to get or set a debugging register
458 */
459#define get_debugreg(var, register) \
460 (var) = native_get_debugreg(register)
461#define set_debugreg(value, register) \
462 native_set_debugreg(register, value)
463
464static inline void load_sp0(struct tss_struct *tss,
465 struct thread_struct *thread)
466{
467 native_load_sp0(tss, thread);
468}
469
470#define set_iopl_mask native_set_iopl_mask
471#define SWAPGS swapgs
472#endif /* CONFIG_PARAVIRT */
473
474/*
475 * Save the cr4 feature set we're using (ie
476 * Pentium 4MB enable and PPro Global page
477 * enable), so that any CPU's that boot up
478 * after us can get the correct flags.
479 */
480extern unsigned long mmu_cr4_features;
481
482static inline void set_in_cr4(unsigned long mask)
483{
484 unsigned cr4;
485 mmu_cr4_features |= mask;
486 cr4 = read_cr4();
487 cr4 |= mask;
488 write_cr4(cr4);
489}
490
491static inline void clear_in_cr4(unsigned long mask)
492{
493 unsigned cr4;
494 mmu_cr4_features &= ~mask;
495 cr4 = read_cr4();
496 cr4 &= ~mask;
497 write_cr4(cr4);
498}
499
500struct microcode_header {
501 unsigned int hdrver;
502 unsigned int rev;
503 unsigned int date;
504 unsigned int sig;
505 unsigned int cksum;
506 unsigned int ldrver;
507 unsigned int pf;
508 unsigned int datasize;
509 unsigned int totalsize;
510 unsigned int reserved[3];
511};
512
513struct microcode {
514 struct microcode_header hdr;
515 unsigned int bits[0];
516};
517
518typedef struct microcode microcode_t;
519typedef struct microcode_header microcode_header_t;
520
521/* microcode format is extended from prescott processors */
522struct extended_signature {
523 unsigned int sig;
524 unsigned int pf;
525 unsigned int cksum;
526};
527
528struct extended_sigtable {
529 unsigned int count;
530 unsigned int cksum;
531 unsigned int reserved[3];
532 struct extended_signature sigs[0];
533};
534
535typedef struct {
536 unsigned long seg;
537} mm_segment_t;
538
539
540/*
541 * create a kernel thread without removing it from tasklists
542 */
543extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
544
545/* Free all resources held by a thread. */
546extern void release_thread(struct task_struct *);
547
548/* Prepare to copy thread state - unlazy all lazy status */
549extern void prepare_to_copy(struct task_struct *tsk);
550
551unsigned long get_wchan(struct task_struct *p);
552
553/*
554 * Generic CPUID function
555 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
556 * resulting in stale register contents being returned.
557 */
558static inline void cpuid(unsigned int op,
559 unsigned int *eax, unsigned int *ebx,
560 unsigned int *ecx, unsigned int *edx)
561{
562 *eax = op;
563 *ecx = 0;
564 __cpuid(eax, ebx, ecx, edx);
565}
566
567/* Some CPUID calls want 'count' to be placed in ecx */
568static inline void cpuid_count(unsigned int op, int count,
569 unsigned int *eax, unsigned int *ebx,
570 unsigned int *ecx, unsigned int *edx)
571{
572 *eax = op;
573 *ecx = count;
574 __cpuid(eax, ebx, ecx, edx);
575}
576
577/*
578 * CPUID functions returning a single datum
579 */
580static inline unsigned int cpuid_eax(unsigned int op)
581{
582 unsigned int eax, ebx, ecx, edx;
583
584 cpuid(op, &eax, &ebx, &ecx, &edx);
585 return eax;
586}
587static inline unsigned int cpuid_ebx(unsigned int op)
588{
589 unsigned int eax, ebx, ecx, edx;
590
591 cpuid(op, &eax, &ebx, &ecx, &edx);
592 return ebx;
593}
594static inline unsigned int cpuid_ecx(unsigned int op)
595{
596 unsigned int eax, ebx, ecx, edx;
597
598 cpuid(op, &eax, &ebx, &ecx, &edx);
599 return ecx;
600}
601static inline unsigned int cpuid_edx(unsigned int op)
602{
603 unsigned int eax, ebx, ecx, edx;
604
605 cpuid(op, &eax, &ebx, &ecx, &edx);
606 return edx;
607}
608
609/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
610static inline void rep_nop(void)
611{
612 __asm__ __volatile__("rep;nop": : :"memory");
613}
614
615/* Stop speculative execution */
616static inline void sync_core(void)
617{
618 int tmp;
619 asm volatile("cpuid" : "=a" (tmp) : "0" (1)
620 : "ebx", "ecx", "edx", "memory");
621}
622
623#define cpu_relax() rep_nop()
624
625static inline void __monitor(const void *eax, unsigned long ecx,
626 unsigned long edx)
627{
628 /* "monitor %eax,%ecx,%edx;" */
629 asm volatile(
630 ".byte 0x0f,0x01,0xc8;"
631 : :"a" (eax), "c" (ecx), "d"(edx));
632}
633
634static inline void __mwait(unsigned long eax, unsigned long ecx)
635{
636 /* "mwait %eax,%ecx;" */
637 asm volatile(
638 ".byte 0x0f,0x01,0xc9;"
639 : :"a" (eax), "c" (ecx));
640}
641
642static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
643{
644 /* "mwait %eax,%ecx;" */
645 asm volatile(
646 "sti; .byte 0x0f,0x01,0xc9;"
647 : :"a" (eax), "c" (ecx));
648}
649
650extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
651
652extern int force_mwait;
653
654extern void select_idle_routine(const struct cpuinfo_x86 *c);
655
656extern unsigned long boot_option_idle_override;
657
658extern void enable_sep_cpu(void);
659extern int sysenter_setup(void);
660
661/* Defined in head.S */
662extern struct desc_ptr early_gdt_descr;
663
664extern void cpu_set_gdt(int);
665extern void switch_to_new_gdt(void);
666extern void cpu_init(void);
667extern void init_gdt(int cpu);
668
669/* from system description table in BIOS. Mostly for MCA use, but
670 * others may find it useful. */
671extern unsigned int machine_id;
672extern unsigned int machine_submodel_id;
673extern unsigned int BIOS_revision;
674extern unsigned int mca_pentium_flag;
675
676/* Boot loader type from the setup header */
677extern int bootloader_type;
678
679extern char ignore_fpu_irq;
680#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
681
682#define HAVE_ARCH_PICK_MMAP_LAYOUT 1
683#define ARCH_HAS_PREFETCHW
684#define ARCH_HAS_SPINLOCK_PREFETCH
685
686#ifdef CONFIG_X86_32
687#define BASE_PREFETCH ASM_NOP4
688#define ARCH_HAS_PREFETCH
689#else
690#define BASE_PREFETCH "prefetcht0 (%1)"
691#endif
692
693/* Prefetch instructions for Pentium III and AMD Athlon */
694/* It's not worth to care about 3dnow! prefetches for the K6
695 because they are microcoded there and very slow.
696 However we don't do prefetches for pre XP Athlons currently
697 That should be fixed. */
698static inline void prefetch(const void *x)
699{
700 alternative_input(BASE_PREFETCH,
701 "prefetchnta (%1)",
702 X86_FEATURE_XMM,
703 "r" (x));
704}
705
706/* 3dnow! prefetch to get an exclusive cache line. Useful for
707 spinlocks to avoid one state transition in the cache coherency protocol. */
708static inline void prefetchw(const void *x)
709{
710 alternative_input(BASE_PREFETCH,
711 "prefetchw (%1)",
712 X86_FEATURE_3DNOW,
713 "r" (x));
714}
715
716#define spin_lock_prefetch(x) prefetchw(x)
1#ifdef CONFIG_X86_32 717#ifdef CONFIG_X86_32
2# include "processor_32.h" 718/*
719 * User space process size: 3GB (default).
720 */
721#define TASK_SIZE (PAGE_OFFSET)
722
723#define INIT_THREAD { \
724 .sp0 = sizeof(init_stack) + (long)&init_stack, \
725 .vm86_info = NULL, \
726 .sysenter_cs = __KERNEL_CS, \
727 .io_bitmap_ptr = NULL, \
728 .fs = __KERNEL_PERCPU, \
729}
730
731/*
732 * Note that the .io_bitmap member must be extra-big. This is because
733 * the CPU will access an additional byte beyond the end of the IO
734 * permission bitmap. The extra byte must be all 1 bits, and must
735 * be within the limit.
736 */
737#define INIT_TSS { \
738 .x86_tss = { \
739 .sp0 = sizeof(init_stack) + (long)&init_stack, \
740 .ss0 = __KERNEL_DS, \
741 .ss1 = __KERNEL_CS, \
742 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
743 }, \
744 .io_bitmap = { [0 ... IO_BITMAP_LONGS] = ~0 }, \
745}
746
747#define start_thread(regs, new_eip, new_esp) do { \
748 __asm__("movl %0,%%gs": :"r" (0)); \
749 regs->fs = 0; \
750 set_fs(USER_DS); \
751 regs->ds = __USER_DS; \
752 regs->es = __USER_DS; \
753 regs->ss = __USER_DS; \
754 regs->cs = __USER_CS; \
755 regs->ip = new_eip; \
756 regs->sp = new_esp; \
757} while (0)
758
759
760extern unsigned long thread_saved_pc(struct task_struct *tsk);
761
762#define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
763#define KSTK_TOP(info) \
764({ \
765 unsigned long *__ptr = (unsigned long *)(info); \
766 (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
767})
768
769/*
770 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
771 * This is necessary to guarantee that the entire "struct pt_regs"
772 * is accessable even if the CPU haven't stored the SS/ESP registers
773 * on the stack (interrupt gate does not save these registers
774 * when switching to the same priv ring).
775 * Therefore beware: accessing the ss/esp fields of the
776 * "struct pt_regs" is possible, but they may contain the
777 * completely wrong values.
778 */
779#define task_pt_regs(task) \
780({ \
781 struct pt_regs *__regs__; \
782 __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
783 __regs__ - 1; \
784})
785
786#define KSTK_ESP(task) (task_pt_regs(task)->sp)
787
3#else 788#else
4# include "processor_64.h" 789/*
790 * User space process size. 47bits minus one guard page.
791 */
792#define TASK_SIZE64 (0x800000000000UL - 4096)
793
794/* This decides where the kernel will search for a free chunk of vm
795 * space during mmap's.
796 */
797#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
798 0xc0000000 : 0xFFFFe000)
799
800#define TASK_SIZE (test_thread_flag(TIF_IA32) ? \
801 IA32_PAGE_OFFSET : TASK_SIZE64)
802#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? \
803 IA32_PAGE_OFFSET : TASK_SIZE64)
804
805#define INIT_THREAD { \
806 .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
807}
808
809#define INIT_TSS { \
810 .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
811}
812
813#define start_thread(regs, new_rip, new_rsp) do { \
814 asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \
815 load_gs_index(0); \
816 (regs)->ip = (new_rip); \
817 (regs)->sp = (new_rsp); \
818 write_pda(oldrsp, (new_rsp)); \
819 (regs)->cs = __USER_CS; \
820 (regs)->ss = __USER_DS; \
821 (regs)->flags = 0x200; \
822 set_fs(USER_DS); \
823} while (0)
824
825/*
826 * Return saved PC of a blocked thread.
827 * What is this good for? it will be always the scheduler or ret_from_fork.
828 */
829#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.sp - 8))
830
831#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.sp0 - 1)
832#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
833#endif /* CONFIG_X86_64 */
834
835/* This decides where the kernel will search for a free chunk of vm
836 * space during mmap's.
837 */
838#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
839
840#define KSTK_EIP(task) (task_pt_regs(task)->ip)
841
5#endif 842#endif
diff --git a/include/asm-x86/processor_32.h b/include/asm-x86/processor_32.h
deleted file mode 100644
index 13976b086837..000000000000
--- a/include/asm-x86/processor_32.h
+++ /dev/null
@@ -1,786 +0,0 @@
1/*
2 * include/asm-i386/processor.h
3 *
4 * Copyright (C) 1994 Linus Torvalds
5 */
6
7#ifndef __ASM_I386_PROCESSOR_H
8#define __ASM_I386_PROCESSOR_H
9
10#include <asm/vm86.h>
11#include <asm/math_emu.h>
12#include <asm/segment.h>
13#include <asm/page.h>
14#include <asm/types.h>
15#include <asm/sigcontext.h>
16#include <asm/cpufeature.h>
17#include <asm/msr.h>
18#include <asm/system.h>
19#include <linux/cache.h>
20#include <linux/threads.h>
21#include <asm/percpu.h>
22#include <linux/cpumask.h>
23#include <linux/init.h>
24#include <asm/processor-flags.h>
25
26/* flag for disabling the tsc */
27extern int tsc_disable;
28
29struct desc_struct {
30 unsigned long a,b;
31};
32
33#define desc_empty(desc) \
34 (!((desc)->a | (desc)->b))
35
36#define desc_equal(desc1, desc2) \
37 (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
38/*
39 * Default implementation of macro that returns current
40 * instruction pointer ("program counter").
41 */
42#define current_text_addr() ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
43
44/*
45 * CPU type and hardware bug flags. Kept separately for each CPU.
46 * Members of this structure are referenced in head.S, so think twice
47 * before touching them. [mj]
48 */
49
50struct cpuinfo_x86 {
51 __u8 x86; /* CPU family */
52 __u8 x86_vendor; /* CPU vendor */
53 __u8 x86_model;
54 __u8 x86_mask;
55 char wp_works_ok; /* It doesn't on 386's */
56 char hlt_works_ok; /* Problems on some 486Dx4's and old 386's */
57 char hard_math;
58 char rfu;
59 int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
60 unsigned long x86_capability[NCAPINTS];
61 char x86_vendor_id[16];
62 char x86_model_id[64];
63 int x86_cache_size; /* in KB - valid for CPUS which support this
64 call */
65 int x86_cache_alignment; /* In bytes */
66 char fdiv_bug;
67 char f00f_bug;
68 char coma_bug;
69 char pad0;
70 int x86_power;
71 unsigned long loops_per_jiffy;
72#ifdef CONFIG_SMP
73 cpumask_t llc_shared_map; /* cpus sharing the last level cache */
74#endif
75 unsigned char x86_max_cores; /* cpuid returned max cores value */
76 unsigned char apicid;
77 unsigned short x86_clflush_size;
78#ifdef CONFIG_SMP
79 unsigned char booted_cores; /* number of cores as seen by OS */
80 __u8 phys_proc_id; /* Physical processor id. */
81 __u8 cpu_core_id; /* Core id */
82 __u8 cpu_index; /* index into per_cpu list */
83#endif
84} __attribute__((__aligned__(SMP_CACHE_BYTES)));
85
86#define X86_VENDOR_INTEL 0
87#define X86_VENDOR_CYRIX 1
88#define X86_VENDOR_AMD 2
89#define X86_VENDOR_UMC 3
90#define X86_VENDOR_NEXGEN 4
91#define X86_VENDOR_CENTAUR 5
92#define X86_VENDOR_TRANSMETA 7
93#define X86_VENDOR_NSC 8
94#define X86_VENDOR_NUM 9
95#define X86_VENDOR_UNKNOWN 0xff
96
97/*
98 * capabilities of CPUs
99 */
100
101extern struct cpuinfo_x86 boot_cpu_data;
102extern struct cpuinfo_x86 new_cpu_data;
103extern struct tss_struct doublefault_tss;
104DECLARE_PER_CPU(struct tss_struct, init_tss);
105
106#ifdef CONFIG_SMP
107DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
108#define cpu_data(cpu) per_cpu(cpu_info, cpu)
109#define current_cpu_data cpu_data(smp_processor_id())
110#else
111#define cpu_data(cpu) boot_cpu_data
112#define current_cpu_data boot_cpu_data
113#endif
114
115/*
116 * the following now lives in the per cpu area:
117 * extern int cpu_llc_id[NR_CPUS];
118 */
119DECLARE_PER_CPU(u8, cpu_llc_id);
120extern char ignore_fpu_irq;
121
122void __init cpu_detect(struct cpuinfo_x86 *c);
123
124extern void identify_boot_cpu(void);
125extern void identify_secondary_cpu(struct cpuinfo_x86 *);
126extern void print_cpu_info(struct cpuinfo_x86 *);
127extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
128extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
129extern unsigned short num_cache_leaves;
130
131#ifdef CONFIG_X86_HT
132extern void detect_ht(struct cpuinfo_x86 *c);
133#else
134static inline void detect_ht(struct cpuinfo_x86 *c) {}
135#endif
136
137static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
138 unsigned int *ecx, unsigned int *edx)
139{
140 /* ecx is often an input as well as an output. */
141 __asm__("cpuid"
142 : "=a" (*eax),
143 "=b" (*ebx),
144 "=c" (*ecx),
145 "=d" (*edx)
146 : "0" (*eax), "2" (*ecx));
147}
148
149#define load_cr3(pgdir) write_cr3(__pa(pgdir))
150
151/*
152 * Save the cr4 feature set we're using (ie
153 * Pentium 4MB enable and PPro Global page
154 * enable), so that any CPU's that boot up
155 * after us can get the correct flags.
156 */
157extern unsigned long mmu_cr4_features;
158
159static inline void set_in_cr4 (unsigned long mask)
160{
161 unsigned cr4;
162 mmu_cr4_features |= mask;
163 cr4 = read_cr4();
164 cr4 |= mask;
165 write_cr4(cr4);
166}
167
168static inline void clear_in_cr4 (unsigned long mask)
169{
170 unsigned cr4;
171 mmu_cr4_features &= ~mask;
172 cr4 = read_cr4();
173 cr4 &= ~mask;
174 write_cr4(cr4);
175}
176
177/* Stop speculative execution */
178static inline void sync_core(void)
179{
180 int tmp;
181 asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
182}
183
184static inline void __monitor(const void *eax, unsigned long ecx,
185 unsigned long edx)
186{
187 /* "monitor %eax,%ecx,%edx;" */
188 asm volatile(
189 ".byte 0x0f,0x01,0xc8;"
190 : :"a" (eax), "c" (ecx), "d"(edx));
191}
192
193static inline void __mwait(unsigned long eax, unsigned long ecx)
194{
195 /* "mwait %eax,%ecx;" */
196 asm volatile(
197 ".byte 0x0f,0x01,0xc9;"
198 : :"a" (eax), "c" (ecx));
199}
200
201extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
202
203/* from system description table in BIOS. Mostly for MCA use, but
204others may find it useful. */
205extern unsigned int machine_id;
206extern unsigned int machine_submodel_id;
207extern unsigned int BIOS_revision;
208extern unsigned int mca_pentium_flag;
209
210/* Boot loader type from the setup header */
211extern int bootloader_type;
212
213/*
214 * User space process size: 3GB (default).
215 */
216#define TASK_SIZE (PAGE_OFFSET)
217
218/* This decides where the kernel will search for a free chunk of vm
219 * space during mmap's.
220 */
221#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
222
223#define HAVE_ARCH_PICK_MMAP_LAYOUT
224
225extern void hard_disable_TSC(void);
226extern void disable_TSC(void);
227extern void hard_enable_TSC(void);
228
229/*
230 * Size of io_bitmap.
231 */
232#define IO_BITMAP_BITS 65536
233#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
234#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
235#define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
236#define INVALID_IO_BITMAP_OFFSET 0x8000
237#define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000
238
239struct i387_fsave_struct {
240 long cwd;
241 long swd;
242 long twd;
243 long fip;
244 long fcs;
245 long foo;
246 long fos;
247 long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
248 long status; /* software status information */
249};
250
251struct i387_fxsave_struct {
252 unsigned short cwd;
253 unsigned short swd;
254 unsigned short twd;
255 unsigned short fop;
256 long fip;
257 long fcs;
258 long foo;
259 long fos;
260 long mxcsr;
261 long mxcsr_mask;
262 long st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
263 long xmm_space[32]; /* 8*16 bytes for each XMM-reg = 128 bytes */
264 long padding[56];
265} __attribute__ ((aligned (16)));
266
267struct i387_soft_struct {
268 long cwd;
269 long swd;
270 long twd;
271 long fip;
272 long fcs;
273 long foo;
274 long fos;
275 long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */
276 unsigned char ftop, changed, lookahead, no_update, rm, alimit;
277 struct info *info;
278 unsigned long entry_eip;
279};
280
281union i387_union {
282 struct i387_fsave_struct fsave;
283 struct i387_fxsave_struct fxsave;
284 struct i387_soft_struct soft;
285};
286
287typedef struct {
288 unsigned long seg;
289} mm_segment_t;
290
291struct thread_struct;
292
293/* This is the TSS defined by the hardware. */
294struct i386_hw_tss {
295 unsigned short back_link,__blh;
296 unsigned long esp0;
297 unsigned short ss0,__ss0h;
298 unsigned long esp1;
299 unsigned short ss1,__ss1h; /* ss1 is used to cache MSR_IA32_SYSENTER_CS */
300 unsigned long esp2;
301 unsigned short ss2,__ss2h;
302 unsigned long __cr3;
303 unsigned long eip;
304 unsigned long eflags;
305 unsigned long eax,ecx,edx,ebx;
306 unsigned long esp;
307 unsigned long ebp;
308 unsigned long esi;
309 unsigned long edi;
310 unsigned short es, __esh;
311 unsigned short cs, __csh;
312 unsigned short ss, __ssh;
313 unsigned short ds, __dsh;
314 unsigned short fs, __fsh;
315 unsigned short gs, __gsh;
316 unsigned short ldt, __ldth;
317 unsigned short trace, io_bitmap_base;
318} __attribute__((packed));
319
320struct tss_struct {
321 struct i386_hw_tss x86_tss;
322
323 /*
324 * The extra 1 is there because the CPU will access an
325 * additional byte beyond the end of the IO permission
326 * bitmap. The extra byte must be all 1 bits, and must
327 * be within the limit.
328 */
329 unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
330 /*
331 * Cache the current maximum and the last task that used the bitmap:
332 */
333 unsigned long io_bitmap_max;
334 struct thread_struct *io_bitmap_owner;
335 /*
336 * pads the TSS to be cacheline-aligned (size is 0x100)
337 */
338 unsigned long __cacheline_filler[35];
339 /*
340 * .. and then another 0x100 bytes for emergency kernel stack
341 */
342 unsigned long stack[64];
343} __attribute__((packed));
344
345#define ARCH_MIN_TASKALIGN 16
346
347struct thread_struct {
348/* cached TLS descriptors. */
349 struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
350 unsigned long esp0;
351 unsigned long sysenter_cs;
352 unsigned long eip;
353 unsigned long esp;
354 unsigned long fs;
355 unsigned long gs;
356/* Hardware debugging registers */
357 unsigned long debugreg[8]; /* %%db0-7 debug registers */
358/* fault info */
359 unsigned long cr2, trap_no, error_code;
360/* floating point info */
361 union i387_union i387;
362/* virtual 86 mode info */
363 struct vm86_struct __user * vm86_info;
364 unsigned long screen_bitmap;
365 unsigned long v86flags, v86mask, saved_esp0;
366 unsigned int saved_fs, saved_gs;
367/* IO permissions */
368 unsigned long *io_bitmap_ptr;
369 unsigned long iopl;
370/* max allowed port in the bitmap, in bytes: */
371 unsigned long io_bitmap_max;
372};
373
374#define INIT_THREAD { \
375 .esp0 = sizeof(init_stack) + (long)&init_stack, \
376 .vm86_info = NULL, \
377 .sysenter_cs = __KERNEL_CS, \
378 .io_bitmap_ptr = NULL, \
379 .fs = __KERNEL_PERCPU, \
380}
381
382/*
383 * Note that the .io_bitmap member must be extra-big. This is because
384 * the CPU will access an additional byte beyond the end of the IO
385 * permission bitmap. The extra byte must be all 1 bits, and must
386 * be within the limit.
387 */
388#define INIT_TSS { \
389 .x86_tss = { \
390 .esp0 = sizeof(init_stack) + (long)&init_stack, \
391 .ss0 = __KERNEL_DS, \
392 .ss1 = __KERNEL_CS, \
393 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
394 }, \
395 .io_bitmap = { [ 0 ... IO_BITMAP_LONGS] = ~0 }, \
396}
397
398#define start_thread(regs, new_eip, new_esp) do { \
399 __asm__("movl %0,%%gs": :"r" (0)); \
400 regs->xfs = 0; \
401 set_fs(USER_DS); \
402 regs->xds = __USER_DS; \
403 regs->xes = __USER_DS; \
404 regs->xss = __USER_DS; \
405 regs->xcs = __USER_CS; \
406 regs->eip = new_eip; \
407 regs->esp = new_esp; \
408} while (0)
409
410/* Forward declaration, a strange C thing */
411struct task_struct;
412struct mm_struct;
413
414/* Free all resources held by a thread. */
415extern void release_thread(struct task_struct *);
416
417/* Prepare to copy thread state - unlazy all lazy status */
418extern void prepare_to_copy(struct task_struct *tsk);
419
420/*
421 * create a kernel thread without removing it from tasklists
422 */
423extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
424
425extern unsigned long thread_saved_pc(struct task_struct *tsk);
426void show_trace(struct task_struct *task, struct pt_regs *regs, unsigned long *stack);
427
428unsigned long get_wchan(struct task_struct *p);
429
430#define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
431#define KSTK_TOP(info) \
432({ \
433 unsigned long *__ptr = (unsigned long *)(info); \
434 (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
435})
436
437/*
438 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
439 * This is necessary to guarantee that the entire "struct pt_regs"
440 * is accessable even if the CPU haven't stored the SS/ESP registers
441 * on the stack (interrupt gate does not save these registers
442 * when switching to the same priv ring).
443 * Therefore beware: accessing the xss/esp fields of the
444 * "struct pt_regs" is possible, but they may contain the
445 * completely wrong values.
446 */
447#define task_pt_regs(task) \
448({ \
449 struct pt_regs *__regs__; \
450 __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
451 __regs__ - 1; \
452})
453
454#define KSTK_EIP(task) (task_pt_regs(task)->eip)
455#define KSTK_ESP(task) (task_pt_regs(task)->esp)
456
457
458struct microcode_header {
459 unsigned int hdrver;
460 unsigned int rev;
461 unsigned int date;
462 unsigned int sig;
463 unsigned int cksum;
464 unsigned int ldrver;
465 unsigned int pf;
466 unsigned int datasize;
467 unsigned int totalsize;
468 unsigned int reserved[3];
469};
470
471struct microcode {
472 struct microcode_header hdr;
473 unsigned int bits[0];
474};
475
476typedef struct microcode microcode_t;
477typedef struct microcode_header microcode_header_t;
478
479/* microcode format is extended from prescott processors */
480struct extended_signature {
481 unsigned int sig;
482 unsigned int pf;
483 unsigned int cksum;
484};
485
486struct extended_sigtable {
487 unsigned int count;
488 unsigned int cksum;
489 unsigned int reserved[3];
490 struct extended_signature sigs[0];
491};
492
493/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
494static inline void rep_nop(void)
495{
496 __asm__ __volatile__("rep;nop": : :"memory");
497}
498
499#define cpu_relax() rep_nop()
500
501static inline void native_load_esp0(struct tss_struct *tss, struct thread_struct *thread)
502{
503 tss->x86_tss.esp0 = thread->esp0;
504 /* This can only happen when SEP is enabled, no need to test "SEP"arately */
505 if (unlikely(tss->x86_tss.ss1 != thread->sysenter_cs)) {
506 tss->x86_tss.ss1 = thread->sysenter_cs;
507 wrmsr(MSR_IA32_SYSENTER_CS, thread->sysenter_cs, 0);
508 }
509}
510
511
512static inline unsigned long native_get_debugreg(int regno)
513{
514 unsigned long val = 0; /* Damn you, gcc! */
515
516 switch (regno) {
517 case 0:
518 asm("movl %%db0, %0" :"=r" (val)); break;
519 case 1:
520 asm("movl %%db1, %0" :"=r" (val)); break;
521 case 2:
522 asm("movl %%db2, %0" :"=r" (val)); break;
523 case 3:
524 asm("movl %%db3, %0" :"=r" (val)); break;
525 case 6:
526 asm("movl %%db6, %0" :"=r" (val)); break;
527 case 7:
528 asm("movl %%db7, %0" :"=r" (val)); break;
529 default:
530 BUG();
531 }
532 return val;
533}
534
535static inline void native_set_debugreg(int regno, unsigned long value)
536{
537 switch (regno) {
538 case 0:
539 asm("movl %0,%%db0" : /* no output */ :"r" (value));
540 break;
541 case 1:
542 asm("movl %0,%%db1" : /* no output */ :"r" (value));
543 break;
544 case 2:
545 asm("movl %0,%%db2" : /* no output */ :"r" (value));
546 break;
547 case 3:
548 asm("movl %0,%%db3" : /* no output */ :"r" (value));
549 break;
550 case 6:
551 asm("movl %0,%%db6" : /* no output */ :"r" (value));
552 break;
553 case 7:
554 asm("movl %0,%%db7" : /* no output */ :"r" (value));
555 break;
556 default:
557 BUG();
558 }
559}
560
561/*
562 * Set IOPL bits in EFLAGS from given mask
563 */
564static inline void native_set_iopl_mask(unsigned mask)
565{
566 unsigned int reg;
567 __asm__ __volatile__ ("pushfl;"
568 "popl %0;"
569 "andl %1, %0;"
570 "orl %2, %0;"
571 "pushl %0;"
572 "popfl"
573 : "=&r" (reg)
574 : "i" (~X86_EFLAGS_IOPL), "r" (mask));
575}
576
577#ifdef CONFIG_PARAVIRT
578#include <asm/paravirt.h>
579#else
580#define paravirt_enabled() 0
581#define __cpuid native_cpuid
582
583static inline void load_esp0(struct tss_struct *tss, struct thread_struct *thread)
584{
585 native_load_esp0(tss, thread);
586}
587
588/*
589 * These special macros can be used to get or set a debugging register
590 */
591#define get_debugreg(var, register) \
592 (var) = native_get_debugreg(register)
593#define set_debugreg(value, register) \
594 native_set_debugreg(register, value)
595
596#define set_iopl_mask native_set_iopl_mask
597#endif /* CONFIG_PARAVIRT */
598
599/*
600 * Generic CPUID function
601 * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
602 * resulting in stale register contents being returned.
603 */
604static inline void cpuid(unsigned int op,
605 unsigned int *eax, unsigned int *ebx,
606 unsigned int *ecx, unsigned int *edx)
607{
608 *eax = op;
609 *ecx = 0;
610 __cpuid(eax, ebx, ecx, edx);
611}
612
613/* Some CPUID calls want 'count' to be placed in ecx */
614static inline void cpuid_count(unsigned int op, int count,
615 unsigned int *eax, unsigned int *ebx,
616 unsigned int *ecx, unsigned int *edx)
617{
618 *eax = op;
619 *ecx = count;
620 __cpuid(eax, ebx, ecx, edx);
621}
622
623/*
624 * CPUID functions returning a single datum
625 */
626static inline unsigned int cpuid_eax(unsigned int op)
627{
628 unsigned int eax, ebx, ecx, edx;
629
630 cpuid(op, &eax, &ebx, &ecx, &edx);
631 return eax;
632}
633static inline unsigned int cpuid_ebx(unsigned int op)
634{
635 unsigned int eax, ebx, ecx, edx;
636
637 cpuid(op, &eax, &ebx, &ecx, &edx);
638 return ebx;
639}
640static inline unsigned int cpuid_ecx(unsigned int op)
641{
642 unsigned int eax, ebx, ecx, edx;
643
644 cpuid(op, &eax, &ebx, &ecx, &edx);
645 return ecx;
646}
647static inline unsigned int cpuid_edx(unsigned int op)
648{
649 unsigned int eax, ebx, ecx, edx;
650
651 cpuid(op, &eax, &ebx, &ecx, &edx);
652 return edx;
653}
654
655/* generic versions from gas */
656#define GENERIC_NOP1 ".byte 0x90\n"
657#define GENERIC_NOP2 ".byte 0x89,0xf6\n"
658#define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n"
659#define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n"
660#define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4
661#define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
662#define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
663#define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7
664
665/* Opteron nops */
666#define K8_NOP1 GENERIC_NOP1
667#define K8_NOP2 ".byte 0x66,0x90\n"
668#define K8_NOP3 ".byte 0x66,0x66,0x90\n"
669#define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n"
670#define K8_NOP5 K8_NOP3 K8_NOP2
671#define K8_NOP6 K8_NOP3 K8_NOP3
672#define K8_NOP7 K8_NOP4 K8_NOP3
673#define K8_NOP8 K8_NOP4 K8_NOP4
674
675/* K7 nops */
676/* uses eax dependencies (arbitary choice) */
677#define K7_NOP1 GENERIC_NOP1
678#define K7_NOP2 ".byte 0x8b,0xc0\n"
679#define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
680#define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
681#define K7_NOP5 K7_NOP4 ASM_NOP1
682#define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n"
683#define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n"
684#define K7_NOP8 K7_NOP7 ASM_NOP1
685
686/* P6 nops */
687/* uses eax dependencies (Intel-recommended choice) */
688#define P6_NOP1 GENERIC_NOP1
689#define P6_NOP2 ".byte 0x66,0x90\n"
690#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
691#define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
692#define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
693#define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
694#define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
695#define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
696
697#ifdef CONFIG_MK8
698#define ASM_NOP1 K8_NOP1
699#define ASM_NOP2 K8_NOP2
700#define ASM_NOP3 K8_NOP3
701#define ASM_NOP4 K8_NOP4
702#define ASM_NOP5 K8_NOP5
703#define ASM_NOP6 K8_NOP6
704#define ASM_NOP7 K8_NOP7
705#define ASM_NOP8 K8_NOP8
706#elif defined(CONFIG_MK7)
707#define ASM_NOP1 K7_NOP1
708#define ASM_NOP2 K7_NOP2
709#define ASM_NOP3 K7_NOP3
710#define ASM_NOP4 K7_NOP4
711#define ASM_NOP5 K7_NOP5
712#define ASM_NOP6 K7_NOP6
713#define ASM_NOP7 K7_NOP7
714#define ASM_NOP8 K7_NOP8
715#elif defined(CONFIG_M686) || defined(CONFIG_MPENTIUMII) || \
716 defined(CONFIG_MPENTIUMIII) || defined(CONFIG_MPENTIUMM) || \
717 defined(CONFIG_MCORE2) || defined(CONFIG_PENTIUM4)
718#define ASM_NOP1 P6_NOP1
719#define ASM_NOP2 P6_NOP2
720#define ASM_NOP3 P6_NOP3
721#define ASM_NOP4 P6_NOP4
722#define ASM_NOP5 P6_NOP5
723#define ASM_NOP6 P6_NOP6
724#define ASM_NOP7 P6_NOP7
725#define ASM_NOP8 P6_NOP8
726#else
727#define ASM_NOP1 GENERIC_NOP1
728#define ASM_NOP2 GENERIC_NOP2
729#define ASM_NOP3 GENERIC_NOP3
730#define ASM_NOP4 GENERIC_NOP4
731#define ASM_NOP5 GENERIC_NOP5
732#define ASM_NOP6 GENERIC_NOP6
733#define ASM_NOP7 GENERIC_NOP7
734#define ASM_NOP8 GENERIC_NOP8
735#endif
736
737#define ASM_NOP_MAX 8
738
739/* Prefetch instructions for Pentium III and AMD Athlon */
740/* It's not worth to care about 3dnow! prefetches for the K6
741 because they are microcoded there and very slow.
742 However we don't do prefetches for pre XP Athlons currently
743 That should be fixed. */
744#define ARCH_HAS_PREFETCH
745static inline void prefetch(const void *x)
746{
747 alternative_input(ASM_NOP4,
748 "prefetchnta (%1)",
749 X86_FEATURE_XMM,
750 "r" (x));
751}
752
753#define ARCH_HAS_PREFETCH
754#define ARCH_HAS_PREFETCHW
755#define ARCH_HAS_SPINLOCK_PREFETCH
756
757/* 3dnow! prefetch to get an exclusive cache line. Useful for
758 spinlocks to avoid one state transition in the cache coherency protocol. */
759static inline void prefetchw(const void *x)
760{
761 alternative_input(ASM_NOP4,
762 "prefetchw (%1)",
763 X86_FEATURE_3DNOW,
764 "r" (x));
765}
766#define spin_lock_prefetch(x) prefetchw(x)
767
768extern void select_idle_routine(const struct cpuinfo_x86 *c);
769
770#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
771
772extern unsigned long boot_option_idle_override;
773extern void enable_sep_cpu(void);
774extern int sysenter_setup(void);
775
776/* Defined in head.S */
777extern struct Xgt_desc_struct early_gdt_descr;
778
779extern void cpu_set_gdt(int);
780extern void switch_to_new_gdt(void);
781extern void cpu_init(void);
782extern void init_gdt(int cpu);
783
784extern int force_mwait;
785
786#endif /* __ASM_I386_PROCESSOR_H */
diff --git a/include/asm-x86/processor_64.h b/include/asm-x86/processor_64.h
deleted file mode 100644
index e4f19970a82b..000000000000
--- a/include/asm-x86/processor_64.h
+++ /dev/null
@@ -1,452 +0,0 @@
1/*
2 * include/asm-x86_64/processor.h
3 *
4 * Copyright (C) 1994 Linus Torvalds
5 */
6
7#ifndef __ASM_X86_64_PROCESSOR_H
8#define __ASM_X86_64_PROCESSOR_H
9
10#include <asm/segment.h>
11#include <asm/page.h>
12#include <asm/types.h>
13#include <asm/sigcontext.h>
14#include <asm/cpufeature.h>
15#include <linux/threads.h>
16#include <asm/msr.h>
17#include <asm/current.h>
18#include <asm/system.h>
19#include <asm/mmsegment.h>
20#include <asm/percpu.h>
21#include <linux/personality.h>
22#include <linux/cpumask.h>
23#include <asm/processor-flags.h>
24
25#define TF_MASK 0x00000100
26#define IF_MASK 0x00000200
27#define IOPL_MASK 0x00003000
28#define NT_MASK 0x00004000
29#define VM_MASK 0x00020000
30#define AC_MASK 0x00040000
31#define VIF_MASK 0x00080000 /* virtual interrupt flag */
32#define VIP_MASK 0x00100000 /* virtual interrupt pending */
33#define ID_MASK 0x00200000
34
35#define desc_empty(desc) \
36 (!((desc)->a | (desc)->b))
37
38#define desc_equal(desc1, desc2) \
39 (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
40
41/*
42 * Default implementation of macro that returns current
43 * instruction pointer ("program counter").
44 */
45#define current_text_addr() ({ void *pc; asm volatile("leaq 1f(%%rip),%0\n1:":"=r"(pc)); pc; })
46
47/*
48 * CPU type and hardware bug flags. Kept separately for each CPU.
49 */
50
51struct cpuinfo_x86 {
52 __u8 x86; /* CPU family */
53 __u8 x86_vendor; /* CPU vendor */
54 __u8 x86_model;
55 __u8 x86_mask;
56 int cpuid_level; /* Maximum supported CPUID level, -1=no CPUID */
57 __u32 x86_capability[NCAPINTS];
58 char x86_vendor_id[16];
59 char x86_model_id[64];
60 int x86_cache_size; /* in KB */
61 int x86_clflush_size;
62 int x86_cache_alignment;
63 int x86_tlbsize; /* number of 4K pages in DTLB/ITLB combined(in pages)*/
64 __u8 x86_virt_bits, x86_phys_bits;
65 __u8 x86_max_cores; /* cpuid returned max cores value */
66 __u32 x86_power;
67 __u32 extended_cpuid_level; /* Max extended CPUID function supported */
68 unsigned long loops_per_jiffy;
69#ifdef CONFIG_SMP
70 cpumask_t llc_shared_map; /* cpus sharing the last level cache */
71#endif
72 __u8 apicid;
73#ifdef CONFIG_SMP
74 __u8 booted_cores; /* number of cores as seen by OS */
75 __u8 phys_proc_id; /* Physical Processor id. */
76 __u8 cpu_core_id; /* Core id. */
77 __u8 cpu_index; /* index into per_cpu list */
78#endif
79} ____cacheline_aligned;
80
81#define X86_VENDOR_INTEL 0
82#define X86_VENDOR_CYRIX 1
83#define X86_VENDOR_AMD 2
84#define X86_VENDOR_UMC 3
85#define X86_VENDOR_NEXGEN 4
86#define X86_VENDOR_CENTAUR 5
87#define X86_VENDOR_TRANSMETA 7
88#define X86_VENDOR_NUM 8
89#define X86_VENDOR_UNKNOWN 0xff
90
91#ifdef CONFIG_SMP
92DECLARE_PER_CPU(struct cpuinfo_x86, cpu_info);
93#define cpu_data(cpu) per_cpu(cpu_info, cpu)
94#define current_cpu_data cpu_data(smp_processor_id())
95#else
96#define cpu_data(cpu) boot_cpu_data
97#define current_cpu_data boot_cpu_data
98#endif
99
100extern char ignore_irq13;
101
102extern void identify_cpu(struct cpuinfo_x86 *);
103extern void print_cpu_info(struct cpuinfo_x86 *);
104extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c);
105extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c);
106extern unsigned short num_cache_leaves;
107
108/*
109 * Save the cr4 feature set we're using (ie
110 * Pentium 4MB enable and PPro Global page
111 * enable), so that any CPU's that boot up
112 * after us can get the correct flags.
113 */
114extern unsigned long mmu_cr4_features;
115
116static inline void set_in_cr4 (unsigned long mask)
117{
118 mmu_cr4_features |= mask;
119 __asm__("movq %%cr4,%%rax\n\t"
120 "orq %0,%%rax\n\t"
121 "movq %%rax,%%cr4\n"
122 : : "irg" (mask)
123 :"ax");
124}
125
126static inline void clear_in_cr4 (unsigned long mask)
127{
128 mmu_cr4_features &= ~mask;
129 __asm__("movq %%cr4,%%rax\n\t"
130 "andq %0,%%rax\n\t"
131 "movq %%rax,%%cr4\n"
132 : : "irg" (~mask)
133 :"ax");
134}
135
136
137/*
138 * User space process size. 47bits minus one guard page.
139 */
140#define TASK_SIZE64 (0x800000000000UL - 4096)
141
142/* This decides where the kernel will search for a free chunk of vm
143 * space during mmap's.
144 */
145#define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000)
146
147#define TASK_SIZE (test_thread_flag(TIF_IA32) ? IA32_PAGE_OFFSET : TASK_SIZE64)
148#define TASK_SIZE_OF(child) ((test_tsk_thread_flag(child, TIF_IA32)) ? IA32_PAGE_OFFSET : TASK_SIZE64)
149
150#define TASK_UNMAPPED_BASE PAGE_ALIGN(TASK_SIZE/3)
151
152/*
153 * Size of io_bitmap.
154 */
155#define IO_BITMAP_BITS 65536
156#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
157#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
158#define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
159#define INVALID_IO_BITMAP_OFFSET 0x8000
160
161struct i387_fxsave_struct {
162 u16 cwd;
163 u16 swd;
164 u16 twd;
165 u16 fop;
166 u64 rip;
167 u64 rdp;
168 u32 mxcsr;
169 u32 mxcsr_mask;
170 u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
171 u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
172 u32 padding[24];
173} __attribute__ ((aligned (16)));
174
175union i387_union {
176 struct i387_fxsave_struct fxsave;
177};
178
179struct tss_struct {
180 u32 reserved1;
181 u64 rsp0;
182 u64 rsp1;
183 u64 rsp2;
184 u64 reserved2;
185 u64 ist[7];
186 u32 reserved3;
187 u32 reserved4;
188 u16 reserved5;
189 u16 io_bitmap_base;
190 /*
191 * The extra 1 is there because the CPU will access an
192 * additional byte beyond the end of the IO permission
193 * bitmap. The extra byte must be all 1 bits, and must
194 * be within the limit. Thus we have:
195 *
196 * 128 bytes, the bitmap itself, for ports 0..0x3ff
197 * 8 bytes, for an extra "long" of ~0UL
198 */
199 unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
200} __attribute__((packed)) ____cacheline_aligned;
201
202
203extern struct cpuinfo_x86 boot_cpu_data;
204DECLARE_PER_CPU(struct tss_struct,init_tss);
205/* Save the original ist values for checking stack pointers during debugging */
206struct orig_ist {
207 unsigned long ist[7];
208};
209DECLARE_PER_CPU(struct orig_ist, orig_ist);
210
211#ifdef CONFIG_X86_VSMP
212#define ARCH_MIN_TASKALIGN (1 << INTERNODE_CACHE_SHIFT)
213#define ARCH_MIN_MMSTRUCT_ALIGN (1 << INTERNODE_CACHE_SHIFT)
214#else
215#define ARCH_MIN_TASKALIGN 16
216#define ARCH_MIN_MMSTRUCT_ALIGN 0
217#endif
218
219struct thread_struct {
220 unsigned long rsp0;
221 unsigned long rsp;
222 unsigned long userrsp; /* Copy from PDA */
223 unsigned long fs;
224 unsigned long gs;
225 unsigned short es, ds, fsindex, gsindex;
226/* Hardware debugging registers */
227 unsigned long debugreg0;
228 unsigned long debugreg1;
229 unsigned long debugreg2;
230 unsigned long debugreg3;
231 unsigned long debugreg6;
232 unsigned long debugreg7;
233/* fault info */
234 unsigned long cr2, trap_no, error_code;
235/* floating point info */
236 union i387_union i387 __attribute__((aligned(16)));
237/* IO permissions. the bitmap could be moved into the GDT, that would make
238 switch faster for a limited number of ioperm using tasks. -AK */
239 int ioperm;
240 unsigned long *io_bitmap_ptr;
241 unsigned io_bitmap_max;
242/* cached TLS descriptors. */
243 u64 tls_array[GDT_ENTRY_TLS_ENTRIES];
244} __attribute__((aligned(16)));
245
246#define INIT_THREAD { \
247 .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
248}
249
250#define INIT_TSS { \
251 .rsp0 = (unsigned long)&init_stack + sizeof(init_stack) \
252}
253
254#define INIT_MMAP \
255{ &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, NULL, NULL }
256
257#define start_thread(regs,new_rip,new_rsp) do { \
258 asm volatile("movl %0,%%fs; movl %0,%%es; movl %0,%%ds": :"r" (0)); \
259 load_gs_index(0); \
260 (regs)->rip = (new_rip); \
261 (regs)->rsp = (new_rsp); \
262 write_pda(oldrsp, (new_rsp)); \
263 (regs)->cs = __USER_CS; \
264 (regs)->ss = __USER_DS; \
265 (regs)->eflags = 0x200; \
266 set_fs(USER_DS); \
267} while(0)
268
269#define get_debugreg(var, register) \
270 __asm__("movq %%db" #register ", %0" \
271 :"=r" (var))
272#define set_debugreg(value, register) \
273 __asm__("movq %0,%%db" #register \
274 : /* no output */ \
275 :"r" (value))
276
277struct task_struct;
278struct mm_struct;
279
280/* Free all resources held by a thread. */
281extern void release_thread(struct task_struct *);
282
283/* Prepare to copy thread state - unlazy all lazy status */
284extern void prepare_to_copy(struct task_struct *tsk);
285
286/*
287 * create a kernel thread without removing it from tasklists
288 */
289extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
290
291/*
292 * Return saved PC of a blocked thread.
293 * What is this good for? it will be always the scheduler or ret_from_fork.
294 */
295#define thread_saved_pc(t) (*(unsigned long *)((t)->thread.rsp - 8))
296
297extern unsigned long get_wchan(struct task_struct *p);
298#define task_pt_regs(tsk) ((struct pt_regs *)(tsk)->thread.rsp0 - 1)
299#define KSTK_EIP(tsk) (task_pt_regs(tsk)->rip)
300#define KSTK_ESP(tsk) -1 /* sorry. doesn't work for syscall. */
301
302
303struct microcode_header {
304 unsigned int hdrver;
305 unsigned int rev;
306 unsigned int date;
307 unsigned int sig;
308 unsigned int cksum;
309 unsigned int ldrver;
310 unsigned int pf;
311 unsigned int datasize;
312 unsigned int totalsize;
313 unsigned int reserved[3];
314};
315
316struct microcode {
317 struct microcode_header hdr;
318 unsigned int bits[0];
319};
320
321typedef struct microcode microcode_t;
322typedef struct microcode_header microcode_header_t;
323
324/* microcode format is extended from prescott processors */
325struct extended_signature {
326 unsigned int sig;
327 unsigned int pf;
328 unsigned int cksum;
329};
330
331struct extended_sigtable {
332 unsigned int count;
333 unsigned int cksum;
334 unsigned int reserved[3];
335 struct extended_signature sigs[0];
336};
337
338
339#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2)
340#define ASM_NOP1 P6_NOP1
341#define ASM_NOP2 P6_NOP2
342#define ASM_NOP3 P6_NOP3
343#define ASM_NOP4 P6_NOP4
344#define ASM_NOP5 P6_NOP5
345#define ASM_NOP6 P6_NOP6
346#define ASM_NOP7 P6_NOP7
347#define ASM_NOP8 P6_NOP8
348#else
349#define ASM_NOP1 K8_NOP1
350#define ASM_NOP2 K8_NOP2
351#define ASM_NOP3 K8_NOP3
352#define ASM_NOP4 K8_NOP4
353#define ASM_NOP5 K8_NOP5
354#define ASM_NOP6 K8_NOP6
355#define ASM_NOP7 K8_NOP7
356#define ASM_NOP8 K8_NOP8
357#endif
358
359/* Opteron nops */
360#define K8_NOP1 ".byte 0x90\n"
361#define K8_NOP2 ".byte 0x66,0x90\n"
362#define K8_NOP3 ".byte 0x66,0x66,0x90\n"
363#define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n"
364#define K8_NOP5 K8_NOP3 K8_NOP2
365#define K8_NOP6 K8_NOP3 K8_NOP3
366#define K8_NOP7 K8_NOP4 K8_NOP3
367#define K8_NOP8 K8_NOP4 K8_NOP4
368
369/* P6 nops */
370/* uses eax dependencies (Intel-recommended choice) */
371#define P6_NOP1 ".byte 0x90\n"
372#define P6_NOP2 ".byte 0x66,0x90\n"
373#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
374#define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
375#define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
376#define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
377#define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
378#define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
379
380#define ASM_NOP_MAX 8
381
382/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
383static inline void rep_nop(void)
384{
385 __asm__ __volatile__("rep;nop": : :"memory");
386}
387
388/* Stop speculative execution */
389static inline void sync_core(void)
390{
391 int tmp;
392 asm volatile("cpuid" : "=a" (tmp) : "0" (1) : "ebx","ecx","edx","memory");
393}
394
395#define ARCH_HAS_PREFETCHW 1
396static inline void prefetchw(void *x)
397{
398 alternative_input("prefetcht0 (%1)",
399 "prefetchw (%1)",
400 X86_FEATURE_3DNOW,
401 "r" (x));
402}
403
404#define ARCH_HAS_SPINLOCK_PREFETCH 1
405
406#define spin_lock_prefetch(x) prefetchw(x)
407
408#define cpu_relax() rep_nop()
409
410static inline void __monitor(const void *eax, unsigned long ecx,
411 unsigned long edx)
412{
413 /* "monitor %eax,%ecx,%edx;" */
414 asm volatile(
415 ".byte 0x0f,0x01,0xc8;"
416 : :"a" (eax), "c" (ecx), "d"(edx));
417}
418
419static inline void __mwait(unsigned long eax, unsigned long ecx)
420{
421 /* "mwait %eax,%ecx;" */
422 asm volatile(
423 ".byte 0x0f,0x01,0xc9;"
424 : :"a" (eax), "c" (ecx));
425}
426
427static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
428{
429 /* "mwait %eax,%ecx;" */
430 asm volatile(
431 "sti; .byte 0x0f,0x01,0xc9;"
432 : :"a" (eax), "c" (ecx));
433}
434
435extern void mwait_idle_with_hints(unsigned long eax, unsigned long ecx);
436
437#define stack_current() \
438({ \
439 struct thread_info *ti; \
440 asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
441 ti->task; \
442})
443
444#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
445
446extern unsigned long boot_option_idle_override;
447/* Boot loader type from the setup header */
448extern int bootloader_type;
449
450#define HAVE_ARCH_PICK_MMAP_LAYOUT 1
451
452#endif /* __ASM_X86_64_PROCESSOR_H */
diff --git a/include/asm-x86/proto.h b/include/asm-x86/proto.h
index dabba55f7ed8..68563c0709ac 100644
--- a/include/asm-x86/proto.h
+++ b/include/asm-x86/proto.h
@@ -5,87 +5,24 @@
5 5
6/* misc architecture specific prototypes */ 6/* misc architecture specific prototypes */
7 7
8struct cpuinfo_x86;
9struct pt_regs;
10
11extern void start_kernel(void);
12extern void pda_init(int);
13
14extern void early_idt_handler(void); 8extern void early_idt_handler(void);
15 9
16extern void mcheck_init(struct cpuinfo_x86 *c);
17extern void init_memory_mapping(unsigned long start, unsigned long end); 10extern void init_memory_mapping(unsigned long start, unsigned long end);
18 11
19extern void system_call(void); 12extern void system_call(void);
20extern int kernel_syscall(void);
21extern void syscall_init(void); 13extern void syscall_init(void);
22 14
23extern void ia32_syscall(void); 15extern void ia32_syscall(void);
24extern void ia32_cstar_target(void); 16extern void ia32_cstar_target(void);
25extern void ia32_sysenter_target(void); 17extern void ia32_sysenter_target(void);
26
27extern void config_acpi_tables(void);
28extern void ia32_syscall(void);
29
30extern int pmtimer_mark_offset(void);
31extern void pmtimer_resume(void);
32extern void pmtimer_wait(unsigned);
33extern unsigned int do_gettimeoffset_pm(void);
34#ifdef CONFIG_X86_PM_TIMER
35extern u32 pmtmr_ioport;
36#else
37#define pmtmr_ioport 0
38#endif
39extern int nohpet;
40
41extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2)));
42
43extern void early_identify_cpu(struct cpuinfo_x86 *c);
44
45extern int k8_scan_nodes(unsigned long start, unsigned long end);
46
47extern void numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn);
48extern unsigned long numa_free_all_bootmem(void);
49 18
50extern void reserve_bootmem_generic(unsigned long phys, unsigned len); 19extern void reserve_bootmem_generic(unsigned long phys, unsigned len);
51 20
52extern void load_gs_index(unsigned gs);
53
54extern unsigned long end_pfn_map;
55
56extern void show_trace(struct task_struct *, struct pt_regs *, unsigned long * rsp);
57extern void show_registers(struct pt_regs *regs);
58
59extern void exception_table_check(void);
60
61extern void acpi_reserve_bootmem(void);
62
63extern void swap_low_mappings(void);
64
65extern void __show_regs(struct pt_regs * regs);
66extern void show_regs(struct pt_regs * regs);
67
68extern void syscall32_cpu_init(void); 21extern void syscall32_cpu_init(void);
69 22
70extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long end);
71
72extern void early_quirks(void);
73extern void check_efer(void); 23extern void check_efer(void);
74 24
75extern void select_idle_routine(const struct cpuinfo_x86 *c);
76
77extern unsigned long table_start, table_end;
78
79extern int exception_trace;
80extern unsigned cpu_khz;
81extern unsigned tsc_khz;
82
83extern int reboot_force; 25extern int reboot_force;
84extern int notsc_setup(char *);
85
86extern int gsi_irq_sharing(int gsi);
87
88extern int force_mwait;
89 26
90long do_arch_prctl(struct task_struct *task, int code, unsigned long addr); 27long do_arch_prctl(struct task_struct *task, int code, unsigned long addr);
91 28
diff --git a/include/asm-x86/ptrace-abi.h b/include/asm-x86/ptrace-abi.h
index 7524e1233833..81a8ee4c55fc 100644
--- a/include/asm-x86/ptrace-abi.h
+++ b/include/asm-x86/ptrace-abi.h
@@ -78,4 +78,66 @@
78# define PTRACE_SYSEMU_SINGLESTEP 32 78# define PTRACE_SYSEMU_SINGLESTEP 32
79#endif 79#endif
80 80
81#define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */
82
83#ifndef __ASSEMBLY__
84
85#include <asm/types.h>
86
87/* configuration/status structure used in PTRACE_BTS_CONFIG and
88 PTRACE_BTS_STATUS commands.
89*/
90struct ptrace_bts_config {
91 /* requested or actual size of BTS buffer in bytes */
92 u32 size;
93 /* bitmask of below flags */
94 u32 flags;
95 /* buffer overflow signal */
96 u32 signal;
97 /* actual size of bts_struct in bytes */
98 u32 bts_size;
99};
100#endif
101
102#define PTRACE_BTS_O_TRACE 0x1 /* branch trace */
103#define PTRACE_BTS_O_SCHED 0x2 /* scheduling events w/ jiffies */
104#define PTRACE_BTS_O_SIGNAL 0x4 /* send SIG<signal> on buffer overflow
105 instead of wrapping around */
106#define PTRACE_BTS_O_CUT_SIZE 0x8 /* cut requested size to max available
107 instead of failing */
108
109#define PTRACE_BTS_CONFIG 40
110/* Configure branch trace recording.
111 ADDR points to a struct ptrace_bts_config.
112 DATA gives the size of that buffer.
113 A new buffer is allocated, iff the size changes.
114 Returns the number of bytes read.
115*/
116#define PTRACE_BTS_STATUS 41
117/* Return the current configuration in a struct ptrace_bts_config
118 pointed to by ADDR; DATA gives the size of that buffer.
119 Returns the number of bytes written.
120*/
121#define PTRACE_BTS_SIZE 42
122/* Return the number of available BTS records.
123 DATA and ADDR are ignored.
124*/
125#define PTRACE_BTS_GET 43
126/* Get a single BTS record.
127 DATA defines the index into the BTS array, where 0 is the newest
128 entry, and higher indices refer to older entries.
129 ADDR is pointing to struct bts_struct (see asm/ds.h).
130*/
131#define PTRACE_BTS_CLEAR 44
132/* Clear the BTS buffer.
133 DATA and ADDR are ignored.
134*/
135#define PTRACE_BTS_DRAIN 45
136/* Read all available BTS records and clear the buffer.
137 ADDR points to an array of struct bts_struct.
138 DATA gives the size of that buffer.
139 BTS records are read from oldest to newest.
140 Returns number of BTS records drained.
141*/
142
81#endif 143#endif
diff --git a/include/asm-x86/ptrace.h b/include/asm-x86/ptrace.h
index 213c97300cb3..d9e04b46a440 100644
--- a/include/asm-x86/ptrace.h
+++ b/include/asm-x86/ptrace.h
@@ -4,12 +4,15 @@
4#include <linux/compiler.h> /* For __user */ 4#include <linux/compiler.h> /* For __user */
5#include <asm/ptrace-abi.h> 5#include <asm/ptrace-abi.h>
6 6
7
7#ifndef __ASSEMBLY__ 8#ifndef __ASSEMBLY__
8 9
9#ifdef __i386__ 10#ifdef __i386__
10/* this struct defines the way the registers are stored on the 11/* this struct defines the way the registers are stored on the
11 stack during a system call. */ 12 stack during a system call. */
12 13
14#ifndef __KERNEL__
15
13struct pt_regs { 16struct pt_regs {
14 long ebx; 17 long ebx;
15 long ecx; 18 long ecx;
@@ -21,7 +24,7 @@ struct pt_regs {
21 int xds; 24 int xds;
22 int xes; 25 int xes;
23 int xfs; 26 int xfs;
24 /* int xgs; */ 27 /* int gs; */
25 long orig_eax; 28 long orig_eax;
26 long eip; 29 long eip;
27 int xcs; 30 int xcs;
@@ -30,44 +33,37 @@ struct pt_regs {
30 int xss; 33 int xss;
31}; 34};
32 35
33#ifdef __KERNEL__ 36#else /* __KERNEL__ */
37
38struct pt_regs {
39 long bx;
40 long cx;
41 long dx;
42 long si;
43 long di;
44 long bp;
45 long ax;
46 int ds;
47 int es;
48 int fs;
49 /* int gs; */
50 long orig_ax;
51 long ip;
52 int cs;
53 long flags;
54 long sp;
55 int ss;
56};
34 57
35#include <asm/vm86.h> 58#include <asm/vm86.h>
36#include <asm/segment.h> 59#include <asm/segment.h>
37 60
38struct task_struct;
39extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
40
41/*
42 * user_mode_vm(regs) determines whether a register set came from user mode.
43 * This is true if V8086 mode was enabled OR if the register set was from
44 * protected mode with RPL-3 CS value. This tricky test checks that with
45 * one comparison. Many places in the kernel can bypass this full check
46 * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
47 */
48static inline int user_mode(struct pt_regs *regs)
49{
50 return (regs->xcs & SEGMENT_RPL_MASK) == USER_RPL;
51}
52static inline int user_mode_vm(struct pt_regs *regs)
53{
54 return ((regs->xcs & SEGMENT_RPL_MASK) | (regs->eflags & VM_MASK)) >= USER_RPL;
55}
56static inline int v8086_mode(struct pt_regs *regs)
57{
58 return (regs->eflags & VM_MASK);
59}
60
61#define instruction_pointer(regs) ((regs)->eip)
62#define frame_pointer(regs) ((regs)->ebp)
63#define stack_pointer(regs) ((regs)->esp)
64#define regs_return_value(regs) ((regs)->eax)
65
66extern unsigned long profile_pc(struct pt_regs *regs);
67#endif /* __KERNEL__ */ 61#endif /* __KERNEL__ */
68 62
69#else /* __i386__ */ 63#else /* __i386__ */
70 64
65#ifndef __KERNEL__
66
71struct pt_regs { 67struct pt_regs {
72 unsigned long r15; 68 unsigned long r15;
73 unsigned long r14; 69 unsigned long r14;
@@ -96,47 +92,143 @@ struct pt_regs {
96/* top of stack page */ 92/* top of stack page */
97}; 93};
98 94
95#else /* __KERNEL__ */
96
97struct pt_regs {
98 unsigned long r15;
99 unsigned long r14;
100 unsigned long r13;
101 unsigned long r12;
102 unsigned long bp;
103 unsigned long bx;
104/* arguments: non interrupts/non tracing syscalls only save upto here*/
105 unsigned long r11;
106 unsigned long r10;
107 unsigned long r9;
108 unsigned long r8;
109 unsigned long ax;
110 unsigned long cx;
111 unsigned long dx;
112 unsigned long si;
113 unsigned long di;
114 unsigned long orig_ax;
115/* end of arguments */
116/* cpu exception frame or undefined */
117 unsigned long ip;
118 unsigned long cs;
119 unsigned long flags;
120 unsigned long sp;
121 unsigned long ss;
122/* top of stack page */
123};
124
125#endif /* __KERNEL__ */
126#endif /* !__i386__ */
127
99#ifdef __KERNEL__ 128#ifdef __KERNEL__
100 129
101#define user_mode(regs) (!!((regs)->cs & 3)) 130/* the DS BTS struct is used for ptrace as well */
102#define user_mode_vm(regs) user_mode(regs) 131#include <asm/ds.h>
103#define instruction_pointer(regs) ((regs)->rip) 132
104#define frame_pointer(regs) ((regs)->rbp) 133struct task_struct;
105#define stack_pointer(regs) ((regs)->rsp) 134
106#define regs_return_value(regs) ((regs)->rax) 135extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier);
107 136
108extern unsigned long profile_pc(struct pt_regs *regs); 137extern unsigned long profile_pc(struct pt_regs *regs);
138
139extern unsigned long
140convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
141
142#ifdef CONFIG_X86_32
143extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
144#else
109void signal_fault(struct pt_regs *regs, void __user *frame, char *where); 145void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
146#endif
110 147
111struct task_struct; 148#define regs_return_value(regs) ((regs)->ax)
149
150/*
151 * user_mode_vm(regs) determines whether a register set came from user mode.
152 * This is true if V8086 mode was enabled OR if the register set was from
153 * protected mode with RPL-3 CS value. This tricky test checks that with
154 * one comparison. Many places in the kernel can bypass this full check
155 * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
156 */
157static inline int user_mode(struct pt_regs *regs)
158{
159#ifdef CONFIG_X86_32
160 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
161#else
162 return !!(regs->cs & 3);
163#endif
164}
165
166static inline int user_mode_vm(struct pt_regs *regs)
167{
168#ifdef CONFIG_X86_32
169 return ((regs->cs & SEGMENT_RPL_MASK) |
170 (regs->flags & VM_MASK)) >= USER_RPL;
171#else
172 return user_mode(regs);
173#endif
174}
175
176static inline int v8086_mode(struct pt_regs *regs)
177{
178#ifdef CONFIG_X86_32
179 return (regs->flags & VM_MASK);
180#else
181 return 0; /* No V86 mode support in long mode */
182#endif
183}
184
185/*
186 * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
187 * when it traps. So regs will be the current sp.
188 *
189 * This is valid only for kernel mode traps.
190 */
191static inline unsigned long kernel_trap_sp(struct pt_regs *regs)
192{
193#ifdef CONFIG_X86_32
194 return (unsigned long)regs;
195#else
196 return regs->sp;
197#endif
198}
199
200static inline unsigned long instruction_pointer(struct pt_regs *regs)
201{
202 return regs->ip;
203}
204
205static inline unsigned long frame_pointer(struct pt_regs *regs)
206{
207 return regs->bp;
208}
209
210/*
211 * These are defined as per linux/ptrace.h, which see.
212 */
213#define arch_has_single_step() (1)
214extern void user_enable_single_step(struct task_struct *);
215extern void user_disable_single_step(struct task_struct *);
216
217extern void user_enable_block_step(struct task_struct *);
218#ifdef CONFIG_X86_DEBUGCTLMSR
219#define arch_has_block_step() (1)
220#else
221#define arch_has_block_step() (boot_cpu_data.x86 >= 6)
222#endif
223
224struct user_desc;
225extern int do_get_thread_area(struct task_struct *p, int idx,
226 struct user_desc __user *info);
227extern int do_set_thread_area(struct task_struct *p, int idx,
228 struct user_desc __user *info, int can_allocate);
112 229
113extern unsigned long
114convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs);
115
116enum {
117 EF_CF = 0x00000001,
118 EF_PF = 0x00000004,
119 EF_AF = 0x00000010,
120 EF_ZF = 0x00000040,
121 EF_SF = 0x00000080,
122 EF_TF = 0x00000100,
123 EF_IE = 0x00000200,
124 EF_DF = 0x00000400,
125 EF_OF = 0x00000800,
126 EF_IOPL = 0x00003000,
127 EF_IOPL_RING0 = 0x00000000,
128 EF_IOPL_RING1 = 0x00001000,
129 EF_IOPL_RING2 = 0x00002000,
130 EF_NT = 0x00004000, /* nested task */
131 EF_RF = 0x00010000, /* resume */
132 EF_VM = 0x00020000, /* virtual mode */
133 EF_AC = 0x00040000, /* alignment */
134 EF_VIF = 0x00080000, /* virtual interrupt */
135 EF_VIP = 0x00100000, /* virtual interrupt pending */
136 EF_ID = 0x00200000, /* id */
137};
138#endif /* __KERNEL__ */ 230#endif /* __KERNEL__ */
139#endif /* !__i386__ */ 231
140#endif /* !__ASSEMBLY__ */ 232#endif /* !__ASSEMBLY__ */
141 233
142#endif 234#endif
diff --git a/include/asm-x86/resume-trace.h b/include/asm-x86/resume-trace.h
index 9b6dd093a9f7..46f725b0bc82 100644
--- a/include/asm-x86/resume-trace.h
+++ b/include/asm-x86/resume-trace.h
@@ -1,5 +1,20 @@
1#ifdef CONFIG_X86_32 1#ifndef _ASM_X86_RESUME_TRACE_H
2# include "resume-trace_32.h" 2#define _ASM_X86_RESUME_TRACE_H
3#else 3
4# include "resume-trace_64.h" 4#include <asm/asm.h>
5
6#define TRACE_RESUME(user) do { \
7 if (pm_trace_enabled) { \
8 void *tracedata; \
9 asm volatile(_ASM_MOV_UL " $1f,%0\n" \
10 ".section .tracedata,\"a\"\n" \
11 "1:\t.word %c1\n\t" \
12 _ASM_PTR " %c2\n" \
13 ".previous" \
14 :"=r" (tracedata) \
15 : "i" (__LINE__), "i" (__FILE__)); \
16 generate_resume_trace(tracedata, user); \
17 } \
18} while (0)
19
5#endif 20#endif
diff --git a/include/asm-x86/resume-trace_32.h b/include/asm-x86/resume-trace_32.h
deleted file mode 100644
index ec9cfd656230..000000000000
--- a/include/asm-x86/resume-trace_32.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#define TRACE_RESUME(user) do { \
2 if (pm_trace_enabled) { \
3 void *tracedata; \
4 asm volatile("movl $1f,%0\n" \
5 ".section .tracedata,\"a\"\n" \
6 "1:\t.word %c1\n" \
7 "\t.long %c2\n" \
8 ".previous" \
9 :"=r" (tracedata) \
10 : "i" (__LINE__), "i" (__FILE__)); \
11 generate_resume_trace(tracedata, user); \
12 } \
13} while (0)
diff --git a/include/asm-x86/resume-trace_64.h b/include/asm-x86/resume-trace_64.h
deleted file mode 100644
index 34bf998fdf62..000000000000
--- a/include/asm-x86/resume-trace_64.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#define TRACE_RESUME(user) do { \
2 if (pm_trace_enabled) { \
3 void *tracedata; \
4 asm volatile("movq $1f,%0\n" \
5 ".section .tracedata,\"a\"\n" \
6 "1:\t.word %c1\n" \
7 "\t.quad %c2\n" \
8 ".previous" \
9 :"=r" (tracedata) \
10 : "i" (__LINE__), "i" (__FILE__)); \
11 generate_resume_trace(tracedata, user); \
12 } \
13} while (0)
diff --git a/include/asm-x86/rio.h b/include/asm-x86/rio.h
index c7350f6d2015..97cdcc9887ba 100644
--- a/include/asm-x86/rio.h
+++ b/include/asm-x86/rio.h
@@ -1,6 +1,6 @@
1/* 1/*
2 * Derived from include/asm-i386/mach-summit/mach_mpparse.h 2 * Derived from include/asm-x86/mach-summit/mach_mpparse.h
3 * and include/asm-i386/mach-default/bios_ebda.h 3 * and include/asm-x86/mach-default/bios_ebda.h
4 * 4 *
5 * Author: Laurent Vivier <Laurent.Vivier@bull.net> 5 * Author: Laurent Vivier <Laurent.Vivier@bull.net>
6 */ 6 */
diff --git a/include/asm-x86/rwlock.h b/include/asm-x86/rwlock.h
index f2b64a429e6b..6a8c0d645108 100644
--- a/include/asm-x86/rwlock.h
+++ b/include/asm-x86/rwlock.h
@@ -2,7 +2,6 @@
2#define _ASM_X86_RWLOCK_H 2#define _ASM_X86_RWLOCK_H
3 3
4#define RW_LOCK_BIAS 0x01000000 4#define RW_LOCK_BIAS 0x01000000
5#define RW_LOCK_BIAS_STR "0x01000000"
6 5
7/* Actual code is in asm/spinlock.h or in arch/x86/lib/rwlock.S */ 6/* Actual code is in asm/spinlock.h or in arch/x86/lib/rwlock.S */
8 7
diff --git a/include/asm-x86/rwsem.h b/include/asm-x86/rwsem.h
index 041906f3c6df..520a379f4b80 100644
--- a/include/asm-x86/rwsem.h
+++ b/include/asm-x86/rwsem.h
@@ -2,7 +2,7 @@
2 * 2 *
3 * Written by David Howells (dhowells@redhat.com). 3 * Written by David Howells (dhowells@redhat.com).
4 * 4 *
5 * Derived from asm-i386/semaphore.h 5 * Derived from asm-x86/semaphore.h
6 * 6 *
7 * 7 *
8 * The MSW of the count is the negated number of active writers and waiting 8 * The MSW of the count is the negated number of active writers and waiting
@@ -44,10 +44,14 @@
44 44
45struct rwsem_waiter; 45struct rwsem_waiter;
46 46
47extern struct rw_semaphore *FASTCALL(rwsem_down_read_failed(struct rw_semaphore *sem)); 47extern asmregparm struct rw_semaphore *
48extern struct rw_semaphore *FASTCALL(rwsem_down_write_failed(struct rw_semaphore *sem)); 48 rwsem_down_read_failed(struct rw_semaphore *sem);
49extern struct rw_semaphore *FASTCALL(rwsem_wake(struct rw_semaphore *)); 49extern asmregparm struct rw_semaphore *
50extern struct rw_semaphore *FASTCALL(rwsem_downgrade_wake(struct rw_semaphore *sem)); 50 rwsem_down_write_failed(struct rw_semaphore *sem);
51extern asmregparm struct rw_semaphore *
52 rwsem_wake(struct rw_semaphore *);
53extern asmregparm struct rw_semaphore *
54 rwsem_downgrade_wake(struct rw_semaphore *sem);
51 55
52/* 56/*
53 * the semaphore definition 57 * the semaphore definition
diff --git a/include/asm-x86/scatterlist.h b/include/asm-x86/scatterlist.h
index 3a1e76257a27..d13c197866d6 100644
--- a/include/asm-x86/scatterlist.h
+++ b/include/asm-x86/scatterlist.h
@@ -1,5 +1,35 @@
1#ifndef _ASM_X86_SCATTERLIST_H
2#define _ASM_X86_SCATTERLIST_H
3
4#include <asm/types.h>
5
6struct scatterlist {
7#ifdef CONFIG_DEBUG_SG
8 unsigned long sg_magic;
9#endif
10 unsigned long page_link;
11 unsigned int offset;
12 unsigned int length;
13 dma_addr_t dma_address;
14#ifdef CONFIG_X86_64
15 unsigned int dma_length;
16#endif
17};
18
19#define ARCH_HAS_SG_CHAIN
20#define ISA_DMA_THRESHOLD (0x00ffffff)
21
22/*
23 * These macros should be used after a pci_map_sg call has been done
24 * to get bus addresses of each of the SG entries and their lengths.
25 * You should only work with the number of sg entries pci_map_sg
26 * returns.
27 */
28#define sg_dma_address(sg) ((sg)->dma_address)
1#ifdef CONFIG_X86_32 29#ifdef CONFIG_X86_32
2# include "scatterlist_32.h" 30# define sg_dma_len(sg) ((sg)->length)
3#else 31#else
4# include "scatterlist_64.h" 32# define sg_dma_len(sg) ((sg)->dma_length)
33#endif
34
5#endif 35#endif
diff --git a/include/asm-x86/scatterlist_32.h b/include/asm-x86/scatterlist_32.h
deleted file mode 100644
index 0e7d997a34be..000000000000
--- a/include/asm-x86/scatterlist_32.h
+++ /dev/null
@@ -1,28 +0,0 @@
1#ifndef _I386_SCATTERLIST_H
2#define _I386_SCATTERLIST_H
3
4#include <asm/types.h>
5
6struct scatterlist {
7#ifdef CONFIG_DEBUG_SG
8 unsigned long sg_magic;
9#endif
10 unsigned long page_link;
11 unsigned int offset;
12 dma_addr_t dma_address;
13 unsigned int length;
14};
15
16#define ARCH_HAS_SG_CHAIN
17
18/* These macros should be used after a pci_map_sg call has been done
19 * to get bus addresses of each of the SG entries and their lengths.
20 * You should only work with the number of sg entries pci_map_sg
21 * returns.
22 */
23#define sg_dma_address(sg) ((sg)->dma_address)
24#define sg_dma_len(sg) ((sg)->length)
25
26#define ISA_DMA_THRESHOLD (0x00ffffff)
27
28#endif /* !(_I386_SCATTERLIST_H) */
diff --git a/include/asm-x86/scatterlist_64.h b/include/asm-x86/scatterlist_64.h
deleted file mode 100644
index 1847c72befeb..000000000000
--- a/include/asm-x86/scatterlist_64.h
+++ /dev/null
@@ -1,29 +0,0 @@
1#ifndef _X8664_SCATTERLIST_H
2#define _X8664_SCATTERLIST_H
3
4#include <asm/types.h>
5
6struct scatterlist {
7#ifdef CONFIG_DEBUG_SG
8 unsigned long sg_magic;
9#endif
10 unsigned long page_link;
11 unsigned int offset;
12 unsigned int length;
13 dma_addr_t dma_address;
14 unsigned int dma_length;
15};
16
17#define ARCH_HAS_SG_CHAIN
18
19#define ISA_DMA_THRESHOLD (0x00ffffff)
20
21/* These macros should be used after a pci_map_sg call has been done
22 * to get bus addresses of each of the SG entries and their lengths.
23 * You should only work with the number of sg entries pci_map_sg
24 * returns.
25 */
26#define sg_dma_address(sg) ((sg)->dma_address)
27#define sg_dma_len(sg) ((sg)->dma_length)
28
29#endif
diff --git a/include/asm-x86/segment.h b/include/asm-x86/segment.h
index 605068280e28..23f0535fec61 100644
--- a/include/asm-x86/segment.h
+++ b/include/asm-x86/segment.h
@@ -1,5 +1,204 @@
1#ifndef _ASM_X86_SEGMENT_H_
2#define _ASM_X86_SEGMENT_H_
3
4/* Simple and small GDT entries for booting only */
5
6#define GDT_ENTRY_BOOT_CS 2
7#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
8
9#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
10#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
11
12#define GDT_ENTRY_BOOT_TSS (GDT_ENTRY_BOOT_CS + 2)
13#define __BOOT_TSS (GDT_ENTRY_BOOT_TSS * 8)
14
1#ifdef CONFIG_X86_32 15#ifdef CONFIG_X86_32
2# include "segment_32.h" 16/*
17 * The layout of the per-CPU GDT under Linux:
18 *
19 * 0 - null
20 * 1 - reserved
21 * 2 - reserved
22 * 3 - reserved
23 *
24 * 4 - unused <==== new cacheline
25 * 5 - unused
26 *
27 * ------- start of TLS (Thread-Local Storage) segments:
28 *
29 * 6 - TLS segment #1 [ glibc's TLS segment ]
30 * 7 - TLS segment #2 [ Wine's %fs Win32 segment ]
31 * 8 - TLS segment #3
32 * 9 - reserved
33 * 10 - reserved
34 * 11 - reserved
35 *
36 * ------- start of kernel segments:
37 *
38 * 12 - kernel code segment <==== new cacheline
39 * 13 - kernel data segment
40 * 14 - default user CS
41 * 15 - default user DS
42 * 16 - TSS
43 * 17 - LDT
44 * 18 - PNPBIOS support (16->32 gate)
45 * 19 - PNPBIOS support
46 * 20 - PNPBIOS support
47 * 21 - PNPBIOS support
48 * 22 - PNPBIOS support
49 * 23 - APM BIOS support
50 * 24 - APM BIOS support
51 * 25 - APM BIOS support
52 *
53 * 26 - ESPFIX small SS
54 * 27 - per-cpu [ offset to per-cpu data area ]
55 * 28 - unused
56 * 29 - unused
57 * 30 - unused
58 * 31 - TSS for double fault handler
59 */
60#define GDT_ENTRY_TLS_MIN 6
61#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
62
63#define GDT_ENTRY_DEFAULT_USER_CS 14
64#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
65
66#define GDT_ENTRY_DEFAULT_USER_DS 15
67#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
68
69#define GDT_ENTRY_KERNEL_BASE 12
70
71#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
72#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
73
74#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
75#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
76
77#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
78#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
79
80#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6)
81#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11)
82
83#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)
84#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
85
86#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15)
87#ifdef CONFIG_SMP
88#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
3#else 89#else
4# include "segment_64.h" 90#define __KERNEL_PERCPU 0
91#endif
92
93#define GDT_ENTRY_DOUBLEFAULT_TSS 31
94
95/*
96 * The GDT has 32 entries
97 */
98#define GDT_ENTRIES 32
99
100/* The PnP BIOS entries in the GDT */
101#define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0)
102#define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1)
103#define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2)
104#define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3)
105#define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4)
106
107/* The PnP BIOS selectors */
108#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8) /* segment for calling fn */
109#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8) /* code segment for BIOS */
110#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8) /* data segment for BIOS */
111#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8) /* transfer data segment */
112#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8) /* another data segment */
113
114/* Bottom two bits of selector give the ring privilege level */
115#define SEGMENT_RPL_MASK 0x3
116/* Bit 2 is table indicator (LDT/GDT) */
117#define SEGMENT_TI_MASK 0x4
118
119/* User mode is privilege level 3 */
120#define USER_RPL 0x3
121/* LDT segment has TI set, GDT has it cleared */
122#define SEGMENT_LDT 0x4
123#define SEGMENT_GDT 0x0
124
125/*
126 * Matching rules for certain types of segments.
127 */
128
129/* Matches only __KERNEL_CS, ignoring PnP / USER / APM segments */
130#define SEGMENT_IS_KERNEL_CODE(x) (((x) & 0xfc) == GDT_ENTRY_KERNEL_CS * 8)
131
132/* Matches __KERNEL_CS and __USER_CS (they must be 2 entries apart) */
133#define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xec) == GDT_ENTRY_KERNEL_CS * 8)
134
135/* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
136#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
137
138
139#else
140#include <asm/cache.h>
141
142#define __KERNEL_CS 0x10
143#define __KERNEL_DS 0x18
144
145#define __KERNEL32_CS 0x08
146
147/*
148 * we cannot use the same code segment descriptor for user and kernel
149 * -- not even in the long flat mode, because of different DPL /kkeil
150 * The segment offset needs to contain a RPL. Grr. -AK
151 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets)
152 */
153
154#define __USER32_CS 0x23 /* 4*8+3 */
155#define __USER_DS 0x2b /* 5*8+3 */
156#define __USER_CS 0x33 /* 6*8+3 */
157#define __USER32_DS __USER_DS
158
159#define GDT_ENTRY_TSS 8 /* needs two entries */
160#define GDT_ENTRY_LDT 10 /* needs two entries */
161#define GDT_ENTRY_TLS_MIN 12
162#define GDT_ENTRY_TLS_MAX 14
163
164#define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
165#define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
166
167/* TLS indexes for 64bit - hardcoded in arch_prctl */
168#define FS_TLS 0
169#define GS_TLS 1
170
171#define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
172#define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
173
174#define GDT_ENTRIES 16
175
176#endif
177
178#ifndef CONFIG_PARAVIRT
179#define get_kernel_rpl() 0
180#endif
181
182/* User mode is privilege level 3 */
183#define USER_RPL 0x3
184/* LDT segment has TI set, GDT has it cleared */
185#define SEGMENT_LDT 0x4
186#define SEGMENT_GDT 0x0
187
188/* Bottom two bits of selector give the ring privilege level */
189#define SEGMENT_RPL_MASK 0x3
190/* Bit 2 is table indicator (LDT/GDT) */
191#define SEGMENT_TI_MASK 0x4
192
193#define IDT_ENTRIES 256
194#define GDT_SIZE (GDT_ENTRIES * 8)
195#define GDT_ENTRY_TLS_ENTRIES 3
196#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
197
198#ifdef __KERNEL__
199#ifndef __ASSEMBLY__
200extern const char early_idt_handlers[IDT_ENTRIES][10];
201#endif
202#endif
203
5#endif 204#endif
diff --git a/include/asm-x86/segment_32.h b/include/asm-x86/segment_32.h
deleted file mode 100644
index 597a47c2515f..000000000000
--- a/include/asm-x86/segment_32.h
+++ /dev/null
@@ -1,148 +0,0 @@
1#ifndef _ASM_SEGMENT_H
2#define _ASM_SEGMENT_H
3
4/*
5 * The layout of the per-CPU GDT under Linux:
6 *
7 * 0 - null
8 * 1 - reserved
9 * 2 - reserved
10 * 3 - reserved
11 *
12 * 4 - unused <==== new cacheline
13 * 5 - unused
14 *
15 * ------- start of TLS (Thread-Local Storage) segments:
16 *
17 * 6 - TLS segment #1 [ glibc's TLS segment ]
18 * 7 - TLS segment #2 [ Wine's %fs Win32 segment ]
19 * 8 - TLS segment #3
20 * 9 - reserved
21 * 10 - reserved
22 * 11 - reserved
23 *
24 * ------- start of kernel segments:
25 *
26 * 12 - kernel code segment <==== new cacheline
27 * 13 - kernel data segment
28 * 14 - default user CS
29 * 15 - default user DS
30 * 16 - TSS
31 * 17 - LDT
32 * 18 - PNPBIOS support (16->32 gate)
33 * 19 - PNPBIOS support
34 * 20 - PNPBIOS support
35 * 21 - PNPBIOS support
36 * 22 - PNPBIOS support
37 * 23 - APM BIOS support
38 * 24 - APM BIOS support
39 * 25 - APM BIOS support
40 *
41 * 26 - ESPFIX small SS
42 * 27 - per-cpu [ offset to per-cpu data area ]
43 * 28 - unused
44 * 29 - unused
45 * 30 - unused
46 * 31 - TSS for double fault handler
47 */
48#define GDT_ENTRY_TLS_ENTRIES 3
49#define GDT_ENTRY_TLS_MIN 6
50#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
51
52#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
53
54#define GDT_ENTRY_DEFAULT_USER_CS 14
55#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
56
57#define GDT_ENTRY_DEFAULT_USER_DS 15
58#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
59
60#define GDT_ENTRY_KERNEL_BASE 12
61
62#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
63#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
64
65#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
66#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
67
68#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
69#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
70
71#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6)
72#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11)
73
74#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)
75#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
76
77#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15)
78#ifdef CONFIG_SMP
79#define __KERNEL_PERCPU (GDT_ENTRY_PERCPU * 8)
80#else
81#define __KERNEL_PERCPU 0
82#endif
83
84#define GDT_ENTRY_DOUBLEFAULT_TSS 31
85
86/*
87 * The GDT has 32 entries
88 */
89#define GDT_ENTRIES 32
90#define GDT_SIZE (GDT_ENTRIES * 8)
91
92/* Simple and small GDT entries for booting only */
93
94#define GDT_ENTRY_BOOT_CS 2
95#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
96
97#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
98#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
99
100/* The PnP BIOS entries in the GDT */
101#define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0)
102#define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1)
103#define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2)
104#define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3)
105#define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4)
106
107/* The PnP BIOS selectors */
108#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8) /* segment for calling fn */
109#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8) /* code segment for BIOS */
110#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8) /* data segment for BIOS */
111#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8) /* transfer data segment */
112#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8) /* another data segment */
113
114/*
115 * The interrupt descriptor table has room for 256 idt's,
116 * the global descriptor table is dependent on the number
117 * of tasks we can have..
118 */
119#define IDT_ENTRIES 256
120
121/* Bottom two bits of selector give the ring privilege level */
122#define SEGMENT_RPL_MASK 0x3
123/* Bit 2 is table indicator (LDT/GDT) */
124#define SEGMENT_TI_MASK 0x4
125
126/* User mode is privilege level 3 */
127#define USER_RPL 0x3
128/* LDT segment has TI set, GDT has it cleared */
129#define SEGMENT_LDT 0x4
130#define SEGMENT_GDT 0x0
131
132#ifndef CONFIG_PARAVIRT
133#define get_kernel_rpl() 0
134#endif
135/*
136 * Matching rules for certain types of segments.
137 */
138
139/* Matches only __KERNEL_CS, ignoring PnP / USER / APM segments */
140#define SEGMENT_IS_KERNEL_CODE(x) (((x) & 0xfc) == GDT_ENTRY_KERNEL_CS * 8)
141
142/* Matches __KERNEL_CS and __USER_CS (they must be 2 entries apart) */
143#define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xec) == GDT_ENTRY_KERNEL_CS * 8)
144
145/* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
146#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
147
148#endif
diff --git a/include/asm-x86/segment_64.h b/include/asm-x86/segment_64.h
deleted file mode 100644
index 04b8ab21328f..000000000000
--- a/include/asm-x86/segment_64.h
+++ /dev/null
@@ -1,53 +0,0 @@
1#ifndef _ASM_SEGMENT_H
2#define _ASM_SEGMENT_H
3
4#include <asm/cache.h>
5
6/* Simple and small GDT entries for booting only */
7
8#define GDT_ENTRY_BOOT_CS 2
9#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
10
11#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
12#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
13
14#define __KERNEL_CS 0x10
15#define __KERNEL_DS 0x18
16
17#define __KERNEL32_CS 0x08
18
19/*
20 * we cannot use the same code segment descriptor for user and kernel
21 * -- not even in the long flat mode, because of different DPL /kkeil
22 * The segment offset needs to contain a RPL. Grr. -AK
23 * GDT layout to get 64bit syscall right (sysret hardcodes gdt offsets)
24 */
25
26#define __USER32_CS 0x23 /* 4*8+3 */
27#define __USER_DS 0x2b /* 5*8+3 */
28#define __USER_CS 0x33 /* 6*8+3 */
29#define __USER32_DS __USER_DS
30
31#define GDT_ENTRY_TSS 8 /* needs two entries */
32#define GDT_ENTRY_LDT 10 /* needs two entries */
33#define GDT_ENTRY_TLS_MIN 12
34#define GDT_ENTRY_TLS_MAX 14
35
36#define GDT_ENTRY_TLS_ENTRIES 3
37
38#define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
39#define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
40
41/* TLS indexes for 64bit - hardcoded in arch_prctl */
42#define FS_TLS 0
43#define GS_TLS 1
44
45#define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
46#define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
47
48#define IDT_ENTRIES 256
49#define GDT_ENTRIES 16
50#define GDT_SIZE (GDT_ENTRIES * 8)
51#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
52
53#endif
diff --git a/include/asm-x86/semaphore_32.h b/include/asm-x86/semaphore_32.h
index 835c1d751a9f..ac96d3804d0c 100644
--- a/include/asm-x86/semaphore_32.h
+++ b/include/asm-x86/semaphore_32.h
@@ -83,10 +83,10 @@ static inline void init_MUTEX_LOCKED (struct semaphore *sem)
83 sema_init(sem, 0); 83 sema_init(sem, 0);
84} 84}
85 85
86fastcall void __down_failed(void /* special register calling convention */); 86extern asmregparm void __down_failed(atomic_t *count_ptr);
87fastcall int __down_failed_interruptible(void /* params in registers */); 87extern asmregparm int __down_failed_interruptible(atomic_t *count_ptr);
88fastcall int __down_failed_trylock(void /* params in registers */); 88extern asmregparm int __down_failed_trylock(atomic_t *count_ptr);
89fastcall void __up_wakeup(void /* special register calling convention */); 89extern asmregparm void __up_wakeup(atomic_t *count_ptr);
90 90
91/* 91/*
92 * This is ugly, but we want the default case to fall through. 92 * This is ugly, but we want the default case to fall through.
diff --git a/include/asm-x86/setup.h b/include/asm-x86/setup.h
index 24d786e07b49..071e054abd82 100644
--- a/include/asm-x86/setup.h
+++ b/include/asm-x86/setup.h
@@ -3,6 +3,13 @@
3 3
4#define COMMAND_LINE_SIZE 2048 4#define COMMAND_LINE_SIZE 2048
5 5
6#ifndef __ASSEMBLY__
7char *machine_specific_memory_setup(void);
8#ifndef CONFIG_PARAVIRT
9#define paravirt_post_allocator_init() do {} while (0)
10#endif
11#endif /* __ASSEMBLY__ */
12
6#ifdef __KERNEL__ 13#ifdef __KERNEL__
7 14
8#ifdef __i386__ 15#ifdef __i386__
@@ -51,9 +58,7 @@ void __init add_memory_region(unsigned long long start,
51 58
52extern unsigned long init_pg_tables_end; 59extern unsigned long init_pg_tables_end;
53 60
54#ifndef CONFIG_PARAVIRT 61
55#define paravirt_post_allocator_init() do {} while (0)
56#endif
57 62
58#endif /* __i386__ */ 63#endif /* __i386__ */
59#endif /* _SETUP */ 64#endif /* _SETUP */
diff --git a/include/asm-x86/sigcontext.h b/include/asm-x86/sigcontext.h
index c047f9dc3423..681deade5f00 100644
--- a/include/asm-x86/sigcontext.h
+++ b/include/asm-x86/sigcontext.h
@@ -63,20 +63,20 @@ struct sigcontext {
63 unsigned short fs, __fsh; 63 unsigned short fs, __fsh;
64 unsigned short es, __esh; 64 unsigned short es, __esh;
65 unsigned short ds, __dsh; 65 unsigned short ds, __dsh;
66 unsigned long edi; 66 unsigned long di;
67 unsigned long esi; 67 unsigned long si;
68 unsigned long ebp; 68 unsigned long bp;
69 unsigned long esp; 69 unsigned long sp;
70 unsigned long ebx; 70 unsigned long bx;
71 unsigned long edx; 71 unsigned long dx;
72 unsigned long ecx; 72 unsigned long cx;
73 unsigned long eax; 73 unsigned long ax;
74 unsigned long trapno; 74 unsigned long trapno;
75 unsigned long err; 75 unsigned long err;
76 unsigned long eip; 76 unsigned long ip;
77 unsigned short cs, __csh; 77 unsigned short cs, __csh;
78 unsigned long eflags; 78 unsigned long flags;
79 unsigned long esp_at_signal; 79 unsigned long sp_at_signal;
80 unsigned short ss, __ssh; 80 unsigned short ss, __ssh;
81 struct _fpstate __user * fpstate; 81 struct _fpstate __user * fpstate;
82 unsigned long oldmask; 82 unsigned long oldmask;
@@ -111,16 +111,16 @@ struct sigcontext {
111 unsigned long r13; 111 unsigned long r13;
112 unsigned long r14; 112 unsigned long r14;
113 unsigned long r15; 113 unsigned long r15;
114 unsigned long rdi; 114 unsigned long di;
115 unsigned long rsi; 115 unsigned long si;
116 unsigned long rbp; 116 unsigned long bp;
117 unsigned long rbx; 117 unsigned long bx;
118 unsigned long rdx; 118 unsigned long dx;
119 unsigned long rax; 119 unsigned long ax;
120 unsigned long rcx; 120 unsigned long cx;
121 unsigned long rsp; 121 unsigned long sp;
122 unsigned long rip; 122 unsigned long ip;
123 unsigned long eflags; /* RFLAGS */ 123 unsigned long flags;
124 unsigned short cs; 124 unsigned short cs;
125 unsigned short gs; 125 unsigned short gs;
126 unsigned short fs; 126 unsigned short fs;
diff --git a/include/asm-x86/sigcontext32.h b/include/asm-x86/sigcontext32.h
index 3d657038ab7c..6ffab4fd593a 100644
--- a/include/asm-x86/sigcontext32.h
+++ b/include/asm-x86/sigcontext32.h
@@ -48,20 +48,20 @@ struct sigcontext_ia32 {
48 unsigned short fs, __fsh; 48 unsigned short fs, __fsh;
49 unsigned short es, __esh; 49 unsigned short es, __esh;
50 unsigned short ds, __dsh; 50 unsigned short ds, __dsh;
51 unsigned int edi; 51 unsigned int di;
52 unsigned int esi; 52 unsigned int si;
53 unsigned int ebp; 53 unsigned int bp;
54 unsigned int esp; 54 unsigned int sp;
55 unsigned int ebx; 55 unsigned int bx;
56 unsigned int edx; 56 unsigned int dx;
57 unsigned int ecx; 57 unsigned int cx;
58 unsigned int eax; 58 unsigned int ax;
59 unsigned int trapno; 59 unsigned int trapno;
60 unsigned int err; 60 unsigned int err;
61 unsigned int eip; 61 unsigned int ip;
62 unsigned short cs, __csh; 62 unsigned short cs, __csh;
63 unsigned int eflags; 63 unsigned int flags;
64 unsigned int esp_at_signal; 64 unsigned int sp_at_signal;
65 unsigned short ss, __ssh; 65 unsigned short ss, __ssh;
66 unsigned int fpstate; /* really (struct _fpstate_ia32 *) */ 66 unsigned int fpstate; /* really (struct _fpstate_ia32 *) */
67 unsigned int oldmask; 67 unsigned int oldmask;
diff --git a/include/asm-x86/signal.h b/include/asm-x86/signal.h
index 987a422a2c78..aee7eca585ab 100644
--- a/include/asm-x86/signal.h
+++ b/include/asm-x86/signal.h
@@ -245,21 +245,14 @@ static __inline__ int sigfindinword(unsigned long word)
245 245
246struct pt_regs; 246struct pt_regs;
247 247
248#define ptrace_signal_deliver(regs, cookie) \
249 do { \
250 if (current->ptrace & PT_DTRACE) { \
251 current->ptrace &= ~PT_DTRACE; \
252 (regs)->eflags &= ~TF_MASK; \
253 } \
254 } while (0)
255
256#else /* __i386__ */ 248#else /* __i386__ */
257 249
258#undef __HAVE_ARCH_SIG_BITOPS 250#undef __HAVE_ARCH_SIG_BITOPS
259 251
252#endif /* !__i386__ */
253
260#define ptrace_signal_deliver(regs, cookie) do { } while (0) 254#define ptrace_signal_deliver(regs, cookie) do { } while (0)
261 255
262#endif /* !__i386__ */
263#endif /* __KERNEL__ */ 256#endif /* __KERNEL__ */
264#endif /* __ASSEMBLY__ */ 257#endif /* __ASSEMBLY__ */
265 258
diff --git a/include/asm-x86/smp_32.h b/include/asm-x86/smp_32.h
index e10b7affdfe5..56152e312287 100644
--- a/include/asm-x86/smp_32.h
+++ b/include/asm-x86/smp_32.h
@@ -1,51 +1,41 @@
1#ifndef __ASM_SMP_H 1#ifndef __ASM_SMP_H
2#define __ASM_SMP_H 2#define __ASM_SMP_H
3 3
4#ifndef __ASSEMBLY__
5#include <linux/cpumask.h>
6#include <linux/init.h>
7
4/* 8/*
5 * We need the APIC definitions automatically as part of 'smp.h' 9 * We need the APIC definitions automatically as part of 'smp.h'
6 */ 10 */
7#ifndef __ASSEMBLY__ 11#ifdef CONFIG_X86_LOCAL_APIC
8#include <linux/kernel.h> 12# include <asm/mpspec.h>
9#include <linux/threads.h> 13# include <asm/apic.h>
10#include <linux/cpumask.h> 14# ifdef CONFIG_X86_IO_APIC
15# include <asm/io_apic.h>
16# endif
11#endif 17#endif
12 18
13#if defined(CONFIG_X86_LOCAL_APIC) && !defined(__ASSEMBLY__) 19extern cpumask_t cpu_callout_map;
14#include <linux/bitops.h> 20extern cpumask_t cpu_callin_map;
15#include <asm/mpspec.h>
16#include <asm/apic.h>
17#ifdef CONFIG_X86_IO_APIC
18#include <asm/io_apic.h>
19#endif
20#endif
21 21
22#define BAD_APICID 0xFFu 22extern int smp_num_siblings;
23#ifdef CONFIG_SMP 23extern unsigned int num_processors;
24#ifndef __ASSEMBLY__
25 24
26/*
27 * Private routines/data
28 */
29
30extern void smp_alloc_memory(void); 25extern void smp_alloc_memory(void);
31extern int pic_mode; 26extern void lock_ipi_call_lock(void);
32extern int smp_num_siblings; 27extern void unlock_ipi_call_lock(void);
33DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
34DECLARE_PER_CPU(cpumask_t, cpu_core_map);
35 28
36extern void (*mtrr_hook) (void); 29extern void (*mtrr_hook) (void);
37extern void zap_low_mappings (void); 30extern void zap_low_mappings (void);
38extern void lock_ipi_call_lock(void);
39extern void unlock_ipi_call_lock(void);
40 31
41#define MAX_APICID 256
42extern u8 __initdata x86_cpu_to_apicid_init[]; 32extern u8 __initdata x86_cpu_to_apicid_init[];
43extern void *x86_cpu_to_apicid_ptr; 33extern void *x86_cpu_to_apicid_early_ptr;
44DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
45
46#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
47 34
48extern void set_cpu_sibling_map(int cpu); 35DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
36DECLARE_PER_CPU(cpumask_t, cpu_core_map);
37DECLARE_PER_CPU(u8, cpu_llc_id);
38DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
49 39
50#ifdef CONFIG_HOTPLUG_CPU 40#ifdef CONFIG_HOTPLUG_CPU
51extern void cpu_exit_clear(void); 41extern void cpu_exit_clear(void);
@@ -53,6 +43,9 @@ extern void cpu_uninit(void);
53extern void remove_siblinginfo(int cpu); 43extern void remove_siblinginfo(int cpu);
54#endif 44#endif
55 45
46/* Globals due to paravirt */
47extern void set_cpu_sibling_map(int cpu);
48
56struct smp_ops 49struct smp_ops
57{ 50{
58 void (*smp_prepare_boot_cpu)(void); 51 void (*smp_prepare_boot_cpu)(void);
@@ -67,6 +60,7 @@ struct smp_ops
67 int wait); 60 int wait);
68}; 61};
69 62
63#ifdef CONFIG_SMP
70extern struct smp_ops smp_ops; 64extern struct smp_ops smp_ops;
71 65
72static inline void smp_prepare_boot_cpu(void) 66static inline void smp_prepare_boot_cpu(void)
@@ -107,10 +101,12 @@ int native_cpu_up(unsigned int cpunum);
107void native_smp_cpus_done(unsigned int max_cpus); 101void native_smp_cpus_done(unsigned int max_cpus);
108 102
109#ifndef CONFIG_PARAVIRT 103#ifndef CONFIG_PARAVIRT
110#define startup_ipi_hook(phys_apicid, start_eip, start_esp) \ 104#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
111do { } while (0)
112#endif 105#endif
113 106
107extern int __cpu_disable(void);
108extern void __cpu_die(unsigned int cpu);
109
114/* 110/*
115 * This function is needed by all SMP systems. It must _always_ be valid 111 * This function is needed by all SMP systems. It must _always_ be valid
116 * from the initial startup. We map APIC_BASE very early in page_setup(), 112 * from the initial startup. We map APIC_BASE very early in page_setup(),
@@ -119,9 +115,11 @@ do { } while (0)
119DECLARE_PER_CPU(int, cpu_number); 115DECLARE_PER_CPU(int, cpu_number);
120#define raw_smp_processor_id() (x86_read_percpu(cpu_number)) 116#define raw_smp_processor_id() (x86_read_percpu(cpu_number))
121 117
122extern cpumask_t cpu_callout_map; 118#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
123extern cpumask_t cpu_callin_map; 119
124extern cpumask_t cpu_possible_map; 120extern int safe_smp_processor_id(void);
121
122void __cpuinit smp_store_cpu_info(int id);
125 123
126/* We don't mark CPUs online until __cpu_up(), so we need another measure */ 124/* We don't mark CPUs online until __cpu_up(), so we need another measure */
127static inline int num_booting_cpus(void) 125static inline int num_booting_cpus(void)
@@ -129,56 +127,39 @@ static inline int num_booting_cpus(void)
129 return cpus_weight(cpu_callout_map); 127 return cpus_weight(cpu_callout_map);
130} 128}
131 129
132extern int safe_smp_processor_id(void);
133extern int __cpu_disable(void);
134extern void __cpu_die(unsigned int cpu);
135extern unsigned int num_processors;
136
137void __cpuinit smp_store_cpu_info(int id);
138
139#endif /* !__ASSEMBLY__ */
140
141#else /* CONFIG_SMP */ 130#else /* CONFIG_SMP */
142 131
143#define safe_smp_processor_id() 0 132#define safe_smp_processor_id() 0
144#define cpu_physical_id(cpu) boot_cpu_physical_apicid 133#define cpu_physical_id(cpu) boot_cpu_physical_apicid
145 134
146#define NO_PROC_ID 0xFF /* No processor magic marker */ 135#endif /* !CONFIG_SMP */
147
148#endif /* CONFIG_SMP */
149
150#ifndef __ASSEMBLY__
151 136
152#ifdef CONFIG_X86_LOCAL_APIC 137#ifdef CONFIG_X86_LOCAL_APIC
153 138
154#ifdef APIC_DEFINITION 139static __inline int logical_smp_processor_id(void)
140{
141 /* we don't want to mark this access volatile - bad code generation */
142 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
143}
144
145# ifdef APIC_DEFINITION
155extern int hard_smp_processor_id(void); 146extern int hard_smp_processor_id(void);
156#else 147# else
157#include <mach_apicdef.h> 148# include <mach_apicdef.h>
158static inline int hard_smp_processor_id(void) 149static inline int hard_smp_processor_id(void)
159{ 150{
160 /* we don't want to mark this access volatile - bad code generation */ 151 /* we don't want to mark this access volatile - bad code generation */
161 return GET_APIC_ID(*(unsigned long *)(APIC_BASE+APIC_ID)); 152 return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
162} 153}
163#endif /* APIC_DEFINITION */ 154# endif /* APIC_DEFINITION */
164 155
165#else /* CONFIG_X86_LOCAL_APIC */ 156#else /* CONFIG_X86_LOCAL_APIC */
166 157
167#ifndef CONFIG_SMP 158# ifndef CONFIG_SMP
168#define hard_smp_processor_id() 0 159# define hard_smp_processor_id() 0
169#endif 160# endif
170 161
171#endif /* CONFIG_X86_LOCAL_APIC */ 162#endif /* CONFIG_X86_LOCAL_APIC */
172 163
173extern u8 apicid_2_node[]; 164#endif /* !ASSEMBLY */
174
175#ifdef CONFIG_X86_LOCAL_APIC
176static __inline int logical_smp_processor_id(void)
177{
178 /* we don't want to mark this access volatile - bad code generation */
179 return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR));
180}
181#endif
182#endif
183
184#endif 165#endif
diff --git a/include/asm-x86/smp_64.h b/include/asm-x86/smp_64.h
index ab612b0ff270..e0a75519ad21 100644
--- a/include/asm-x86/smp_64.h
+++ b/include/asm-x86/smp_64.h
@@ -1,130 +1,101 @@
1#ifndef __ASM_SMP_H 1#ifndef __ASM_SMP_H
2#define __ASM_SMP_H 2#define __ASM_SMP_H
3 3
4/*
5 * We need the APIC definitions automatically as part of 'smp.h'
6 */
7#include <linux/threads.h>
8#include <linux/cpumask.h> 4#include <linux/cpumask.h>
9#include <linux/bitops.h>
10#include <linux/init.h> 5#include <linux/init.h>
11extern int disable_apic;
12 6
13#include <asm/mpspec.h> 7/*
8 * We need the APIC definitions automatically as part of 'smp.h'
9 */
14#include <asm/apic.h> 10#include <asm/apic.h>
15#include <asm/io_apic.h> 11#include <asm/io_apic.h>
16#include <asm/thread_info.h> 12#include <asm/mpspec.h>
17
18#ifdef CONFIG_SMP
19
20#include <asm/pda.h> 13#include <asm/pda.h>
14#include <asm/thread_info.h>
21 15
22struct pt_regs;
23
24extern cpumask_t cpu_present_mask;
25extern cpumask_t cpu_possible_map;
26extern cpumask_t cpu_online_map;
27extern cpumask_t cpu_callout_map; 16extern cpumask_t cpu_callout_map;
28extern cpumask_t cpu_initialized; 17extern cpumask_t cpu_initialized;
29 18
30/* 19extern int smp_num_siblings;
31 * Private routines/data 20extern unsigned int num_processors;
32 */ 21
33
34extern void smp_alloc_memory(void); 22extern void smp_alloc_memory(void);
35extern volatile unsigned long smp_invalidate_needed;
36extern void lock_ipi_call_lock(void); 23extern void lock_ipi_call_lock(void);
37extern void unlock_ipi_call_lock(void); 24extern void unlock_ipi_call_lock(void);
38extern int smp_num_siblings; 25
39extern void smp_send_reschedule(int cpu);
40extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *), 26extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
41 void *info, int wait); 27 void *info, int wait);
42 28
43/* 29extern u16 __initdata x86_cpu_to_apicid_init[];
44 * cpu_sibling_map and cpu_core_map now live 30extern u16 __initdata x86_bios_cpu_apicid_init[];
45 * in the per cpu area 31extern void *x86_cpu_to_apicid_early_ptr;
46 * 32extern void *x86_bios_cpu_apicid_early_ptr;
47 * extern cpumask_t cpu_sibling_map[NR_CPUS]; 33
48 * extern cpumask_t cpu_core_map[NR_CPUS];
49 */
50DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 34DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
51DECLARE_PER_CPU(cpumask_t, cpu_core_map); 35DECLARE_PER_CPU(cpumask_t, cpu_core_map);
52DECLARE_PER_CPU(u8, cpu_llc_id); 36DECLARE_PER_CPU(u16, cpu_llc_id);
53 37DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
54#define SMP_TRAMPOLINE_BASE 0x6000 38DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
55
56/*
57 * On x86 all CPUs are mapped 1:1 to the APIC space.
58 * This simplifies scheduling and IPI sending and
59 * compresses data structures.
60 */
61 39
62static inline int num_booting_cpus(void) 40static inline int cpu_present_to_apicid(int mps_cpu)
63{ 41{
64 return cpus_weight(cpu_callout_map); 42 if (cpu_present(mps_cpu))
43 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
44 else
45 return BAD_APICID;
65} 46}
66 47
67#define raw_smp_processor_id() read_pda(cpunumber) 48#ifdef CONFIG_SMP
49
50#define SMP_TRAMPOLINE_BASE 0x6000
68 51
69extern int __cpu_disable(void); 52extern int __cpu_disable(void);
70extern void __cpu_die(unsigned int cpu); 53extern void __cpu_die(unsigned int cpu);
71extern void prefill_possible_map(void); 54extern void prefill_possible_map(void);
72extern unsigned num_processors;
73extern unsigned __cpuinitdata disabled_cpus; 55extern unsigned __cpuinitdata disabled_cpus;
74 56
75#define NO_PROC_ID 0xFF /* No processor magic marker */ 57#define raw_smp_processor_id() read_pda(cpunumber)
76 58#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
77#endif /* CONFIG_SMP */
78 59
79#define safe_smp_processor_id() smp_processor_id() 60#define stack_smp_processor_id() \
80 61 ({ \
81static inline int hard_smp_processor_id(void) 62 struct thread_info *ti; \
82{ 63 __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
83 /* we don't want to mark this access volatile - bad code generation */ 64 ti->cpu; \
84 return GET_APIC_ID(*(unsigned int *)(APIC_BASE+APIC_ID)); 65})
85}
86 66
87/* 67/*
88 * Some lowlevel functions might want to know about 68 * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
89 * the real APIC ID <-> CPU # mapping. 69 * scheduling and IPI sending and compresses data structures.
90 */ 70 */
91extern u8 __initdata x86_cpu_to_apicid_init[]; 71static inline int num_booting_cpus(void)
92extern void *x86_cpu_to_apicid_ptr;
93DECLARE_PER_CPU(u8, x86_cpu_to_apicid); /* physical ID */
94extern u8 bios_cpu_apicid[];
95
96static inline int cpu_present_to_apicid(int mps_cpu)
97{ 72{
98 if (mps_cpu < NR_CPUS) 73 return cpus_weight(cpu_callout_map);
99 return (int)bios_cpu_apicid[mps_cpu];
100 else
101 return BAD_APICID;
102} 74}
103 75
104#ifndef CONFIG_SMP 76extern void smp_send_reschedule(int cpu);
77
78#else /* CONFIG_SMP */
79
80extern unsigned int boot_cpu_id;
81#define cpu_physical_id(cpu) boot_cpu_id
105#define stack_smp_processor_id() 0 82#define stack_smp_processor_id() 0
106#define cpu_logical_map(x) (x) 83
107#else 84#endif /* !CONFIG_SMP */
108#include <asm/thread_info.h> 85
109#define stack_smp_processor_id() \ 86#define safe_smp_processor_id() smp_processor_id()
110({ \
111 struct thread_info *ti; \
112 __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
113 ti->cpu; \
114})
115#endif
116 87
117static __inline int logical_smp_processor_id(void) 88static __inline int logical_smp_processor_id(void)
118{ 89{
119 /* we don't want to mark this access volatile - bad code generation */ 90 /* we don't want to mark this access volatile - bad code generation */
120 return GET_APIC_LOGICAL_ID(*(unsigned long *)(APIC_BASE+APIC_LDR)); 91 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
92}
93
94static inline int hard_smp_processor_id(void)
95{
96 /* we don't want to mark this access volatile - bad code generation */
97 return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
121} 98}
122 99
123#ifdef CONFIG_SMP
124#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
125#else
126extern unsigned int boot_cpu_id;
127#define cpu_physical_id(cpu) boot_cpu_id
128#endif /* !CONFIG_SMP */
129#endif 100#endif
130 101
diff --git a/include/asm-x86/socket.h b/include/asm-x86/socket.h
index 99ca648b94c5..80af9c4ccad7 100644
--- a/include/asm-x86/socket.h
+++ b/include/asm-x86/socket.h
@@ -52,4 +52,6 @@
52#define SO_TIMESTAMPNS 35 52#define SO_TIMESTAMPNS 35
53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 53#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
54 54
55#define SO_MARK 36
56
55#endif /* _ASM_SOCKET_H */ 57#endif /* _ASM_SOCKET_H */
diff --git a/include/asm-x86/sparsemem.h b/include/asm-x86/sparsemem.h
index 3f203b1d9ee8..fa58cd55411a 100644
--- a/include/asm-x86/sparsemem.h
+++ b/include/asm-x86/sparsemem.h
@@ -1,5 +1,34 @@
1#ifndef _ASM_X86_SPARSEMEM_H
2#define _ASM_X86_SPARSEMEM_H
3
4#ifdef CONFIG_SPARSEMEM
5/*
6 * generic non-linear memory support:
7 *
8 * 1) we will not split memory into more chunks than will fit into the flags
9 * field of the struct page
10 *
11 * SECTION_SIZE_BITS 2^n: size of each section
12 * MAX_PHYSADDR_BITS 2^n: max size of physical address space
13 * MAX_PHYSMEM_BITS 2^n: how much memory we can have in that space
14 *
15 */
16
1#ifdef CONFIG_X86_32 17#ifdef CONFIG_X86_32
2# include "sparsemem_32.h" 18# ifdef CONFIG_X86_PAE
3#else 19# define SECTION_SIZE_BITS 30
4# include "sparsemem_64.h" 20# define MAX_PHYSADDR_BITS 36
21# define MAX_PHYSMEM_BITS 36
22# else
23# define SECTION_SIZE_BITS 26
24# define MAX_PHYSADDR_BITS 32
25# define MAX_PHYSMEM_BITS 32
26# endif
27#else /* CONFIG_X86_32 */
28# define SECTION_SIZE_BITS 27 /* matt - 128 is convenient right now */
29# define MAX_PHYSADDR_BITS 40
30# define MAX_PHYSMEM_BITS 40
31#endif
32
33#endif /* CONFIG_SPARSEMEM */
5#endif 34#endif
diff --git a/include/asm-x86/sparsemem_32.h b/include/asm-x86/sparsemem_32.h
deleted file mode 100644
index cfeed990585f..000000000000
--- a/include/asm-x86/sparsemem_32.h
+++ /dev/null
@@ -1,31 +0,0 @@
1#ifndef _I386_SPARSEMEM_H
2#define _I386_SPARSEMEM_H
3#ifdef CONFIG_SPARSEMEM
4
5/*
6 * generic non-linear memory support:
7 *
8 * 1) we will not split memory into more chunks than will fit into the
9 * flags field of the struct page
10 */
11
12/*
13 * SECTION_SIZE_BITS 2^N: how big each section will be
14 * MAX_PHYSADDR_BITS 2^N: how much physical address space we have
15 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
16 */
17#ifdef CONFIG_X86_PAE
18#define SECTION_SIZE_BITS 30
19#define MAX_PHYSADDR_BITS 36
20#define MAX_PHYSMEM_BITS 36
21#else
22#define SECTION_SIZE_BITS 26
23#define MAX_PHYSADDR_BITS 32
24#define MAX_PHYSMEM_BITS 32
25#endif
26
27/* XXX: FIXME -- wli */
28#define kern_addr_valid(kaddr) (0)
29
30#endif /* CONFIG_SPARSEMEM */
31#endif /* _I386_SPARSEMEM_H */
diff --git a/include/asm-x86/sparsemem_64.h b/include/asm-x86/sparsemem_64.h
deleted file mode 100644
index dabb16714a71..000000000000
--- a/include/asm-x86/sparsemem_64.h
+++ /dev/null
@@ -1,26 +0,0 @@
1#ifndef _ASM_X86_64_SPARSEMEM_H
2#define _ASM_X86_64_SPARSEMEM_H 1
3
4#ifdef CONFIG_SPARSEMEM
5
6/*
7 * generic non-linear memory support:
8 *
9 * 1) we will not split memory into more chunks than will fit into the flags
10 * field of the struct page
11 *
12 * SECTION_SIZE_BITS 2^n: size of each section
13 * MAX_PHYSADDR_BITS 2^n: max size of physical address space
14 * MAX_PHYSMEM_BITS 2^n: how much memory we can have in that space
15 *
16 */
17
18#define SECTION_SIZE_BITS 27 /* matt - 128 is convenient right now */
19#define MAX_PHYSADDR_BITS 40
20#define MAX_PHYSMEM_BITS 40
21
22extern int early_pfn_to_nid(unsigned long pfn);
23
24#endif /* CONFIG_SPARSEMEM */
25
26#endif /* _ASM_X86_64_SPARSEMEM_H */
diff --git a/include/asm-x86/spinlock.h b/include/asm-x86/spinlock.h
index d74d85e71dcb..23804c1890ff 100644
--- a/include/asm-x86/spinlock.h
+++ b/include/asm-x86/spinlock.h
@@ -1,5 +1,296 @@
1#ifndef _X86_SPINLOCK_H_
2#define _X86_SPINLOCK_H_
3
4#include <asm/atomic.h>
5#include <asm/rwlock.h>
6#include <asm/page.h>
7#include <asm/processor.h>
8#include <linux/compiler.h>
9
10/*
11 * Your basic SMP spinlocks, allowing only a single CPU anywhere
12 *
13 * Simple spin lock operations. There are two variants, one clears IRQ's
14 * on the local processor, one does not.
15 *
16 * These are fair FIFO ticket locks, which are currently limited to 256
17 * CPUs.
18 *
19 * (the type definitions are in asm/spinlock_types.h)
20 */
21
1#ifdef CONFIG_X86_32 22#ifdef CONFIG_X86_32
2# include "spinlock_32.h" 23typedef char _slock_t;
24# define LOCK_INS_DEC "decb"
25# define LOCK_INS_XCH "xchgb"
26# define LOCK_INS_MOV "movb"
27# define LOCK_INS_CMP "cmpb"
28# define LOCK_PTR_REG "a"
3#else 29#else
4# include "spinlock_64.h" 30typedef int _slock_t;
31# define LOCK_INS_DEC "decl"
32# define LOCK_INS_XCH "xchgl"
33# define LOCK_INS_MOV "movl"
34# define LOCK_INS_CMP "cmpl"
35# define LOCK_PTR_REG "D"
36#endif
37
38#if defined(CONFIG_X86_32) && \
39 (defined(CONFIG_X86_OOSTORE) || defined(CONFIG_X86_PPRO_FENCE))
40/*
41 * On PPro SMP or if we are using OOSTORE, we use a locked operation to unlock
42 * (PPro errata 66, 92)
43 */
44# define UNLOCK_LOCK_PREFIX LOCK_PREFIX
45#else
46# define UNLOCK_LOCK_PREFIX
47#endif
48
49/*
50 * Ticket locks are conceptually two parts, one indicating the current head of
51 * the queue, and the other indicating the current tail. The lock is acquired
52 * by atomically noting the tail and incrementing it by one (thus adding
53 * ourself to the queue and noting our position), then waiting until the head
54 * becomes equal to the the initial value of the tail.
55 *
56 * We use an xadd covering *both* parts of the lock, to increment the tail and
57 * also load the position of the head, which takes care of memory ordering
58 * issues and should be optimal for the uncontended case. Note the tail must be
59 * in the high part, because a wide xadd increment of the low part would carry
60 * up and contaminate the high part.
61 *
62 * With fewer than 2^8 possible CPUs, we can use x86's partial registers to
63 * save some instructions and make the code more elegant. There really isn't
64 * much between them in performance though, especially as locks are out of line.
65 */
66#if (NR_CPUS < 256)
67static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
68{
69 int tmp = *(volatile signed int *)(&(lock)->slock);
70
71 return (((tmp >> 8) & 0xff) != (tmp & 0xff));
72}
73
74static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
75{
76 int tmp = *(volatile signed int *)(&(lock)->slock);
77
78 return (((tmp >> 8) & 0xff) - (tmp & 0xff)) > 1;
79}
80
81static inline void __raw_spin_lock(raw_spinlock_t *lock)
82{
83 short inc = 0x0100;
84
85 __asm__ __volatile__ (
86 LOCK_PREFIX "xaddw %w0, %1\n"
87 "1:\t"
88 "cmpb %h0, %b0\n\t"
89 "je 2f\n\t"
90 "rep ; nop\n\t"
91 "movb %1, %b0\n\t"
92 /* don't need lfence here, because loads are in-order */
93 "jmp 1b\n"
94 "2:"
95 :"+Q" (inc), "+m" (lock->slock)
96 :
97 :"memory", "cc");
98}
99
100#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
101
102static inline int __raw_spin_trylock(raw_spinlock_t *lock)
103{
104 int tmp;
105 short new;
106
107 asm volatile(
108 "movw %2,%w0\n\t"
109 "cmpb %h0,%b0\n\t"
110 "jne 1f\n\t"
111 "movw %w0,%w1\n\t"
112 "incb %h1\n\t"
113 "lock ; cmpxchgw %w1,%2\n\t"
114 "1:"
115 "sete %b1\n\t"
116 "movzbl %b1,%0\n\t"
117 :"=&a" (tmp), "=Q" (new), "+m" (lock->slock)
118 :
119 : "memory", "cc");
120
121 return tmp;
122}
123
124static inline void __raw_spin_unlock(raw_spinlock_t *lock)
125{
126 __asm__ __volatile__(
127 UNLOCK_LOCK_PREFIX "incb %0"
128 :"+m" (lock->slock)
129 :
130 :"memory", "cc");
131}
132#else
133static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
134{
135 int tmp = *(volatile signed int *)(&(lock)->slock);
136
137 return (((tmp >> 16) & 0xffff) != (tmp & 0xffff));
138}
139
140static inline int __raw_spin_is_contended(raw_spinlock_t *lock)
141{
142 int tmp = *(volatile signed int *)(&(lock)->slock);
143
144 return (((tmp >> 16) & 0xffff) - (tmp & 0xffff)) > 1;
145}
146
147static inline void __raw_spin_lock(raw_spinlock_t *lock)
148{
149 int inc = 0x00010000;
150 int tmp;
151
152 __asm__ __volatile__ (
153 "lock ; xaddl %0, %1\n"
154 "movzwl %w0, %2\n\t"
155 "shrl $16, %0\n\t"
156 "1:\t"
157 "cmpl %0, %2\n\t"
158 "je 2f\n\t"
159 "rep ; nop\n\t"
160 "movzwl %1, %2\n\t"
161 /* don't need lfence here, because loads are in-order */
162 "jmp 1b\n"
163 "2:"
164 :"+Q" (inc), "+m" (lock->slock), "=r" (tmp)
165 :
166 :"memory", "cc");
167}
168
169#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
170
171static inline int __raw_spin_trylock(raw_spinlock_t *lock)
172{
173 int tmp;
174 int new;
175
176 asm volatile(
177 "movl %2,%0\n\t"
178 "movl %0,%1\n\t"
179 "roll $16, %0\n\t"
180 "cmpl %0,%1\n\t"
181 "jne 1f\n\t"
182 "addl $0x00010000, %1\n\t"
183 "lock ; cmpxchgl %1,%2\n\t"
184 "1:"
185 "sete %b1\n\t"
186 "movzbl %b1,%0\n\t"
187 :"=&a" (tmp), "=r" (new), "+m" (lock->slock)
188 :
189 : "memory", "cc");
190
191 return tmp;
192}
193
194static inline void __raw_spin_unlock(raw_spinlock_t *lock)
195{
196 __asm__ __volatile__(
197 UNLOCK_LOCK_PREFIX "incw %0"
198 :"+m" (lock->slock)
199 :
200 :"memory", "cc");
201}
202#endif
203
204static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
205{
206 while (__raw_spin_is_locked(lock))
207 cpu_relax();
208}
209
210/*
211 * Read-write spinlocks, allowing multiple readers
212 * but only one writer.
213 *
214 * NOTE! it is quite common to have readers in interrupts
215 * but no interrupt writers. For those circumstances we
216 * can "mix" irq-safe locks - any writer needs to get a
217 * irq-safe write-lock, but readers can get non-irqsafe
218 * read-locks.
219 *
220 * On x86, we implement read-write locks as a 32-bit counter
221 * with the high bit (sign) being the "contended" bit.
222 */
223
224/**
225 * read_can_lock - would read_trylock() succeed?
226 * @lock: the rwlock in question.
227 */
228static inline int __raw_read_can_lock(raw_rwlock_t *lock)
229{
230 return (int)(lock)->lock > 0;
231}
232
233/**
234 * write_can_lock - would write_trylock() succeed?
235 * @lock: the rwlock in question.
236 */
237static inline int __raw_write_can_lock(raw_rwlock_t *lock)
238{
239 return (lock)->lock == RW_LOCK_BIAS;
240}
241
242static inline void __raw_read_lock(raw_rwlock_t *rw)
243{
244 asm volatile(LOCK_PREFIX " subl $1,(%0)\n\t"
245 "jns 1f\n"
246 "call __read_lock_failed\n\t"
247 "1:\n"
248 ::LOCK_PTR_REG (rw) : "memory");
249}
250
251static inline void __raw_write_lock(raw_rwlock_t *rw)
252{
253 asm volatile(LOCK_PREFIX " subl %1,(%0)\n\t"
254 "jz 1f\n"
255 "call __write_lock_failed\n\t"
256 "1:\n"
257 ::LOCK_PTR_REG (rw), "i" (RW_LOCK_BIAS) : "memory");
258}
259
260static inline int __raw_read_trylock(raw_rwlock_t *lock)
261{
262 atomic_t *count = (atomic_t *)lock;
263
264 atomic_dec(count);
265 if (atomic_read(count) >= 0)
266 return 1;
267 atomic_inc(count);
268 return 0;
269}
270
271static inline int __raw_write_trylock(raw_rwlock_t *lock)
272{
273 atomic_t *count = (atomic_t *)lock;
274
275 if (atomic_sub_and_test(RW_LOCK_BIAS, count))
276 return 1;
277 atomic_add(RW_LOCK_BIAS, count);
278 return 0;
279}
280
281static inline void __raw_read_unlock(raw_rwlock_t *rw)
282{
283 asm volatile(LOCK_PREFIX "incl %0" :"+m" (rw->lock) : : "memory");
284}
285
286static inline void __raw_write_unlock(raw_rwlock_t *rw)
287{
288 asm volatile(LOCK_PREFIX "addl %1, %0"
289 : "+m" (rw->lock) : "i" (RW_LOCK_BIAS) : "memory");
290}
291
292#define _raw_spin_relax(lock) cpu_relax()
293#define _raw_read_relax(lock) cpu_relax()
294#define _raw_write_relax(lock) cpu_relax()
295
5#endif 296#endif
diff --git a/include/asm-x86/spinlock_32.h b/include/asm-x86/spinlock_32.h
deleted file mode 100644
index d3bcebed60ca..000000000000
--- a/include/asm-x86/spinlock_32.h
+++ /dev/null
@@ -1,221 +0,0 @@
1#ifndef __ASM_SPINLOCK_H
2#define __ASM_SPINLOCK_H
3
4#include <asm/atomic.h>
5#include <asm/rwlock.h>
6#include <asm/page.h>
7#include <asm/processor.h>
8#include <linux/compiler.h>
9
10#ifdef CONFIG_PARAVIRT
11#include <asm/paravirt.h>
12#else
13#define CLI_STRING "cli"
14#define STI_STRING "sti"
15#define CLI_STI_CLOBBERS
16#define CLI_STI_INPUT_ARGS
17#endif /* CONFIG_PARAVIRT */
18
19/*
20 * Your basic SMP spinlocks, allowing only a single CPU anywhere
21 *
22 * Simple spin lock operations. There are two variants, one clears IRQ's
23 * on the local processor, one does not.
24 *
25 * We make no fairness assumptions. They have a cost.
26 *
27 * (the type definitions are in asm/spinlock_types.h)
28 */
29
30static inline int __raw_spin_is_locked(raw_spinlock_t *x)
31{
32 return *(volatile signed char *)(&(x)->slock) <= 0;
33}
34
35static inline void __raw_spin_lock(raw_spinlock_t *lock)
36{
37 asm volatile("\n1:\t"
38 LOCK_PREFIX " ; decb %0\n\t"
39 "jns 3f\n"
40 "2:\t"
41 "rep;nop\n\t"
42 "cmpb $0,%0\n\t"
43 "jle 2b\n\t"
44 "jmp 1b\n"
45 "3:\n\t"
46 : "+m" (lock->slock) : : "memory");
47}
48
49/*
50 * It is easier for the lock validator if interrupts are not re-enabled
51 * in the middle of a lock-acquire. This is a performance feature anyway
52 * so we turn it off:
53 *
54 * NOTE: there's an irqs-on section here, which normally would have to be
55 * irq-traced, but on CONFIG_TRACE_IRQFLAGS we never use this variant.
56 */
57#ifndef CONFIG_PROVE_LOCKING
58static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
59{
60 asm volatile(
61 "\n1:\t"
62 LOCK_PREFIX " ; decb %[slock]\n\t"
63 "jns 5f\n"
64 "2:\t"
65 "testl $0x200, %[flags]\n\t"
66 "jz 4f\n\t"
67 STI_STRING "\n"
68 "3:\t"
69 "rep;nop\n\t"
70 "cmpb $0, %[slock]\n\t"
71 "jle 3b\n\t"
72 CLI_STRING "\n\t"
73 "jmp 1b\n"
74 "4:\t"
75 "rep;nop\n\t"
76 "cmpb $0, %[slock]\n\t"
77 "jg 1b\n\t"
78 "jmp 4b\n"
79 "5:\n\t"
80 : [slock] "+m" (lock->slock)
81 : [flags] "r" (flags)
82 CLI_STI_INPUT_ARGS
83 : "memory" CLI_STI_CLOBBERS);
84}
85#endif
86
87static inline int __raw_spin_trylock(raw_spinlock_t *lock)
88{
89 char oldval;
90 asm volatile(
91 "xchgb %b0,%1"
92 :"=q" (oldval), "+m" (lock->slock)
93 :"0" (0) : "memory");
94 return oldval > 0;
95}
96
97/*
98 * __raw_spin_unlock based on writing $1 to the low byte.
99 * This method works. Despite all the confusion.
100 * (except on PPro SMP or if we are using OOSTORE, so we use xchgb there)
101 * (PPro errata 66, 92)
102 */
103
104#if !defined(CONFIG_X86_OOSTORE) && !defined(CONFIG_X86_PPRO_FENCE)
105
106static inline void __raw_spin_unlock(raw_spinlock_t *lock)
107{
108 asm volatile("movb $1,%0" : "+m" (lock->slock) :: "memory");
109}
110
111#else
112
113static inline void __raw_spin_unlock(raw_spinlock_t *lock)
114{
115 char oldval = 1;
116
117 asm volatile("xchgb %b0, %1"
118 : "=q" (oldval), "+m" (lock->slock)
119 : "0" (oldval) : "memory");
120}
121
122#endif
123
124static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
125{
126 while (__raw_spin_is_locked(lock))
127 cpu_relax();
128}
129
130/*
131 * Read-write spinlocks, allowing multiple readers
132 * but only one writer.
133 *
134 * NOTE! it is quite common to have readers in interrupts
135 * but no interrupt writers. For those circumstances we
136 * can "mix" irq-safe locks - any writer needs to get a
137 * irq-safe write-lock, but readers can get non-irqsafe
138 * read-locks.
139 *
140 * On x86, we implement read-write locks as a 32-bit counter
141 * with the high bit (sign) being the "contended" bit.
142 *
143 * The inline assembly is non-obvious. Think about it.
144 *
145 * Changed to use the same technique as rw semaphores. See
146 * semaphore.h for details. -ben
147 *
148 * the helpers are in arch/i386/kernel/semaphore.c
149 */
150
151/**
152 * read_can_lock - would read_trylock() succeed?
153 * @lock: the rwlock in question.
154 */
155static inline int __raw_read_can_lock(raw_rwlock_t *x)
156{
157 return (int)(x)->lock > 0;
158}
159
160/**
161 * write_can_lock - would write_trylock() succeed?
162 * @lock: the rwlock in question.
163 */
164static inline int __raw_write_can_lock(raw_rwlock_t *x)
165{
166 return (x)->lock == RW_LOCK_BIAS;
167}
168
169static inline void __raw_read_lock(raw_rwlock_t *rw)
170{
171 asm volatile(LOCK_PREFIX " subl $1,(%0)\n\t"
172 "jns 1f\n"
173 "call __read_lock_failed\n\t"
174 "1:\n"
175 ::"a" (rw) : "memory");
176}
177
178static inline void __raw_write_lock(raw_rwlock_t *rw)
179{
180 asm volatile(LOCK_PREFIX " subl $" RW_LOCK_BIAS_STR ",(%0)\n\t"
181 "jz 1f\n"
182 "call __write_lock_failed\n\t"
183 "1:\n"
184 ::"a" (rw) : "memory");
185}
186
187static inline int __raw_read_trylock(raw_rwlock_t *lock)
188{
189 atomic_t *count = (atomic_t *)lock;
190 atomic_dec(count);
191 if (atomic_read(count) >= 0)
192 return 1;
193 atomic_inc(count);
194 return 0;
195}
196
197static inline int __raw_write_trylock(raw_rwlock_t *lock)
198{
199 atomic_t *count = (atomic_t *)lock;
200 if (atomic_sub_and_test(RW_LOCK_BIAS, count))
201 return 1;
202 atomic_add(RW_LOCK_BIAS, count);
203 return 0;
204}
205
206static inline void __raw_read_unlock(raw_rwlock_t *rw)
207{
208 asm volatile(LOCK_PREFIX "incl %0" :"+m" (rw->lock) : : "memory");
209}
210
211static inline void __raw_write_unlock(raw_rwlock_t *rw)
212{
213 asm volatile(LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ", %0"
214 : "+m" (rw->lock) : : "memory");
215}
216
217#define _raw_spin_relax(lock) cpu_relax()
218#define _raw_read_relax(lock) cpu_relax()
219#define _raw_write_relax(lock) cpu_relax()
220
221#endif /* __ASM_SPINLOCK_H */
diff --git a/include/asm-x86/spinlock_64.h b/include/asm-x86/spinlock_64.h
deleted file mode 100644
index 88bf981e73cf..000000000000
--- a/include/asm-x86/spinlock_64.h
+++ /dev/null
@@ -1,167 +0,0 @@
1#ifndef __ASM_SPINLOCK_H
2#define __ASM_SPINLOCK_H
3
4#include <asm/atomic.h>
5#include <asm/rwlock.h>
6#include <asm/page.h>
7#include <asm/processor.h>
8
9/*
10 * Your basic SMP spinlocks, allowing only a single CPU anywhere
11 *
12 * Simple spin lock operations. There are two variants, one clears IRQ's
13 * on the local processor, one does not.
14 *
15 * We make no fairness assumptions. They have a cost.
16 *
17 * (the type definitions are in asm/spinlock_types.h)
18 */
19
20static inline int __raw_spin_is_locked(raw_spinlock_t *lock)
21{
22 return *(volatile signed int *)(&(lock)->slock) <= 0;
23}
24
25static inline void __raw_spin_lock(raw_spinlock_t *lock)
26{
27 asm volatile(
28 "\n1:\t"
29 LOCK_PREFIX " ; decl %0\n\t"
30 "jns 2f\n"
31 "3:\n"
32 "rep;nop\n\t"
33 "cmpl $0,%0\n\t"
34 "jle 3b\n\t"
35 "jmp 1b\n"
36 "2:\t" : "=m" (lock->slock) : : "memory");
37}
38
39/*
40 * Same as __raw_spin_lock, but reenable interrupts during spinning.
41 */
42#ifndef CONFIG_PROVE_LOCKING
43static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
44{
45 asm volatile(
46 "\n1:\t"
47 LOCK_PREFIX " ; decl %0\n\t"
48 "jns 5f\n"
49 "testl $0x200, %1\n\t" /* interrupts were disabled? */
50 "jz 4f\n\t"
51 "sti\n"
52 "3:\t"
53 "rep;nop\n\t"
54 "cmpl $0, %0\n\t"
55 "jle 3b\n\t"
56 "cli\n\t"
57 "jmp 1b\n"
58 "4:\t"
59 "rep;nop\n\t"
60 "cmpl $0, %0\n\t"
61 "jg 1b\n\t"
62 "jmp 4b\n"
63 "5:\n\t"
64 : "+m" (lock->slock) : "r" ((unsigned)flags) : "memory");
65}
66#endif
67
68static inline int __raw_spin_trylock(raw_spinlock_t *lock)
69{
70 int oldval;
71
72 asm volatile(
73 "xchgl %0,%1"
74 :"=q" (oldval), "=m" (lock->slock)
75 :"0" (0) : "memory");
76
77 return oldval > 0;
78}
79
80static inline void __raw_spin_unlock(raw_spinlock_t *lock)
81{
82 asm volatile("movl $1,%0" :"=m" (lock->slock) :: "memory");
83}
84
85static inline void __raw_spin_unlock_wait(raw_spinlock_t *lock)
86{
87 while (__raw_spin_is_locked(lock))
88 cpu_relax();
89}
90
91/*
92 * Read-write spinlocks, allowing multiple readers
93 * but only one writer.
94 *
95 * NOTE! it is quite common to have readers in interrupts
96 * but no interrupt writers. For those circumstances we
97 * can "mix" irq-safe locks - any writer needs to get a
98 * irq-safe write-lock, but readers can get non-irqsafe
99 * read-locks.
100 *
101 * On x86, we implement read-write locks as a 32-bit counter
102 * with the high bit (sign) being the "contended" bit.
103 */
104
105static inline int __raw_read_can_lock(raw_rwlock_t *lock)
106{
107 return (int)(lock)->lock > 0;
108}
109
110static inline int __raw_write_can_lock(raw_rwlock_t *lock)
111{
112 return (lock)->lock == RW_LOCK_BIAS;
113}
114
115static inline void __raw_read_lock(raw_rwlock_t *rw)
116{
117 asm volatile(LOCK_PREFIX "subl $1,(%0)\n\t"
118 "jns 1f\n"
119 "call __read_lock_failed\n"
120 "1:\n"
121 ::"D" (rw), "i" (RW_LOCK_BIAS) : "memory");
122}
123
124static inline void __raw_write_lock(raw_rwlock_t *rw)
125{
126 asm volatile(LOCK_PREFIX "subl %1,(%0)\n\t"
127 "jz 1f\n"
128 "\tcall __write_lock_failed\n\t"
129 "1:\n"
130 ::"D" (rw), "i" (RW_LOCK_BIAS) : "memory");
131}
132
133static inline int __raw_read_trylock(raw_rwlock_t *lock)
134{
135 atomic_t *count = (atomic_t *)lock;
136 atomic_dec(count);
137 if (atomic_read(count) >= 0)
138 return 1;
139 atomic_inc(count);
140 return 0;
141}
142
143static inline int __raw_write_trylock(raw_rwlock_t *lock)
144{
145 atomic_t *count = (atomic_t *)lock;
146 if (atomic_sub_and_test(RW_LOCK_BIAS, count))
147 return 1;
148 atomic_add(RW_LOCK_BIAS, count);
149 return 0;
150}
151
152static inline void __raw_read_unlock(raw_rwlock_t *rw)
153{
154 asm volatile(LOCK_PREFIX " ; incl %0" :"=m" (rw->lock) : : "memory");
155}
156
157static inline void __raw_write_unlock(raw_rwlock_t *rw)
158{
159 asm volatile(LOCK_PREFIX " ; addl $" RW_LOCK_BIAS_STR ",%0"
160 : "=m" (rw->lock) : : "memory");
161}
162
163#define _raw_spin_relax(lock) cpu_relax()
164#define _raw_read_relax(lock) cpu_relax()
165#define _raw_write_relax(lock) cpu_relax()
166
167#endif /* __ASM_SPINLOCK_H */
diff --git a/include/asm-x86/spinlock_types.h b/include/asm-x86/spinlock_types.h
index 4da9345c1500..9029cf78cf5d 100644
--- a/include/asm-x86/spinlock_types.h
+++ b/include/asm-x86/spinlock_types.h
@@ -9,7 +9,7 @@ typedef struct {
9 unsigned int slock; 9 unsigned int slock;
10} raw_spinlock_t; 10} raw_spinlock_t;
11 11
12#define __RAW_SPIN_LOCK_UNLOCKED { 1 } 12#define __RAW_SPIN_LOCK_UNLOCKED { 0 }
13 13
14typedef struct { 14typedef struct {
15 unsigned int lock; 15 unsigned int lock;
diff --git a/include/asm-x86/stacktrace.h b/include/asm-x86/stacktrace.h
index 70dd5bae3235..30f82526a8e2 100644
--- a/include/asm-x86/stacktrace.h
+++ b/include/asm-x86/stacktrace.h
@@ -9,12 +9,13 @@ struct stacktrace_ops {
9 void (*warning)(void *data, char *msg); 9 void (*warning)(void *data, char *msg);
10 /* msg must contain %s for the symbol */ 10 /* msg must contain %s for the symbol */
11 void (*warning_symbol)(void *data, char *msg, unsigned long symbol); 11 void (*warning_symbol)(void *data, char *msg, unsigned long symbol);
12 void (*address)(void *data, unsigned long address); 12 void (*address)(void *data, unsigned long address, int reliable);
13 /* On negative return stop dumping */ 13 /* On negative return stop dumping */
14 int (*stack)(void *data, char *name); 14 int (*stack)(void *data, char *name);
15}; 15};
16 16
17void dump_trace(struct task_struct *tsk, struct pt_regs *regs, unsigned long *stack, 17void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
18 unsigned long *stack, unsigned long bp,
18 const struct stacktrace_ops *ops, void *data); 19 const struct stacktrace_ops *ops, void *data);
19 20
20#endif 21#endif
diff --git a/include/asm-x86/suspend_32.h b/include/asm-x86/suspend_32.h
index a2520732ffd6..1bbda3ad7796 100644
--- a/include/asm-x86/suspend_32.h
+++ b/include/asm-x86/suspend_32.h
@@ -12,8 +12,8 @@ static inline int arch_prepare_suspend(void) { return 0; }
12struct saved_context { 12struct saved_context {
13 u16 es, fs, gs, ss; 13 u16 es, fs, gs, ss;
14 unsigned long cr0, cr2, cr3, cr4; 14 unsigned long cr0, cr2, cr3, cr4;
15 struct Xgt_desc_struct gdt; 15 struct desc_ptr gdt;
16 struct Xgt_desc_struct idt; 16 struct desc_ptr idt;
17 u16 ldt; 17 u16 ldt;
18 u16 tss; 18 u16 tss;
19 unsigned long tr; 19 unsigned long tr;
diff --git a/include/asm-x86/suspend_64.h b/include/asm-x86/suspend_64.h
index c505a76bcf6e..2eb92cb81a0d 100644
--- a/include/asm-x86/suspend_64.h
+++ b/include/asm-x86/suspend_64.h
@@ -15,7 +15,14 @@ arch_prepare_suspend(void)
15 return 0; 15 return 0;
16} 16}
17 17
18/* Image of the saved processor state. If you touch this, fix acpi/wakeup.S. */ 18/*
19 * Image of the saved processor state, used by the low level ACPI suspend to
20 * RAM code and by the low level hibernation code.
21 *
22 * If you modify it, fix arch/x86/kernel/acpi/wakeup_64.S and make sure that
23 * __save/__restore_processor_state(), defined in arch/x86/kernel/suspend_64.c,
24 * still work as required.
25 */
19struct saved_context { 26struct saved_context {
20 struct pt_regs regs; 27 struct pt_regs regs;
21 u16 ds, es, fs, gs, ss; 28 u16 ds, es, fs, gs, ss;
@@ -38,8 +45,6 @@ struct saved_context {
38#define loaddebug(thread,register) \ 45#define loaddebug(thread,register) \
39 set_debugreg((thread)->debugreg##register, register) 46 set_debugreg((thread)->debugreg##register, register)
40 47
41extern void fix_processor_context(void);
42
43/* routines for saving/restoring kernel state */ 48/* routines for saving/restoring kernel state */
44extern int acpi_save_state_mem(void); 49extern int acpi_save_state_mem(void);
45extern char core_restore_code; 50extern char core_restore_code;
diff --git a/include/asm-x86/system.h b/include/asm-x86/system.h
index 692562b48f2a..ee32ef9367f4 100644
--- a/include/asm-x86/system.h
+++ b/include/asm-x86/system.h
@@ -1,5 +1,414 @@
1#ifndef _ASM_X86_SYSTEM_H_
2#define _ASM_X86_SYSTEM_H_
3
4#include <asm/asm.h>
5#include <asm/segment.h>
6#include <asm/cpufeature.h>
7#include <asm/cmpxchg.h>
8#include <asm/nops.h>
9
10#include <linux/kernel.h>
11#include <linux/irqflags.h>
12
13/* entries in ARCH_DLINFO: */
14#ifdef CONFIG_IA32_EMULATION
15# define AT_VECTOR_SIZE_ARCH 2
16#else
17# define AT_VECTOR_SIZE_ARCH 1
18#endif
19
20#ifdef CONFIG_X86_32
21
22struct task_struct; /* one of the stranger aspects of C forward declarations */
23extern struct task_struct *FASTCALL(__switch_to(struct task_struct *prev,
24 struct task_struct *next));
25
26/*
27 * Saving eflags is important. It switches not only IOPL between tasks,
28 * it also protects other tasks from NT leaking through sysenter etc.
29 */
30#define switch_to(prev, next, last) do { \
31 unsigned long esi, edi; \
32 asm volatile("pushfl\n\t" /* Save flags */ \
33 "pushl %%ebp\n\t" \
34 "movl %%esp,%0\n\t" /* save ESP */ \
35 "movl %5,%%esp\n\t" /* restore ESP */ \
36 "movl $1f,%1\n\t" /* save EIP */ \
37 "pushl %6\n\t" /* restore EIP */ \
38 "jmp __switch_to\n" \
39 "1:\t" \
40 "popl %%ebp\n\t" \
41 "popfl" \
42 :"=m" (prev->thread.sp), "=m" (prev->thread.ip), \
43 "=a" (last), "=S" (esi), "=D" (edi) \
44 :"m" (next->thread.sp), "m" (next->thread.ip), \
45 "2" (prev), "d" (next)); \
46} while (0)
47
48/*
49 * disable hlt during certain critical i/o operations
50 */
51#define HAVE_DISABLE_HLT
52#else
53#define __SAVE(reg, offset) "movq %%" #reg ",(14-" #offset ")*8(%%rsp)\n\t"
54#define __RESTORE(reg, offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
55
56/* frame pointer must be last for get_wchan */
57#define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
58#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
59
60#define __EXTRA_CLOBBER \
61 , "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", \
62 "r12", "r13", "r14", "r15"
63
64/* Save restore flags to clear handle leaking NT */
65#define switch_to(prev, next, last) \
66 asm volatile(SAVE_CONTEXT \
67 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
68 "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
69 "call __switch_to\n\t" \
70 ".globl thread_return\n" \
71 "thread_return:\n\t" \
72 "movq %%gs:%P[pda_pcurrent],%%rsi\n\t" \
73 "movq %P[thread_info](%%rsi),%%r8\n\t" \
74 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \
75 "movq %%rax,%%rdi\n\t" \
76 "jc ret_from_fork\n\t" \
77 RESTORE_CONTEXT \
78 : "=a" (last) \
79 : [next] "S" (next), [prev] "D" (prev), \
80 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
81 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
82 [tif_fork] "i" (TIF_FORK), \
83 [thread_info] "i" (offsetof(struct task_struct, stack)), \
84 [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \
85 : "memory", "cc" __EXTRA_CLOBBER)
86#endif
87
88#ifdef __KERNEL__
89#define _set_base(addr, base) do { unsigned long __pr; \
90__asm__ __volatile__ ("movw %%dx,%1\n\t" \
91 "rorl $16,%%edx\n\t" \
92 "movb %%dl,%2\n\t" \
93 "movb %%dh,%3" \
94 :"=&d" (__pr) \
95 :"m" (*((addr)+2)), \
96 "m" (*((addr)+4)), \
97 "m" (*((addr)+7)), \
98 "0" (base) \
99 ); } while (0)
100
101#define _set_limit(addr, limit) do { unsigned long __lr; \
102__asm__ __volatile__ ("movw %%dx,%1\n\t" \
103 "rorl $16,%%edx\n\t" \
104 "movb %2,%%dh\n\t" \
105 "andb $0xf0,%%dh\n\t" \
106 "orb %%dh,%%dl\n\t" \
107 "movb %%dl,%2" \
108 :"=&d" (__lr) \
109 :"m" (*(addr)), \
110 "m" (*((addr)+6)), \
111 "0" (limit) \
112 ); } while (0)
113
114#define set_base(ldt, base) _set_base(((char *)&(ldt)) , (base))
115#define set_limit(ldt, limit) _set_limit(((char *)&(ldt)) , ((limit)-1))
116
117extern void load_gs_index(unsigned);
118
119/*
120 * Load a segment. Fall back on loading the zero
121 * segment if something goes wrong..
122 */
123#define loadsegment(seg, value) \
124 asm volatile("\n" \
125 "1:\t" \
126 "movl %k0,%%" #seg "\n" \
127 "2:\n" \
128 ".section .fixup,\"ax\"\n" \
129 "3:\t" \
130 "movl %k1, %%" #seg "\n\t" \
131 "jmp 2b\n" \
132 ".previous\n" \
133 ".section __ex_table,\"a\"\n\t" \
134 _ASM_ALIGN "\n\t" \
135 _ASM_PTR " 1b,3b\n" \
136 ".previous" \
137 : :"r" (value), "r" (0))
138
139
140/*
141 * Save a segment register away
142 */
143#define savesegment(seg, value) \
144 asm volatile("mov %%" #seg ",%0":"=rm" (value))
145
146static inline unsigned long get_limit(unsigned long segment)
147{
148 unsigned long __limit;
149 __asm__("lsll %1,%0"
150 :"=r" (__limit):"r" (segment));
151 return __limit+1;
152}
153
154static inline void native_clts(void)
155{
156 asm volatile ("clts");
157}
158
159/*
160 * Volatile isn't enough to prevent the compiler from reordering the
161 * read/write functions for the control registers and messing everything up.
162 * A memory clobber would solve the problem, but would prevent reordering of
163 * all loads stores around it, which can hurt performance. Solution is to
164 * use a variable and mimic reads and writes to it to enforce serialization
165 */
166static unsigned long __force_order;
167
168static inline unsigned long native_read_cr0(void)
169{
170 unsigned long val;
171 asm volatile("mov %%cr0,%0\n\t" :"=r" (val), "=m" (__force_order));
172 return val;
173}
174
175static inline void native_write_cr0(unsigned long val)
176{
177 asm volatile("mov %0,%%cr0": :"r" (val), "m" (__force_order));
178}
179
180static inline unsigned long native_read_cr2(void)
181{
182 unsigned long val;
183 asm volatile("mov %%cr2,%0\n\t" :"=r" (val), "=m" (__force_order));
184 return val;
185}
186
187static inline void native_write_cr2(unsigned long val)
188{
189 asm volatile("mov %0,%%cr2": :"r" (val), "m" (__force_order));
190}
191
192static inline unsigned long native_read_cr3(void)
193{
194 unsigned long val;
195 asm volatile("mov %%cr3,%0\n\t" :"=r" (val), "=m" (__force_order));
196 return val;
197}
198
199static inline void native_write_cr3(unsigned long val)
200{
201 asm volatile("mov %0,%%cr3": :"r" (val), "m" (__force_order));
202}
203
204static inline unsigned long native_read_cr4(void)
205{
206 unsigned long val;
207 asm volatile("mov %%cr4,%0\n\t" :"=r" (val), "=m" (__force_order));
208 return val;
209}
210
211static inline unsigned long native_read_cr4_safe(void)
212{
213 unsigned long val;
214 /* This could fault if %cr4 does not exist. In x86_64, a cr4 always
215 * exists, so it will never fail. */
216#ifdef CONFIG_X86_32
217 asm volatile("1: mov %%cr4, %0 \n"
218 "2: \n"
219 ".section __ex_table,\"a\" \n"
220 ".long 1b,2b \n"
221 ".previous \n"
222 : "=r" (val), "=m" (__force_order) : "0" (0));
223#else
224 val = native_read_cr4();
225#endif
226 return val;
227}
228
229static inline void native_write_cr4(unsigned long val)
230{
231 asm volatile("mov %0,%%cr4": :"r" (val), "m" (__force_order));
232}
233
234#ifdef CONFIG_X86_64
235static inline unsigned long native_read_cr8(void)
236{
237 unsigned long cr8;
238 asm volatile("movq %%cr8,%0" : "=r" (cr8));
239 return cr8;
240}
241
242static inline void native_write_cr8(unsigned long val)
243{
244 asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
245}
246#endif
247
248static inline void native_wbinvd(void)
249{
250 asm volatile("wbinvd": : :"memory");
251}
252#ifdef CONFIG_PARAVIRT
253#include <asm/paravirt.h>
254#else
255#define read_cr0() (native_read_cr0())
256#define write_cr0(x) (native_write_cr0(x))
257#define read_cr2() (native_read_cr2())
258#define write_cr2(x) (native_write_cr2(x))
259#define read_cr3() (native_read_cr3())
260#define write_cr3(x) (native_write_cr3(x))
261#define read_cr4() (native_read_cr4())
262#define read_cr4_safe() (native_read_cr4_safe())
263#define write_cr4(x) (native_write_cr4(x))
264#define wbinvd() (native_wbinvd())
265#ifdef CONFIG_X86_64
266#define read_cr8() (native_read_cr8())
267#define write_cr8(x) (native_write_cr8(x))
268#endif
269
270/* Clear the 'TS' bit */
271#define clts() (native_clts())
272
273#endif/* CONFIG_PARAVIRT */
274
275#define stts() write_cr0(8 | read_cr0())
276
277#endif /* __KERNEL__ */
278
279static inline void clflush(void *__p)
280{
281 asm volatile("clflush %0" : "+m" (*(char __force *)__p));
282}
283
284#define nop() __asm__ __volatile__ ("nop")
285
286void disable_hlt(void);
287void enable_hlt(void);
288
289extern int es7000_plat;
290void cpu_idle_wait(void);
291
292extern unsigned long arch_align_stack(unsigned long sp);
293extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
294
295void default_idle(void);
296
297/*
298 * Force strict CPU ordering.
299 * And yes, this is required on UP too when we're talking
300 * to devices.
301 */
1#ifdef CONFIG_X86_32 302#ifdef CONFIG_X86_32
2# include "system_32.h" 303/*
304 * For now, "wmb()" doesn't actually do anything, as all
305 * Intel CPU's follow what Intel calls a *Processor Order*,
306 * in which all writes are seen in the program order even
307 * outside the CPU.
308 *
309 * I expect future Intel CPU's to have a weaker ordering,
310 * but I'd also expect them to finally get their act together
311 * and add some real memory barriers if so.
312 *
313 * Some non intel clones support out of order store. wmb() ceases to be a
314 * nop for these.
315 */
316#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
317#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
318#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
3#else 319#else
4# include "system_64.h" 320#define mb() asm volatile("mfence":::"memory")
321#define rmb() asm volatile("lfence":::"memory")
322#define wmb() asm volatile("sfence" ::: "memory")
323#endif
324
325/**
326 * read_barrier_depends - Flush all pending reads that subsequents reads
327 * depend on.
328 *
329 * No data-dependent reads from memory-like regions are ever reordered
330 * over this barrier. All reads preceding this primitive are guaranteed
331 * to access memory (but not necessarily other CPUs' caches) before any
332 * reads following this primitive that depend on the data return by
333 * any of the preceding reads. This primitive is much lighter weight than
334 * rmb() on most CPUs, and is never heavier weight than is
335 * rmb().
336 *
337 * These ordering constraints are respected by both the local CPU
338 * and the compiler.
339 *
340 * Ordering is not guaranteed by anything other than these primitives,
341 * not even by data dependencies. See the documentation for
342 * memory_barrier() for examples and URLs to more information.
343 *
344 * For example, the following code would force ordering (the initial
345 * value of "a" is zero, "b" is one, and "p" is "&a"):
346 *
347 * <programlisting>
348 * CPU 0 CPU 1
349 *
350 * b = 2;
351 * memory_barrier();
352 * p = &b; q = p;
353 * read_barrier_depends();
354 * d = *q;
355 * </programlisting>
356 *
357 * because the read of "*q" depends on the read of "p" and these
358 * two reads are separated by a read_barrier_depends(). However,
359 * the following code, with the same initial values for "a" and "b":
360 *
361 * <programlisting>
362 * CPU 0 CPU 1
363 *
364 * a = 2;
365 * memory_barrier();
366 * b = 3; y = b;
367 * read_barrier_depends();
368 * x = a;
369 * </programlisting>
370 *
371 * does not enforce ordering, since there is no data dependency between
372 * the read of "a" and the read of "b". Therefore, on some CPUs, such
373 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
374 * in cases like this where there are no data dependencies.
375 **/
376
377#define read_barrier_depends() do { } while (0)
378
379#ifdef CONFIG_SMP
380#define smp_mb() mb()
381#ifdef CONFIG_X86_PPRO_FENCE
382# define smp_rmb() rmb()
383#else
384# define smp_rmb() barrier()
385#endif
386#ifdef CONFIG_X86_OOSTORE
387# define smp_wmb() wmb()
388#else
389# define smp_wmb() barrier()
390#endif
391#define smp_read_barrier_depends() read_barrier_depends()
392#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
393#else
394#define smp_mb() barrier()
395#define smp_rmb() barrier()
396#define smp_wmb() barrier()
397#define smp_read_barrier_depends() do { } while (0)
398#define set_mb(var, value) do { var = value; barrier(); } while (0)
399#endif
400
401/*
402 * Stop RDTSC speculation. This is needed when you need to use RDTSC
403 * (or get_cycles or vread that possibly accesses the TSC) in a defined
404 * code region.
405 *
406 * (Could use an alternative three way for this if there was one.)
407 */
408static inline void rdtsc_barrier(void)
409{
410 alternative(ASM_NOP3, "mfence", X86_FEATURE_MFENCE_RDTSC);
411 alternative(ASM_NOP3, "lfence", X86_FEATURE_LFENCE_RDTSC);
412}
413
5#endif 414#endif
diff --git a/include/asm-x86/system_32.h b/include/asm-x86/system_32.h
deleted file mode 100644
index ef8468883bac..000000000000
--- a/include/asm-x86/system_32.h
+++ /dev/null
@@ -1,320 +0,0 @@
1#ifndef __ASM_SYSTEM_H
2#define __ASM_SYSTEM_H
3
4#include <linux/kernel.h>
5#include <asm/segment.h>
6#include <asm/cpufeature.h>
7#include <asm/cmpxchg.h>
8
9#ifdef __KERNEL__
10#define AT_VECTOR_SIZE_ARCH 2 /* entries in ARCH_DLINFO */
11
12struct task_struct; /* one of the stranger aspects of C forward declarations.. */
13extern struct task_struct * FASTCALL(__switch_to(struct task_struct *prev, struct task_struct *next));
14
15/*
16 * Saving eflags is important. It switches not only IOPL between tasks,
17 * it also protects other tasks from NT leaking through sysenter etc.
18 */
19#define switch_to(prev,next,last) do { \
20 unsigned long esi,edi; \
21 asm volatile("pushfl\n\t" /* Save flags */ \
22 "pushl %%ebp\n\t" \
23 "movl %%esp,%0\n\t" /* save ESP */ \
24 "movl %5,%%esp\n\t" /* restore ESP */ \
25 "movl $1f,%1\n\t" /* save EIP */ \
26 "pushl %6\n\t" /* restore EIP */ \
27 "jmp __switch_to\n" \
28 "1:\t" \
29 "popl %%ebp\n\t" \
30 "popfl" \
31 :"=m" (prev->thread.esp),"=m" (prev->thread.eip), \
32 "=a" (last),"=S" (esi),"=D" (edi) \
33 :"m" (next->thread.esp),"m" (next->thread.eip), \
34 "2" (prev), "d" (next)); \
35} while (0)
36
37#define _set_base(addr,base) do { unsigned long __pr; \
38__asm__ __volatile__ ("movw %%dx,%1\n\t" \
39 "rorl $16,%%edx\n\t" \
40 "movb %%dl,%2\n\t" \
41 "movb %%dh,%3" \
42 :"=&d" (__pr) \
43 :"m" (*((addr)+2)), \
44 "m" (*((addr)+4)), \
45 "m" (*((addr)+7)), \
46 "0" (base) \
47 ); } while(0)
48
49#define _set_limit(addr,limit) do { unsigned long __lr; \
50__asm__ __volatile__ ("movw %%dx,%1\n\t" \
51 "rorl $16,%%edx\n\t" \
52 "movb %2,%%dh\n\t" \
53 "andb $0xf0,%%dh\n\t" \
54 "orb %%dh,%%dl\n\t" \
55 "movb %%dl,%2" \
56 :"=&d" (__lr) \
57 :"m" (*(addr)), \
58 "m" (*((addr)+6)), \
59 "0" (limit) \
60 ); } while(0)
61
62#define set_base(ldt,base) _set_base( ((char *)&(ldt)) , (base) )
63#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , ((limit)-1) )
64
65/*
66 * Load a segment. Fall back on loading the zero
67 * segment if something goes wrong..
68 */
69#define loadsegment(seg,value) \
70 asm volatile("\n" \
71 "1:\t" \
72 "mov %0,%%" #seg "\n" \
73 "2:\n" \
74 ".section .fixup,\"ax\"\n" \
75 "3:\t" \
76 "pushl $0\n\t" \
77 "popl %%" #seg "\n\t" \
78 "jmp 2b\n" \
79 ".previous\n" \
80 ".section __ex_table,\"a\"\n\t" \
81 ".align 4\n\t" \
82 ".long 1b,3b\n" \
83 ".previous" \
84 : :"rm" (value))
85
86/*
87 * Save a segment register away
88 */
89#define savesegment(seg, value) \
90 asm volatile("mov %%" #seg ",%0":"=rm" (value))
91
92
93static inline void native_clts(void)
94{
95 asm volatile ("clts");
96}
97
98static inline unsigned long native_read_cr0(void)
99{
100 unsigned long val;
101 asm volatile("movl %%cr0,%0\n\t" :"=r" (val));
102 return val;
103}
104
105static inline void native_write_cr0(unsigned long val)
106{
107 asm volatile("movl %0,%%cr0": :"r" (val));
108}
109
110static inline unsigned long native_read_cr2(void)
111{
112 unsigned long val;
113 asm volatile("movl %%cr2,%0\n\t" :"=r" (val));
114 return val;
115}
116
117static inline void native_write_cr2(unsigned long val)
118{
119 asm volatile("movl %0,%%cr2": :"r" (val));
120}
121
122static inline unsigned long native_read_cr3(void)
123{
124 unsigned long val;
125 asm volatile("movl %%cr3,%0\n\t" :"=r" (val));
126 return val;
127}
128
129static inline void native_write_cr3(unsigned long val)
130{
131 asm volatile("movl %0,%%cr3": :"r" (val));
132}
133
134static inline unsigned long native_read_cr4(void)
135{
136 unsigned long val;
137 asm volatile("movl %%cr4,%0\n\t" :"=r" (val));
138 return val;
139}
140
141static inline unsigned long native_read_cr4_safe(void)
142{
143 unsigned long val;
144 /* This could fault if %cr4 does not exist */
145 asm volatile("1: movl %%cr4, %0 \n"
146 "2: \n"
147 ".section __ex_table,\"a\" \n"
148 ".long 1b,2b \n"
149 ".previous \n"
150 : "=r" (val): "0" (0));
151 return val;
152}
153
154static inline void native_write_cr4(unsigned long val)
155{
156 asm volatile("movl %0,%%cr4": :"r" (val));
157}
158
159static inline void native_wbinvd(void)
160{
161 asm volatile("wbinvd": : :"memory");
162}
163
164static inline void clflush(volatile void *__p)
165{
166 asm volatile("clflush %0" : "+m" (*(char __force *)__p));
167}
168
169#ifdef CONFIG_PARAVIRT
170#include <asm/paravirt.h>
171#else
172#define read_cr0() (native_read_cr0())
173#define write_cr0(x) (native_write_cr0(x))
174#define read_cr2() (native_read_cr2())
175#define write_cr2(x) (native_write_cr2(x))
176#define read_cr3() (native_read_cr3())
177#define write_cr3(x) (native_write_cr3(x))
178#define read_cr4() (native_read_cr4())
179#define read_cr4_safe() (native_read_cr4_safe())
180#define write_cr4(x) (native_write_cr4(x))
181#define wbinvd() (native_wbinvd())
182
183/* Clear the 'TS' bit */
184#define clts() (native_clts())
185
186#endif/* CONFIG_PARAVIRT */
187
188/* Set the 'TS' bit */
189#define stts() write_cr0(8 | read_cr0())
190
191#endif /* __KERNEL__ */
192
193static inline unsigned long get_limit(unsigned long segment)
194{
195 unsigned long __limit;
196 __asm__("lsll %1,%0"
197 :"=r" (__limit):"r" (segment));
198 return __limit+1;
199}
200
201#define nop() __asm__ __volatile__ ("nop")
202
203/*
204 * Force strict CPU ordering.
205 * And yes, this is required on UP too when we're talking
206 * to devices.
207 *
208 * For now, "wmb()" doesn't actually do anything, as all
209 * Intel CPU's follow what Intel calls a *Processor Order*,
210 * in which all writes are seen in the program order even
211 * outside the CPU.
212 *
213 * I expect future Intel CPU's to have a weaker ordering,
214 * but I'd also expect them to finally get their act together
215 * and add some real memory barriers if so.
216 *
217 * Some non intel clones support out of order store. wmb() ceases to be a
218 * nop for these.
219 */
220
221
222#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
223#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
224#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
225
226/**
227 * read_barrier_depends - Flush all pending reads that subsequents reads
228 * depend on.
229 *
230 * No data-dependent reads from memory-like regions are ever reordered
231 * over this barrier. All reads preceding this primitive are guaranteed
232 * to access memory (but not necessarily other CPUs' caches) before any
233 * reads following this primitive that depend on the data return by
234 * any of the preceding reads. This primitive is much lighter weight than
235 * rmb() on most CPUs, and is never heavier weight than is
236 * rmb().
237 *
238 * These ordering constraints are respected by both the local CPU
239 * and the compiler.
240 *
241 * Ordering is not guaranteed by anything other than these primitives,
242 * not even by data dependencies. See the documentation for
243 * memory_barrier() for examples and URLs to more information.
244 *
245 * For example, the following code would force ordering (the initial
246 * value of "a" is zero, "b" is one, and "p" is "&a"):
247 *
248 * <programlisting>
249 * CPU 0 CPU 1
250 *
251 * b = 2;
252 * memory_barrier();
253 * p = &b; q = p;
254 * read_barrier_depends();
255 * d = *q;
256 * </programlisting>
257 *
258 * because the read of "*q" depends on the read of "p" and these
259 * two reads are separated by a read_barrier_depends(). However,
260 * the following code, with the same initial values for "a" and "b":
261 *
262 * <programlisting>
263 * CPU 0 CPU 1
264 *
265 * a = 2;
266 * memory_barrier();
267 * b = 3; y = b;
268 * read_barrier_depends();
269 * x = a;
270 * </programlisting>
271 *
272 * does not enforce ordering, since there is no data dependency between
273 * the read of "a" and the read of "b". Therefore, on some CPUs, such
274 * as Alpha, "y" could be set to 3 and "x" to 0. Use rmb()
275 * in cases like this where there are no data dependencies.
276 **/
277
278#define read_barrier_depends() do { } while(0)
279
280#ifdef CONFIG_SMP
281#define smp_mb() mb()
282#ifdef CONFIG_X86_PPRO_FENCE
283# define smp_rmb() rmb()
284#else
285# define smp_rmb() barrier()
286#endif
287#ifdef CONFIG_X86_OOSTORE
288# define smp_wmb() wmb()
289#else
290# define smp_wmb() barrier()
291#endif
292#define smp_read_barrier_depends() read_barrier_depends()
293#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
294#else
295#define smp_mb() barrier()
296#define smp_rmb() barrier()
297#define smp_wmb() barrier()
298#define smp_read_barrier_depends() do { } while(0)
299#define set_mb(var, value) do { var = value; barrier(); } while (0)
300#endif
301
302#include <linux/irqflags.h>
303
304/*
305 * disable hlt during certain critical i/o operations
306 */
307#define HAVE_DISABLE_HLT
308void disable_hlt(void);
309void enable_hlt(void);
310
311extern int es7000_plat;
312void cpu_idle_wait(void);
313
314extern unsigned long arch_align_stack(unsigned long sp);
315extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
316
317void default_idle(void);
318void __show_registers(struct pt_regs *, int all);
319
320#endif
diff --git a/include/asm-x86/system_64.h b/include/asm-x86/system_64.h
index 4cb23848d460..97fa251ccb2b 100644
--- a/include/asm-x86/system_64.h
+++ b/include/asm-x86/system_64.h
@@ -1,119 +1,9 @@
1#ifndef __ASM_SYSTEM_H 1#ifndef __ASM_SYSTEM_H
2#define __ASM_SYSTEM_H 2#define __ASM_SYSTEM_H
3 3
4#include <linux/kernel.h>
5#include <asm/segment.h> 4#include <asm/segment.h>
6#include <asm/cmpxchg.h> 5#include <asm/cmpxchg.h>
7 6
8#ifdef __KERNEL__
9
10#define __SAVE(reg,offset) "movq %%" #reg ",(14-" #offset ")*8(%%rsp)\n\t"
11#define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
12
13/* frame pointer must be last for get_wchan */
14#define SAVE_CONTEXT "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
15#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
16
17#define __EXTRA_CLOBBER \
18 ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
19
20/* Save restore flags to clear handle leaking NT */
21#define switch_to(prev,next,last) \
22 asm volatile(SAVE_CONTEXT \
23 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
24 "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
25 "call __switch_to\n\t" \
26 ".globl thread_return\n" \
27 "thread_return:\n\t" \
28 "movq %%gs:%P[pda_pcurrent],%%rsi\n\t" \
29 "movq %P[thread_info](%%rsi),%%r8\n\t" \
30 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \
31 "movq %%rax,%%rdi\n\t" \
32 "jc ret_from_fork\n\t" \
33 RESTORE_CONTEXT \
34 : "=a" (last) \
35 : [next] "S" (next), [prev] "D" (prev), \
36 [threadrsp] "i" (offsetof(struct task_struct, thread.rsp)), \
37 [ti_flags] "i" (offsetof(struct thread_info, flags)),\
38 [tif_fork] "i" (TIF_FORK), \
39 [thread_info] "i" (offsetof(struct task_struct, stack)), \
40 [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent)) \
41 : "memory", "cc" __EXTRA_CLOBBER)
42
43extern void load_gs_index(unsigned);
44
45/*
46 * Load a segment. Fall back on loading the zero
47 * segment if something goes wrong..
48 */
49#define loadsegment(seg,value) \
50 asm volatile("\n" \
51 "1:\t" \
52 "movl %k0,%%" #seg "\n" \
53 "2:\n" \
54 ".section .fixup,\"ax\"\n" \
55 "3:\t" \
56 "movl %1,%%" #seg "\n\t" \
57 "jmp 2b\n" \
58 ".previous\n" \
59 ".section __ex_table,\"a\"\n\t" \
60 ".align 8\n\t" \
61 ".quad 1b,3b\n" \
62 ".previous" \
63 : :"r" (value), "r" (0))
64
65/*
66 * Clear and set 'TS' bit respectively
67 */
68#define clts() __asm__ __volatile__ ("clts")
69
70static inline unsigned long read_cr0(void)
71{
72 unsigned long cr0;
73 asm volatile("movq %%cr0,%0" : "=r" (cr0));
74 return cr0;
75}
76
77static inline void write_cr0(unsigned long val)
78{
79 asm volatile("movq %0,%%cr0" :: "r" (val));
80}
81
82static inline unsigned long read_cr2(void)
83{
84 unsigned long cr2;
85 asm volatile("movq %%cr2,%0" : "=r" (cr2));
86 return cr2;
87}
88
89static inline void write_cr2(unsigned long val)
90{
91 asm volatile("movq %0,%%cr2" :: "r" (val));
92}
93
94static inline unsigned long read_cr3(void)
95{
96 unsigned long cr3;
97 asm volatile("movq %%cr3,%0" : "=r" (cr3));
98 return cr3;
99}
100
101static inline void write_cr3(unsigned long val)
102{
103 asm volatile("movq %0,%%cr3" :: "r" (val) : "memory");
104}
105
106static inline unsigned long read_cr4(void)
107{
108 unsigned long cr4;
109 asm volatile("movq %%cr4,%0" : "=r" (cr4));
110 return cr4;
111}
112
113static inline void write_cr4(unsigned long val)
114{
115 asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
116}
117 7
118static inline unsigned long read_cr8(void) 8static inline unsigned long read_cr8(void)
119{ 9{
@@ -127,52 +17,6 @@ static inline void write_cr8(unsigned long val)
127 asm volatile("movq %0,%%cr8" :: "r" (val) : "memory"); 17 asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
128} 18}
129 19
130#define stts() write_cr0(8 | read_cr0())
131
132#define wbinvd() \
133 __asm__ __volatile__ ("wbinvd": : :"memory")
134
135#endif /* __KERNEL__ */
136
137static inline void clflush(volatile void *__p)
138{
139 asm volatile("clflush %0" : "+m" (*(char __force *)__p));
140}
141
142#define nop() __asm__ __volatile__ ("nop")
143
144#ifdef CONFIG_SMP
145#define smp_mb() mb()
146#define smp_rmb() barrier()
147#define smp_wmb() barrier()
148#define smp_read_barrier_depends() do {} while(0)
149#else
150#define smp_mb() barrier()
151#define smp_rmb() barrier()
152#define smp_wmb() barrier()
153#define smp_read_barrier_depends() do {} while(0)
154#endif
155
156
157/*
158 * Force strict CPU ordering.
159 * And yes, this is required on UP too when we're talking
160 * to devices.
161 */
162#define mb() asm volatile("mfence":::"memory")
163#define rmb() asm volatile("lfence":::"memory")
164#define wmb() asm volatile("sfence" ::: "memory")
165
166#define read_barrier_depends() do {} while(0)
167#define set_mb(var, value) do { (void) xchg(&var, value); } while (0)
168
169#define warn_if_not_ulong(x) do { unsigned long foo; (void) (&(x) == &foo); } while (0)
170
171#include <linux/irqflags.h> 20#include <linux/irqflags.h>
172 21
173void cpu_idle_wait(void);
174
175extern unsigned long arch_align_stack(unsigned long sp);
176extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
177
178#endif 22#endif
diff --git a/include/asm-x86/thread_info_32.h b/include/asm-x86/thread_info_32.h
index 22a8cbcd35e2..5bd508260ffb 100644
--- a/include/asm-x86/thread_info_32.h
+++ b/include/asm-x86/thread_info_32.h
@@ -85,7 +85,7 @@ struct thread_info {
85 85
86 86
87/* how to get the current stack pointer from C */ 87/* how to get the current stack pointer from C */
88register unsigned long current_stack_pointer asm("esp") __attribute_used__; 88register unsigned long current_stack_pointer asm("esp") __used;
89 89
90/* how to get the thread information struct from C */ 90/* how to get the thread information struct from C */
91static inline struct thread_info *current_thread_info(void) 91static inline struct thread_info *current_thread_info(void)
@@ -132,11 +132,16 @@ static inline struct thread_info *current_thread_info(void)
132#define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */ 132#define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */
133#define TIF_SECCOMP 7 /* secure computing */ 133#define TIF_SECCOMP 7 /* secure computing */
134#define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */ 134#define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
135#define TIF_HRTICK_RESCHED 9 /* reprogram hrtick timer */
135#define TIF_MEMDIE 16 136#define TIF_MEMDIE 16
136#define TIF_DEBUG 17 /* uses debug registers */ 137#define TIF_DEBUG 17 /* uses debug registers */
137#define TIF_IO_BITMAP 18 /* uses I/O bitmap */ 138#define TIF_IO_BITMAP 18 /* uses I/O bitmap */
138#define TIF_FREEZE 19 /* is freezing for suspend */ 139#define TIF_FREEZE 19 /* is freezing for suspend */
139#define TIF_NOTSC 20 /* TSC is not accessible in userland */ 140#define TIF_NOTSC 20 /* TSC is not accessible in userland */
141#define TIF_FORCED_TF 21 /* true if TF in eflags artificially */
142#define TIF_DEBUGCTLMSR 22 /* uses thread_struct.debugctlmsr */
143#define TIF_DS_AREA_MSR 23 /* uses thread_struct.ds_area_msr */
144#define TIF_BTS_TRACE_TS 24 /* record scheduling event timestamps */
140 145
141#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 146#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
142#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 147#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
@@ -147,10 +152,15 @@ static inline struct thread_info *current_thread_info(void)
147#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 152#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
148#define _TIF_SECCOMP (1<<TIF_SECCOMP) 153#define _TIF_SECCOMP (1<<TIF_SECCOMP)
149#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 154#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
155#define _TIF_HRTICK_RESCHED (1<<TIF_HRTICK_RESCHED)
150#define _TIF_DEBUG (1<<TIF_DEBUG) 156#define _TIF_DEBUG (1<<TIF_DEBUG)
151#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) 157#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP)
152#define _TIF_FREEZE (1<<TIF_FREEZE) 158#define _TIF_FREEZE (1<<TIF_FREEZE)
153#define _TIF_NOTSC (1<<TIF_NOTSC) 159#define _TIF_NOTSC (1<<TIF_NOTSC)
160#define _TIF_FORCED_TF (1<<TIF_FORCED_TF)
161#define _TIF_DEBUGCTLMSR (1<<TIF_DEBUGCTLMSR)
162#define _TIF_DS_AREA_MSR (1<<TIF_DS_AREA_MSR)
163#define _TIF_BTS_TRACE_TS (1<<TIF_BTS_TRACE_TS)
154 164
155/* work to do on interrupt/exception return */ 165/* work to do on interrupt/exception return */
156#define _TIF_WORK_MASK \ 166#define _TIF_WORK_MASK \
@@ -160,8 +170,12 @@ static inline struct thread_info *current_thread_info(void)
160#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP) 170#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP)
161 171
162/* flags to check in __switch_to() */ 172/* flags to check in __switch_to() */
163#define _TIF_WORK_CTXSW_NEXT (_TIF_IO_BITMAP | _TIF_NOTSC | _TIF_DEBUG) 173#define _TIF_WORK_CTXSW \
164#define _TIF_WORK_CTXSW_PREV (_TIF_IO_BITMAP | _TIF_NOTSC) 174 (_TIF_IO_BITMAP | _TIF_NOTSC | _TIF_DEBUGCTLMSR | \
175 _TIF_DS_AREA_MSR | _TIF_BTS_TRACE_TS)
176#define _TIF_WORK_CTXSW_PREV _TIF_WORK_CTXSW
177#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW | _TIF_DEBUG)
178
165 179
166/* 180/*
167 * Thread-synchronous status. 181 * Thread-synchronous status.
diff --git a/include/asm-x86/thread_info_64.h b/include/asm-x86/thread_info_64.h
index beae2bfb62ca..6c9b214b8fc3 100644
--- a/include/asm-x86/thread_info_64.h
+++ b/include/asm-x86/thread_info_64.h
@@ -21,7 +21,7 @@
21#ifndef __ASSEMBLY__ 21#ifndef __ASSEMBLY__
22struct task_struct; 22struct task_struct;
23struct exec_domain; 23struct exec_domain;
24#include <asm/mmsegment.h> 24#include <asm/processor.h>
25 25
26struct thread_info { 26struct thread_info {
27 struct task_struct *task; /* main task structure */ 27 struct task_struct *task; /* main task structure */
@@ -33,6 +33,9 @@ struct thread_info {
33 33
34 mm_segment_t addr_limit; 34 mm_segment_t addr_limit;
35 struct restart_block restart_block; 35 struct restart_block restart_block;
36#ifdef CONFIG_IA32_EMULATION
37 void __user *sysenter_return;
38#endif
36}; 39};
37#endif 40#endif
38 41
@@ -74,20 +77,14 @@ static inline struct thread_info *stack_thread_info(void)
74 77
75/* thread information allocation */ 78/* thread information allocation */
76#ifdef CONFIG_DEBUG_STACK_USAGE 79#ifdef CONFIG_DEBUG_STACK_USAGE
77#define alloc_thread_info(tsk) \ 80#define THREAD_FLAGS (GFP_KERNEL | __GFP_ZERO)
78 ({ \
79 struct thread_info *ret; \
80 \
81 ret = ((struct thread_info *) __get_free_pages(GFP_KERNEL,THREAD_ORDER)); \
82 if (ret) \
83 memset(ret, 0, THREAD_SIZE); \
84 ret; \
85 })
86#else 81#else
87#define alloc_thread_info(tsk) \ 82#define THREAD_FLAGS GFP_KERNEL
88 ((struct thread_info *) __get_free_pages(GFP_KERNEL,THREAD_ORDER))
89#endif 83#endif
90 84
85#define alloc_thread_info(tsk) \
86 ((struct thread_info *) __get_free_pages(THREAD_FLAGS, THREAD_ORDER))
87
91#define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_ORDER) 88#define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_ORDER)
92 89
93#else /* !__ASSEMBLY__ */ 90#else /* !__ASSEMBLY__ */
@@ -115,6 +112,7 @@ static inline struct thread_info *stack_thread_info(void)
115#define TIF_SECCOMP 8 /* secure computing */ 112#define TIF_SECCOMP 8 /* secure computing */
116#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */ 113#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
117#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */ 114#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */
115#define TIF_HRTICK_RESCHED 11 /* reprogram hrtick timer */
118/* 16 free */ 116/* 16 free */
119#define TIF_IA32 17 /* 32bit process */ 117#define TIF_IA32 17 /* 32bit process */
120#define TIF_FORK 18 /* ret_from_fork */ 118#define TIF_FORK 18 /* ret_from_fork */
@@ -123,6 +121,10 @@ static inline struct thread_info *stack_thread_info(void)
123#define TIF_DEBUG 21 /* uses debug registers */ 121#define TIF_DEBUG 21 /* uses debug registers */
124#define TIF_IO_BITMAP 22 /* uses I/O bitmap */ 122#define TIF_IO_BITMAP 22 /* uses I/O bitmap */
125#define TIF_FREEZE 23 /* is freezing for suspend */ 123#define TIF_FREEZE 23 /* is freezing for suspend */
124#define TIF_FORCED_TF 24 /* true if TF in eflags artificially */
125#define TIF_DEBUGCTLMSR 25 /* uses thread_struct.debugctlmsr */
126#define TIF_DS_AREA_MSR 26 /* uses thread_struct.ds_area_msr */
127#define TIF_BTS_TRACE_TS 27 /* record scheduling event timestamps */
126 128
127#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 129#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
128#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 130#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
@@ -133,12 +135,17 @@ static inline struct thread_info *stack_thread_info(void)
133#define _TIF_SECCOMP (1<<TIF_SECCOMP) 135#define _TIF_SECCOMP (1<<TIF_SECCOMP)
134#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 136#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
135#define _TIF_MCE_NOTIFY (1<<TIF_MCE_NOTIFY) 137#define _TIF_MCE_NOTIFY (1<<TIF_MCE_NOTIFY)
138#define _TIF_HRTICK_RESCHED (1<<TIF_HRTICK_RESCHED)
136#define _TIF_IA32 (1<<TIF_IA32) 139#define _TIF_IA32 (1<<TIF_IA32)
137#define _TIF_FORK (1<<TIF_FORK) 140#define _TIF_FORK (1<<TIF_FORK)
138#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 141#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
139#define _TIF_DEBUG (1<<TIF_DEBUG) 142#define _TIF_DEBUG (1<<TIF_DEBUG)
140#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) 143#define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP)
141#define _TIF_FREEZE (1<<TIF_FREEZE) 144#define _TIF_FREEZE (1<<TIF_FREEZE)
145#define _TIF_FORCED_TF (1<<TIF_FORCED_TF)
146#define _TIF_DEBUGCTLMSR (1<<TIF_DEBUGCTLMSR)
147#define _TIF_DS_AREA_MSR (1<<TIF_DS_AREA_MSR)
148#define _TIF_BTS_TRACE_TS (1<<TIF_BTS_TRACE_TS)
142 149
143/* work to do on interrupt/exception return */ 150/* work to do on interrupt/exception return */
144#define _TIF_WORK_MASK \ 151#define _TIF_WORK_MASK \
@@ -146,8 +153,14 @@ static inline struct thread_info *stack_thread_info(void)
146/* work to do on any return to user space */ 153/* work to do on any return to user space */
147#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP) 154#define _TIF_ALLWORK_MASK (0x0000FFFF & ~_TIF_SECCOMP)
148 155
156#define _TIF_DO_NOTIFY_MASK \
157 (_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY|_TIF_HRTICK_RESCHED)
158
149/* flags to check in __switch_to() */ 159/* flags to check in __switch_to() */
150#define _TIF_WORK_CTXSW (_TIF_DEBUG|_TIF_IO_BITMAP) 160#define _TIF_WORK_CTXSW \
161 (_TIF_IO_BITMAP|_TIF_DEBUGCTLMSR|_TIF_DS_AREA_MSR|_TIF_BTS_TRACE_TS)
162#define _TIF_WORK_CTXSW_PREV _TIF_WORK_CTXSW
163#define _TIF_WORK_CTXSW_NEXT (_TIF_WORK_CTXSW|_TIF_DEBUG)
151 164
152#define PREEMPT_ACTIVE 0x10000000 165#define PREEMPT_ACTIVE 0x10000000
153 166
diff --git a/include/asm-x86/time.h b/include/asm-x86/time.h
index eac011366dc2..68779b048a3e 100644
--- a/include/asm-x86/time.h
+++ b/include/asm-x86/time.h
@@ -1,8 +1,12 @@
1#ifndef _ASMi386_TIME_H 1#ifndef _ASMX86_TIME_H
2#define _ASMi386_TIME_H 2#define _ASMX86_TIME_H
3 3
4extern void (*late_time_init)(void);
5extern void hpet_time_init(void);
6
7#include <asm/mc146818rtc.h>
8#ifdef CONFIG_X86_32
4#include <linux/efi.h> 9#include <linux/efi.h>
5#include "mach_time.h"
6 10
7static inline unsigned long native_get_wallclock(void) 11static inline unsigned long native_get_wallclock(void)
8{ 12{
@@ -28,8 +32,20 @@ static inline int native_set_wallclock(unsigned long nowtime)
28 return retval; 32 return retval;
29} 33}
30 34
31extern void (*late_time_init)(void); 35#else
32extern void hpet_time_init(void); 36extern void native_time_init_hook(void);
37
38static inline unsigned long native_get_wallclock(void)
39{
40 return mach_get_cmos_time();
41}
42
43static inline int native_set_wallclock(unsigned long nowtime)
44{
45 return mach_set_rtc_mmss(nowtime);
46}
47
48#endif
33 49
34#ifdef CONFIG_PARAVIRT 50#ifdef CONFIG_PARAVIRT
35#include <asm/paravirt.h> 51#include <asm/paravirt.h>
diff --git a/include/asm-x86/timer.h b/include/asm-x86/timer.h
index 0db7e994fb8b..4f6fcb050c11 100644
--- a/include/asm-x86/timer.h
+++ b/include/asm-x86/timer.h
@@ -2,6 +2,7 @@
2#define _ASMi386_TIMER_H 2#define _ASMi386_TIMER_H
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/pm.h> 4#include <linux/pm.h>
5#include <linux/percpu.h>
5 6
6#define TICK_SIZE (tick_nsec / 1000) 7#define TICK_SIZE (tick_nsec / 1000)
7 8
@@ -16,7 +17,7 @@ extern int recalibrate_cpu_khz(void);
16#define calculate_cpu_khz() native_calculate_cpu_khz() 17#define calculate_cpu_khz() native_calculate_cpu_khz()
17#endif 18#endif
18 19
19/* Accellerators for sched_clock() 20/* Accelerators for sched_clock()
20 * convert from cycles(64bits) => nanoseconds (64bits) 21 * convert from cycles(64bits) => nanoseconds (64bits)
21 * basic equation: 22 * basic equation:
22 * ns = cycles / (freq / ns_per_sec) 23 * ns = cycles / (freq / ns_per_sec)
@@ -31,20 +32,32 @@ extern int recalibrate_cpu_khz(void);
31 * And since SC is a constant power of two, we can convert the div 32 * And since SC is a constant power of two, we can convert the div
32 * into a shift. 33 * into a shift.
33 * 34 *
34 * We can use khz divisor instead of mhz to keep a better percision, since 35 * We can use khz divisor instead of mhz to keep a better precision, since
35 * cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits. 36 * cyc2ns_scale is limited to 10^6 * 2^10, which fits in 32 bits.
36 * (mathieu.desnoyers@polymtl.ca) 37 * (mathieu.desnoyers@polymtl.ca)
37 * 38 *
38 * -johnstul@us.ibm.com "math is hard, lets go shopping!" 39 * -johnstul@us.ibm.com "math is hard, lets go shopping!"
39 */ 40 */
40extern unsigned long cyc2ns_scale __read_mostly; 41
42DECLARE_PER_CPU(unsigned long, cyc2ns);
41 43
42#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */ 44#define CYC2NS_SCALE_FACTOR 10 /* 2^10, carefully chosen */
43 45
44static inline unsigned long long cycles_2_ns(unsigned long long cyc) 46static inline unsigned long long __cycles_2_ns(unsigned long long cyc)
45{ 47{
46 return (cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR; 48 return cyc * per_cpu(cyc2ns, smp_processor_id()) >> CYC2NS_SCALE_FACTOR;
47} 49}
48 50
51static inline unsigned long long cycles_2_ns(unsigned long long cyc)
52{
53 unsigned long long ns;
54 unsigned long flags;
55
56 local_irq_save(flags);
57 ns = __cycles_2_ns(cyc);
58 local_irq_restore(flags);
59
60 return ns;
61}
49 62
50#endif 63#endif
diff --git a/include/asm-x86/timex.h b/include/asm-x86/timex.h
index 39a21ab030f0..27cfd6c599ba 100644
--- a/include/asm-x86/timex.h
+++ b/include/asm-x86/timex.h
@@ -7,6 +7,8 @@
7 7
8#ifdef CONFIG_X86_ELAN 8#ifdef CONFIG_X86_ELAN
9# define PIT_TICK_RATE 1189200 /* AMD Elan has different frequency! */ 9# define PIT_TICK_RATE 1189200 /* AMD Elan has different frequency! */
10#elif defined(CONFIG_X86_RDC321X)
11# define PIT_TICK_RATE 1041667 /* Underlying HZ for R8610 */
10#else 12#else
11# define PIT_TICK_RATE 1193182 /* Underlying HZ */ 13# define PIT_TICK_RATE 1193182 /* Underlying HZ */
12#endif 14#endif
diff --git a/include/asm-x86/tlbflush.h b/include/asm-x86/tlbflush.h
index 9af4cc83a1af..3998709ed637 100644
--- a/include/asm-x86/tlbflush.h
+++ b/include/asm-x86/tlbflush.h
@@ -1,5 +1,158 @@
1#ifndef _ASM_X86_TLBFLUSH_H
2#define _ASM_X86_TLBFLUSH_H
3
4#include <linux/mm.h>
5#include <linux/sched.h>
6
7#include <asm/processor.h>
8#include <asm/system.h>
9
10#ifdef CONFIG_PARAVIRT
11#include <asm/paravirt.h>
12#else
13#define __flush_tlb() __native_flush_tlb()
14#define __flush_tlb_global() __native_flush_tlb_global()
15#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
16#endif
17
18static inline void __native_flush_tlb(void)
19{
20 write_cr3(read_cr3());
21}
22
23static inline void __native_flush_tlb_global(void)
24{
25 unsigned long cr4 = read_cr4();
26
27 /* clear PGE */
28 write_cr4(cr4 & ~X86_CR4_PGE);
29 /* write old PGE again and flush TLBs */
30 write_cr4(cr4);
31}
32
33static inline void __native_flush_tlb_single(unsigned long addr)
34{
35 __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory");
36}
37
38static inline void __flush_tlb_all(void)
39{
40 if (cpu_has_pge)
41 __flush_tlb_global();
42 else
43 __flush_tlb();
44}
45
46static inline void __flush_tlb_one(unsigned long addr)
47{
48 if (cpu_has_invlpg)
49 __flush_tlb_single(addr);
50 else
51 __flush_tlb();
52}
53
1#ifdef CONFIG_X86_32 54#ifdef CONFIG_X86_32
2# include "tlbflush_32.h" 55# define TLB_FLUSH_ALL 0xffffffff
3#else 56#else
4# include "tlbflush_64.h" 57# define TLB_FLUSH_ALL -1ULL
58#endif
59
60/*
61 * TLB flushing:
62 *
63 * - flush_tlb() flushes the current mm struct TLBs
64 * - flush_tlb_all() flushes all processes TLBs
65 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
66 * - flush_tlb_page(vma, vmaddr) flushes one page
67 * - flush_tlb_range(vma, start, end) flushes a range of pages
68 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
69 * - flush_tlb_others(cpumask, mm, va) flushes TLBs on other cpus
70 *
71 * ..but the i386 has somewhat limited tlb flushing capabilities,
72 * and page-granular flushes are available only on i486 and up.
73 *
74 * x86-64 can only flush individual pages or full VMs. For a range flush
75 * we always do the full VM. Might be worth trying if for a small
76 * range a few INVLPGs in a row are a win.
77 */
78
79#ifndef CONFIG_SMP
80
81#define flush_tlb() __flush_tlb()
82#define flush_tlb_all() __flush_tlb_all()
83#define local_flush_tlb() __flush_tlb()
84
85static inline void flush_tlb_mm(struct mm_struct *mm)
86{
87 if (mm == current->active_mm)
88 __flush_tlb();
89}
90
91static inline void flush_tlb_page(struct vm_area_struct *vma,
92 unsigned long addr)
93{
94 if (vma->vm_mm == current->active_mm)
95 __flush_tlb_one(addr);
96}
97
98static inline void flush_tlb_range(struct vm_area_struct *vma,
99 unsigned long start, unsigned long end)
100{
101 if (vma->vm_mm == current->active_mm)
102 __flush_tlb();
103}
104
105static inline void native_flush_tlb_others(const cpumask_t *cpumask,
106 struct mm_struct *mm,
107 unsigned long va)
108{
109}
110
111#else /* SMP */
112
113#include <asm/smp.h>
114
115#define local_flush_tlb() __flush_tlb()
116
117extern void flush_tlb_all(void);
118extern void flush_tlb_current_task(void);
119extern void flush_tlb_mm(struct mm_struct *);
120extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
121
122#define flush_tlb() flush_tlb_current_task()
123
124static inline void flush_tlb_range(struct vm_area_struct *vma,
125 unsigned long start, unsigned long end)
126{
127 flush_tlb_mm(vma->vm_mm);
128}
129
130void native_flush_tlb_others(const cpumask_t *cpumask, struct mm_struct *mm,
131 unsigned long va);
132
133#define TLBSTATE_OK 1
134#define TLBSTATE_LAZY 2
135
136#ifdef CONFIG_X86_32
137struct tlb_state
138{
139 struct mm_struct *active_mm;
140 int state;
141 char __cacheline_padding[L1_CACHE_BYTES-8];
142};
143DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate);
144#endif
145
146#endif /* SMP */
147
148#ifndef CONFIG_PARAVIRT
149#define flush_tlb_others(mask, mm, va) native_flush_tlb_others(&mask, mm, va)
5#endif 150#endif
151
152static inline void flush_tlb_kernel_range(unsigned long start,
153 unsigned long end)
154{
155 flush_tlb_all();
156}
157
158#endif /* _ASM_X86_TLBFLUSH_H */
diff --git a/include/asm-x86/tlbflush_32.h b/include/asm-x86/tlbflush_32.h
deleted file mode 100644
index 2bd5b95e2048..000000000000
--- a/include/asm-x86/tlbflush_32.h
+++ /dev/null
@@ -1,168 +0,0 @@
1#ifndef _I386_TLBFLUSH_H
2#define _I386_TLBFLUSH_H
3
4#include <linux/mm.h>
5#include <asm/processor.h>
6
7#ifdef CONFIG_PARAVIRT
8#include <asm/paravirt.h>
9#else
10#define __flush_tlb() __native_flush_tlb()
11#define __flush_tlb_global() __native_flush_tlb_global()
12#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
13#endif
14
15#define __native_flush_tlb() \
16 do { \
17 unsigned int tmpreg; \
18 \
19 __asm__ __volatile__( \
20 "movl %%cr3, %0; \n" \
21 "movl %0, %%cr3; # flush TLB \n" \
22 : "=r" (tmpreg) \
23 :: "memory"); \
24 } while (0)
25
26/*
27 * Global pages have to be flushed a bit differently. Not a real
28 * performance problem because this does not happen often.
29 */
30#define __native_flush_tlb_global() \
31 do { \
32 unsigned int tmpreg, cr4, cr4_orig; \
33 \
34 __asm__ __volatile__( \
35 "movl %%cr4, %2; # turn off PGE \n" \
36 "movl %2, %1; \n" \
37 "andl %3, %1; \n" \
38 "movl %1, %%cr4; \n" \
39 "movl %%cr3, %0; \n" \
40 "movl %0, %%cr3; # flush TLB \n" \
41 "movl %2, %%cr4; # turn PGE back on \n" \
42 : "=&r" (tmpreg), "=&r" (cr4), "=&r" (cr4_orig) \
43 : "i" (~X86_CR4_PGE) \
44 : "memory"); \
45 } while (0)
46
47#define __native_flush_tlb_single(addr) \
48 __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
49
50# define __flush_tlb_all() \
51 do { \
52 if (cpu_has_pge) \
53 __flush_tlb_global(); \
54 else \
55 __flush_tlb(); \
56 } while (0)
57
58#define cpu_has_invlpg (boot_cpu_data.x86 > 3)
59
60#ifdef CONFIG_X86_INVLPG
61# define __flush_tlb_one(addr) __flush_tlb_single(addr)
62#else
63# define __flush_tlb_one(addr) \
64 do { \
65 if (cpu_has_invlpg) \
66 __flush_tlb_single(addr); \
67 else \
68 __flush_tlb(); \
69 } while (0)
70#endif
71
72/*
73 * TLB flushing:
74 *
75 * - flush_tlb() flushes the current mm struct TLBs
76 * - flush_tlb_all() flushes all processes TLBs
77 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
78 * - flush_tlb_page(vma, vmaddr) flushes one page
79 * - flush_tlb_range(vma, start, end) flushes a range of pages
80 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
81 * - flush_tlb_others(cpumask, mm, va) flushes a TLBs on other cpus
82 *
83 * ..but the i386 has somewhat limited tlb flushing capabilities,
84 * and page-granular flushes are available only on i486 and up.
85 */
86
87#define TLB_FLUSH_ALL 0xffffffff
88
89
90#ifndef CONFIG_SMP
91
92#include <linux/sched.h>
93
94#define flush_tlb() __flush_tlb()
95#define flush_tlb_all() __flush_tlb_all()
96#define local_flush_tlb() __flush_tlb()
97
98static inline void flush_tlb_mm(struct mm_struct *mm)
99{
100 if (mm == current->active_mm)
101 __flush_tlb();
102}
103
104static inline void flush_tlb_page(struct vm_area_struct *vma,
105 unsigned long addr)
106{
107 if (vma->vm_mm == current->active_mm)
108 __flush_tlb_one(addr);
109}
110
111static inline void flush_tlb_range(struct vm_area_struct *vma,
112 unsigned long start, unsigned long end)
113{
114 if (vma->vm_mm == current->active_mm)
115 __flush_tlb();
116}
117
118static inline void native_flush_tlb_others(const cpumask_t *cpumask,
119 struct mm_struct *mm, unsigned long va)
120{
121}
122
123#else /* SMP */
124
125#include <asm/smp.h>
126
127#define local_flush_tlb() \
128 __flush_tlb()
129
130extern void flush_tlb_all(void);
131extern void flush_tlb_current_task(void);
132extern void flush_tlb_mm(struct mm_struct *);
133extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
134
135#define flush_tlb() flush_tlb_current_task()
136
137static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
138{
139 flush_tlb_mm(vma->vm_mm);
140}
141
142void native_flush_tlb_others(const cpumask_t *cpumask, struct mm_struct *mm,
143 unsigned long va);
144
145#define TLBSTATE_OK 1
146#define TLBSTATE_LAZY 2
147
148struct tlb_state
149{
150 struct mm_struct *active_mm;
151 int state;
152 char __cacheline_padding[L1_CACHE_BYTES-8];
153};
154DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate);
155#endif /* SMP */
156
157#ifndef CONFIG_PARAVIRT
158#define flush_tlb_others(mask, mm, va) \
159 native_flush_tlb_others(&mask, mm, va)
160#endif
161
162static inline void flush_tlb_kernel_range(unsigned long start,
163 unsigned long end)
164{
165 flush_tlb_all();
166}
167
168#endif /* _I386_TLBFLUSH_H */
diff --git a/include/asm-x86/tlbflush_64.h b/include/asm-x86/tlbflush_64.h
deleted file mode 100644
index 7731fd23d572..000000000000
--- a/include/asm-x86/tlbflush_64.h
+++ /dev/null
@@ -1,100 +0,0 @@
1#ifndef _X8664_TLBFLUSH_H
2#define _X8664_TLBFLUSH_H
3
4#include <linux/mm.h>
5#include <linux/sched.h>
6#include <asm/processor.h>
7#include <asm/system.h>
8
9static inline void __flush_tlb(void)
10{
11 write_cr3(read_cr3());
12}
13
14static inline void __flush_tlb_all(void)
15{
16 unsigned long cr4 = read_cr4();
17 write_cr4(cr4 & ~X86_CR4_PGE); /* clear PGE */
18 write_cr4(cr4); /* write old PGE again and flush TLBs */
19}
20
21#define __flush_tlb_one(addr) \
22 __asm__ __volatile__("invlpg (%0)" :: "r" (addr) : "memory")
23
24
25/*
26 * TLB flushing:
27 *
28 * - flush_tlb() flushes the current mm struct TLBs
29 * - flush_tlb_all() flushes all processes TLBs
30 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
31 * - flush_tlb_page(vma, vmaddr) flushes one page
32 * - flush_tlb_range(vma, start, end) flushes a range of pages
33 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
34 *
35 * x86-64 can only flush individual pages or full VMs. For a range flush
36 * we always do the full VM. Might be worth trying if for a small
37 * range a few INVLPGs in a row are a win.
38 */
39
40#ifndef CONFIG_SMP
41
42#define flush_tlb() __flush_tlb()
43#define flush_tlb_all() __flush_tlb_all()
44#define local_flush_tlb() __flush_tlb()
45
46static inline void flush_tlb_mm(struct mm_struct *mm)
47{
48 if (mm == current->active_mm)
49 __flush_tlb();
50}
51
52static inline void flush_tlb_page(struct vm_area_struct *vma,
53 unsigned long addr)
54{
55 if (vma->vm_mm == current->active_mm)
56 __flush_tlb_one(addr);
57}
58
59static inline void flush_tlb_range(struct vm_area_struct *vma,
60 unsigned long start, unsigned long end)
61{
62 if (vma->vm_mm == current->active_mm)
63 __flush_tlb();
64}
65
66#else
67
68#include <asm/smp.h>
69
70#define local_flush_tlb() \
71 __flush_tlb()
72
73extern void flush_tlb_all(void);
74extern void flush_tlb_current_task(void);
75extern void flush_tlb_mm(struct mm_struct *);
76extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
77
78#define flush_tlb() flush_tlb_current_task()
79
80static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long start, unsigned long end)
81{
82 flush_tlb_mm(vma->vm_mm);
83}
84
85#define TLBSTATE_OK 1
86#define TLBSTATE_LAZY 2
87
88/* Roughly an IPI every 20MB with 4k pages for freeing page table
89 ranges. Cost is about 42k of memory for each CPU. */
90#define ARCH_FREE_PTE_NR 5350
91
92#endif
93
94static inline void flush_tlb_kernel_range(unsigned long start,
95 unsigned long end)
96{
97 flush_tlb_all();
98}
99
100#endif /* _X8664_TLBFLUSH_H */
diff --git a/include/asm-x86/topology.h b/include/asm-x86/topology.h
index b10fde9798ea..8af05a93f097 100644
--- a/include/asm-x86/topology.h
+++ b/include/asm-x86/topology.h
@@ -1,5 +1,188 @@
1/*
2 * Written by: Matthew Dobson, IBM Corporation
3 *
4 * Copyright (C) 2002, IBM Corp.
5 *
6 * All rights reserved.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
16 * NON INFRINGEMENT. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 * Send feedback to <colpatch@us.ibm.com>
24 */
25#ifndef _ASM_X86_TOPOLOGY_H
26#define _ASM_X86_TOPOLOGY_H
27
28#ifdef CONFIG_NUMA
29#include <linux/cpumask.h>
30#include <asm/mpspec.h>
31
32/* Mappings between logical cpu number and node number */
1#ifdef CONFIG_X86_32 33#ifdef CONFIG_X86_32
2# include "topology_32.h" 34extern int cpu_to_node_map[];
35
3#else 36#else
4# include "topology_64.h" 37DECLARE_PER_CPU(int, x86_cpu_to_node_map);
38extern int x86_cpu_to_node_map_init[];
39extern void *x86_cpu_to_node_map_early_ptr;
40/* Returns the number of the current Node. */
41#define numa_node_id() (early_cpu_to_node(raw_smp_processor_id()))
42#endif
43
44extern cpumask_t node_to_cpumask_map[];
45
46#define NUMA_NO_NODE (-1)
47
48/* Returns the number of the node containing CPU 'cpu' */
49#ifdef CONFIG_X86_32
50#define early_cpu_to_node(cpu) cpu_to_node(cpu)
51static inline int cpu_to_node(int cpu)
52{
53 return cpu_to_node_map[cpu];
54}
55
56#else /* CONFIG_X86_64 */
57static inline int early_cpu_to_node(int cpu)
58{
59 int *cpu_to_node_map = x86_cpu_to_node_map_early_ptr;
60
61 if (cpu_to_node_map)
62 return cpu_to_node_map[cpu];
63 else if (per_cpu_offset(cpu))
64 return per_cpu(x86_cpu_to_node_map, cpu);
65 else
66 return NUMA_NO_NODE;
67}
68
69static inline int cpu_to_node(int cpu)
70{
71#ifdef CONFIG_DEBUG_PER_CPU_MAPS
72 if (x86_cpu_to_node_map_early_ptr) {
73 printk("KERN_NOTICE cpu_to_node(%d): usage too early!\n",
74 (int)cpu);
75 dump_stack();
76 return ((int *)x86_cpu_to_node_map_early_ptr)[cpu];
77 }
78#endif
79 if (per_cpu_offset(cpu))
80 return per_cpu(x86_cpu_to_node_map, cpu);
81 else
82 return NUMA_NO_NODE;
83}
84#endif /* CONFIG_X86_64 */
85
86/*
87 * Returns the number of the node containing Node 'node'. This
88 * architecture is flat, so it is a pretty simple function!
89 */
90#define parent_node(node) (node)
91
92/* Returns a bitmask of CPUs on Node 'node'. */
93static inline cpumask_t node_to_cpumask(int node)
94{
95 return node_to_cpumask_map[node];
96}
97
98/* Returns the number of the first CPU on Node 'node'. */
99static inline int node_to_first_cpu(int node)
100{
101 cpumask_t mask = node_to_cpumask(node);
102
103 return first_cpu(mask);
104}
105
106#define pcibus_to_node(bus) __pcibus_to_node(bus)
107#define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus)
108
109#ifdef CONFIG_X86_32
110extern unsigned long node_start_pfn[];
111extern unsigned long node_end_pfn[];
112extern unsigned long node_remap_size[];
113#define node_has_online_mem(nid) (node_start_pfn[nid] != node_end_pfn[nid])
114
115# ifdef CONFIG_X86_HT
116# define ENABLE_TOPO_DEFINES
117# endif
118
119# define SD_CACHE_NICE_TRIES 1
120# define SD_IDLE_IDX 1
121# define SD_NEWIDLE_IDX 2
122# define SD_FORKEXEC_IDX 0
123
124#else
125
126# ifdef CONFIG_SMP
127# define ENABLE_TOPO_DEFINES
128# endif
129
130# define SD_CACHE_NICE_TRIES 2
131# define SD_IDLE_IDX 2
132# define SD_NEWIDLE_IDX 0
133# define SD_FORKEXEC_IDX 1
134
135#endif
136
137/* sched_domains SD_NODE_INIT for NUMAQ machines */
138#define SD_NODE_INIT (struct sched_domain) { \
139 .span = CPU_MASK_NONE, \
140 .parent = NULL, \
141 .child = NULL, \
142 .groups = NULL, \
143 .min_interval = 8, \
144 .max_interval = 32, \
145 .busy_factor = 32, \
146 .imbalance_pct = 125, \
147 .cache_nice_tries = SD_CACHE_NICE_TRIES, \
148 .busy_idx = 3, \
149 .idle_idx = SD_IDLE_IDX, \
150 .newidle_idx = SD_NEWIDLE_IDX, \
151 .wake_idx = 1, \
152 .forkexec_idx = SD_FORKEXEC_IDX, \
153 .flags = SD_LOAD_BALANCE \
154 | SD_BALANCE_EXEC \
155 | SD_BALANCE_FORK \
156 | SD_SERIALIZE \
157 | SD_WAKE_BALANCE, \
158 .last_balance = jiffies, \
159 .balance_interval = 1, \
160 .nr_balance_failed = 0, \
161}
162
163#ifdef CONFIG_X86_64_ACPI_NUMA
164extern int __node_distance(int, int);
165#define node_distance(a, b) __node_distance(a, b)
166#endif
167
168#else /* CONFIG_NUMA */
169
170#include <asm-generic/topology.h>
171
172#endif
173
174extern cpumask_t cpu_coregroup_map(int cpu);
175
176#ifdef ENABLE_TOPO_DEFINES
177#define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id)
178#define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id)
179#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
180#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
181#endif
182
183#ifdef CONFIG_SMP
184#define mc_capable() (boot_cpu_data.x86_max_cores > 1)
185#define smt_capable() (smp_num_siblings > 1)
186#endif
187
5#endif 188#endif
diff --git a/include/asm-x86/topology_32.h b/include/asm-x86/topology_32.h
deleted file mode 100644
index 9040f5a61278..000000000000
--- a/include/asm-x86/topology_32.h
+++ /dev/null
@@ -1,121 +0,0 @@
1/*
2 * linux/include/asm-i386/topology.h
3 *
4 * Written by: Matthew Dobson, IBM Corporation
5 *
6 * Copyright (C) 2002, IBM Corp.
7 *
8 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * Send feedback to <colpatch@us.ibm.com>
26 */
27#ifndef _ASM_I386_TOPOLOGY_H
28#define _ASM_I386_TOPOLOGY_H
29
30#ifdef CONFIG_X86_HT
31#define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id)
32#define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id)
33#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
34#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
35#endif
36
37#ifdef CONFIG_NUMA
38
39#include <asm/mpspec.h>
40
41#include <linux/cpumask.h>
42
43/* Mappings between logical cpu number and node number */
44extern cpumask_t node_2_cpu_mask[];
45extern int cpu_2_node[];
46
47/* Returns the number of the node containing CPU 'cpu' */
48static inline int cpu_to_node(int cpu)
49{
50 return cpu_2_node[cpu];
51}
52
53/* Returns the number of the node containing Node 'node'. This architecture is flat,
54 so it is a pretty simple function! */
55#define parent_node(node) (node)
56
57/* Returns a bitmask of CPUs on Node 'node'. */
58static inline cpumask_t node_to_cpumask(int node)
59{
60 return node_2_cpu_mask[node];
61}
62
63/* Returns the number of the first CPU on Node 'node'. */
64static inline int node_to_first_cpu(int node)
65{
66 cpumask_t mask = node_to_cpumask(node);
67 return first_cpu(mask);
68}
69
70#define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node
71#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus))
72
73/* sched_domains SD_NODE_INIT for NUMAQ machines */
74#define SD_NODE_INIT (struct sched_domain) { \
75 .span = CPU_MASK_NONE, \
76 .parent = NULL, \
77 .child = NULL, \
78 .groups = NULL, \
79 .min_interval = 8, \
80 .max_interval = 32, \
81 .busy_factor = 32, \
82 .imbalance_pct = 125, \
83 .cache_nice_tries = 1, \
84 .busy_idx = 3, \
85 .idle_idx = 1, \
86 .newidle_idx = 2, \
87 .wake_idx = 1, \
88 .flags = SD_LOAD_BALANCE \
89 | SD_BALANCE_EXEC \
90 | SD_BALANCE_FORK \
91 | SD_SERIALIZE \
92 | SD_WAKE_BALANCE, \
93 .last_balance = jiffies, \
94 .balance_interval = 1, \
95 .nr_balance_failed = 0, \
96}
97
98extern unsigned long node_start_pfn[];
99extern unsigned long node_end_pfn[];
100extern unsigned long node_remap_size[];
101
102#define node_has_online_mem(nid) (node_start_pfn[nid] != node_end_pfn[nid])
103
104#else /* !CONFIG_NUMA */
105/*
106 * Other i386 platforms should define their own version of the
107 * above macros here.
108 */
109
110#include <asm-generic/topology.h>
111
112#endif /* CONFIG_NUMA */
113
114extern cpumask_t cpu_coregroup_map(int cpu);
115
116#ifdef CONFIG_SMP
117#define mc_capable() (boot_cpu_data.x86_max_cores > 1)
118#define smt_capable() (smp_num_siblings > 1)
119#endif
120
121#endif /* _ASM_I386_TOPOLOGY_H */
diff --git a/include/asm-x86/topology_64.h b/include/asm-x86/topology_64.h
deleted file mode 100644
index a718dda037e0..000000000000
--- a/include/asm-x86/topology_64.h
+++ /dev/null
@@ -1,71 +0,0 @@
1#ifndef _ASM_X86_64_TOPOLOGY_H
2#define _ASM_X86_64_TOPOLOGY_H
3
4
5#ifdef CONFIG_NUMA
6
7#include <asm/mpspec.h>
8#include <linux/bitops.h>
9
10extern cpumask_t cpu_online_map;
11
12extern unsigned char cpu_to_node[];
13extern cpumask_t node_to_cpumask[];
14
15#ifdef CONFIG_ACPI_NUMA
16extern int __node_distance(int, int);
17#define node_distance(a,b) __node_distance(a,b)
18/* #else fallback version */
19#endif
20
21#define cpu_to_node(cpu) (cpu_to_node[cpu])
22#define parent_node(node) (node)
23#define node_to_first_cpu(node) (first_cpu(node_to_cpumask[node]))
24#define node_to_cpumask(node) (node_to_cpumask[node])
25#define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node
26#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus));
27
28#define numa_node_id() read_pda(nodenumber)
29
30/* sched_domains SD_NODE_INIT for x86_64 machines */
31#define SD_NODE_INIT (struct sched_domain) { \
32 .span = CPU_MASK_NONE, \
33 .parent = NULL, \
34 .child = NULL, \
35 .groups = NULL, \
36 .min_interval = 8, \
37 .max_interval = 32, \
38 .busy_factor = 32, \
39 .imbalance_pct = 125, \
40 .cache_nice_tries = 2, \
41 .busy_idx = 3, \
42 .idle_idx = 2, \
43 .newidle_idx = 0, \
44 .wake_idx = 1, \
45 .forkexec_idx = 1, \
46 .flags = SD_LOAD_BALANCE \
47 | SD_BALANCE_FORK \
48 | SD_BALANCE_EXEC \
49 | SD_SERIALIZE \
50 | SD_WAKE_BALANCE, \
51 .last_balance = jiffies, \
52 .balance_interval = 1, \
53 .nr_balance_failed = 0, \
54}
55
56#endif
57
58#ifdef CONFIG_SMP
59#define topology_physical_package_id(cpu) (cpu_data(cpu).phys_proc_id)
60#define topology_core_id(cpu) (cpu_data(cpu).cpu_core_id)
61#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
62#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
63#define mc_capable() (boot_cpu_data.x86_max_cores > 1)
64#define smt_capable() (smp_num_siblings > 1)
65#endif
66
67#include <asm-generic/topology.h>
68
69extern cpumask_t cpu_coregroup_map(int cpu);
70
71#endif
diff --git a/include/asm-x86/tsc.h b/include/asm-x86/tsc.h
index 6baab30dc2c8..7d3e27f7d484 100644
--- a/include/asm-x86/tsc.h
+++ b/include/asm-x86/tsc.h
@@ -17,6 +17,8 @@ typedef unsigned long long cycles_t;
17extern unsigned int cpu_khz; 17extern unsigned int cpu_khz;
18extern unsigned int tsc_khz; 18extern unsigned int tsc_khz;
19 19
20extern void disable_TSC(void);
21
20static inline cycles_t get_cycles(void) 22static inline cycles_t get_cycles(void)
21{ 23{
22 unsigned long long ret = 0; 24 unsigned long long ret = 0;
@@ -25,39 +27,22 @@ static inline cycles_t get_cycles(void)
25 if (!cpu_has_tsc) 27 if (!cpu_has_tsc)
26 return 0; 28 return 0;
27#endif 29#endif
28
29#if defined(CONFIG_X86_GENERIC) || defined(CONFIG_X86_TSC)
30 rdtscll(ret); 30 rdtscll(ret);
31#endif 31
32 return ret; 32 return ret;
33} 33}
34 34
35/* Like get_cycles, but make sure the CPU is synchronized. */ 35static inline cycles_t vget_cycles(void)
36static __always_inline cycles_t get_cycles_sync(void)
37{ 36{
38 unsigned long long ret;
39 unsigned eax, edx;
40
41 /*
42 * Use RDTSCP if possible; it is guaranteed to be synchronous
43 * and doesn't cause a VMEXIT on Hypervisors
44 */
45 alternative_io(ASM_NOP3, ".byte 0x0f,0x01,0xf9", X86_FEATURE_RDTSCP,
46 ASM_OUTPUT2("=a" (eax), "=d" (edx)),
47 "a" (0U), "d" (0U) : "ecx", "memory");
48 ret = (((unsigned long long)edx) << 32) | ((unsigned long long)eax);
49 if (ret)
50 return ret;
51
52 /* 37 /*
53 * Don't do an additional sync on CPUs where we know 38 * We only do VDSOs on TSC capable CPUs, so this shouldnt
54 * RDTSC is already synchronous: 39 * access boot_cpu_data (which is not VDSO-safe):
55 */ 40 */
56 alternative_io("cpuid", ASM_NOP2, X86_FEATURE_SYNC_RDTSC, 41#ifndef CONFIG_X86_TSC
57 "=a" (eax), "0" (1) : "ebx","ecx","edx","memory"); 42 if (!cpu_has_tsc)
58 rdtscll(ret); 43 return 0;
59 44#endif
60 return ret; 45 return (cycles_t) __native_read_tsc();
61} 46}
62 47
63extern void tsc_init(void); 48extern void tsc_init(void);
@@ -73,8 +58,7 @@ int check_tsc_unstable(void);
73extern void check_tsc_sync_source(int cpu); 58extern void check_tsc_sync_source(int cpu);
74extern void check_tsc_sync_target(void); 59extern void check_tsc_sync_target(void);
75 60
76#ifdef CONFIG_X86_64
77extern void tsc_calibrate(void); 61extern void tsc_calibrate(void);
78#endif 62extern int notsc_setup(char *);
79 63
80#endif 64#endif
diff --git a/include/asm-x86/uaccess_64.h b/include/asm-x86/uaccess_64.h
index f4ce8768ad44..31d794702719 100644
--- a/include/asm-x86/uaccess_64.h
+++ b/include/asm-x86/uaccess_64.h
@@ -65,6 +65,8 @@ struct exception_table_entry
65 unsigned long insn, fixup; 65 unsigned long insn, fixup;
66}; 66};
67 67
68extern int fixup_exception(struct pt_regs *regs);
69
68#define ARCH_HAS_SEARCH_EXTABLE 70#define ARCH_HAS_SEARCH_EXTABLE
69 71
70/* 72/*
diff --git a/include/asm-x86/unistd_32.h b/include/asm-x86/unistd_32.h
index 9b15545eb9b5..8d8f9b5adbb9 100644
--- a/include/asm-x86/unistd_32.h
+++ b/include/asm-x86/unistd_32.h
@@ -333,8 +333,6 @@
333 333
334#ifdef __KERNEL__ 334#ifdef __KERNEL__
335 335
336#define NR_syscalls 325
337
338#define __ARCH_WANT_IPC_PARSE_VERSION 336#define __ARCH_WANT_IPC_PARSE_VERSION
339#define __ARCH_WANT_OLD_READDIR 337#define __ARCH_WANT_OLD_READDIR
340#define __ARCH_WANT_OLD_STAT 338#define __ARCH_WANT_OLD_STAT
diff --git a/include/asm-x86/user_32.h b/include/asm-x86/user_32.h
index 0e85d2a5e33a..ed8b8fc6906c 100644
--- a/include/asm-x86/user_32.h
+++ b/include/asm-x86/user_32.h
@@ -75,13 +75,23 @@ struct user_fxsr_struct {
75 * doesn't use the extra segment registers) 75 * doesn't use the extra segment registers)
76 */ 76 */
77struct user_regs_struct { 77struct user_regs_struct {
78 long ebx, ecx, edx, esi, edi, ebp, eax; 78 unsigned long bx;
79 unsigned short ds, __ds, es, __es; 79 unsigned long cx;
80 unsigned short fs, __fs, gs, __gs; 80 unsigned long dx;
81 long orig_eax, eip; 81 unsigned long si;
82 unsigned short cs, __cs; 82 unsigned long di;
83 long eflags, esp; 83 unsigned long bp;
84 unsigned short ss, __ss; 84 unsigned long ax;
85 unsigned long ds;
86 unsigned long es;
87 unsigned long fs;
88 unsigned long gs;
89 unsigned long orig_ax;
90 unsigned long ip;
91 unsigned long cs;
92 unsigned long flags;
93 unsigned long sp;
94 unsigned long ss;
85}; 95};
86 96
87/* When the kernel dumps core, it starts by dumping the user struct - 97/* When the kernel dumps core, it starts by dumping the user struct -
diff --git a/include/asm-x86/user_64.h b/include/asm-x86/user_64.h
index 12785c649ac5..a5449d456cc0 100644
--- a/include/asm-x86/user_64.h
+++ b/include/asm-x86/user_64.h
@@ -40,13 +40,13 @@
40 * and both the standard and SIMD floating point data can be accessed via 40 * and both the standard and SIMD floating point data can be accessed via
41 * the new ptrace requests. In either case, changes to the FPU environment 41 * the new ptrace requests. In either case, changes to the FPU environment
42 * will be reflected in the task's state as expected. 42 * will be reflected in the task's state as expected.
43 * 43 *
44 * x86-64 support by Andi Kleen. 44 * x86-64 support by Andi Kleen.
45 */ 45 */
46 46
47/* This matches the 64bit FXSAVE format as defined by AMD. It is the same 47/* This matches the 64bit FXSAVE format as defined by AMD. It is the same
48 as the 32bit format defined by Intel, except that the selector:offset pairs for 48 as the 32bit format defined by Intel, except that the selector:offset pairs for
49 data and eip are replaced with flat 64bit pointers. */ 49 data and eip are replaced with flat 64bit pointers. */
50struct user_i387_struct { 50struct user_i387_struct {
51 unsigned short cwd; 51 unsigned short cwd;
52 unsigned short swd; 52 unsigned short swd;
@@ -65,13 +65,34 @@ struct user_i387_struct {
65 * Segment register layout in coredumps. 65 * Segment register layout in coredumps.
66 */ 66 */
67struct user_regs_struct { 67struct user_regs_struct {
68 unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10; 68 unsigned long r15;
69 unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax; 69 unsigned long r14;
70 unsigned long rip,cs,eflags; 70 unsigned long r13;
71 unsigned long rsp,ss; 71 unsigned long r12;
72 unsigned long fs_base, gs_base; 72 unsigned long bp;
73 unsigned long ds,es,fs,gs; 73 unsigned long bx;
74}; 74 unsigned long r11;
75 unsigned long r10;
76 unsigned long r9;
77 unsigned long r8;
78 unsigned long ax;
79 unsigned long cx;
80 unsigned long dx;
81 unsigned long si;
82 unsigned long di;
83 unsigned long orig_ax;
84 unsigned long ip;
85 unsigned long cs;
86 unsigned long flags;
87 unsigned long sp;
88 unsigned long ss;
89 unsigned long fs_base;
90 unsigned long gs_base;
91 unsigned long ds;
92 unsigned long es;
93 unsigned long fs;
94 unsigned long gs;
95};
75 96
76/* When the kernel dumps core, it starts by dumping the user struct - 97/* When the kernel dumps core, it starts by dumping the user struct -
77 this will be used by gdb to figure out where the data and stack segments 98 this will be used by gdb to figure out where the data and stack segments
@@ -94,7 +115,7 @@ struct user{
94 This is actually the bottom of the stack, 115 This is actually the bottom of the stack,
95 the top of the stack is always found in the 116 the top of the stack is always found in the
96 esp register. */ 117 esp register. */
97 long int signal; /* Signal that caused the core dump. */ 118 long int signal; /* Signal that caused the core dump. */
98 int reserved; /* No longer used */ 119 int reserved; /* No longer used */
99 int pad1; 120 int pad1;
100 struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */ 121 struct user_pt_regs * u_ar0; /* Used by gdb to help find the values for */
diff --git a/include/asm-x86/vdso.h b/include/asm-x86/vdso.h
new file mode 100644
index 000000000000..629bcb6e8e45
--- /dev/null
+++ b/include/asm-x86/vdso.h
@@ -0,0 +1,28 @@
1#ifndef _ASM_X86_VDSO_H
2#define _ASM_X86_VDSO_H 1
3
4#ifdef CONFIG_X86_64
5extern const char VDSO64_PRELINK[];
6
7/*
8 * Given a pointer to the vDSO image, find the pointer to VDSO64_name
9 * as that symbol is defined in the vDSO sources or linker script.
10 */
11#define VDSO64_SYMBOL(base, name) ({ \
12 extern const char VDSO64_##name[]; \
13 (void *) (VDSO64_##name - VDSO64_PRELINK + (unsigned long) (base)); })
14#endif
15
16#if defined CONFIG_X86_32 || defined CONFIG_COMPAT
17extern const char VDSO32_PRELINK[];
18
19/*
20 * Given a pointer to the vDSO image, find the pointer to VDSO32_name
21 * as that symbol is defined in the vDSO sources or linker script.
22 */
23#define VDSO32_SYMBOL(base, name) ({ \
24 extern const char VDSO32_##name[]; \
25 (void *) (VDSO32_##name - VDSO32_PRELINK + (unsigned long) (base)); })
26#endif
27
28#endif /* asm-x86/vdso.h */
diff --git a/include/asm-x86/vsyscall.h b/include/asm-x86/vsyscall.h
index f01c49f5d108..17b3700949bf 100644
--- a/include/asm-x86/vsyscall.h
+++ b/include/asm-x86/vsyscall.h
@@ -36,6 +36,8 @@ extern volatile unsigned long __jiffies;
36extern int vgetcpu_mode; 36extern int vgetcpu_mode;
37extern struct timezone sys_tz; 37extern struct timezone sys_tz;
38 38
39extern void map_vsyscall(void);
40
39#endif /* __KERNEL__ */ 41#endif /* __KERNEL__ */
40 42
41#endif /* _ASM_X86_64_VSYSCALL_H_ */ 43#endif /* _ASM_X86_64_VSYSCALL_H_ */
diff --git a/include/asm-x86/vsyscall32.h b/include/asm-x86/vsyscall32.h
deleted file mode 100644
index c631c082f8f7..000000000000
--- a/include/asm-x86/vsyscall32.h
+++ /dev/null
@@ -1,20 +0,0 @@
1#ifndef _ASM_VSYSCALL32_H
2#define _ASM_VSYSCALL32_H 1
3
4/* Values need to match arch/x86_64/ia32/vsyscall.lds */
5
6#ifdef __ASSEMBLY__
7#define VSYSCALL32_BASE 0xffffe000
8#define VSYSCALL32_SYSEXIT (VSYSCALL32_BASE + 0x410)
9#else
10#define VSYSCALL32_BASE 0xffffe000UL
11#define VSYSCALL32_END (VSYSCALL32_BASE + PAGE_SIZE)
12#define VSYSCALL32_EHDR ((const struct elf32_hdr *) VSYSCALL32_BASE)
13
14#define VSYSCALL32_VSYSCALL ((void *)VSYSCALL32_BASE + 0x400)
15#define VSYSCALL32_SYSEXIT ((void *)VSYSCALL32_BASE + 0x410)
16#define VSYSCALL32_SIGRETURN ((void __user *)VSYSCALL32_BASE + 0x500)
17#define VSYSCALL32_RTSIGRETURN ((void __user *)VSYSCALL32_BASE + 0x600)
18#endif
19
20#endif
diff --git a/include/asm-x86/xor_32.h b/include/asm-x86/xor_32.h
index 23c86cef3b25..a41ef1bdd424 100644
--- a/include/asm-x86/xor_32.h
+++ b/include/asm-x86/xor_32.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-i386/xor.h
3 *
4 * Optimized RAID-5 checksumming functions for MMX and SSE. 2 * Optimized RAID-5 checksumming functions for MMX and SSE.
5 * 3 *
6 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
diff --git a/include/asm-x86/xor_64.h b/include/asm-x86/xor_64.h
index f942fcc21831..1eee7fcb2420 100644
--- a/include/asm-x86/xor_64.h
+++ b/include/asm-x86/xor_64.h
@@ -1,6 +1,4 @@
1/* 1/*
2 * include/asm-x86_64/xor.h
3 *
4 * Optimized RAID-5 checksumming functions for MMX and SSE. 2 * Optimized RAID-5 checksumming functions for MMX and SSE.
5 * 3 *
6 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
diff --git a/include/asm-xtensa/socket.h b/include/asm-xtensa/socket.h
index 1f5aeacb9da2..6100682b1da2 100644
--- a/include/asm-xtensa/socket.h
+++ b/include/asm-xtensa/socket.h
@@ -63,4 +63,6 @@
63#define SO_TIMESTAMPNS 35 63#define SO_TIMESTAMPNS 35
64#define SCM_TIMESTAMPNS SO_TIMESTAMPNS 64#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
65 65
66#define SO_MARK 36
67
66#endif /* _XTENSA_SOCKET_H */ 68#endif /* _XTENSA_SOCKET_H */
diff --git a/include/crypto/aead.h b/include/crypto/aead.h
new file mode 100644
index 000000000000..0edf949f6369
--- /dev/null
+++ b/include/crypto/aead.h
@@ -0,0 +1,105 @@
1/*
2 * AEAD: Authenticated Encryption with Associated Data
3 *
4 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _CRYPTO_AEAD_H
14#define _CRYPTO_AEAD_H
15
16#include <linux/crypto.h>
17#include <linux/kernel.h>
18#include <linux/slab.h>
19
20/**
21 * struct aead_givcrypt_request - AEAD request with IV generation
22 * @seq: Sequence number for IV generation
23 * @giv: Space for generated IV
24 * @areq: The AEAD request itself
25 */
26struct aead_givcrypt_request {
27 u64 seq;
28 u8 *giv;
29
30 struct aead_request areq;
31};
32
33static inline struct crypto_aead *aead_givcrypt_reqtfm(
34 struct aead_givcrypt_request *req)
35{
36 return crypto_aead_reqtfm(&req->areq);
37}
38
39static inline int crypto_aead_givencrypt(struct aead_givcrypt_request *req)
40{
41 struct aead_tfm *crt = crypto_aead_crt(aead_givcrypt_reqtfm(req));
42 return crt->givencrypt(req);
43};
44
45static inline int crypto_aead_givdecrypt(struct aead_givcrypt_request *req)
46{
47 struct aead_tfm *crt = crypto_aead_crt(aead_givcrypt_reqtfm(req));
48 return crt->givdecrypt(req);
49};
50
51static inline void aead_givcrypt_set_tfm(struct aead_givcrypt_request *req,
52 struct crypto_aead *tfm)
53{
54 req->areq.base.tfm = crypto_aead_tfm(tfm);
55}
56
57static inline struct aead_givcrypt_request *aead_givcrypt_alloc(
58 struct crypto_aead *tfm, gfp_t gfp)
59{
60 struct aead_givcrypt_request *req;
61
62 req = kmalloc(sizeof(struct aead_givcrypt_request) +
63 crypto_aead_reqsize(tfm), gfp);
64
65 if (likely(req))
66 aead_givcrypt_set_tfm(req, tfm);
67
68 return req;
69}
70
71static inline void aead_givcrypt_free(struct aead_givcrypt_request *req)
72{
73 kfree(req);
74}
75
76static inline void aead_givcrypt_set_callback(
77 struct aead_givcrypt_request *req, u32 flags,
78 crypto_completion_t complete, void *data)
79{
80 aead_request_set_callback(&req->areq, flags, complete, data);
81}
82
83static inline void aead_givcrypt_set_crypt(struct aead_givcrypt_request *req,
84 struct scatterlist *src,
85 struct scatterlist *dst,
86 unsigned int nbytes, void *iv)
87{
88 aead_request_set_crypt(&req->areq, src, dst, nbytes, iv);
89}
90
91static inline void aead_givcrypt_set_assoc(struct aead_givcrypt_request *req,
92 struct scatterlist *assoc,
93 unsigned int assoclen)
94{
95 aead_request_set_assoc(&req->areq, assoc, assoclen);
96}
97
98static inline void aead_givcrypt_set_giv(struct aead_givcrypt_request *req,
99 u8 *giv, u64 seq)
100{
101 req->giv = giv;
102 req->seq = seq;
103}
104
105#endif /* _CRYPTO_AEAD_H */
diff --git a/include/crypto/aes.h b/include/crypto/aes.h
new file mode 100644
index 000000000000..d480b76715a8
--- /dev/null
+++ b/include/crypto/aes.h
@@ -0,0 +1,31 @@
1/*
2 * Common values for AES algorithms
3 */
4
5#ifndef _CRYPTO_AES_H
6#define _CRYPTO_AES_H
7
8#include <linux/types.h>
9#include <linux/crypto.h>
10
11#define AES_MIN_KEY_SIZE 16
12#define AES_MAX_KEY_SIZE 32
13#define AES_KEYSIZE_128 16
14#define AES_KEYSIZE_192 24
15#define AES_KEYSIZE_256 32
16#define AES_BLOCK_SIZE 16
17
18struct crypto_aes_ctx {
19 u32 key_length;
20 u32 key_enc[60];
21 u32 key_dec[60];
22};
23
24extern u32 crypto_ft_tab[4][256];
25extern u32 crypto_fl_tab[4][256];
26extern u32 crypto_it_tab[4][256];
27extern u32 crypto_il_tab[4][256];
28
29int crypto_aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
30 unsigned int key_len);
31#endif
diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
index b9b05d399d2b..60d06e784be3 100644
--- a/include/crypto/algapi.h
+++ b/include/crypto/algapi.h
@@ -111,8 +111,15 @@ void crypto_drop_spawn(struct crypto_spawn *spawn);
111struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type, 111struct crypto_tfm *crypto_spawn_tfm(struct crypto_spawn *spawn, u32 type,
112 u32 mask); 112 u32 mask);
113 113
114static inline void crypto_set_spawn(struct crypto_spawn *spawn,
115 struct crypto_instance *inst)
116{
117 spawn->inst = inst;
118}
119
114struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb); 120struct crypto_attr_type *crypto_get_attr_type(struct rtattr **tb);
115int crypto_check_attr_type(struct rtattr **tb, u32 type); 121int crypto_check_attr_type(struct rtattr **tb, u32 type);
122const char *crypto_attr_alg_name(struct rtattr *rta);
116struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask); 123struct crypto_alg *crypto_attr_alg(struct rtattr *rta, u32 type, u32 mask);
117int crypto_attr_u32(struct rtattr *rta, u32 *num); 124int crypto_attr_u32(struct rtattr *rta, u32 *num);
118struct crypto_instance *crypto_alloc_instance(const char *name, 125struct crypto_instance *crypto_alloc_instance(const char *name,
@@ -124,6 +131,10 @@ int crypto_enqueue_request(struct crypto_queue *queue,
124struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue); 131struct crypto_async_request *crypto_dequeue_request(struct crypto_queue *queue);
125int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm); 132int crypto_tfm_in_queue(struct crypto_queue *queue, struct crypto_tfm *tfm);
126 133
134/* These functions require the input/output to be aligned as u32. */
135void crypto_inc(u8 *a, unsigned int size);
136void crypto_xor(u8 *dst, const u8 *src, unsigned int size);
137
127int blkcipher_walk_done(struct blkcipher_desc *desc, 138int blkcipher_walk_done(struct blkcipher_desc *desc,
128 struct blkcipher_walk *walk, int err); 139 struct blkcipher_walk *walk, int err);
129int blkcipher_walk_virt(struct blkcipher_desc *desc, 140int blkcipher_walk_virt(struct blkcipher_desc *desc,
@@ -187,20 +198,11 @@ static inline struct crypto_instance *crypto_aead_alg_instance(
187 return crypto_tfm_alg_instance(&aead->base); 198 return crypto_tfm_alg_instance(&aead->base);
188} 199}
189 200
190static inline struct crypto_ablkcipher *crypto_spawn_ablkcipher(
191 struct crypto_spawn *spawn)
192{
193 u32 type = CRYPTO_ALG_TYPE_BLKCIPHER;
194 u32 mask = CRYPTO_ALG_TYPE_MASK;
195
196 return __crypto_ablkcipher_cast(crypto_spawn_tfm(spawn, type, mask));
197}
198
199static inline struct crypto_blkcipher *crypto_spawn_blkcipher( 201static inline struct crypto_blkcipher *crypto_spawn_blkcipher(
200 struct crypto_spawn *spawn) 202 struct crypto_spawn *spawn)
201{ 203{
202 u32 type = CRYPTO_ALG_TYPE_BLKCIPHER; 204 u32 type = CRYPTO_ALG_TYPE_BLKCIPHER;
203 u32 mask = CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC; 205 u32 mask = CRYPTO_ALG_TYPE_MASK;
204 206
205 return __crypto_blkcipher_cast(crypto_spawn_tfm(spawn, type, mask)); 207 return __crypto_blkcipher_cast(crypto_spawn_tfm(spawn, type, mask));
206} 208}
@@ -303,5 +305,14 @@ static inline struct crypto_alg *crypto_get_attr_alg(struct rtattr **tb,
303 return crypto_attr_alg(tb[1], type, mask); 305 return crypto_attr_alg(tb[1], type, mask);
304} 306}
305 307
308/*
309 * Returns CRYPTO_ALG_ASYNC if type/mask requires the use of sync algorithms.
310 * Otherwise returns zero.
311 */
312static inline int crypto_requires_sync(u32 type, u32 mask)
313{
314 return (type ^ CRYPTO_ALG_ASYNC) & mask & CRYPTO_ALG_ASYNC;
315}
316
306#endif /* _CRYPTO_ALGAPI_H */ 317#endif /* _CRYPTO_ALGAPI_H */
307 318
diff --git a/include/crypto/authenc.h b/include/crypto/authenc.h
new file mode 100644
index 000000000000..e47b044929a8
--- /dev/null
+++ b/include/crypto/authenc.h
@@ -0,0 +1,27 @@
1/*
2 * Authenc: Simple AEAD wrapper for IPsec
3 *
4 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12#ifndef _CRYPTO_AUTHENC_H
13#define _CRYPTO_AUTHENC_H
14
15#include <linux/types.h>
16
17enum {
18 CRYPTO_AUTHENC_KEYA_UNSPEC,
19 CRYPTO_AUTHENC_KEYA_PARAM,
20};
21
22struct crypto_authenc_key_param {
23 __be32 enckeylen;
24};
25
26#endif /* _CRYPTO_AUTHENC_H */
27
diff --git a/include/crypto/ctr.h b/include/crypto/ctr.h
new file mode 100644
index 000000000000..4180fc080e3b
--- /dev/null
+++ b/include/crypto/ctr.h
@@ -0,0 +1,20 @@
1/*
2 * CTR: Counter mode
3 *
4 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _CRYPTO_CTR_H
14#define _CRYPTO_CTR_H
15
16#define CTR_RFC3686_NONCE_SIZE 4
17#define CTR_RFC3686_IV_SIZE 8
18#define CTR_RFC3686_BLOCK_SIZE 16
19
20#endif /* _CRYPTO_CTR_H */
diff --git a/include/crypto/des.h b/include/crypto/des.h
new file mode 100644
index 000000000000..2971c6304ade
--- /dev/null
+++ b/include/crypto/des.h
@@ -0,0 +1,19 @@
1/*
2 * DES & Triple DES EDE Cipher Algorithms.
3 */
4
5#ifndef __CRYPTO_DES_H
6#define __CRYPTO_DES_H
7
8#define DES_KEY_SIZE 8
9#define DES_EXPKEY_WORDS 32
10#define DES_BLOCK_SIZE 8
11
12#define DES3_EDE_KEY_SIZE (3 * DES_KEY_SIZE)
13#define DES3_EDE_EXPKEY_WORDS (3 * DES_EXPKEY_WORDS)
14#define DES3_EDE_BLOCK_SIZE DES_BLOCK_SIZE
15
16
17extern unsigned long des_ekey(u32 *pe, const u8 *k);
18
19#endif /* __CRYPTO_DES_H */
diff --git a/include/crypto/internal/aead.h b/include/crypto/internal/aead.h
new file mode 100644
index 000000000000..d838c945575a
--- /dev/null
+++ b/include/crypto/internal/aead.h
@@ -0,0 +1,80 @@
1/*
2 * AEAD: Authenticated Encryption with Associated Data
3 *
4 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _CRYPTO_INTERNAL_AEAD_H
14#define _CRYPTO_INTERNAL_AEAD_H
15
16#include <crypto/aead.h>
17#include <crypto/algapi.h>
18#include <linux/types.h>
19
20struct rtattr;
21
22struct crypto_aead_spawn {
23 struct crypto_spawn base;
24};
25
26extern const struct crypto_type crypto_nivaead_type;
27
28static inline void crypto_set_aead_spawn(
29 struct crypto_aead_spawn *spawn, struct crypto_instance *inst)
30{
31 crypto_set_spawn(&spawn->base, inst);
32}
33
34int crypto_grab_aead(struct crypto_aead_spawn *spawn, const char *name,
35 u32 type, u32 mask);
36
37static inline void crypto_drop_aead(struct crypto_aead_spawn *spawn)
38{
39 crypto_drop_spawn(&spawn->base);
40}
41
42static inline struct crypto_alg *crypto_aead_spawn_alg(
43 struct crypto_aead_spawn *spawn)
44{
45 return spawn->base.alg;
46}
47
48static inline struct crypto_aead *crypto_spawn_aead(
49 struct crypto_aead_spawn *spawn)
50{
51 return __crypto_aead_cast(
52 crypto_spawn_tfm(&spawn->base, CRYPTO_ALG_TYPE_AEAD,
53 CRYPTO_ALG_TYPE_MASK));
54}
55
56struct crypto_instance *aead_geniv_alloc(struct crypto_template *tmpl,
57 struct rtattr **tb, u32 type,
58 u32 mask);
59void aead_geniv_free(struct crypto_instance *inst);
60int aead_geniv_init(struct crypto_tfm *tfm);
61void aead_geniv_exit(struct crypto_tfm *tfm);
62
63static inline struct crypto_aead *aead_geniv_base(struct crypto_aead *geniv)
64{
65 return crypto_aead_crt(geniv)->base;
66}
67
68static inline void *aead_givcrypt_reqctx(struct aead_givcrypt_request *req)
69{
70 return aead_request_ctx(&req->areq);
71}
72
73static inline void aead_givcrypt_complete(struct aead_givcrypt_request *req,
74 int err)
75{
76 aead_request_complete(&req->areq, err);
77}
78
79#endif /* _CRYPTO_INTERNAL_AEAD_H */
80
diff --git a/include/crypto/internal/skcipher.h b/include/crypto/internal/skcipher.h
new file mode 100644
index 000000000000..2ba42cd7d6aa
--- /dev/null
+++ b/include/crypto/internal/skcipher.h
@@ -0,0 +1,110 @@
1/*
2 * Symmetric key ciphers.
3 *
4 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _CRYPTO_INTERNAL_SKCIPHER_H
14#define _CRYPTO_INTERNAL_SKCIPHER_H
15
16#include <crypto/algapi.h>
17#include <crypto/skcipher.h>
18#include <linux/types.h>
19
20struct rtattr;
21
22struct crypto_skcipher_spawn {
23 struct crypto_spawn base;
24};
25
26extern const struct crypto_type crypto_givcipher_type;
27
28static inline void crypto_set_skcipher_spawn(
29 struct crypto_skcipher_spawn *spawn, struct crypto_instance *inst)
30{
31 crypto_set_spawn(&spawn->base, inst);
32}
33
34int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name,
35 u32 type, u32 mask);
36
37static inline void crypto_drop_skcipher(struct crypto_skcipher_spawn *spawn)
38{
39 crypto_drop_spawn(&spawn->base);
40}
41
42static inline struct crypto_alg *crypto_skcipher_spawn_alg(
43 struct crypto_skcipher_spawn *spawn)
44{
45 return spawn->base.alg;
46}
47
48static inline struct crypto_ablkcipher *crypto_spawn_skcipher(
49 struct crypto_skcipher_spawn *spawn)
50{
51 return __crypto_ablkcipher_cast(
52 crypto_spawn_tfm(&spawn->base, crypto_skcipher_type(0),
53 crypto_skcipher_mask(0)));
54}
55
56int skcipher_null_givencrypt(struct skcipher_givcrypt_request *req);
57int skcipher_null_givdecrypt(struct skcipher_givcrypt_request *req);
58const char *crypto_default_geniv(const struct crypto_alg *alg);
59
60struct crypto_instance *skcipher_geniv_alloc(struct crypto_template *tmpl,
61 struct rtattr **tb, u32 type,
62 u32 mask);
63void skcipher_geniv_free(struct crypto_instance *inst);
64int skcipher_geniv_init(struct crypto_tfm *tfm);
65void skcipher_geniv_exit(struct crypto_tfm *tfm);
66
67static inline struct crypto_ablkcipher *skcipher_geniv_cipher(
68 struct crypto_ablkcipher *geniv)
69{
70 return crypto_ablkcipher_crt(geniv)->base;
71}
72
73static inline int skcipher_enqueue_givcrypt(
74 struct crypto_queue *queue, struct skcipher_givcrypt_request *request)
75{
76 return ablkcipher_enqueue_request(queue, &request->creq);
77}
78
79static inline struct skcipher_givcrypt_request *skcipher_dequeue_givcrypt(
80 struct crypto_queue *queue)
81{
82 return container_of(ablkcipher_dequeue_request(queue),
83 struct skcipher_givcrypt_request, creq);
84}
85
86static inline void *skcipher_givcrypt_reqctx(
87 struct skcipher_givcrypt_request *req)
88{
89 return ablkcipher_request_ctx(&req->creq);
90}
91
92static inline void ablkcipher_request_complete(struct ablkcipher_request *req,
93 int err)
94{
95 req->base.complete(&req->base, err);
96}
97
98static inline void skcipher_givcrypt_complete(
99 struct skcipher_givcrypt_request *req, int err)
100{
101 ablkcipher_request_complete(&req->creq, err);
102}
103
104static inline u32 ablkcipher_request_flags(struct ablkcipher_request *req)
105{
106 return req->base.flags;
107}
108
109#endif /* _CRYPTO_INTERNAL_SKCIPHER_H */
110
diff --git a/include/crypto/scatterwalk.h b/include/crypto/scatterwalk.h
new file mode 100644
index 000000000000..224658b8d806
--- /dev/null
+++ b/include/crypto/scatterwalk.h
@@ -0,0 +1,119 @@
1/*
2 * Cryptographic scatter and gather helpers.
3 *
4 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
5 * Copyright (c) 2002 Adam J. Richter <adam@yggdrasil.com>
6 * Copyright (c) 2004 Jean-Luc Cooke <jlcooke@certainkey.com>
7 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 *
14 */
15
16#ifndef _CRYPTO_SCATTERWALK_H
17#define _CRYPTO_SCATTERWALK_H
18
19#include <asm/kmap_types.h>
20#include <crypto/algapi.h>
21#include <linux/hardirq.h>
22#include <linux/highmem.h>
23#include <linux/kernel.h>
24#include <linux/mm.h>
25#include <linux/scatterlist.h>
26#include <linux/sched.h>
27
28static inline enum km_type crypto_kmap_type(int out)
29{
30 enum km_type type;
31
32 if (in_softirq())
33 type = out * (KM_SOFTIRQ1 - KM_SOFTIRQ0) + KM_SOFTIRQ0;
34 else
35 type = out * (KM_USER1 - KM_USER0) + KM_USER0;
36
37 return type;
38}
39
40static inline void *crypto_kmap(struct page *page, int out)
41{
42 return kmap_atomic(page, crypto_kmap_type(out));
43}
44
45static inline void crypto_kunmap(void *vaddr, int out)
46{
47 kunmap_atomic(vaddr, crypto_kmap_type(out));
48}
49
50static inline void crypto_yield(u32 flags)
51{
52 if (flags & CRYPTO_TFM_REQ_MAY_SLEEP)
53 cond_resched();
54}
55
56static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
57 struct scatterlist *sg2)
58{
59 sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);
60}
61
62static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
63{
64 return (++sg)->length ? sg : (void *)sg_page(sg);
65}
66
67static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in,
68 struct scatter_walk *walk_out)
69{
70 return !(((sg_page(walk_in->sg) - sg_page(walk_out->sg)) << PAGE_SHIFT) +
71 (int)(walk_in->offset - walk_out->offset));
72}
73
74static inline unsigned int scatterwalk_pagelen(struct scatter_walk *walk)
75{
76 unsigned int len = walk->sg->offset + walk->sg->length - walk->offset;
77 unsigned int len_this_page = offset_in_page(~walk->offset) + 1;
78 return len_this_page > len ? len : len_this_page;
79}
80
81static inline unsigned int scatterwalk_clamp(struct scatter_walk *walk,
82 unsigned int nbytes)
83{
84 unsigned int len_this_page = scatterwalk_pagelen(walk);
85 return nbytes > len_this_page ? len_this_page : nbytes;
86}
87
88static inline void scatterwalk_advance(struct scatter_walk *walk,
89 unsigned int nbytes)
90{
91 walk->offset += nbytes;
92}
93
94static inline unsigned int scatterwalk_aligned(struct scatter_walk *walk,
95 unsigned int alignmask)
96{
97 return !(walk->offset & alignmask);
98}
99
100static inline struct page *scatterwalk_page(struct scatter_walk *walk)
101{
102 return sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
103}
104
105static inline void scatterwalk_unmap(void *vaddr, int out)
106{
107 crypto_kunmap(vaddr, out);
108}
109
110void scatterwalk_start(struct scatter_walk *walk, struct scatterlist *sg);
111void scatterwalk_copychunks(void *buf, struct scatter_walk *walk,
112 size_t nbytes, int out);
113void *scatterwalk_map(struct scatter_walk *walk, int out);
114void scatterwalk_done(struct scatter_walk *walk, int out, int more);
115
116void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
117 unsigned int start, unsigned int nbytes, int out);
118
119#endif /* _CRYPTO_SCATTERWALK_H */
diff --git a/include/crypto/sha.h b/include/crypto/sha.h
index 0686e1f7a24b..c0ccc2b1a2d8 100644
--- a/include/crypto/sha.h
+++ b/include/crypto/sha.h
@@ -8,6 +8,9 @@
8#define SHA1_DIGEST_SIZE 20 8#define SHA1_DIGEST_SIZE 20
9#define SHA1_BLOCK_SIZE 64 9#define SHA1_BLOCK_SIZE 64
10 10
11#define SHA224_DIGEST_SIZE 28
12#define SHA224_BLOCK_SIZE 64
13
11#define SHA256_DIGEST_SIZE 32 14#define SHA256_DIGEST_SIZE 32
12#define SHA256_BLOCK_SIZE 64 15#define SHA256_BLOCK_SIZE 64
13 16
@@ -23,6 +26,15 @@
23#define SHA1_H3 0x10325476UL 26#define SHA1_H3 0x10325476UL
24#define SHA1_H4 0xc3d2e1f0UL 27#define SHA1_H4 0xc3d2e1f0UL
25 28
29#define SHA224_H0 0xc1059ed8UL
30#define SHA224_H1 0x367cd507UL
31#define SHA224_H2 0x3070dd17UL
32#define SHA224_H3 0xf70e5939UL
33#define SHA224_H4 0xffc00b31UL
34#define SHA224_H5 0x68581511UL
35#define SHA224_H6 0x64f98fa7UL
36#define SHA224_H7 0xbefa4fa4UL
37
26#define SHA256_H0 0x6a09e667UL 38#define SHA256_H0 0x6a09e667UL
27#define SHA256_H1 0xbb67ae85UL 39#define SHA256_H1 0xbb67ae85UL
28#define SHA256_H2 0x3c6ef372UL 40#define SHA256_H2 0x3c6ef372UL
diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
new file mode 100644
index 000000000000..25fd6126522d
--- /dev/null
+++ b/include/crypto/skcipher.h
@@ -0,0 +1,110 @@
1/*
2 * Symmetric key ciphers.
3 *
4 * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 */
12
13#ifndef _CRYPTO_SKCIPHER_H
14#define _CRYPTO_SKCIPHER_H
15
16#include <linux/crypto.h>
17#include <linux/kernel.h>
18#include <linux/slab.h>
19
20/**
21 * struct skcipher_givcrypt_request - Crypto request with IV generation
22 * @seq: Sequence number for IV generation
23 * @giv: Space for generated IV
24 * @creq: The crypto request itself
25 */
26struct skcipher_givcrypt_request {
27 u64 seq;
28 u8 *giv;
29
30 struct ablkcipher_request creq;
31};
32
33static inline struct crypto_ablkcipher *skcipher_givcrypt_reqtfm(
34 struct skcipher_givcrypt_request *req)
35{
36 return crypto_ablkcipher_reqtfm(&req->creq);
37}
38
39static inline int crypto_skcipher_givencrypt(
40 struct skcipher_givcrypt_request *req)
41{
42 struct ablkcipher_tfm *crt =
43 crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req));
44 return crt->givencrypt(req);
45};
46
47static inline int crypto_skcipher_givdecrypt(
48 struct skcipher_givcrypt_request *req)
49{
50 struct ablkcipher_tfm *crt =
51 crypto_ablkcipher_crt(skcipher_givcrypt_reqtfm(req));
52 return crt->givdecrypt(req);
53};
54
55static inline void skcipher_givcrypt_set_tfm(
56 struct skcipher_givcrypt_request *req, struct crypto_ablkcipher *tfm)
57{
58 req->creq.base.tfm = crypto_ablkcipher_tfm(tfm);
59}
60
61static inline struct skcipher_givcrypt_request *skcipher_givcrypt_cast(
62 struct crypto_async_request *req)
63{
64 return container_of(ablkcipher_request_cast(req),
65 struct skcipher_givcrypt_request, creq);
66}
67
68static inline struct skcipher_givcrypt_request *skcipher_givcrypt_alloc(
69 struct crypto_ablkcipher *tfm, gfp_t gfp)
70{
71 struct skcipher_givcrypt_request *req;
72
73 req = kmalloc(sizeof(struct skcipher_givcrypt_request) +
74 crypto_ablkcipher_reqsize(tfm), gfp);
75
76 if (likely(req))
77 skcipher_givcrypt_set_tfm(req, tfm);
78
79 return req;
80}
81
82static inline void skcipher_givcrypt_free(struct skcipher_givcrypt_request *req)
83{
84 kfree(req);
85}
86
87static inline void skcipher_givcrypt_set_callback(
88 struct skcipher_givcrypt_request *req, u32 flags,
89 crypto_completion_t complete, void *data)
90{
91 ablkcipher_request_set_callback(&req->creq, flags, complete, data);
92}
93
94static inline void skcipher_givcrypt_set_crypt(
95 struct skcipher_givcrypt_request *req,
96 struct scatterlist *src, struct scatterlist *dst,
97 unsigned int nbytes, void *iv)
98{
99 ablkcipher_request_set_crypt(&req->creq, src, dst, nbytes, iv);
100}
101
102static inline void skcipher_givcrypt_set_giv(
103 struct skcipher_givcrypt_request *req, u8 *giv, u64 seq)
104{
105 req->giv = giv;
106 req->seq = seq;
107}
108
109#endif /* _CRYPTO_SKCIPHER_H */
110
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 6a65231bc785..c0f9bb78727d 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -1,4 +1,5 @@
1header-y += byteorder/ 1header-y += byteorder/
2header-y += can/
2header-y += dvb/ 3header-y += dvb/
3header-y += hdlc/ 4header-y += hdlc/
4header-y += isdn/ 5header-y += isdn/
@@ -34,13 +35,13 @@ header-y += atmsap.h
34header-y += atmsvc.h 35header-y += atmsvc.h
35header-y += atm_zatm.h 36header-y += atm_zatm.h
36header-y += auto_fs4.h 37header-y += auto_fs4.h
37header-y += auxvec.h
38header-y += ax25.h 38header-y += ax25.h
39header-y += b1lli.h 39header-y += b1lli.h
40header-y += baycom.h 40header-y += baycom.h
41header-y += bfs_fs.h 41header-y += bfs_fs.h
42header-y += blkpg.h 42header-y += blkpg.h
43header-y += bpqether.h 43header-y += bpqether.h
44header-y += can.h
44header-y += cdk.h 45header-y += cdk.h
45header-y += chio.h 46header-y += chio.h
46header-y += coda_psdev.h 47header-y += coda_psdev.h
@@ -49,6 +50,7 @@ header-y += comstats.h
49header-y += const.h 50header-y += const.h
50header-y += cgroupstats.h 51header-y += cgroupstats.h
51header-y += cycx_cfm.h 52header-y += cycx_cfm.h
53header-y += dlmconstants.h
52header-y += dlm_device.h 54header-y += dlm_device.h
53header-y += dlm_netlink.h 55header-y += dlm_netlink.h
54header-y += dm-ioctl.h 56header-y += dm-ioctl.h
@@ -72,7 +74,7 @@ header-y += gen_stats.h
72header-y += gigaset_dev.h 74header-y += gigaset_dev.h
73header-y += hdsmart.h 75header-y += hdsmart.h
74header-y += hysdn_if.h 76header-y += hysdn_if.h
75header-y += i2c-dev.h 77header-y += i2o-dev.h
76header-y += i8k.h 78header-y += i8k.h
77header-y += if_arcnet.h 79header-y += if_arcnet.h
78header-y += if_bonding.h 80header-y += if_bonding.h
@@ -98,7 +100,6 @@ header-y += iso_fs.h
98header-y += ixjuser.h 100header-y += ixjuser.h
99header-y += jffs2.h 101header-y += jffs2.h
100header-y += keyctl.h 102header-y += keyctl.h
101header-y += kvm.h
102header-y += limits.h 103header-y += limits.h
103header-y += lock_dlm_plock.h 104header-y += lock_dlm_plock.h
104header-y += magic.h 105header-y += magic.h
@@ -142,21 +143,22 @@ header-y += snmp.h
142header-y += sockios.h 143header-y += sockios.h
143header-y += som.h 144header-y += som.h
144header-y += sound.h 145header-y += sound.h
146header-y += suspend_ioctls.h
145header-y += taskstats.h 147header-y += taskstats.h
146header-y += telephony.h 148header-y += telephony.h
147header-y += termios.h 149header-y += termios.h
148header-y += ticable.h
149header-y += times.h 150header-y += times.h
150header-y += tiocl.h 151header-y += tiocl.h
151header-y += tipc.h 152header-y += tipc.h
153header-y += tipc_config.h
152header-y += toshiba.h 154header-y += toshiba.h
153header-y += ultrasound.h 155header-y += ultrasound.h
154header-y += un.h 156header-y += un.h
155header-y += utime.h 157header-y += utime.h
158header-y += veth.h
156header-y += video_decoder.h 159header-y += video_decoder.h
157header-y += video_encoder.h 160header-y += video_encoder.h
158header-y += videotext.h 161header-y += videotext.h
159header-y += vt.h
160header-y += x25.h 162header-y += x25.h
161 163
162unifdef-y += acct.h 164unifdef-y += acct.h
@@ -171,6 +173,7 @@ unifdef-y += atm.h
171unifdef-y += atm_tcp.h 173unifdef-y += atm_tcp.h
172unifdef-y += audit.h 174unifdef-y += audit.h
173unifdef-y += auto_fs.h 175unifdef-y += auto_fs.h
176unifdef-y += auxvec.h
174unifdef-y += binfmts.h 177unifdef-y += binfmts.h
175unifdef-y += capability.h 178unifdef-y += capability.h
176unifdef-y += capi.h 179unifdef-y += capi.h
@@ -212,7 +215,7 @@ unifdef-y += hdreg.h
212unifdef-y += hiddev.h 215unifdef-y += hiddev.h
213unifdef-y += hpet.h 216unifdef-y += hpet.h
214unifdef-y += i2c.h 217unifdef-y += i2c.h
215unifdef-y += i2o-dev.h 218unifdef-y += i2c-dev.h
216unifdef-y += icmp.h 219unifdef-y += icmp.h
217unifdef-y += icmpv6.h 220unifdef-y += icmpv6.h
218unifdef-y += if_addr.h 221unifdef-y += if_addr.h
@@ -227,7 +230,6 @@ unifdef-y += if_ltalk.h
227unifdef-y += if_link.h 230unifdef-y += if_link.h
228unifdef-y += if_pppol2tp.h 231unifdef-y += if_pppol2tp.h
229unifdef-y += if_pppox.h 232unifdef-y += if_pppox.h
230unifdef-y += if_shaper.h
231unifdef-y += if_tr.h 233unifdef-y += if_tr.h
232unifdef-y += if_tun.h 234unifdef-y += if_tun.h
233unifdef-y += if_vlan.h 235unifdef-y += if_vlan.h
@@ -254,6 +256,7 @@ unifdef-y += kd.h
254unifdef-y += kernelcapi.h 256unifdef-y += kernelcapi.h
255unifdef-y += kernel.h 257unifdef-y += kernel.h
256unifdef-y += keyboard.h 258unifdef-y += keyboard.h
259unifdef-$(CONFIG_HAVE_KVM) += kvm.h
257unifdef-y += llc.h 260unifdef-y += llc.h
258unifdef-y += loop.h 261unifdef-y += loop.h
259unifdef-y += lp.h 262unifdef-y += lp.h
@@ -325,6 +328,7 @@ unifdef-y += sonypi.h
325unifdef-y += soundcard.h 328unifdef-y += soundcard.h
326unifdef-y += stat.h 329unifdef-y += stat.h
327unifdef-y += stddef.h 330unifdef-y += stddef.h
331unifdef-y += string.h
328unifdef-y += synclink.h 332unifdef-y += synclink.h
329unifdef-y += sysctl.h 333unifdef-y += sysctl.h
330unifdef-y += tcp.h 334unifdef-y += tcp.h
@@ -346,6 +350,7 @@ unifdef-y += videodev.h
346unifdef-y += virtio_config.h 350unifdef-y += virtio_config.h
347unifdef-y += virtio_blk.h 351unifdef-y += virtio_blk.h
348unifdef-y += virtio_net.h 352unifdef-y += virtio_net.h
353unifdef-y += vt.h
349unifdef-y += wait.h 354unifdef-y += wait.h
350unifdef-y += wanrouter.h 355unifdef-y += wanrouter.h
351unifdef-y += watchdog.h 356unifdef-y += watchdog.h
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 8ccedf7a0a5a..63f2e6ed698f 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -40,6 +40,7 @@
40#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_drivers.h>
41#include <acpi/acpi_numa.h> 41#include <acpi/acpi_numa.h>
42#include <asm/acpi.h> 42#include <asm/acpi.h>
43#include <linux/dmi.h>
43 44
44 45
45#ifdef CONFIG_ACPI 46#ifdef CONFIG_ACPI
@@ -132,6 +133,11 @@ extern unsigned long acpi_realmode_flags;
132int acpi_register_gsi (u32 gsi, int triggering, int polarity); 133int acpi_register_gsi (u32 gsi, int triggering, int polarity);
133int acpi_gsi_to_irq (u32 gsi, unsigned int *irq); 134int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
134 135
136#ifdef CONFIG_X86_IO_APIC
137extern int acpi_get_override_irq(int bus_irq, int *trigger, int *polarity);
138#else
139#define acpi_get_override_irq(bus, trigger, polarity) (-1)
140#endif
135/* 141/*
136 * This function undoes the effect of one call to acpi_register_gsi(). 142 * This function undoes the effect of one call to acpi_register_gsi().
137 * If this matches the last registration, any IRQ resources for gsi 143 * If this matches the last registration, any IRQ resources for gsi
@@ -187,7 +193,9 @@ extern int ec_transaction(u8 command,
187#endif /*CONFIG_ACPI_EC*/ 193#endif /*CONFIG_ACPI_EC*/
188 194
189extern int acpi_blacklisted(void); 195extern int acpi_blacklisted(void);
190extern void acpi_bios_year(char *s); 196#ifdef CONFIG_DMI
197extern void acpi_dmi_osi_linux(int enable, const struct dmi_system_id *d);
198#endif
191 199
192#ifdef CONFIG_ACPI_NUMA 200#ifdef CONFIG_ACPI_NUMA
193int acpi_get_pxm(acpi_handle handle); 201int acpi_get_pxm(acpi_handle handle);
@@ -221,5 +229,5 @@ static inline int acpi_boot_table_init(void)
221 return 0; 229 return 0;
222} 230}
223 231
224#endif /* CONFIG_ACPI */ 232#endif /* !CONFIG_ACPI */
225#endif /*_LINUX_ACPI_H*/ 233#endif /*_LINUX_ACPI_H*/
diff --git a/include/linux/acpi_pmtmr.h b/include/linux/acpi_pmtmr.h
index 1d0ef1ae8036..7e3d2859be50 100644
--- a/include/linux/acpi_pmtmr.h
+++ b/include/linux/acpi_pmtmr.h
@@ -25,6 +25,8 @@ static inline u32 acpi_pm_read_early(void)
25 return acpi_pm_read_verified() & ACPI_PM_MASK; 25 return acpi_pm_read_verified() & ACPI_PM_MASK;
26} 26}
27 27
28extern void pmtimer_wait(unsigned);
29
28#else 30#else
29 31
30static inline u32 acpi_pm_read_early(void) 32static inline u32 acpi_pm_read_early(void)
diff --git a/include/linux/apm_bios.h b/include/linux/apm_bios.h
index 9754baa14921..01a6244c9bc9 100644
--- a/include/linux/apm_bios.h
+++ b/include/linux/apm_bios.h
@@ -18,6 +18,9 @@
18 18
19#include <linux/types.h> 19#include <linux/types.h>
20 20
21typedef unsigned short apm_event_t;
22typedef unsigned short apm_eventinfo_t;
23
21struct apm_bios_info { 24struct apm_bios_info {
22 __u16 version; 25 __u16 version;
23 __u16 cseg; 26 __u16 cseg;
@@ -32,9 +35,6 @@ struct apm_bios_info {
32 35
33#ifdef __KERNEL__ 36#ifdef __KERNEL__
34 37
35typedef unsigned short apm_event_t;
36typedef unsigned short apm_eventinfo_t;
37
38#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8) 38#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8)
39#define APM_CS_16 (APM_CS + 8) 39#define APM_CS_16 (APM_CS + 8)
40#define APM_DS (APM_CS_16 + 8) 40#define APM_DS (APM_CS_16 + 8)
diff --git a/include/linux/aspm.h b/include/linux/aspm.h
new file mode 100644
index 000000000000..f41a69895485
--- /dev/null
+++ b/include/linux/aspm.h
@@ -0,0 +1,44 @@
1/*
2 * aspm.h
3 *
4 * PCI Express ASPM defines and function prototypes
5 *
6 * Copyright (C) 2007 Intel Corp.
7 * Zhang Yanmin (yanmin.zhang@intel.com)
8 * Shaohua Li (shaohua.li@intel.com)
9 *
10 * For more information, please consult the following manuals (look at
11 * http://www.pcisig.com/ for how to get them):
12 *
13 * PCI Express Specification
14 */
15
16#ifndef LINUX_ASPM_H
17#define LINUX_ASPM_H
18
19#include <linux/pci.h>
20
21#define PCIE_LINK_STATE_L0S 1
22#define PCIE_LINK_STATE_L1 2
23#define PCIE_LINK_STATE_CLKPM 4
24
25#ifdef CONFIG_PCIEASPM
26extern void pcie_aspm_init_link_state(struct pci_dev *pdev);
27extern void pcie_aspm_exit_link_state(struct pci_dev *pdev);
28extern void pcie_aspm_pm_state_change(struct pci_dev *pdev);
29extern void pci_disable_link_state(struct pci_dev *pdev, int state);
30#else
31#define pcie_aspm_init_link_state(pdev) do {} while (0)
32#define pcie_aspm_exit_link_state(pdev) do {} while (0)
33#define pcie_aspm_pm_state_change(pdev) do {} while (0)
34#define pci_disable_link_state(pdev, state) do {} while (0)
35#endif
36
37#ifdef CONFIG_PCIEASPM_DEBUG /* this depends on CONFIG_PCIEASPM */
38extern void pcie_aspm_create_sysfs_dev_files(struct pci_dev *pdev);
39extern void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev);
40#else
41#define pcie_aspm_create_sysfs_dev_files(pdev) do {} while (0)
42#define pcie_aspm_remove_sysfs_dev_files(pdev) do {} while (0)
43#endif
44#endif /* LINUX_ASPM_H */
diff --git a/include/linux/ata.h b/include/linux/ata.h
index 8263a7b74d34..78bbacaed8c4 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -43,6 +43,7 @@ enum {
43 ATA_MAX_SECTORS_128 = 128, 43 ATA_MAX_SECTORS_128 = 128,
44 ATA_MAX_SECTORS = 256, 44 ATA_MAX_SECTORS = 256,
45 ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */ 45 ATA_MAX_SECTORS_LBA48 = 65535,/* TODO: 65536? */
46 ATA_MAX_SECTORS_TAPE = 65535,
46 47
47 ATA_ID_WORDS = 256, 48 ATA_ID_WORDS = 256,
48 ATA_ID_SERNO = 10, 49 ATA_ID_SERNO = 10,
@@ -180,6 +181,7 @@ enum {
180 ATA_CMD_VERIFY_EXT = 0x42, 181 ATA_CMD_VERIFY_EXT = 0x42,
181 ATA_CMD_STANDBYNOW1 = 0xE0, 182 ATA_CMD_STANDBYNOW1 = 0xE0,
182 ATA_CMD_IDLEIMMEDIATE = 0xE1, 183 ATA_CMD_IDLEIMMEDIATE = 0xE1,
184 ATA_CMD_SLEEP = 0xE6,
183 ATA_CMD_INIT_DEV_PARAMS = 0x91, 185 ATA_CMD_INIT_DEV_PARAMS = 0x91,
184 ATA_CMD_READ_NATIVE_MAX = 0xF8, 186 ATA_CMD_READ_NATIVE_MAX = 0xF8,
185 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27, 187 ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
@@ -188,6 +190,8 @@ enum {
188 ATA_CMD_READ_LOG_EXT = 0x2f, 190 ATA_CMD_READ_LOG_EXT = 0x2f,
189 ATA_CMD_PMP_READ = 0xE4, 191 ATA_CMD_PMP_READ = 0xE4,
190 ATA_CMD_PMP_WRITE = 0xE8, 192 ATA_CMD_PMP_WRITE = 0xE8,
193 ATA_CMD_CONF_OVERLAY = 0xB1,
194 ATA_CMD_SEC_FREEZE_LOCK = 0xF5,
191 195
192 /* READ_LOG_EXT pages */ 196 /* READ_LOG_EXT pages */
193 ATA_LOG_SATA_NCQ = 0x10, 197 ATA_LOG_SATA_NCQ = 0x10,
@@ -235,6 +239,20 @@ enum {
235 239
236 /* SETFEATURE Sector counts for SATA features */ 240 /* SETFEATURE Sector counts for SATA features */
237 SATA_AN = 0x05, /* Asynchronous Notification */ 241 SATA_AN = 0x05, /* Asynchronous Notification */
242 SATA_DIPM = 0x03, /* Device Initiated Power Management */
243
244 /* feature values for SET_MAX */
245 ATA_SET_MAX_ADDR = 0x00,
246 ATA_SET_MAX_PASSWD = 0x01,
247 ATA_SET_MAX_LOCK = 0x02,
248 ATA_SET_MAX_UNLOCK = 0x03,
249 ATA_SET_MAX_FREEZE_LOCK = 0x04,
250
251 /* feature values for DEVICE CONFIGURATION OVERLAY */
252 ATA_DCO_RESTORE = 0xC0,
253 ATA_DCO_FREEZE_LOCK = 0xC1,
254 ATA_DCO_IDENTIFY = 0xC2,
255 ATA_DCO_SET = 0xC3,
238 256
239 /* ATAPI stuff */ 257 /* ATAPI stuff */
240 ATAPI_PKT_DMA = (1 << 0), 258 ATAPI_PKT_DMA = (1 << 0),
@@ -268,9 +286,10 @@ enum {
268 ATA_CBL_NONE = 0, 286 ATA_CBL_NONE = 0,
269 ATA_CBL_PATA40 = 1, 287 ATA_CBL_PATA40 = 1,
270 ATA_CBL_PATA80 = 2, 288 ATA_CBL_PATA80 = 2,
271 ATA_CBL_PATA40_SHORT = 3, /* 40 wire cable to high UDMA spec */ 289 ATA_CBL_PATA40_SHORT = 3, /* 40 wire cable to high UDMA spec */
272 ATA_CBL_PATA_UNK = 4, 290 ATA_CBL_PATA_UNK = 4, /* don't know, maybe 80c? */
273 ATA_CBL_SATA = 5, 291 ATA_CBL_PATA_IGN = 5, /* don't know, ignore cable handling */
292 ATA_CBL_SATA = 6,
274 293
275 /* SATA Status and Control Registers */ 294 /* SATA Status and Control Registers */
276 SCR_STATUS = 0, 295 SCR_STATUS = 0,
@@ -306,6 +325,13 @@ enum {
306 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */ 325 ATA_TFLAG_LBA = (1 << 4), /* enable LBA */
307 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ 326 ATA_TFLAG_FUA = (1 << 5), /* enable FUA */
308 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ 327 ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */
328
329 /* protocol flags */
330 ATA_PROT_FLAG_PIO = (1 << 0), /* is PIO */
331 ATA_PROT_FLAG_DMA = (1 << 1), /* is DMA */
332 ATA_PROT_FLAG_DATA = ATA_PROT_FLAG_PIO | ATA_PROT_FLAG_DMA,
333 ATA_PROT_FLAG_NCQ = (1 << 2), /* is NCQ */
334 ATA_PROT_FLAG_ATAPI = (1 << 3), /* is ATAPI */
309}; 335};
310 336
311enum ata_tf_protocols { 337enum ata_tf_protocols {
@@ -315,9 +341,9 @@ enum ata_tf_protocols {
315 ATA_PROT_PIO, /* PIO data xfer */ 341 ATA_PROT_PIO, /* PIO data xfer */
316 ATA_PROT_DMA, /* DMA */ 342 ATA_PROT_DMA, /* DMA */
317 ATA_PROT_NCQ, /* NCQ */ 343 ATA_PROT_NCQ, /* NCQ */
318 ATA_PROT_ATAPI, /* packet command, PIO data xfer*/ 344 ATAPI_PROT_NODATA, /* packet command, no data */
319 ATA_PROT_ATAPI_NODATA, /* packet command, no data */ 345 ATAPI_PROT_PIO, /* packet command, PIO data xfer*/
320 ATA_PROT_ATAPI_DMA, /* packet command with special DMA sauce */ 346 ATAPI_PROT_DMA, /* packet command with special DMA sauce */
321}; 347};
322 348
323enum ata_ioctls { 349enum ata_ioctls {
@@ -328,8 +354,8 @@ enum ata_ioctls {
328/* core structures */ 354/* core structures */
329 355
330struct ata_prd { 356struct ata_prd {
331 u32 addr; 357 __le32 addr;
332 u32 flags_len; 358 __le32 flags_len;
333}; 359};
334 360
335struct ata_taskfile { 361struct ata_taskfile {
@@ -355,13 +381,69 @@ struct ata_taskfile {
355 u8 command; /* IO operation */ 381 u8 command; /* IO operation */
356}; 382};
357 383
384/*
385 * protocol tests
386 */
387static inline unsigned int ata_prot_flags(u8 prot)
388{
389 switch (prot) {
390 case ATA_PROT_NODATA:
391 return 0;
392 case ATA_PROT_PIO:
393 return ATA_PROT_FLAG_PIO;
394 case ATA_PROT_DMA:
395 return ATA_PROT_FLAG_DMA;
396 case ATA_PROT_NCQ:
397 return ATA_PROT_FLAG_DMA | ATA_PROT_FLAG_NCQ;
398 case ATAPI_PROT_NODATA:
399 return ATA_PROT_FLAG_ATAPI;
400 case ATAPI_PROT_PIO:
401 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_PIO;
402 case ATAPI_PROT_DMA:
403 return ATA_PROT_FLAG_ATAPI | ATA_PROT_FLAG_DMA;
404 }
405 return 0;
406}
407
408static inline int ata_is_atapi(u8 prot)
409{
410 return ata_prot_flags(prot) & ATA_PROT_FLAG_ATAPI;
411}
412
413static inline int ata_is_nodata(u8 prot)
414{
415 return !(ata_prot_flags(prot) & ATA_PROT_FLAG_DATA);
416}
417
418static inline int ata_is_pio(u8 prot)
419{
420 return ata_prot_flags(prot) & ATA_PROT_FLAG_PIO;
421}
422
423static inline int ata_is_dma(u8 prot)
424{
425 return ata_prot_flags(prot) & ATA_PROT_FLAG_DMA;
426}
427
428static inline int ata_is_ncq(u8 prot)
429{
430 return ata_prot_flags(prot) & ATA_PROT_FLAG_NCQ;
431}
432
433static inline int ata_is_data(u8 prot)
434{
435 return ata_prot_flags(prot) & ATA_PROT_FLAG_DATA;
436}
437
438/*
439 * id tests
440 */
358#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0) 441#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
359#define ata_id_has_lba(id) ((id)[49] & (1 << 9)) 442#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
360#define ata_id_has_dma(id) ((id)[49] & (1 << 8)) 443#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
361#define ata_id_has_ncq(id) ((id)[76] & (1 << 8)) 444#define ata_id_has_ncq(id) ((id)[76] & (1 << 8))
362#define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1) 445#define ata_id_queue_depth(id) (((id)[75] & 0x1f) + 1)
363#define ata_id_removeable(id) ((id)[0] & (1 << 7)) 446#define ata_id_removeable(id) ((id)[0] & (1 << 7))
364#define ata_id_has_dword_io(id) ((id)[48] & (1 << 0))
365#define ata_id_has_atapi_AN(id) \ 447#define ata_id_has_atapi_AN(id) \
366 ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \ 448 ( (((id)[76] != 0x0000) && ((id)[76] != 0xffff)) && \
367 ((id)[78] & (1 << 5)) ) 449 ((id)[78] & (1 << 5)) )
@@ -377,6 +459,27 @@ struct ata_taskfile {
377 459
378#define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20) 460#define ata_id_cdb_intr(id) (((id)[0] & 0x60) == 0x20)
379 461
462static inline bool ata_id_has_hipm(const u16 *id)
463{
464 u16 val = id[76];
465
466 if (val == 0 || val == 0xffff)
467 return false;
468
469 return val & (1 << 9);
470}
471
472static inline bool ata_id_has_dipm(const u16 *id)
473{
474 u16 val = id[78];
475
476 if (val == 0 || val == 0xffff)
477 return false;
478
479 return val & (1 << 3);
480}
481
482
380static inline int ata_id_has_fua(const u16 *id) 483static inline int ata_id_has_fua(const u16 *id)
381{ 484{
382 if ((id[84] & 0xC000) != 0x4000) 485 if ((id[84] & 0xC000) != 0x4000)
@@ -402,6 +505,8 @@ static inline int ata_id_has_lba48(const u16 *id)
402{ 505{
403 if ((id[83] & 0xC000) != 0x4000) 506 if ((id[83] & 0xC000) != 0x4000)
404 return 0; 507 return 0;
508 if (!ata_id_u64(id, 100))
509 return 0;
405 return id[83] & (1 << 10); 510 return id[83] & (1 << 10);
406} 511}
407 512
@@ -479,6 +584,26 @@ static inline int ata_id_is_sata(const u16 *id)
479 return ata_id_major_version(id) >= 5 && id[93] == 0; 584 return ata_id_major_version(id) >= 5 && id[93] == 0;
480} 585}
481 586
587static inline int ata_id_has_tpm(const u16 *id)
588{
589 /* The TPM bits are only valid on ATA8 */
590 if (ata_id_major_version(id) < 8)
591 return 0;
592 if ((id[48] & 0xC000) != 0x4000)
593 return 0;
594 return id[48] & (1 << 0);
595}
596
597static inline int ata_id_has_dword_io(const u16 *id)
598{
599 /* ATA 8 reuses this flag for "trusted" computing */
600 if (ata_id_major_version(id) > 7)
601 return 0;
602 if (id[48] & (1 << 0))
603 return 1;
604 return 0;
605}
606
482static inline int ata_id_current_chs_valid(const u16 *id) 607static inline int ata_id_current_chs_valid(const u16 *id)
483{ 608{
484 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command 609 /* For ATA-1 devices, if the INITIALIZE DEVICE PARAMETERS command
@@ -512,6 +637,13 @@ static inline int ata_drive_40wire(const u16 *dev_id)
512 return 1; 637 return 1;
513} 638}
514 639
640static inline int ata_drive_40wire_relaxed(const u16 *dev_id)
641{
642 if ((dev_id[93] & 0x2000) == 0x2000)
643 return 0; /* 80 wire */
644 return 1;
645}
646
515static inline int atapi_cdb_len(const u16 *dev_id) 647static inline int atapi_cdb_len(const u16 *dev_id)
516{ 648{
517 u16 tmp = dev_id[0] & 0x3; 649 u16 tmp = dev_id[0] & 0x3;
@@ -522,11 +654,9 @@ static inline int atapi_cdb_len(const u16 *dev_id)
522 } 654 }
523} 655}
524 656
525static inline int is_atapi_taskfile(const struct ata_taskfile *tf) 657static inline int atapi_command_packet_set(const u16 *dev_id)
526{ 658{
527 return (tf->protocol == ATA_PROT_ATAPI) || 659 return (dev_id[0] >> 8) & 0x1f;
528 (tf->protocol == ATA_PROT_ATAPI_NODATA) ||
529 (tf->protocol == ATA_PROT_ATAPI_DMA);
530} 660}
531 661
532static inline int is_multi_taskfile(struct ata_taskfile *tf) 662static inline int is_multi_taskfile(struct ata_taskfile *tf)
diff --git a/include/linux/atmbr2684.h b/include/linux/atmbr2684.h
index 969fb6c9e1cc..52bf72affbba 100644
--- a/include/linux/atmbr2684.h
+++ b/include/linux/atmbr2684.h
@@ -14,6 +14,9 @@
14#define BR2684_MEDIA_FDDI (3) 14#define BR2684_MEDIA_FDDI (3)
15#define BR2684_MEDIA_802_6 (4) /* 802.6 */ 15#define BR2684_MEDIA_802_6 (4) /* 802.6 */
16 16
17 /* used only at device creation: */
18#define BR2684_FLAG_ROUTED (1<<16) /* payload is routed, not bridged */
19
17/* 20/*
18 * Is there FCS inbound on this VC? This currently isn't supported. 21 * Is there FCS inbound on this VC? This currently isn't supported.
19 */ 22 */
@@ -36,15 +39,22 @@
36#define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */ 39#define BR2684_ENCAPS_AUTODETECT (2) /* Unsuported */
37 40
38/* 41/*
42 * Is this VC bridged or routed?
43 */
44
45#define BR2684_PAYLOAD_ROUTED (0)
46#define BR2684_PAYLOAD_BRIDGED (1)
47
48/*
39 * This is for the ATM_NEWBACKENDIF call - these are like socket families: 49 * This is for the ATM_NEWBACKENDIF call - these are like socket families:
40 * the first element of the structure is the backend number and the rest 50 * the first element of the structure is the backend number and the rest
41 * is per-backend specific 51 * is per-backend specific
42 */ 52 */
43struct atm_newif_br2684 { 53struct atm_newif_br2684 {
44 atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */ 54 atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
45 int media; /* BR2684_MEDIA_* */ 55 int media; /* BR2684_MEDIA_*, flags in upper bits */
46 char ifname[IFNAMSIZ]; 56 char ifname[IFNAMSIZ];
47 int mtu; 57 int mtu;
48}; 58};
49 59
50/* 60/*
@@ -55,10 +65,10 @@ struct atm_newif_br2684 {
55#define BR2684_FIND_BYNUM (1) 65#define BR2684_FIND_BYNUM (1)
56#define BR2684_FIND_BYIFNAME (2) 66#define BR2684_FIND_BYIFNAME (2)
57struct br2684_if_spec { 67struct br2684_if_spec {
58 int method; /* BR2684_FIND_* */ 68 int method; /* BR2684_FIND_* */
59 union { 69 union {
60 char ifname[IFNAMSIZ]; 70 char ifname[IFNAMSIZ];
61 int devnum; 71 int devnum;
62 } spec; 72 } spec;
63}; 73};
64 74
@@ -68,16 +78,16 @@ struct br2684_if_spec {
68 * is per-backend specific 78 * is per-backend specific
69 */ 79 */
70struct atm_backend_br2684 { 80struct atm_backend_br2684 {
71 atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */ 81 atm_backend_t backend_num; /* ATM_BACKEND_BR2684 */
72 struct br2684_if_spec ifspec; 82 struct br2684_if_spec ifspec;
73 int fcs_in; /* BR2684_FCSIN_* */ 83 int fcs_in; /* BR2684_FCSIN_* */
74 int fcs_out; /* BR2684_FCSOUT_* */ 84 int fcs_out; /* BR2684_FCSOUT_* */
75 int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */ 85 int fcs_auto; /* 1: fcs_{in,out} disabled if no FCS rx'ed */
76 int encaps; /* BR2684_ENCAPS_* */ 86 int encaps; /* BR2684_ENCAPS_* */
77 int has_vpiid; /* 1: use vpn_id - Unsupported */ 87 int has_vpiid; /* 1: use vpn_id - Unsupported */
78 __u8 vpn_id[7]; 88 __u8 vpn_id[7];
79 int send_padding; /* unsupported */ 89 int send_padding; /* unsupported */
80 int min_size; /* we will pad smaller packets than this */ 90 int min_size; /* we will pad smaller packets than this */
81}; 91};
82 92
83/* 93/*
@@ -86,8 +96,8 @@ struct atm_backend_br2684 {
86 * efficient per-if in/out filters, this support will be removed 96 * efficient per-if in/out filters, this support will be removed
87 */ 97 */
88struct br2684_filter { 98struct br2684_filter {
89 __be32 prefix; /* network byte order */ 99 __be32 prefix; /* network byte order */
90 __be32 netmask; /* 0 = disable filter */ 100 __be32 netmask; /* 0 = disable filter */
91}; 101};
92 102
93struct br2684_filter_set { 103struct br2684_filter_set {
@@ -95,6 +105,11 @@ struct br2684_filter_set {
95 struct br2684_filter filter; 105 struct br2684_filter filter;
96}; 106};
97 107
108enum br2684_payload {
109 p_routed = BR2684_PAYLOAD_ROUTED,
110 p_bridged = BR2684_PAYLOAD_BRIDGED,
111};
112
98#define BR2684_SETFILT _IOW( 'a', ATMIOC_BACKEND + 0, \ 113#define BR2684_SETFILT _IOW( 'a', ATMIOC_BACKEND + 0, \
99 struct br2684_filter_set) 114 struct br2684_filter_set)
100 115
diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
index 2096e5c72827..a3d07c29d16c 100644
--- a/include/linux/atmdev.h
+++ b/include/linux/atmdev.h
@@ -359,7 +359,7 @@ struct atm_dev {
359 struct proc_dir_entry *proc_entry; /* proc entry */ 359 struct proc_dir_entry *proc_entry; /* proc entry */
360 char *proc_name; /* proc entry name */ 360 char *proc_name; /* proc entry name */
361#endif 361#endif
362 struct class_device class_dev; /* sysfs class device */ 362 struct device class_dev; /* sysfs device */
363 struct list_head dev_list; /* linkage */ 363 struct list_head dev_list; /* linkage */
364}; 364};
365 365
@@ -461,7 +461,7 @@ static inline void atm_dev_put(struct atm_dev *dev)
461 BUG_ON(!test_bit(ATM_DF_REMOVED, &dev->flags)); 461 BUG_ON(!test_bit(ATM_DF_REMOVED, &dev->flags));
462 if (dev->ops->dev_close) 462 if (dev->ops->dev_close)
463 dev->ops->dev_close(dev); 463 dev->ops->dev_close(dev);
464 class_device_put(&dev->class_dev); 464 put_device(&dev->class_dev);
465 } 465 }
466} 466}
467 467
diff --git a/include/linux/attribute_container.h b/include/linux/attribute_container.h
index 8ff274933948..f5582332af04 100644
--- a/include/linux/attribute_container.h
+++ b/include/linux/attribute_container.h
@@ -17,6 +17,7 @@ struct attribute_container {
17 struct list_head node; 17 struct list_head node;
18 struct klist containers; 18 struct klist containers;
19 struct class *class; 19 struct class *class;
20 struct attribute_group *grp;
20 struct class_device_attribute **attrs; 21 struct class_device_attribute **attrs;
21 int (*match)(struct attribute_container *, struct device *); 22 int (*match)(struct attribute_container *, struct device *);
22#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01 23#define ATTRIBUTE_CONTAINER_NO_CLASSDEVS 0x01
diff --git a/include/linux/audit.h b/include/linux/audit.h
index c68781692838..97153027207a 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -98,6 +98,7 @@
98#define AUDIT_FD_PAIR 1317 /* audit record for pipe/socketpair */ 98#define AUDIT_FD_PAIR 1317 /* audit record for pipe/socketpair */
99#define AUDIT_OBJ_PID 1318 /* ptrace target */ 99#define AUDIT_OBJ_PID 1318 /* ptrace target */
100#define AUDIT_TTY 1319 /* Input on an administrative TTY */ 100#define AUDIT_TTY 1319 /* Input on an administrative TTY */
101#define AUDIT_EOE 1320 /* End of multi-record event */
101 102
102#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ 103#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
103#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ 104#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
@@ -115,6 +116,8 @@
115#define AUDIT_MAC_IPSEC_ADDSPD 1413 /* Not used */ 116#define AUDIT_MAC_IPSEC_ADDSPD 1413 /* Not used */
116#define AUDIT_MAC_IPSEC_DELSPD 1414 /* Not used */ 117#define AUDIT_MAC_IPSEC_DELSPD 1414 /* Not used */
117#define AUDIT_MAC_IPSEC_EVENT 1415 /* Audit an IPSec event */ 118#define AUDIT_MAC_IPSEC_EVENT 1415 /* Audit an IPSec event */
119#define AUDIT_MAC_UNLBL_STCADD 1416 /* NetLabel: add a static label */
120#define AUDIT_MAC_UNLBL_STCDEL 1417 /* NetLabel: del a static label */
118 121
119#define AUDIT_FIRST_KERN_ANOM_MSG 1700 122#define AUDIT_FIRST_KERN_ANOM_MSG 1700
120#define AUDIT_LAST_KERN_ANOM_MSG 1799 123#define AUDIT_LAST_KERN_ANOM_MSG 1799
@@ -407,7 +410,8 @@ extern unsigned int audit_serial(void);
407extern void auditsc_get_stamp(struct audit_context *ctx, 410extern void auditsc_get_stamp(struct audit_context *ctx,
408 struct timespec *t, unsigned int *serial); 411 struct timespec *t, unsigned int *serial);
409extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid); 412extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid);
410extern uid_t audit_get_loginuid(struct audit_context *ctx); 413#define audit_get_loginuid(t) ((t)->loginuid)
414#define audit_get_sessionid(t) ((t)->sessionid)
411extern void audit_log_task_context(struct audit_buffer *ab); 415extern void audit_log_task_context(struct audit_buffer *ab);
412extern int __audit_ipc_obj(struct kern_ipc_perm *ipcp); 416extern int __audit_ipc_obj(struct kern_ipc_perm *ipcp);
413extern int __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode); 417extern int __audit_ipc_set_perm(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode);
@@ -486,7 +490,8 @@ extern int audit_signals;
486#define audit_inode_child(d,i,p) do { ; } while (0) 490#define audit_inode_child(d,i,p) do { ; } while (0)
487#define audit_core_dumps(i) do { ; } while (0) 491#define audit_core_dumps(i) do { ; } while (0)
488#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0) 492#define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
489#define audit_get_loginuid(c) ({ -1; }) 493#define audit_get_loginuid(t) (-1)
494#define audit_get_sessionid(t) (-1)
490#define audit_log_task_context(b) do { ; } while (0) 495#define audit_log_task_context(b) do { ; } while (0)
491#define audit_ipc_obj(i) ({ 0; }) 496#define audit_ipc_obj(i) ({ 0; })
492#define audit_ipc_set_perm(q,u,g,m) ({ 0; }) 497#define audit_ipc_set_perm(q,u,g,m) ({ 0; })
@@ -520,9 +525,11 @@ extern void audit_log_end(struct audit_buffer *ab);
520extern void audit_log_hex(struct audit_buffer *ab, 525extern void audit_log_hex(struct audit_buffer *ab,
521 const unsigned char *buf, 526 const unsigned char *buf,
522 size_t len); 527 size_t len);
523extern const char * audit_log_untrustedstring(struct audit_buffer *ab, 528extern int audit_string_contains_control(const char *string,
529 size_t len);
530extern void audit_log_untrustedstring(struct audit_buffer *ab,
524 const char *string); 531 const char *string);
525extern const char * audit_log_n_untrustedstring(struct audit_buffer *ab, 532extern void audit_log_n_untrustedstring(struct audit_buffer *ab,
526 size_t n, 533 size_t n,
527 const char *string); 534 const char *string);
528extern void audit_log_d_path(struct audit_buffer *ab, 535extern void audit_log_d_path(struct audit_buffer *ab,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index bbf906a0b419..90392a9d7a9c 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -34,85 +34,11 @@ struct sg_io_hdr;
34#define BLKDEV_MIN_RQ 4 34#define BLKDEV_MIN_RQ 4
35#define BLKDEV_MAX_RQ 128 /* Default maximum */ 35#define BLKDEV_MAX_RQ 128 /* Default maximum */
36 36
37/* 37int put_io_context(struct io_context *ioc);
38 * This is the per-process anticipatory I/O scheduler state.
39 */
40struct as_io_context {
41 spinlock_t lock;
42
43 void (*dtor)(struct as_io_context *aic); /* destructor */
44 void (*exit)(struct as_io_context *aic); /* called on task exit */
45
46 unsigned long state;
47 atomic_t nr_queued; /* queued reads & sync writes */
48 atomic_t nr_dispatched; /* number of requests gone to the drivers */
49
50 /* IO History tracking */
51 /* Thinktime */
52 unsigned long last_end_request;
53 unsigned long ttime_total;
54 unsigned long ttime_samples;
55 unsigned long ttime_mean;
56 /* Layout pattern */
57 unsigned int seek_samples;
58 sector_t last_request_pos;
59 u64 seek_total;
60 sector_t seek_mean;
61};
62
63struct cfq_queue;
64struct cfq_io_context {
65 struct rb_node rb_node;
66 void *key;
67
68 struct cfq_queue *cfqq[2];
69
70 struct io_context *ioc;
71
72 unsigned long last_end_request;
73 sector_t last_request_pos;
74
75 unsigned long ttime_total;
76 unsigned long ttime_samples;
77 unsigned long ttime_mean;
78
79 unsigned int seek_samples;
80 u64 seek_total;
81 sector_t seek_mean;
82
83 struct list_head queue_list;
84
85 void (*dtor)(struct io_context *); /* destructor */
86 void (*exit)(struct io_context *); /* called on task exit */
87};
88
89/*
90 * This is the per-process I/O subsystem state. It is refcounted and
91 * kmalloc'ed. Currently all fields are modified in process io context
92 * (apart from the atomic refcount), so require no locking.
93 */
94struct io_context {
95 atomic_t refcount;
96 struct task_struct *task;
97
98 unsigned int ioprio_changed;
99
100 /*
101 * For request batching
102 */
103 unsigned long last_waited; /* Time last woken after wait for request */
104 int nr_batch_requests; /* Number of requests left in the batch */
105
106 struct as_io_context *aic;
107 struct rb_root cic_root;
108 void *ioc_data;
109};
110
111void put_io_context(struct io_context *ioc);
112void exit_io_context(void); 38void exit_io_context(void);
113struct io_context *get_io_context(gfp_t gfp_flags, int node); 39struct io_context *get_io_context(gfp_t gfp_flags, int node);
40struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
114void copy_io_context(struct io_context **pdst, struct io_context **psrc); 41void copy_io_context(struct io_context **pdst, struct io_context **psrc);
115void swap_io_context(struct io_context **ioc1, struct io_context **ioc2);
116 42
117struct request; 43struct request;
118typedef void (rq_end_io_fn)(struct request *, int); 44typedef void (rq_end_io_fn)(struct request *, int);
@@ -143,8 +69,6 @@ enum rq_cmd_type_bits {
143 * use REQ_TYPE_SPECIAL and use rq->cmd[0] with the range of driver 69 * use REQ_TYPE_SPECIAL and use rq->cmd[0] with the range of driver
144 * private REQ_LB opcodes to differentiate what type of request this is 70 * private REQ_LB opcodes to differentiate what type of request this is
145 */ 71 */
146 REQ_TYPE_ATA_CMD,
147 REQ_TYPE_ATA_TASK,
148 REQ_TYPE_ATA_TASKFILE, 72 REQ_TYPE_ATA_TASKFILE,
149 REQ_TYPE_ATA_PC, 73 REQ_TYPE_ATA_PC,
150}; 74};
@@ -341,7 +265,6 @@ enum blk_queue_state {
341struct blk_queue_tag { 265struct blk_queue_tag {
342 struct request **tag_index; /* map of busy tags */ 266 struct request **tag_index; /* map of busy tags */
343 unsigned long *tag_map; /* bit map of free/busy tags */ 267 unsigned long *tag_map; /* bit map of free/busy tags */
344 struct list_head busy_list; /* fifo list of busy tags */
345 int busy; /* current depth */ 268 int busy; /* current depth */
346 int max_depth; /* what we will send to device */ 269 int max_depth; /* what we will send to device */
347 int real_max_depth; /* what the array can hold */ 270 int real_max_depth; /* what the array can hold */
@@ -432,9 +355,12 @@ struct request_queue
432 unsigned int max_segment_size; 355 unsigned int max_segment_size;
433 356
434 unsigned long seg_boundary_mask; 357 unsigned long seg_boundary_mask;
358 void *dma_drain_buffer;
359 unsigned int dma_drain_size;
435 unsigned int dma_alignment; 360 unsigned int dma_alignment;
436 361
437 struct blk_queue_tag *queue_tags; 362 struct blk_queue_tag *queue_tags;
363 struct list_head tag_busy_list;
438 364
439 unsigned int nr_sorted; 365 unsigned int nr_sorted;
440 unsigned int in_flight; 366 unsigned int in_flight;
@@ -539,6 +465,8 @@ enum {
539#define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA) 465#define blk_fua_rq(rq) ((rq)->cmd_flags & REQ_FUA)
540#define blk_bidi_rq(rq) ((rq)->next_rq != NULL) 466#define blk_bidi_rq(rq) ((rq)->next_rq != NULL)
541#define blk_empty_barrier(rq) (blk_barrier_rq(rq) && blk_fs_request(rq) && !(rq)->hard_nr_sectors) 467#define blk_empty_barrier(rq) (blk_barrier_rq(rq) && blk_fs_request(rq) && !(rq)->hard_nr_sectors)
468/* rq->queuelist of dequeued request must be list_empty() */
469#define blk_queued_rq(rq) (!list_empty(&(rq)->queuelist))
542 470
543#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist) 471#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
544 472
@@ -697,6 +625,7 @@ extern int blk_execute_rq(struct request_queue *, struct gendisk *,
697extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *, 625extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
698 struct request *, int, rq_end_io_fn *); 626 struct request *, int, rq_end_io_fn *);
699extern int blk_verify_command(unsigned char *, int); 627extern int blk_verify_command(unsigned char *, int);
628extern void blk_unplug(struct request_queue *q);
700 629
701static inline struct request_queue *bdev_get_queue(struct block_device *bdev) 630static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
702{ 631{
@@ -717,29 +646,35 @@ static inline void blk_run_address_space(struct address_space *mapping)
717} 646}
718 647
719/* 648/*
720 * end_request() and friends. Must be called with the request queue spinlock 649 * blk_end_request() and friends.
721 * acquired. All functions called within end_request() _must_be_ atomic. 650 * __blk_end_request() and end_request() must be called with
651 * the request queue spinlock acquired.
722 * 652 *
723 * Several drivers define their own end_request and call 653 * Several drivers define their own end_request and call
724 * end_that_request_first() and end_that_request_last() 654 * blk_end_request() for parts of the original function.
725 * for parts of the original function. This prevents 655 * This prevents code duplication in drivers.
726 * code duplication in drivers.
727 */ 656 */
728extern int end_that_request_first(struct request *, int, int); 657extern int blk_end_request(struct request *rq, int error,
729extern int end_that_request_chunk(struct request *, int, int); 658 unsigned int nr_bytes);
730extern void end_that_request_last(struct request *, int); 659extern int __blk_end_request(struct request *rq, int error,
660 unsigned int nr_bytes);
661extern int blk_end_bidi_request(struct request *rq, int error,
662 unsigned int nr_bytes, unsigned int bidi_bytes);
731extern void end_request(struct request *, int); 663extern void end_request(struct request *, int);
732extern void end_queued_request(struct request *, int); 664extern void end_queued_request(struct request *, int);
733extern void end_dequeued_request(struct request *, int); 665extern void end_dequeued_request(struct request *, int);
666extern int blk_end_request_callback(struct request *rq, int error,
667 unsigned int nr_bytes,
668 int (drv_callback)(struct request *));
734extern void blk_complete_request(struct request *); 669extern void blk_complete_request(struct request *);
735 670
736/* 671/*
737 * end_that_request_first/chunk() takes an uptodate argument. we account 672 * blk_end_request() takes bytes instead of sectors as a complete size.
738 * any value <= as an io error. 0 means -EIO for compatability reasons, 673 * blk_rq_bytes() returns bytes left to complete in the entire request.
739 * any other < 0 value is the direct error type. An uptodate value of 674 * blk_rq_cur_bytes() returns bytes left to complete in the current segment.
740 * 1 indicates successful io completion
741 */ 675 */
742#define end_io_error(uptodate) (unlikely((uptodate) <= 0)) 676extern unsigned int blk_rq_bytes(struct request *rq);
677extern unsigned int blk_rq_cur_bytes(struct request *rq);
743 678
744static inline void blkdev_dequeue_request(struct request *req) 679static inline void blkdev_dequeue_request(struct request *req)
745{ 680{
@@ -761,10 +696,13 @@ extern void blk_queue_max_hw_segments(struct request_queue *, unsigned short);
761extern void blk_queue_max_segment_size(struct request_queue *, unsigned int); 696extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
762extern void blk_queue_hardsect_size(struct request_queue *, unsigned short); 697extern void blk_queue_hardsect_size(struct request_queue *, unsigned short);
763extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b); 698extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
699extern int blk_queue_dma_drain(struct request_queue *q, void *buf,
700 unsigned int size);
764extern void blk_queue_segment_boundary(struct request_queue *, unsigned long); 701extern void blk_queue_segment_boundary(struct request_queue *, unsigned long);
765extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn); 702extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn);
766extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *); 703extern void blk_queue_merge_bvec(struct request_queue *, merge_bvec_fn *);
767extern void blk_queue_dma_alignment(struct request_queue *, int); 704extern void blk_queue_dma_alignment(struct request_queue *, int);
705extern void blk_queue_update_dma_alignment(struct request_queue *, int);
768extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *); 706extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
769extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); 707extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev);
770extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *); 708extern int blk_queue_ordered(struct request_queue *, unsigned, prepare_flush_fn *);
@@ -836,12 +774,7 @@ static inline int bdev_hardsect_size(struct block_device *bdev)
836 774
837static inline int queue_dma_alignment(struct request_queue *q) 775static inline int queue_dma_alignment(struct request_queue *q)
838{ 776{
839 int retval = 511; 777 return q ? q->dma_alignment : 511;
840
841 if (q && q->dma_alignment)
842 retval = q->dma_alignment;
843
844 return retval;
845} 778}
846 779
847/* assumes size > 256 */ 780/* assumes size > 256 */
@@ -894,6 +827,13 @@ static inline void exit_io_context(void)
894{ 827{
895} 828}
896 829
830struct io_context;
831static inline int put_io_context(struct io_context *ioc)
832{
833 return 1;
834}
835
836
897#endif /* CONFIG_BLOCK */ 837#endif /* CONFIG_BLOCK */
898 838
899#endif 839#endif
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 7e11d23ac36a..cfc3147e5cf9 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -148,7 +148,7 @@ extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
148extern void blk_trace_shutdown(struct request_queue *); 148extern void blk_trace_shutdown(struct request_queue *);
149extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *); 149extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *);
150extern int do_blk_trace_setup(struct request_queue *q, 150extern int do_blk_trace_setup(struct request_queue *q,
151 struct block_device *bdev, struct blk_user_trace_setup *buts); 151 char *name, dev_t dev, struct blk_user_trace_setup *buts);
152 152
153 153
154/** 154/**
@@ -282,6 +282,11 @@ static inline void blk_add_trace_remap(struct request_queue *q, struct bio *bio,
282 __blk_add_trace(bt, from, bio->bi_size, bio->bi_rw, BLK_TA_REMAP, !bio_flagged(bio, BIO_UPTODATE), sizeof(r), &r); 282 __blk_add_trace(bt, from, bio->bi_size, bio->bi_rw, BLK_TA_REMAP, !bio_flagged(bio, BIO_UPTODATE), sizeof(r), &r);
283} 283}
284 284
285extern int blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
286 char __user *arg);
287extern int blk_trace_startstop(struct request_queue *q, int start);
288extern int blk_trace_remove(struct request_queue *q);
289
285#else /* !CONFIG_BLK_DEV_IO_TRACE */ 290#else /* !CONFIG_BLK_DEV_IO_TRACE */
286#define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY) 291#define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY)
287#define blk_trace_shutdown(q) do { } while (0) 292#define blk_trace_shutdown(q) do { } while (0)
@@ -290,7 +295,10 @@ static inline void blk_add_trace_remap(struct request_queue *q, struct bio *bio,
290#define blk_add_trace_generic(q, rq, rw, what) do { } while (0) 295#define blk_add_trace_generic(q, rq, rw, what) do { } while (0)
291#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0) 296#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0)
292#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0) 297#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0)
293#define do_blk_trace_setup(q, bdev, buts) (-ENOTTY) 298#define do_blk_trace_setup(q, name, dev, buts) (-ENOTTY)
299#define blk_trace_setup(q, name, dev, arg) (-ENOTTY)
300#define blk_trace_startstop(q, start) (-ENOTTY)
301#define blk_trace_remove(q) (-ENOTTY)
294#endif /* CONFIG_BLK_DEV_IO_TRACE */ 302#endif /* CONFIG_BLK_DEV_IO_TRACE */
295#endif /* __KERNEL__ */ 303#endif /* __KERNEL__ */
296#endif 304#endif
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index c83534ee1e79..0365ec9fc0c9 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -59,7 +59,6 @@ extern void *__alloc_bootmem_core(struct bootmem_data *bdata,
59 unsigned long align, 59 unsigned long align,
60 unsigned long goal, 60 unsigned long goal,
61 unsigned long limit); 61 unsigned long limit);
62extern void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size);
63 62
64#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE 63#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
65extern void reserve_bootmem(unsigned long addr, unsigned long size); 64extern void reserve_bootmem(unsigned long addr, unsigned long size);
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
index da0d83fbadc0..e98801f06dcc 100644
--- a/include/linux/buffer_head.h
+++ b/include/linux/buffer_head.h
@@ -192,6 +192,8 @@ int sync_dirty_buffer(struct buffer_head *bh);
192int submit_bh(int, struct buffer_head *); 192int submit_bh(int, struct buffer_head *);
193void write_boundary_block(struct block_device *bdev, 193void write_boundary_block(struct block_device *bdev,
194 sector_t bblock, unsigned blocksize); 194 sector_t bblock, unsigned blocksize);
195int bh_uptodate_or_lock(struct buffer_head *bh);
196int bh_submit_read(struct buffer_head *bh);
195 197
196extern int buffer_heads_over_limit; 198extern int buffer_heads_over_limit;
197 199
diff --git a/include/linux/can.h b/include/linux/can.h
new file mode 100644
index 000000000000..d18333302cbd
--- /dev/null
+++ b/include/linux/can.h
@@ -0,0 +1,111 @@
1/*
2 * linux/can.h
3 *
4 * Definitions for CAN network layer (socket addr / CAN frame / CAN filter)
5 *
6 * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Urs Thuermann <urs.thuermann@volkswagen.de>
8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9 * All rights reserved.
10 *
11 * Send feedback to <socketcan-users@lists.berlios.de>
12 *
13 */
14
15#ifndef CAN_H
16#define CAN_H
17
18#include <linux/types.h>
19#include <linux/socket.h>
20
21/* controller area network (CAN) kernel definitions */
22
23/* special address description flags for the CAN_ID */
24#define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */
25#define CAN_RTR_FLAG 0x40000000U /* remote transmission request */
26#define CAN_ERR_FLAG 0x20000000U /* error frame */
27
28/* valid bits in CAN ID for frame formats */
29#define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */
30#define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */
31#define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */
32
33/*
34 * Controller Area Network Identifier structure
35 *
36 * bit 0-28 : CAN identifier (11/29 bit)
37 * bit 29 : error frame flag (0 = data frame, 1 = error frame)
38 * bit 30 : remote transmission request flag (1 = rtr frame)
39 * bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
40 */
41typedef __u32 canid_t;
42
43/*
44 * Controller Area Network Error Frame Mask structure
45 *
46 * bit 0-28 : error class mask (see include/linux/can/error.h)
47 * bit 29-31 : set to zero
48 */
49typedef __u32 can_err_mask_t;
50
51/**
52 * struct can_frame - basic CAN frame structure
53 * @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above.
54 * @can_dlc: the data length field of the CAN frame
55 * @data: the CAN frame payload.
56 */
57struct can_frame {
58 canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
59 __u8 can_dlc; /* data length code: 0 .. 8 */
60 __u8 data[8] __attribute__((aligned(8)));
61};
62
63/* particular protocols of the protocol family PF_CAN */
64#define CAN_RAW 1 /* RAW sockets */
65#define CAN_BCM 2 /* Broadcast Manager */
66#define CAN_TP16 3 /* VAG Transport Protocol v1.6 */
67#define CAN_TP20 4 /* VAG Transport Protocol v2.0 */
68#define CAN_MCNET 5 /* Bosch MCNet */
69#define CAN_ISOTP 6 /* ISO 15765-2 Transport Protocol */
70#define CAN_NPROTO 7
71
72#define SOL_CAN_BASE 100
73
74/**
75 * struct sockaddr_can - the sockaddr structure for CAN sockets
76 * @can_family: address family number AF_CAN.
77 * @can_ifindex: CAN network interface index.
78 * @can_addr: protocol specific address information
79 */
80struct sockaddr_can {
81 sa_family_t can_family;
82 int can_ifindex;
83 union {
84 /* transport protocol class address information (e.g. ISOTP) */
85 struct { canid_t rx_id, tx_id; } tp;
86
87 /* reserved for future CAN protocols address information */
88 } can_addr;
89};
90
91/**
92 * struct can_filter - CAN ID based filter in can_register().
93 * @can_id: relevant bits of CAN ID which are not masked out.
94 * @can_mask: CAN mask (see description)
95 *
96 * Description:
97 * A filter matches, when
98 *
99 * <received_can_id> & mask == can_id & mask
100 *
101 * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can
102 * filter for error frames (CAN_ERR_FLAG bit set in mask).
103 */
104struct can_filter {
105 canid_t can_id;
106 canid_t can_mask;
107};
108
109#define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */
110
111#endif /* CAN_H */
diff --git a/include/linux/can/Kbuild b/include/linux/can/Kbuild
new file mode 100644
index 000000000000..eff898aac02b
--- /dev/null
+++ b/include/linux/can/Kbuild
@@ -0,0 +1,3 @@
1header-y += raw.h
2header-y += bcm.h
3header-y += error.h
diff --git a/include/linux/can/bcm.h b/include/linux/can/bcm.h
new file mode 100644
index 000000000000..7f293273c444
--- /dev/null
+++ b/include/linux/can/bcm.h
@@ -0,0 +1,65 @@
1/*
2 * linux/can/bcm.h
3 *
4 * Definitions for CAN Broadcast Manager (BCM)
5 *
6 * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
8 * All rights reserved.
9 *
10 * Send feedback to <socketcan-users@lists.berlios.de>
11 *
12 */
13
14#ifndef CAN_BCM_H
15#define CAN_BCM_H
16
17/**
18 * struct bcm_msg_head - head of messages to/from the broadcast manager
19 * @opcode: opcode, see enum below.
20 * @flags: special flags, see below.
21 * @count: number of frames to send before changing interval.
22 * @ival1: interval for the first @count frames.
23 * @ival2: interval for the following frames.
24 * @can_id: CAN ID of frames to be sent or received.
25 * @nframes: number of frames appended to the message head.
26 * @frames: array of CAN frames.
27 */
28struct bcm_msg_head {
29 __u32 opcode;
30 __u32 flags;
31 __u32 count;
32 struct timeval ival1, ival2;
33 canid_t can_id;
34 __u32 nframes;
35 struct can_frame frames[0];
36};
37
38enum {
39 TX_SETUP = 1, /* create (cyclic) transmission task */
40 TX_DELETE, /* remove (cyclic) transmission task */
41 TX_READ, /* read properties of (cyclic) transmission task */
42 TX_SEND, /* send one CAN frame */
43 RX_SETUP, /* create RX content filter subscription */
44 RX_DELETE, /* remove RX content filter subscription */
45 RX_READ, /* read properties of RX content filter subscription */
46 TX_STATUS, /* reply to TX_READ request */
47 TX_EXPIRED, /* notification on performed transmissions (count=0) */
48 RX_STATUS, /* reply to RX_READ request */
49 RX_TIMEOUT, /* cyclic message is absent */
50 RX_CHANGED /* updated CAN frame (detected content change) */
51};
52
53#define SETTIMER 0x0001
54#define STARTTIMER 0x0002
55#define TX_COUNTEVT 0x0004
56#define TX_ANNOUNCE 0x0008
57#define TX_CP_CAN_ID 0x0010
58#define RX_FILTER_ID 0x0020
59#define RX_CHECK_DLC 0x0040
60#define RX_NO_AUTOTIMER 0x0080
61#define RX_ANNOUNCE_RESUME 0x0100
62#define TX_RESET_MULTI_IDX 0x0200
63#define RX_RTR_FRAME 0x0400
64
65#endif /* CAN_BCM_H */
diff --git a/include/linux/can/core.h b/include/linux/can/core.h
new file mode 100644
index 000000000000..e9ca210ffa5b
--- /dev/null
+++ b/include/linux/can/core.h
@@ -0,0 +1,64 @@
1/*
2 * linux/can/core.h
3 *
4 * Protoypes and definitions for CAN protocol modules using the PF_CAN core
5 *
6 * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Urs Thuermann <urs.thuermann@volkswagen.de>
8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9 * All rights reserved.
10 *
11 * Send feedback to <socketcan-users@lists.berlios.de>
12 *
13 */
14
15#ifndef CAN_CORE_H
16#define CAN_CORE_H
17
18#include <linux/can.h>
19#include <linux/skbuff.h>
20#include <linux/netdevice.h>
21
22#define CAN_VERSION "20071116"
23
24/* increment this number each time you change some user-space interface */
25#define CAN_ABI_VERSION "8"
26
27#define CAN_VERSION_STRING "rev " CAN_VERSION " abi " CAN_ABI_VERSION
28
29#define DNAME(dev) ((dev) ? (dev)->name : "any")
30
31/**
32 * struct can_proto - CAN protocol structure
33 * @type: type argument in socket() syscall, e.g. SOCK_DGRAM.
34 * @protocol: protocol number in socket() syscall.
35 * @capability: capability needed to open the socket, or -1 for no restriction.
36 * @ops: pointer to struct proto_ops for sock->ops.
37 * @prot: pointer to struct proto structure.
38 */
39struct can_proto {
40 int type;
41 int protocol;
42 int capability;
43 struct proto_ops *ops;
44 struct proto *prot;
45};
46
47/* function prototypes for the CAN networklayer core (af_can.c) */
48
49extern int can_proto_register(struct can_proto *cp);
50extern void can_proto_unregister(struct can_proto *cp);
51
52extern int can_rx_register(struct net_device *dev, canid_t can_id,
53 canid_t mask,
54 void (*func)(struct sk_buff *, void *),
55 void *data, char *ident);
56
57extern void can_rx_unregister(struct net_device *dev, canid_t can_id,
58 canid_t mask,
59 void (*func)(struct sk_buff *, void *),
60 void *data);
61
62extern int can_send(struct sk_buff *skb, int loop);
63
64#endif /* CAN_CORE_H */
diff --git a/include/linux/can/error.h b/include/linux/can/error.h
new file mode 100644
index 000000000000..d4127fd9e681
--- /dev/null
+++ b/include/linux/can/error.h
@@ -0,0 +1,93 @@
1/*
2 * linux/can/error.h
3 *
4 * Definitions of the CAN error frame to be filtered and passed to the user.
5 *
6 * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
8 * All rights reserved.
9 *
10 * Send feedback to <socketcan-users@lists.berlios.de>
11 *
12 */
13
14#ifndef CAN_ERROR_H
15#define CAN_ERROR_H
16
17#define CAN_ERR_DLC 8 /* dlc for error frames */
18
19/* error class (mask) in can_id */
20#define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */
21#define CAN_ERR_LOSTARB 0x00000002U /* lost arbitration / data[0] */
22#define CAN_ERR_CRTL 0x00000004U /* controller problems / data[1] */
23#define CAN_ERR_PROT 0x00000008U /* protocol violations / data[2..3] */
24#define CAN_ERR_TRX 0x00000010U /* transceiver status / data[4] */
25#define CAN_ERR_ACK 0x00000020U /* received no ACK on transmission */
26#define CAN_ERR_BUSOFF 0x00000040U /* bus off */
27#define CAN_ERR_BUSERROR 0x00000080U /* bus error (may flood!) */
28#define CAN_ERR_RESTARTED 0x00000100U /* controller restarted */
29
30/* arbitration lost in bit ... / data[0] */
31#define CAN_ERR_LOSTARB_UNSPEC 0x00 /* unspecified */
32 /* else bit number in bitstream */
33
34/* error status of CAN-controller / data[1] */
35#define CAN_ERR_CRTL_UNSPEC 0x00 /* unspecified */
36#define CAN_ERR_CRTL_RX_OVERFLOW 0x01 /* RX buffer overflow */
37#define CAN_ERR_CRTL_TX_OVERFLOW 0x02 /* TX buffer overflow */
38#define CAN_ERR_CRTL_RX_WARNING 0x04 /* reached warning level for RX errors */
39#define CAN_ERR_CRTL_TX_WARNING 0x08 /* reached warning level for TX errors */
40#define CAN_ERR_CRTL_RX_PASSIVE 0x10 /* reached error passive status RX */
41#define CAN_ERR_CRTL_TX_PASSIVE 0x20 /* reached error passive status TX */
42 /* (at least one error counter exceeds */
43 /* the protocol-defined level of 127) */
44
45/* error in CAN protocol (type) / data[2] */
46#define CAN_ERR_PROT_UNSPEC 0x00 /* unspecified */
47#define CAN_ERR_PROT_BIT 0x01 /* single bit error */
48#define CAN_ERR_PROT_FORM 0x02 /* frame format error */
49#define CAN_ERR_PROT_STUFF 0x04 /* bit stuffing error */
50#define CAN_ERR_PROT_BIT0 0x08 /* unable to send dominant bit */
51#define CAN_ERR_PROT_BIT1 0x10 /* unable to send recessive bit */
52#define CAN_ERR_PROT_OVERLOAD 0x20 /* bus overload */
53#define CAN_ERR_PROT_ACTIVE 0x40 /* active error announcement */
54#define CAN_ERR_PROT_TX 0x80 /* error occured on transmission */
55
56/* error in CAN protocol (location) / data[3] */
57#define CAN_ERR_PROT_LOC_UNSPEC 0x00 /* unspecified */
58#define CAN_ERR_PROT_LOC_SOF 0x03 /* start of frame */
59#define CAN_ERR_PROT_LOC_ID28_21 0x02 /* ID bits 28 - 21 (SFF: 10 - 3) */
60#define CAN_ERR_PROT_LOC_ID20_18 0x06 /* ID bits 20 - 18 (SFF: 2 - 0 )*/
61#define CAN_ERR_PROT_LOC_SRTR 0x04 /* substitute RTR (SFF: RTR) */
62#define CAN_ERR_PROT_LOC_IDE 0x05 /* identifier extension */
63#define CAN_ERR_PROT_LOC_ID17_13 0x07 /* ID bits 17-13 */
64#define CAN_ERR_PROT_LOC_ID12_05 0x0F /* ID bits 12-5 */
65#define CAN_ERR_PROT_LOC_ID04_00 0x0E /* ID bits 4-0 */
66#define CAN_ERR_PROT_LOC_RTR 0x0C /* RTR */
67#define CAN_ERR_PROT_LOC_RES1 0x0D /* reserved bit 1 */
68#define CAN_ERR_PROT_LOC_RES0 0x09 /* reserved bit 0 */
69#define CAN_ERR_PROT_LOC_DLC 0x0B /* data length code */
70#define CAN_ERR_PROT_LOC_DATA 0x0A /* data section */
71#define CAN_ERR_PROT_LOC_CRC_SEQ 0x08 /* CRC sequence */
72#define CAN_ERR_PROT_LOC_CRC_DEL 0x18 /* CRC delimiter */
73#define CAN_ERR_PROT_LOC_ACK 0x19 /* ACK slot */
74#define CAN_ERR_PROT_LOC_ACK_DEL 0x1B /* ACK delimiter */
75#define CAN_ERR_PROT_LOC_EOF 0x1A /* end of frame */
76#define CAN_ERR_PROT_LOC_INTERM 0x12 /* intermission */
77
78/* error status of CAN-transceiver / data[4] */
79/* CANH CANL */
80#define CAN_ERR_TRX_UNSPEC 0x00 /* 0000 0000 */
81#define CAN_ERR_TRX_CANH_NO_WIRE 0x04 /* 0000 0100 */
82#define CAN_ERR_TRX_CANH_SHORT_TO_BAT 0x05 /* 0000 0101 */
83#define CAN_ERR_TRX_CANH_SHORT_TO_VCC 0x06 /* 0000 0110 */
84#define CAN_ERR_TRX_CANH_SHORT_TO_GND 0x07 /* 0000 0111 */
85#define CAN_ERR_TRX_CANL_NO_WIRE 0x40 /* 0100 0000 */
86#define CAN_ERR_TRX_CANL_SHORT_TO_BAT 0x50 /* 0101 0000 */
87#define CAN_ERR_TRX_CANL_SHORT_TO_VCC 0x60 /* 0110 0000 */
88#define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 /* 0111 0000 */
89#define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
90
91/* controller specific additional information / data[5..7] */
92
93#endif /* CAN_ERROR_H */
diff --git a/include/linux/can/raw.h b/include/linux/can/raw.h
new file mode 100644
index 000000000000..b2a0f87492c5
--- /dev/null
+++ b/include/linux/can/raw.h
@@ -0,0 +1,31 @@
1/*
2 * linux/can/raw.h
3 *
4 * Definitions for raw CAN sockets
5 *
6 * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Urs Thuermann <urs.thuermann@volkswagen.de>
8 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
9 * All rights reserved.
10 *
11 * Send feedback to <socketcan-users@lists.berlios.de>
12 *
13 */
14
15#ifndef CAN_RAW_H
16#define CAN_RAW_H
17
18#include <linux/can.h>
19
20#define SOL_CAN_RAW (SOL_CAN_BASE + CAN_RAW)
21
22/* for socket options affecting the socket (not the global system) */
23
24enum {
25 CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */
26 CAN_RAW_ERR_FILTER, /* set filter for error frames */
27 CAN_RAW_LOOPBACK, /* local loopback (default:on) */
28 CAN_RAW_RECV_OWN_MSGS /* receive my own msgs (default:off) */
29};
30
31#endif
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index c6d3e22c0624..a5cd2047624e 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -451,6 +451,7 @@ struct cdrom_generic_command
451#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e 451#define GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
452#define GPCMD_READ_10 0x28 452#define GPCMD_READ_10 0x28
453#define GPCMD_READ_12 0xa8 453#define GPCMD_READ_12 0xa8
454#define GPCMD_READ_BUFFER 0x3c
454#define GPCMD_READ_BUFFER_CAPACITY 0x5c 455#define GPCMD_READ_BUFFER_CAPACITY 0x5c
455#define GPCMD_READ_CDVD_CAPACITY 0x25 456#define GPCMD_READ_CDVD_CAPACITY 0x25
456#define GPCMD_READ_CD 0xbe 457#define GPCMD_READ_CD 0xbe
@@ -480,7 +481,9 @@ struct cdrom_generic_command
480#define GPCMD_TEST_UNIT_READY 0x00 481#define GPCMD_TEST_UNIT_READY 0x00
481#define GPCMD_VERIFY_10 0x2f 482#define GPCMD_VERIFY_10 0x2f
482#define GPCMD_WRITE_10 0x2a 483#define GPCMD_WRITE_10 0x2a
484#define GPCMD_WRITE_12 0xaa
483#define GPCMD_WRITE_AND_VERIFY_10 0x2e 485#define GPCMD_WRITE_AND_VERIFY_10 0x2e
486#define GPCMD_WRITE_BUFFER 0x3b
484/* This is listed as optional in ATAPI 2.6, but is (curiously) 487/* This is listed as optional in ATAPI 2.6, but is (curiously)
485 * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji 488 * missing from Mt. Fuji, Table 57. It _is_ mentioned in Mt. Fuji
486 * Table 377 as an MMC command for SCSi devices though... Most ATAPI 489 * Table 377 as an MMC command for SCSi devices though... Most ATAPI
@@ -1184,6 +1187,20 @@ struct media_event_desc {
1184 1187
1185extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med); 1188extern int cdrom_get_media_event(struct cdrom_device_info *cdi, struct media_event_desc *med);
1186 1189
1190static inline void lba_to_msf(int lba, u8 *m, u8 *s, u8 *f)
1191{
1192 lba += CD_MSF_OFFSET;
1193 lba &= 0xffffff; /* negative lbas use only 24 bits */
1194 *m = lba / (CD_SECS * CD_FRAMES);
1195 lba %= (CD_SECS * CD_FRAMES);
1196 *s = lba / CD_FRAMES;
1197 *f = lba % CD_FRAMES;
1198}
1199
1200static inline int msf_to_lba(u8 m, u8 s, u8 f)
1201{
1202 return (((m * CD_SECS) + s) * CD_FRAMES + f) - CD_MSF_OFFSET;
1203}
1187#endif /* End of kernel only stuff */ 1204#endif /* End of kernel only stuff */
1188 1205
1189#endif /* _LINUX_CDROM_H */ 1206#endif /* _LINUX_CDROM_H */
diff --git a/include/linux/cgroup_subsys.h b/include/linux/cgroup_subsys.h
index 0b9bfbde8168..9ec43186ba80 100644
--- a/include/linux/cgroup_subsys.h
+++ b/include/linux/cgroup_subsys.h
@@ -13,12 +13,6 @@ SUBSYS(cpuset)
13 13
14/* */ 14/* */
15 15
16#ifdef CONFIG_CGROUP_CPUACCT
17SUBSYS(cpuacct)
18#endif
19
20/* */
21
22#ifdef CONFIG_CGROUP_DEBUG 16#ifdef CONFIG_CGROUP_DEBUG
23SUBSYS(debug) 17SUBSYS(debug)
24#endif 18#endif
@@ -36,3 +30,10 @@ SUBSYS(cpu_cgroup)
36#endif 30#endif
37 31
38/* */ 32/* */
33
34#ifdef CONFIG_CGROUP_CPUACCT
35SUBSYS(cpuacct)
36#endif
37
38/* */
39
diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h
index 107787aacb64..85778a4b1209 100644
--- a/include/linux/clocksource.h
+++ b/include/linux/clocksource.h
@@ -103,7 +103,7 @@ struct clocksource {
103#define CLOCK_SOURCE_VALID_FOR_HRES 0x20 103#define CLOCK_SOURCE_VALID_FOR_HRES 0x20
104 104
105/* simplify initialization of mask field */ 105/* simplify initialization of mask field */
106#define CLOCKSOURCE_MASK(bits) (cycle_t)(bits<64 ? ((1ULL<<bits)-1) : -1) 106#define CLOCKSOURCE_MASK(bits) (cycle_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
107 107
108/** 108/**
109 * clocksource_khz2mult - calculates mult from khz and shift 109 * clocksource_khz2mult - calculates mult from khz and shift
@@ -215,6 +215,7 @@ static inline void clocksource_calculate_interval(struct clocksource *c,
215 215
216/* used to install a new clocksource */ 216/* used to install a new clocksource */
217extern int clocksource_register(struct clocksource*); 217extern int clocksource_register(struct clocksource*);
218extern void clocksource_unregister(struct clocksource*);
218extern struct clocksource* clocksource_get_next(void); 219extern struct clocksource* clocksource_get_next(void);
219extern void clocksource_change_rating(struct clocksource *cs, int rating); 220extern void clocksource_change_rating(struct clocksource *cs, int rating);
220extern void clocksource_resume(void); 221extern void clocksource_resume(void);
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 0e69d2cf14aa..d38655f2be70 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -191,6 +191,10 @@ asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
191 compat_ulong_t __user *outp, compat_ulong_t __user *exp, 191 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
192 struct compat_timeval __user *tvp); 192 struct compat_timeval __user *tvp);
193 193
194asmlinkage long compat_sys_wait4(compat_pid_t pid,
195 compat_uint_t *stat_addr, int options,
196 struct compat_rusage *ru);
197
194#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) 198#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
195 199
196#define BITS_TO_COMPAT_LONGS(bits) \ 200#define BITS_TO_COMPAT_LONGS(bits) \
@@ -239,6 +243,17 @@ asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
239 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes, 243 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
240 const compat_ulong_t __user *new_nodes); 244 const compat_ulong_t __user *new_nodes);
241 245
246extern int compat_ptrace_request(struct task_struct *child,
247 compat_long_t request,
248 compat_ulong_t addr, compat_ulong_t data);
249
250#ifdef __ARCH_WANT_COMPAT_SYS_PTRACE
251extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
252 compat_ulong_t addr, compat_ulong_t data);
253asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
254 compat_long_t addr, compat_long_t data);
255#endif /* __ARCH_WANT_COMPAT_SYS_PTRACE */
256
242/* 257/*
243 * epoll (fs/eventpoll.c) compat bits follow ... 258 * epoll (fs/eventpoll.c) compat bits follow ...
244 */ 259 */
diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h
index 2d8c0f48f55e..e5eb795f78a1 100644
--- a/include/linux/compiler-gcc3.h
+++ b/include/linux/compiler-gcc3.h
@@ -7,10 +7,8 @@
7 7
8#if __GNUC_MINOR__ >= 3 8#if __GNUC_MINOR__ >= 3
9# define __used __attribute__((__used__)) 9# define __used __attribute__((__used__))
10# define __attribute_used__ __used /* deprecated */
11#else 10#else
12# define __used __attribute__((__unused__)) 11# define __used __attribute__((__unused__))
13# define __attribute_used__ __used /* deprecated */
14#endif 12#endif
15 13
16#if __GNUC_MINOR__ >= 4 14#if __GNUC_MINOR__ >= 4
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index ee7ca5de970c..0ab3a3232330 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -15,7 +15,6 @@
15#endif 15#endif
16 16
17#define __used __attribute__((__used__)) 17#define __used __attribute__((__used__))
18#define __attribute_used__ __used /* deprecated */
19#define __must_check __attribute__((warn_unused_result)) 18#define __must_check __attribute__((warn_unused_result))
20#define __compiler_offsetof(a,b) __builtin_offsetof(a,b) 19#define __compiler_offsetof(a,b) __builtin_offsetof(a,b)
21#define __always_inline inline __attribute__((always_inline)) 20#define __always_inline inline __attribute__((always_inline))
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index c68b67b86ef1..d0e17e1657dc 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -126,10 +126,6 @@ extern void __chk_io_ptr(const volatile void __iomem *);
126 * Mark functions that are referenced only in inline assembly as __used so 126 * Mark functions that are referenced only in inline assembly as __used so
127 * the code is emitted even though it appears to be unreferenced. 127 * the code is emitted even though it appears to be unreferenced.
128 */ 128 */
129#ifndef __attribute_used__
130# define __attribute_used__ /* deprecated */
131#endif
132
133#ifndef __used 129#ifndef __used
134# define __used /* unimplemented */ 130# define __used /* unimplemented */
135#endif 131#endif
@@ -175,4 +171,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
175#define __cold 171#define __cold
176#endif 172#endif
177 173
174/* Simple shorthand for a section definition */
175#ifndef __section
176# define __section(S) __attribute__ ((__section__(#S)))
177#endif
178
178#endif /* __LINUX_COMPILER_H */ 179#endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/completion.h b/include/linux/completion.h
index 33d6aaf94447..d2961b66d53d 100644
--- a/include/linux/completion.h
+++ b/include/linux/completion.h
@@ -44,6 +44,7 @@ static inline void init_completion(struct completion *x)
44 44
45extern void wait_for_completion(struct completion *); 45extern void wait_for_completion(struct completion *);
46extern int wait_for_completion_interruptible(struct completion *x); 46extern int wait_for_completion_interruptible(struct completion *x);
47extern int wait_for_completion_killable(struct completion *x);
47extern unsigned long wait_for_completion_timeout(struct completion *x, 48extern unsigned long wait_for_completion_timeout(struct completion *x,
48 unsigned long timeout); 49 unsigned long timeout);
49extern unsigned long wait_for_completion_interruptible_timeout( 50extern unsigned long wait_for_completion_interruptible_timeout(
diff --git a/include/linux/connector.h b/include/linux/connector.h
index 13fc4541bf23..da6dd957f908 100644
--- a/include/linux/connector.h
+++ b/include/linux/connector.h
@@ -112,7 +112,6 @@ struct cn_queue_dev {
112 struct list_head queue_list; 112 struct list_head queue_list;
113 spinlock_t queue_lock; 113 spinlock_t queue_lock;
114 114
115 int netlink_groups;
116 struct sock *nls; 115 struct sock *nls;
117}; 116};
118 117
@@ -133,15 +132,13 @@ struct cn_callback_data {
133 132
134struct cn_callback_entry { 133struct cn_callback_entry {
135 struct list_head callback_entry; 134 struct list_head callback_entry;
136 struct cn_callback *cb;
137 struct work_struct work; 135 struct work_struct work;
138 struct cn_queue_dev *pdev; 136 struct cn_queue_dev *pdev;
139 137
140 struct cn_callback_id id; 138 struct cn_callback_id id;
141 struct cn_callback_data data; 139 struct cn_callback_data data;
142 140
143 int seq, group; 141 u32 seq, group;
144 struct sock *nls;
145}; 142};
146 143
147struct cn_ctl_entry { 144struct cn_ctl_entry {
diff --git a/include/linux/const.h b/include/linux/const.h
index 07b300bfe34b..c22c707c455d 100644
--- a/include/linux/const.h
+++ b/include/linux/const.h
@@ -7,13 +7,18 @@
7 * C code. Therefore we cannot annotate them always with 7 * C code. Therefore we cannot annotate them always with
8 * 'UL' and other type specifiers unilaterally. We 8 * 'UL' and other type specifiers unilaterally. We
9 * use the following macros to deal with this. 9 * use the following macros to deal with this.
10 *
11 * Similarly, _AT() will cast an expression with a type in C, but
12 * leave it unchanged in asm.
10 */ 13 */
11 14
12#ifdef __ASSEMBLY__ 15#ifdef __ASSEMBLY__
13#define _AC(X,Y) X 16#define _AC(X,Y) X
17#define _AT(T,X) X
14#else 18#else
15#define __AC(X,Y) (X##Y) 19#define __AC(X,Y) (X##Y)
16#define _AC(X,Y) __AC(X,Y) 20#define _AC(X,Y) __AC(X,Y)
21#define _AT(T,X) ((T)(X))
17#endif 22#endif
18 23
19#endif /* !(_LINUX_CONST_H) */ 24#endif /* !(_LINUX_CONST_H) */
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index b79c57569367..0be8d65bc3c8 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -71,18 +71,27 @@ static inline void unregister_cpu_notifier(struct notifier_block *nb)
71 71
72int cpu_up(unsigned int cpu); 72int cpu_up(unsigned int cpu);
73 73
74extern void cpu_hotplug_init(void);
75
74#else 76#else
75 77
76static inline int register_cpu_notifier(struct notifier_block *nb) 78static inline int register_cpu_notifier(struct notifier_block *nb)
77{ 79{
78 return 0; 80 return 0;
79} 81}
82
80static inline void unregister_cpu_notifier(struct notifier_block *nb) 83static inline void unregister_cpu_notifier(struct notifier_block *nb)
81{ 84{
82} 85}
83 86
87static inline void cpu_hotplug_init(void)
88{
89}
90
84#endif /* CONFIG_SMP */ 91#endif /* CONFIG_SMP */
85extern struct sysdev_class cpu_sysdev_class; 92extern struct sysdev_class cpu_sysdev_class;
93extern void cpu_maps_update_begin(void);
94extern void cpu_maps_update_done(void);
86 95
87#ifdef CONFIG_HOTPLUG_CPU 96#ifdef CONFIG_HOTPLUG_CPU
88/* Stop CPUs going up and down. */ 97/* Stop CPUs going up and down. */
@@ -97,8 +106,8 @@ static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
97 mutex_unlock(cpu_hp_mutex); 106 mutex_unlock(cpu_hp_mutex);
98} 107}
99 108
100extern void lock_cpu_hotplug(void); 109extern void get_online_cpus(void);
101extern void unlock_cpu_hotplug(void); 110extern void put_online_cpus(void);
102#define hotcpu_notifier(fn, pri) { \ 111#define hotcpu_notifier(fn, pri) { \
103 static struct notifier_block fn##_nb = \ 112 static struct notifier_block fn##_nb = \
104 { .notifier_call = fn, .priority = pri }; \ 113 { .notifier_call = fn, .priority = pri }; \
@@ -107,7 +116,6 @@ extern void unlock_cpu_hotplug(void);
107#define register_hotcpu_notifier(nb) register_cpu_notifier(nb) 116#define register_hotcpu_notifier(nb) register_cpu_notifier(nb)
108#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb) 117#define unregister_hotcpu_notifier(nb) unregister_cpu_notifier(nb)
109int cpu_down(unsigned int cpu); 118int cpu_down(unsigned int cpu);
110#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
111 119
112#else /* CONFIG_HOTPLUG_CPU */ 120#else /* CONFIG_HOTPLUG_CPU */
113 121
@@ -116,15 +124,12 @@ static inline void cpuhotplug_mutex_lock(struct mutex *cpu_hp_mutex)
116static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex) 124static inline void cpuhotplug_mutex_unlock(struct mutex *cpu_hp_mutex)
117{ } 125{ }
118 126
119#define lock_cpu_hotplug() do { } while (0) 127#define get_online_cpus() do { } while (0)
120#define unlock_cpu_hotplug() do { } while (0) 128#define put_online_cpus() do { } while (0)
121#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0) 129#define hotcpu_notifier(fn, pri) do { (void)(fn); } while (0)
122/* These aren't inline functions due to a GCC bug. */ 130/* These aren't inline functions due to a GCC bug. */
123#define register_hotcpu_notifier(nb) ({ (void)(nb); 0; }) 131#define register_hotcpu_notifier(nb) ({ (void)(nb); 0; })
124#define unregister_hotcpu_notifier(nb) ({ (void)(nb); }) 132#define unregister_hotcpu_notifier(nb) ({ (void)(nb); })
125
126/* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
127static inline int cpu_is_offline(int cpu) { return 0; }
128#endif /* CONFIG_HOTPLUG_CPU */ 133#endif /* CONFIG_HOTPLUG_CPU */
129 134
130#ifdef CONFIG_PM_SLEEP_SMP 135#ifdef CONFIG_PM_SLEEP_SMP
diff --git a/include/linux/cpu_acct.h b/include/linux/cpu_acct.h
deleted file mode 100644
index 6b5fd8a66c8d..000000000000
--- a/include/linux/cpu_acct.h
+++ /dev/null
@@ -1,14 +0,0 @@
1
2#ifndef _LINUX_CPU_ACCT_H
3#define _LINUX_CPU_ACCT_H
4
5#include <linux/cgroup.h>
6#include <asm/cputime.h>
7
8#ifdef CONFIG_CGROUP_CPUACCT
9extern void cpuacct_charge(struct task_struct *, cputime_t cputime);
10#else
11static void inline cpuacct_charge(struct task_struct *p, cputime_t cputime) {}
12#endif
13
14#endif
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 16a51546db44..c4e00161a247 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -92,6 +92,7 @@ struct cpuidle_device {
92 struct kobject kobj; 92 struct kobject kobj;
93 struct completion kobj_unregister; 93 struct completion kobj_unregister;
94 void *governor_data; 94 void *governor_data;
95 struct cpuidle_state *safe_state;
95}; 96};
96 97
97DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices); 98DECLARE_PER_CPU(struct cpuidle_device *, cpuidle_devices);
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 23f55140ccd5..7047f58306a7 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -218,8 +218,8 @@ int __first_cpu(const cpumask_t *srcp);
218int __next_cpu(int n, const cpumask_t *srcp); 218int __next_cpu(int n, const cpumask_t *srcp);
219#define next_cpu(n, src) __next_cpu((n), &(src)) 219#define next_cpu(n, src) __next_cpu((n), &(src))
220#else 220#else
221#define first_cpu(src) 0 221#define first_cpu(src) ({ (void)(src); 0; })
222#define next_cpu(n, src) 1 222#define next_cpu(n, src) ({ (void)(src); 1; })
223#endif 223#endif
224 224
225#define cpumask_of_cpu(cpu) \ 225#define cpumask_of_cpu(cpu) \
@@ -397,6 +397,8 @@ extern cpumask_t cpu_present_map;
397#define cpu_present(cpu) ((cpu) == 0) 397#define cpu_present(cpu) ((cpu) == 0)
398#endif 398#endif
399 399
400#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
401
400#ifdef CONFIG_SMP 402#ifdef CONFIG_SMP
401extern int nr_cpu_ids; 403extern int nr_cpu_ids;
402#define any_online_cpu(mask) __any_online_cpu(&(mask)) 404#define any_online_cpu(mask) __any_online_cpu(&(mask))
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index f3110ebe894a..5e02d1b46370 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -33,10 +33,13 @@
33#define CRYPTO_ALG_TYPE_DIGEST 0x00000002 33#define CRYPTO_ALG_TYPE_DIGEST 0x00000002
34#define CRYPTO_ALG_TYPE_HASH 0x00000003 34#define CRYPTO_ALG_TYPE_HASH 0x00000003
35#define CRYPTO_ALG_TYPE_BLKCIPHER 0x00000004 35#define CRYPTO_ALG_TYPE_BLKCIPHER 0x00000004
36#define CRYPTO_ALG_TYPE_COMPRESS 0x00000005 36#define CRYPTO_ALG_TYPE_ABLKCIPHER 0x00000005
37#define CRYPTO_ALG_TYPE_AEAD 0x00000006 37#define CRYPTO_ALG_TYPE_GIVCIPHER 0x00000006
38#define CRYPTO_ALG_TYPE_COMPRESS 0x00000008
39#define CRYPTO_ALG_TYPE_AEAD 0x00000009
38 40
39#define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e 41#define CRYPTO_ALG_TYPE_HASH_MASK 0x0000000e
42#define CRYPTO_ALG_TYPE_BLKCIPHER_MASK 0x0000000c
40 43
41#define CRYPTO_ALG_LARVAL 0x00000010 44#define CRYPTO_ALG_LARVAL 0x00000010
42#define CRYPTO_ALG_DEAD 0x00000020 45#define CRYPTO_ALG_DEAD 0x00000020
@@ -50,6 +53,12 @@
50#define CRYPTO_ALG_NEED_FALLBACK 0x00000100 53#define CRYPTO_ALG_NEED_FALLBACK 0x00000100
51 54
52/* 55/*
56 * This bit is set for symmetric key ciphers that have already been wrapped
57 * with a generic IV generator to prevent them from being wrapped again.
58 */
59#define CRYPTO_ALG_GENIV 0x00000200
60
61/*
53 * Transform masks and values (for crt_flags). 62 * Transform masks and values (for crt_flags).
54 */ 63 */
55#define CRYPTO_TFM_REQ_MASK 0x000fff00 64#define CRYPTO_TFM_REQ_MASK 0x000fff00
@@ -81,13 +90,11 @@
81#define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN 90#define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN
82#elif defined(ARCH_SLAB_MINALIGN) 91#elif defined(ARCH_SLAB_MINALIGN)
83#define CRYPTO_MINALIGN ARCH_SLAB_MINALIGN 92#define CRYPTO_MINALIGN ARCH_SLAB_MINALIGN
93#else
94#define CRYPTO_MINALIGN __alignof__(unsigned long long)
84#endif 95#endif
85 96
86#ifdef CRYPTO_MINALIGN
87#define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN))) 97#define CRYPTO_MINALIGN_ATTR __attribute__ ((__aligned__(CRYPTO_MINALIGN)))
88#else
89#define CRYPTO_MINALIGN_ATTR
90#endif
91 98
92struct scatterlist; 99struct scatterlist;
93struct crypto_ablkcipher; 100struct crypto_ablkcipher;
@@ -97,6 +104,8 @@ struct crypto_blkcipher;
97struct crypto_hash; 104struct crypto_hash;
98struct crypto_tfm; 105struct crypto_tfm;
99struct crypto_type; 106struct crypto_type;
107struct aead_givcrypt_request;
108struct skcipher_givcrypt_request;
100 109
101typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err); 110typedef void (*crypto_completion_t)(struct crypto_async_request *req, int err);
102 111
@@ -176,6 +185,10 @@ struct ablkcipher_alg {
176 unsigned int keylen); 185 unsigned int keylen);
177 int (*encrypt)(struct ablkcipher_request *req); 186 int (*encrypt)(struct ablkcipher_request *req);
178 int (*decrypt)(struct ablkcipher_request *req); 187 int (*decrypt)(struct ablkcipher_request *req);
188 int (*givencrypt)(struct skcipher_givcrypt_request *req);
189 int (*givdecrypt)(struct skcipher_givcrypt_request *req);
190
191 const char *geniv;
179 192
180 unsigned int min_keysize; 193 unsigned int min_keysize;
181 unsigned int max_keysize; 194 unsigned int max_keysize;
@@ -185,11 +198,16 @@ struct ablkcipher_alg {
185struct aead_alg { 198struct aead_alg {
186 int (*setkey)(struct crypto_aead *tfm, const u8 *key, 199 int (*setkey)(struct crypto_aead *tfm, const u8 *key,
187 unsigned int keylen); 200 unsigned int keylen);
201 int (*setauthsize)(struct crypto_aead *tfm, unsigned int authsize);
188 int (*encrypt)(struct aead_request *req); 202 int (*encrypt)(struct aead_request *req);
189 int (*decrypt)(struct aead_request *req); 203 int (*decrypt)(struct aead_request *req);
204 int (*givencrypt)(struct aead_givcrypt_request *req);
205 int (*givdecrypt)(struct aead_givcrypt_request *req);
206
207 const char *geniv;
190 208
191 unsigned int ivsize; 209 unsigned int ivsize;
192 unsigned int authsize; 210 unsigned int maxauthsize;
193}; 211};
194 212
195struct blkcipher_alg { 213struct blkcipher_alg {
@@ -202,6 +220,8 @@ struct blkcipher_alg {
202 struct scatterlist *dst, struct scatterlist *src, 220 struct scatterlist *dst, struct scatterlist *src,
203 unsigned int nbytes); 221 unsigned int nbytes);
204 222
223 const char *geniv;
224
205 unsigned int min_keysize; 225 unsigned int min_keysize;
206 unsigned int max_keysize; 226 unsigned int max_keysize;
207 unsigned int ivsize; 227 unsigned int ivsize;
@@ -317,6 +337,11 @@ struct ablkcipher_tfm {
317 unsigned int keylen); 337 unsigned int keylen);
318 int (*encrypt)(struct ablkcipher_request *req); 338 int (*encrypt)(struct ablkcipher_request *req);
319 int (*decrypt)(struct ablkcipher_request *req); 339 int (*decrypt)(struct ablkcipher_request *req);
340 int (*givencrypt)(struct skcipher_givcrypt_request *req);
341 int (*givdecrypt)(struct skcipher_givcrypt_request *req);
342
343 struct crypto_ablkcipher *base;
344
320 unsigned int ivsize; 345 unsigned int ivsize;
321 unsigned int reqsize; 346 unsigned int reqsize;
322}; 347};
@@ -326,6 +351,11 @@ struct aead_tfm {
326 unsigned int keylen); 351 unsigned int keylen);
327 int (*encrypt)(struct aead_request *req); 352 int (*encrypt)(struct aead_request *req);
328 int (*decrypt)(struct aead_request *req); 353 int (*decrypt)(struct aead_request *req);
354 int (*givencrypt)(struct aead_givcrypt_request *req);
355 int (*givdecrypt)(struct aead_givcrypt_request *req);
356
357 struct crypto_aead *base;
358
329 unsigned int ivsize; 359 unsigned int ivsize;
330 unsigned int authsize; 360 unsigned int authsize;
331 unsigned int reqsize; 361 unsigned int reqsize;
@@ -525,17 +555,23 @@ static inline struct crypto_ablkcipher *__crypto_ablkcipher_cast(
525 return (struct crypto_ablkcipher *)tfm; 555 return (struct crypto_ablkcipher *)tfm;
526} 556}
527 557
528static inline struct crypto_ablkcipher *crypto_alloc_ablkcipher( 558static inline u32 crypto_skcipher_type(u32 type)
529 const char *alg_name, u32 type, u32 mask)
530{ 559{
531 type &= ~CRYPTO_ALG_TYPE_MASK; 560 type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV);
532 type |= CRYPTO_ALG_TYPE_BLKCIPHER; 561 type |= CRYPTO_ALG_TYPE_BLKCIPHER;
533 mask |= CRYPTO_ALG_TYPE_MASK; 562 return type;
563}
534 564
535 return __crypto_ablkcipher_cast( 565static inline u32 crypto_skcipher_mask(u32 mask)
536 crypto_alloc_base(alg_name, type, mask)); 566{
567 mask &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_GENIV);
568 mask |= CRYPTO_ALG_TYPE_BLKCIPHER_MASK;
569 return mask;
537} 570}
538 571
572struct crypto_ablkcipher *crypto_alloc_ablkcipher(const char *alg_name,
573 u32 type, u32 mask);
574
539static inline struct crypto_tfm *crypto_ablkcipher_tfm( 575static inline struct crypto_tfm *crypto_ablkcipher_tfm(
540 struct crypto_ablkcipher *tfm) 576 struct crypto_ablkcipher *tfm)
541{ 577{
@@ -550,11 +586,8 @@ static inline void crypto_free_ablkcipher(struct crypto_ablkcipher *tfm)
550static inline int crypto_has_ablkcipher(const char *alg_name, u32 type, 586static inline int crypto_has_ablkcipher(const char *alg_name, u32 type,
551 u32 mask) 587 u32 mask)
552{ 588{
553 type &= ~CRYPTO_ALG_TYPE_MASK; 589 return crypto_has_alg(alg_name, crypto_skcipher_type(type),
554 type |= CRYPTO_ALG_TYPE_BLKCIPHER; 590 crypto_skcipher_mask(mask));
555 mask |= CRYPTO_ALG_TYPE_MASK;
556
557 return crypto_has_alg(alg_name, type, mask);
558} 591}
559 592
560static inline struct ablkcipher_tfm *crypto_ablkcipher_crt( 593static inline struct ablkcipher_tfm *crypto_ablkcipher_crt(
@@ -601,7 +634,9 @@ static inline void crypto_ablkcipher_clear_flags(struct crypto_ablkcipher *tfm,
601static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm, 634static inline int crypto_ablkcipher_setkey(struct crypto_ablkcipher *tfm,
602 const u8 *key, unsigned int keylen) 635 const u8 *key, unsigned int keylen)
603{ 636{
604 return crypto_ablkcipher_crt(tfm)->setkey(tfm, key, keylen); 637 struct ablkcipher_tfm *crt = crypto_ablkcipher_crt(tfm);
638
639 return crt->setkey(crt->base, key, keylen);
605} 640}
606 641
607static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm( 642static inline struct crypto_ablkcipher *crypto_ablkcipher_reqtfm(
@@ -633,7 +668,7 @@ static inline unsigned int crypto_ablkcipher_reqsize(
633static inline void ablkcipher_request_set_tfm( 668static inline void ablkcipher_request_set_tfm(
634 struct ablkcipher_request *req, struct crypto_ablkcipher *tfm) 669 struct ablkcipher_request *req, struct crypto_ablkcipher *tfm)
635{ 670{
636 req->base.tfm = crypto_ablkcipher_tfm(tfm); 671 req->base.tfm = crypto_ablkcipher_tfm(crypto_ablkcipher_crt(tfm)->base);
637} 672}
638 673
639static inline struct ablkcipher_request *ablkcipher_request_cast( 674static inline struct ablkcipher_request *ablkcipher_request_cast(
@@ -686,15 +721,7 @@ static inline struct crypto_aead *__crypto_aead_cast(struct crypto_tfm *tfm)
686 return (struct crypto_aead *)tfm; 721 return (struct crypto_aead *)tfm;
687} 722}
688 723
689static inline struct crypto_aead *crypto_alloc_aead(const char *alg_name, 724struct crypto_aead *crypto_alloc_aead(const char *alg_name, u32 type, u32 mask);
690 u32 type, u32 mask)
691{
692 type &= ~CRYPTO_ALG_TYPE_MASK;
693 type |= CRYPTO_ALG_TYPE_AEAD;
694 mask |= CRYPTO_ALG_TYPE_MASK;
695
696 return __crypto_aead_cast(crypto_alloc_base(alg_name, type, mask));
697}
698 725
699static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm) 726static inline struct crypto_tfm *crypto_aead_tfm(struct crypto_aead *tfm)
700{ 727{
@@ -749,9 +776,13 @@ static inline void crypto_aead_clear_flags(struct crypto_aead *tfm, u32 flags)
749static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key, 776static inline int crypto_aead_setkey(struct crypto_aead *tfm, const u8 *key,
750 unsigned int keylen) 777 unsigned int keylen)
751{ 778{
752 return crypto_aead_crt(tfm)->setkey(tfm, key, keylen); 779 struct aead_tfm *crt = crypto_aead_crt(tfm);
780
781 return crt->setkey(crt->base, key, keylen);
753} 782}
754 783
784int crypto_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize);
785
755static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req) 786static inline struct crypto_aead *crypto_aead_reqtfm(struct aead_request *req)
756{ 787{
757 return __crypto_aead_cast(req->base.tfm); 788 return __crypto_aead_cast(req->base.tfm);
@@ -775,7 +806,7 @@ static inline unsigned int crypto_aead_reqsize(struct crypto_aead *tfm)
775static inline void aead_request_set_tfm(struct aead_request *req, 806static inline void aead_request_set_tfm(struct aead_request *req,
776 struct crypto_aead *tfm) 807 struct crypto_aead *tfm)
777{ 808{
778 req->base.tfm = crypto_aead_tfm(tfm); 809 req->base.tfm = crypto_aead_tfm(crypto_aead_crt(tfm)->base);
779} 810}
780 811
781static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm, 812static inline struct aead_request *aead_request_alloc(struct crypto_aead *tfm,
@@ -841,9 +872,9 @@ static inline struct crypto_blkcipher *crypto_blkcipher_cast(
841static inline struct crypto_blkcipher *crypto_alloc_blkcipher( 872static inline struct crypto_blkcipher *crypto_alloc_blkcipher(
842 const char *alg_name, u32 type, u32 mask) 873 const char *alg_name, u32 type, u32 mask)
843{ 874{
844 type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); 875 type &= ~CRYPTO_ALG_TYPE_MASK;
845 type |= CRYPTO_ALG_TYPE_BLKCIPHER; 876 type |= CRYPTO_ALG_TYPE_BLKCIPHER;
846 mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC; 877 mask |= CRYPTO_ALG_TYPE_MASK;
847 878
848 return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask)); 879 return __crypto_blkcipher_cast(crypto_alloc_base(alg_name, type, mask));
849} 880}
@@ -861,9 +892,9 @@ static inline void crypto_free_blkcipher(struct crypto_blkcipher *tfm)
861 892
862static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask) 893static inline int crypto_has_blkcipher(const char *alg_name, u32 type, u32 mask)
863{ 894{
864 type &= ~(CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC); 895 type &= ~CRYPTO_ALG_TYPE_MASK;
865 type |= CRYPTO_ALG_TYPE_BLKCIPHER; 896 type |= CRYPTO_ALG_TYPE_BLKCIPHER;
866 mask |= CRYPTO_ALG_TYPE_MASK | CRYPTO_ALG_ASYNC; 897 mask |= CRYPTO_ALG_TYPE_MASK;
867 898
868 return crypto_has_alg(alg_name, type, mask); 899 return crypto_has_alg(alg_name, type, mask);
869} 900}
@@ -1081,6 +1112,7 @@ static inline struct crypto_hash *crypto_alloc_hash(const char *alg_name,
1081 u32 type, u32 mask) 1112 u32 type, u32 mask)
1082{ 1113{
1083 type &= ~CRYPTO_ALG_TYPE_MASK; 1114 type &= ~CRYPTO_ALG_TYPE_MASK;
1115 mask &= ~CRYPTO_ALG_TYPE_MASK;
1084 type |= CRYPTO_ALG_TYPE_HASH; 1116 type |= CRYPTO_ALG_TYPE_HASH;
1085 mask |= CRYPTO_ALG_TYPE_HASH_MASK; 1117 mask |= CRYPTO_ALG_TYPE_HASH_MASK;
1086 1118
@@ -1100,6 +1132,7 @@ static inline void crypto_free_hash(struct crypto_hash *tfm)
1100static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask) 1132static inline int crypto_has_hash(const char *alg_name, u32 type, u32 mask)
1101{ 1133{
1102 type &= ~CRYPTO_ALG_TYPE_MASK; 1134 type &= ~CRYPTO_ALG_TYPE_MASK;
1135 mask &= ~CRYPTO_ALG_TYPE_MASK;
1103 type |= CRYPTO_ALG_TYPE_HASH; 1136 type |= CRYPTO_ALG_TYPE_HASH;
1104 mask |= CRYPTO_ALG_TYPE_HASH_MASK; 1137 mask |= CRYPTO_ALG_TYPE_HASH_MASK;
1105 1138
diff --git a/include/linux/dccp.h b/include/linux/dccp.h
index 333c3ea82a5d..484e45c7c89a 100644
--- a/include/linux/dccp.h
+++ b/include/linux/dccp.h
@@ -205,6 +205,7 @@ struct dccp_so_feat {
205#define DCCP_SOCKOPT_CHANGE_L 3 205#define DCCP_SOCKOPT_CHANGE_L 3
206#define DCCP_SOCKOPT_CHANGE_R 4 206#define DCCP_SOCKOPT_CHANGE_R 4
207#define DCCP_SOCKOPT_GET_CUR_MPS 5 207#define DCCP_SOCKOPT_GET_CUR_MPS 5
208#define DCCP_SOCKOPT_SERVER_TIMEWAIT 6
208#define DCCP_SOCKOPT_SEND_CSCOV 10 209#define DCCP_SOCKOPT_SEND_CSCOV 10
209#define DCCP_SOCKOPT_RECV_CSCOV 11 210#define DCCP_SOCKOPT_RECV_CSCOV 11
210#define DCCP_SOCKOPT_CCID_RX_INFO 128 211#define DCCP_SOCKOPT_CCID_RX_INFO 128
@@ -227,37 +228,50 @@ struct dccp_so_feat {
227#include <net/tcp_states.h> 228#include <net/tcp_states.h>
228 229
229enum dccp_state { 230enum dccp_state {
230 DCCP_OPEN = TCP_ESTABLISHED, 231 DCCP_OPEN = TCP_ESTABLISHED,
231 DCCP_REQUESTING = TCP_SYN_SENT, 232 DCCP_REQUESTING = TCP_SYN_SENT,
232 DCCP_PARTOPEN = TCP_FIN_WAIT1, /* FIXME: 233 DCCP_LISTEN = TCP_LISTEN,
233 This mapping is horrible, but TCP has 234 DCCP_RESPOND = TCP_SYN_RECV,
234 no matching state for DCCP_PARTOPEN, 235 /*
235 as TCP_SYN_RECV is already used by 236 * States involved in closing a DCCP connection:
236 DCCP_RESPOND, why don't stop using TCP 237 * 1) ACTIVE_CLOSEREQ is entered by a server sending a CloseReq.
237 mapping of states? OK, now we don't use 238 *
238 sk_stream_sendmsg anymore, so doesn't 239 * 2) CLOSING can have three different meanings (RFC 4340, 8.3):
239 seem to exist any reason for us to 240 * a. Client has performed active-close, has sent a Close to the server
240 do the TCP mapping here */ 241 * from state OPEN or PARTOPEN, and is waiting for the final Reset
241 DCCP_LISTEN = TCP_LISTEN, 242 * (in this case, SOCK_DONE == 1).
242 DCCP_RESPOND = TCP_SYN_RECV, 243 * b. Client is asked to perform passive-close, by receiving a CloseReq
243 DCCP_CLOSING = TCP_CLOSING, 244 * in (PART)OPEN state. It sends a Close and waits for final Reset
244 DCCP_TIME_WAIT = TCP_TIME_WAIT, 245 * (in this case, SOCK_DONE == 0).
245 DCCP_CLOSED = TCP_CLOSE, 246 * c. Server performs an active-close as in (a), keeps TIMEWAIT state.
246 DCCP_MAX_STATES = TCP_MAX_STATES, 247 *
248 * 3) The following intermediate states are employed to give passively
249 * closing nodes a chance to process their unread data:
250 * - PASSIVE_CLOSE (from OPEN => CLOSED) and
251 * - PASSIVE_CLOSEREQ (from (PART)OPEN to CLOSING; case (b) above).
252 */
253 DCCP_ACTIVE_CLOSEREQ = TCP_FIN_WAIT1,
254 DCCP_PASSIVE_CLOSE = TCP_CLOSE_WAIT, /* any node receiving a Close */
255 DCCP_CLOSING = TCP_CLOSING,
256 DCCP_TIME_WAIT = TCP_TIME_WAIT,
257 DCCP_CLOSED = TCP_CLOSE,
258 DCCP_PARTOPEN = TCP_MAX_STATES,
259 DCCP_PASSIVE_CLOSEREQ, /* clients receiving CloseReq */
260 DCCP_MAX_STATES
247}; 261};
248 262
249#define DCCP_STATE_MASK 0xf 263#define DCCP_STATE_MASK 0x1f
250#define DCCP_ACTION_FIN (1<<7)
251 264
252enum { 265enum {
253 DCCPF_OPEN = TCPF_ESTABLISHED, 266 DCCPF_OPEN = TCPF_ESTABLISHED,
254 DCCPF_REQUESTING = TCPF_SYN_SENT, 267 DCCPF_REQUESTING = TCPF_SYN_SENT,
255 DCCPF_PARTOPEN = TCPF_FIN_WAIT1, 268 DCCPF_LISTEN = TCPF_LISTEN,
256 DCCPF_LISTEN = TCPF_LISTEN, 269 DCCPF_RESPOND = TCPF_SYN_RECV,
257 DCCPF_RESPOND = TCPF_SYN_RECV, 270 DCCPF_ACTIVE_CLOSEREQ = TCPF_FIN_WAIT1,
258 DCCPF_CLOSING = TCPF_CLOSING, 271 DCCPF_CLOSING = TCPF_CLOSING,
259 DCCPF_TIME_WAIT = TCPF_TIME_WAIT, 272 DCCPF_TIME_WAIT = TCPF_TIME_WAIT,
260 DCCPF_CLOSED = TCPF_CLOSE, 273 DCCPF_CLOSED = TCPF_CLOSE,
274 DCCPF_PARTOPEN = (1 << DCCP_PARTOPEN),
261}; 275};
262 276
263static inline struct dccp_hdr *dccp_hdr(const struct sk_buff *skb) 277static inline struct dccp_hdr *dccp_hdr(const struct sk_buff *skb)
@@ -393,13 +407,23 @@ struct dccp_opt_pend {
393 407
394extern void dccp_minisock_init(struct dccp_minisock *dmsk); 408extern void dccp_minisock_init(struct dccp_minisock *dmsk);
395 409
396extern int dccp_parse_options(struct sock *sk, struct sk_buff *skb); 410/**
397 411 * struct dccp_request_sock - represent DCCP-specific connection request
412 * @dreq_inet_rsk: structure inherited from
413 * @dreq_iss: initial sequence number sent on the Response (RFC 4340, 7.1)
414 * @dreq_isr: initial sequence number received on the Request
415 * @dreq_service: service code present on the Request (there is just one)
416 * The following two fields are analogous to the ones in dccp_sock:
417 * @dreq_timestamp_echo: last received timestamp to echo (13.1)
418 * @dreq_timestamp_echo: the time of receiving the last @dreq_timestamp_echo
419 */
398struct dccp_request_sock { 420struct dccp_request_sock {
399 struct inet_request_sock dreq_inet_rsk; 421 struct inet_request_sock dreq_inet_rsk;
400 __u64 dreq_iss; 422 __u64 dreq_iss;
401 __u64 dreq_isr; 423 __u64 dreq_isr;
402 __be32 dreq_service; 424 __be32 dreq_service;
425 __u32 dreq_timestamp_echo;
426 __u32 dreq_timestamp_time;
403}; 427};
404 428
405static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req) 429static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req)
@@ -409,6 +433,9 @@ static inline struct dccp_request_sock *dccp_rsk(const struct request_sock *req)
409 433
410extern struct inet_timewait_death_row dccp_death_row; 434extern struct inet_timewait_death_row dccp_death_row;
411 435
436extern int dccp_parse_options(struct sock *sk, struct dccp_request_sock *dreq,
437 struct sk_buff *skb);
438
412struct dccp_options_received { 439struct dccp_options_received {
413 u32 dccpor_ndp; /* only 24 bits */ 440 u32 dccpor_ndp; /* only 24 bits */
414 u32 dccpor_timestamp; 441 u32 dccpor_timestamp;
@@ -462,8 +489,8 @@ struct dccp_ackvec;
462 * @dccps_gar - greatest valid ack number received on a non-Sync; initialized to %dccps_iss 489 * @dccps_gar - greatest valid ack number received on a non-Sync; initialized to %dccps_iss
463 * @dccps_service - first (passive sock) or unique (active sock) service code 490 * @dccps_service - first (passive sock) or unique (active sock) service code
464 * @dccps_service_list - second .. last service code on passive socket 491 * @dccps_service_list - second .. last service code on passive socket
465 * @dccps_timestamp_time - time of latest TIMESTAMP option
466 * @dccps_timestamp_echo - latest timestamp received on a TIMESTAMP option 492 * @dccps_timestamp_echo - latest timestamp received on a TIMESTAMP option
493 * @dccps_timestamp_time - time of receiving latest @dccps_timestamp_echo
467 * @dccps_l_ack_ratio - feature-local Ack Ratio 494 * @dccps_l_ack_ratio - feature-local Ack Ratio
468 * @dccps_r_ack_ratio - feature-remote Ack Ratio 495 * @dccps_r_ack_ratio - feature-remote Ack Ratio
469 * @dccps_pcslen - sender partial checksum coverage (via sockopt) 496 * @dccps_pcslen - sender partial checksum coverage (via sockopt)
@@ -479,6 +506,7 @@ struct dccp_ackvec;
479 * @dccps_role - role of this sock, one of %dccp_role 506 * @dccps_role - role of this sock, one of %dccp_role
480 * @dccps_hc_rx_insert_options - receiver wants to add options when acking 507 * @dccps_hc_rx_insert_options - receiver wants to add options when acking
481 * @dccps_hc_tx_insert_options - sender wants to add options when sending 508 * @dccps_hc_tx_insert_options - sender wants to add options when sending
509 * @dccps_server_timewait - server holds timewait state on close (RFC 4340, 8.3)
482 * @dccps_xmit_timer - timer for when CCID is not ready to send 510 * @dccps_xmit_timer - timer for when CCID is not ready to send
483 * @dccps_syn_rtt - RTT sample from Request/Response exchange (in usecs) 511 * @dccps_syn_rtt - RTT sample from Request/Response exchange (in usecs)
484 */ 512 */
@@ -498,8 +526,8 @@ struct dccp_sock {
498 __u64 dccps_gar; 526 __u64 dccps_gar;
499 __be32 dccps_service; 527 __be32 dccps_service;
500 struct dccp_service_list *dccps_service_list; 528 struct dccp_service_list *dccps_service_list;
501 ktime_t dccps_timestamp_time;
502 __u32 dccps_timestamp_echo; 529 __u32 dccps_timestamp_echo;
530 __u32 dccps_timestamp_time;
503 __u16 dccps_l_ack_ratio; 531 __u16 dccps_l_ack_ratio;
504 __u16 dccps_r_ack_ratio; 532 __u16 dccps_r_ack_ratio;
505 __u16 dccps_pcslen; 533 __u16 dccps_pcslen;
@@ -515,6 +543,7 @@ struct dccp_sock {
515 enum dccp_role dccps_role:2; 543 enum dccp_role dccps_role:2;
516 __u8 dccps_hc_rx_insert_options:1; 544 __u8 dccps_hc_rx_insert_options:1;
517 __u8 dccps_hc_tx_insert_options:1; 545 __u8 dccps_hc_tx_insert_options:1;
546 __u8 dccps_server_timewait:1;
518 struct timer_list dccps_xmit_timer; 547 struct timer_list dccps_xmit_timer;
519}; 548};
520 549
diff --git a/include/linux/debug_locks.h b/include/linux/debug_locks.h
index 1678a5de7013..f4a5871767f5 100644
--- a/include/linux/debug_locks.h
+++ b/include/linux/debug_locks.h
@@ -47,6 +47,7 @@ struct task_struct;
47 47
48#ifdef CONFIG_LOCKDEP 48#ifdef CONFIG_LOCKDEP
49extern void debug_show_all_locks(void); 49extern void debug_show_all_locks(void);
50extern void __debug_show_held_locks(struct task_struct *task);
50extern void debug_show_held_locks(struct task_struct *task); 51extern void debug_show_held_locks(struct task_struct *task);
51extern void debug_check_no_locks_freed(const void *from, unsigned long len); 52extern void debug_check_no_locks_freed(const void *from, unsigned long len);
52extern void debug_check_no_locks_held(struct task_struct *task); 53extern void debug_check_no_locks_held(struct task_struct *task);
@@ -55,6 +56,10 @@ static inline void debug_show_all_locks(void)
55{ 56{
56} 57}
57 58
59static inline void __debug_show_held_locks(struct task_struct *task)
60{
61}
62
58static inline void debug_show_held_locks(struct task_struct *task) 63static inline void debug_show_held_locks(struct task_struct *task)
59{ 64{
60} 65}
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 37c66d1254b5..e765e191663d 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -115,7 +115,9 @@ struct io_restrictions {
115 unsigned short max_hw_segments; 115 unsigned short max_hw_segments;
116 unsigned short hardsect_size; 116 unsigned short hardsect_size;
117 unsigned int max_segment_size; 117 unsigned int max_segment_size;
118 unsigned int max_hw_sectors;
118 unsigned long seg_boundary_mask; 119 unsigned long seg_boundary_mask;
120 unsigned long bounce_pfn;
119 unsigned char no_cluster; /* inverted so that 0 is default */ 121 unsigned char no_cluster; /* inverted so that 0 is default */
120}; 122};
121 123
diff --git a/include/linux/device.h b/include/linux/device.h
index 2e15822fe409..db375be333c7 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -25,75 +25,72 @@
25#include <asm/device.h> 25#include <asm/device.h>
26 26
27#define DEVICE_NAME_SIZE 50 27#define DEVICE_NAME_SIZE 50
28#define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */ 28/* DEVICE_NAME_HALF is really less than half to accommodate slop */
29#define DEVICE_NAME_HALF __stringify(20)
29#define DEVICE_ID_SIZE 32 30#define DEVICE_ID_SIZE 32
30#define BUS_ID_SIZE KOBJ_NAME_LEN 31#define BUS_ID_SIZE KOBJ_NAME_LEN
31 32
32 33
33struct device; 34struct device;
34struct device_driver; 35struct device_driver;
36struct driver_private;
35struct class; 37struct class;
36struct class_device; 38struct class_device;
37struct bus_type; 39struct bus_type;
40struct bus_type_private;
38 41
39struct bus_attribute { 42struct bus_attribute {
40 struct attribute attr; 43 struct attribute attr;
41 ssize_t (*show)(struct bus_type *, char * buf); 44 ssize_t (*show)(struct bus_type *bus, char *buf);
42 ssize_t (*store)(struct bus_type *, const char * buf, size_t count); 45 ssize_t (*store)(struct bus_type *bus, const char *buf, size_t count);
43}; 46};
44 47
45#define BUS_ATTR(_name,_mode,_show,_store) \ 48#define BUS_ATTR(_name, _mode, _show, _store) \
46struct bus_attribute bus_attr_##_name = __ATTR(_name,_mode,_show,_store) 49struct bus_attribute bus_attr_##_name = __ATTR(_name, _mode, _show, _store)
47 50
48extern int __must_check bus_create_file(struct bus_type *, 51extern int __must_check bus_create_file(struct bus_type *,
49 struct bus_attribute *); 52 struct bus_attribute *);
50extern void bus_remove_file(struct bus_type *, struct bus_attribute *); 53extern void bus_remove_file(struct bus_type *, struct bus_attribute *);
51 54
52struct bus_type { 55struct bus_type {
53 const char * name; 56 const char *name;
54 struct module * owner; 57 struct bus_attribute *bus_attrs;
58 struct device_attribute *dev_attrs;
59 struct driver_attribute *drv_attrs;
55 60
56 struct kset subsys; 61 int (*match)(struct device *dev, struct device_driver *drv);
57 struct kset drivers; 62 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
58 struct kset devices; 63 int (*probe)(struct device *dev);
59 struct klist klist_devices; 64 int (*remove)(struct device *dev);
60 struct klist klist_drivers; 65 void (*shutdown)(struct device *dev);
61
62 struct blocking_notifier_head bus_notifier;
63
64 struct bus_attribute * bus_attrs;
65 struct device_attribute * dev_attrs;
66 struct driver_attribute * drv_attrs;
67
68 int (*match)(struct device * dev, struct device_driver * drv);
69 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
70 int (*probe)(struct device * dev);
71 int (*remove)(struct device * dev);
72 void (*shutdown)(struct device * dev);
73 66
74 int (*suspend)(struct device * dev, pm_message_t state); 67 int (*suspend)(struct device *dev, pm_message_t state);
75 int (*suspend_late)(struct device * dev, pm_message_t state); 68 int (*suspend_late)(struct device *dev, pm_message_t state);
76 int (*resume_early)(struct device * dev); 69 int (*resume_early)(struct device *dev);
77 int (*resume)(struct device * dev); 70 int (*resume)(struct device *dev);
78 71
79 unsigned int drivers_autoprobe:1; 72 struct bus_type_private *p;
80}; 73};
81 74
82extern int __must_check bus_register(struct bus_type * bus); 75extern int __must_check bus_register(struct bus_type *bus);
83extern void bus_unregister(struct bus_type * bus); 76extern void bus_unregister(struct bus_type *bus);
84 77
85extern int __must_check bus_rescan_devices(struct bus_type * bus); 78extern int __must_check bus_rescan_devices(struct bus_type *bus);
86 79
87/* iterator helpers for buses */ 80/* iterator helpers for buses */
88 81
89int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data, 82int bus_for_each_dev(struct bus_type *bus, struct device *start, void *data,
90 int (*fn)(struct device *, void *)); 83 int (*fn)(struct device *dev, void *data));
91struct device * bus_find_device(struct bus_type *bus, struct device *start, 84struct device *bus_find_device(struct bus_type *bus, struct device *start,
92 void *data, int (*match)(struct device *, void *)); 85 void *data,
86 int (*match)(struct device *dev, void *data));
87struct device *bus_find_device_by_name(struct bus_type *bus,
88 struct device *start,
89 const char *name);
93 90
94int __must_check bus_for_each_drv(struct bus_type *bus, 91int __must_check bus_for_each_drv(struct bus_type *bus,
95 struct device_driver *start, void *data, 92 struct device_driver *start, void *data,
96 int (*fn)(struct device_driver *, void *)); 93 int (*fn)(struct device_driver *, void *));
97 94
98/* 95/*
99 * Bus notifiers: Get notified of addition/removal of devices 96 * Bus notifiers: Get notified of addition/removal of devices
@@ -118,111 +115,128 @@ extern int bus_unregister_notifier(struct bus_type *bus,
118#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be 115#define BUS_NOTIFY_UNBIND_DRIVER 0x00000004 /* driver about to be
119 unbound */ 116 unbound */
120 117
118extern struct kset *bus_get_kset(struct bus_type *bus);
119extern struct klist *bus_get_device_klist(struct bus_type *bus);
120
121struct device_driver { 121struct device_driver {
122 const char * name; 122 const char *name;
123 struct bus_type * bus; 123 struct bus_type *bus;
124 124
125 struct kobject kobj; 125 struct module *owner;
126 struct klist klist_devices; 126 const char *mod_name; /* used for built-in modules */
127 struct klist_node knode_bus;
128 127
129 struct module * owner; 128 int (*probe) (struct device *dev);
130 const char * mod_name; /* used for built-in modules */ 129 int (*remove) (struct device *dev);
131 struct module_kobject * mkobj; 130 void (*shutdown) (struct device *dev);
131 int (*suspend) (struct device *dev, pm_message_t state);
132 int (*resume) (struct device *dev);
133 struct attribute_group **groups;
132 134
133 int (*probe) (struct device * dev); 135 struct driver_private *p;
134 int (*remove) (struct device * dev);
135 void (*shutdown) (struct device * dev);
136 int (*suspend) (struct device * dev, pm_message_t state);
137 int (*resume) (struct device * dev);
138}; 136};
139 137
140 138
141extern int __must_check driver_register(struct device_driver * drv); 139extern int __must_check driver_register(struct device_driver *drv);
142extern void driver_unregister(struct device_driver * drv); 140extern void driver_unregister(struct device_driver *drv);
143 141
144extern struct device_driver * get_driver(struct device_driver * drv); 142extern struct device_driver *get_driver(struct device_driver *drv);
145extern void put_driver(struct device_driver * drv); 143extern void put_driver(struct device_driver *drv);
146extern struct device_driver *driver_find(const char *name, struct bus_type *bus); 144extern struct device_driver *driver_find(const char *name,
145 struct bus_type *bus);
147extern int driver_probe_done(void); 146extern int driver_probe_done(void);
148 147
149/* sysfs interface for exporting driver attributes */ 148/* sysfs interface for exporting driver attributes */
150 149
151struct driver_attribute { 150struct driver_attribute {
152 struct attribute attr; 151 struct attribute attr;
153 ssize_t (*show)(struct device_driver *, char * buf); 152 ssize_t (*show)(struct device_driver *driver, char *buf);
154 ssize_t (*store)(struct device_driver *, const char * buf, size_t count); 153 ssize_t (*store)(struct device_driver *driver, const char *buf,
154 size_t count);
155}; 155};
156 156
157#define DRIVER_ATTR(_name,_mode,_show,_store) \ 157#define DRIVER_ATTR(_name, _mode, _show, _store) \
158struct driver_attribute driver_attr_##_name = __ATTR(_name,_mode,_show,_store) 158struct driver_attribute driver_attr_##_name = \
159 __ATTR(_name, _mode, _show, _store)
159 160
160extern int __must_check driver_create_file(struct device_driver *, 161extern int __must_check driver_create_file(struct device_driver *driver,
161 struct driver_attribute *); 162 struct driver_attribute *attr);
162extern void driver_remove_file(struct device_driver *, struct driver_attribute *); 163extern void driver_remove_file(struct device_driver *driver,
164 struct driver_attribute *attr);
163 165
164extern int __must_check driver_for_each_device(struct device_driver * drv, 166extern int __must_check driver_add_kobj(struct device_driver *drv,
165 struct device *start, void *data, 167 struct kobject *kobj,
166 int (*fn)(struct device *, void *)); 168 const char *fmt, ...);
167struct device * driver_find_device(struct device_driver *drv, 169
168 struct device *start, void *data, 170extern int __must_check driver_for_each_device(struct device_driver *drv,
169 int (*match)(struct device *, void *)); 171 struct device *start,
172 void *data,
173 int (*fn)(struct device *dev,
174 void *));
175struct device *driver_find_device(struct device_driver *drv,
176 struct device *start, void *data,
177 int (*match)(struct device *dev, void *data));
170 178
171/* 179/*
172 * device classes 180 * device classes
173 */ 181 */
174struct class { 182struct class {
175 const char * name; 183 const char *name;
176 struct module * owner; 184 struct module *owner;
177 185
178 struct kset subsys; 186 struct kset subsys;
179 struct list_head children; 187 struct list_head children;
180 struct list_head devices; 188 struct list_head devices;
181 struct list_head interfaces; 189 struct list_head interfaces;
182 struct kset class_dirs; 190 struct kset class_dirs;
183 struct semaphore sem; /* locks both the children and interfaces lists */ 191 struct semaphore sem; /* locks children, devices, interfaces */
184 192 struct class_attribute *class_attrs;
185 struct class_attribute * class_attrs; 193 struct class_device_attribute *class_dev_attrs;
186 struct class_device_attribute * class_dev_attrs; 194 struct device_attribute *dev_attrs;
187 struct device_attribute * dev_attrs;
188 195
189 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env); 196 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
190 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env); 197 int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
191 198
192 void (*release)(struct class_device *dev); 199 void (*release)(struct class_device *dev);
193 void (*class_release)(struct class *class); 200 void (*class_release)(struct class *class);
194 void (*dev_release)(struct device *dev); 201 void (*dev_release)(struct device *dev);
195 202
196 int (*suspend)(struct device *, pm_message_t state); 203 int (*suspend)(struct device *dev, pm_message_t state);
197 int (*resume)(struct device *); 204 int (*resume)(struct device *dev);
198}; 205};
199 206
200extern int __must_check class_register(struct class *); 207extern int __must_check class_register(struct class *class);
201extern void class_unregister(struct class *); 208extern void class_unregister(struct class *class);
209extern int class_for_each_device(struct class *class, void *data,
210 int (*fn)(struct device *dev, void *data));
211extern struct device *class_find_device(struct class *class, void *data,
212 int (*match)(struct device *, void *));
213extern struct class_device *class_find_child(struct class *class, void *data,
214 int (*match)(struct class_device *, void *));
202 215
203 216
204struct class_attribute { 217struct class_attribute {
205 struct attribute attr; 218 struct attribute attr;
206 ssize_t (*show)(struct class *, char * buf); 219 ssize_t (*show)(struct class *class, char *buf);
207 ssize_t (*store)(struct class *, const char * buf, size_t count); 220 ssize_t (*store)(struct class *class, const char *buf, size_t count);
208}; 221};
209 222
210#define CLASS_ATTR(_name,_mode,_show,_store) \ 223#define CLASS_ATTR(_name, _mode, _show, _store) \
211struct class_attribute class_attr_##_name = __ATTR(_name,_mode,_show,_store) 224struct class_attribute class_attr_##_name = __ATTR(_name, _mode, _show, _store)
212 225
213extern int __must_check class_create_file(struct class *, 226extern int __must_check class_create_file(struct class *class,
214 const struct class_attribute *); 227 const struct class_attribute *attr);
215extern void class_remove_file(struct class *, const struct class_attribute *); 228extern void class_remove_file(struct class *class,
229 const struct class_attribute *attr);
216 230
217struct class_device_attribute { 231struct class_device_attribute {
218 struct attribute attr; 232 struct attribute attr;
219 ssize_t (*show)(struct class_device *, char * buf); 233 ssize_t (*show)(struct class_device *, char *buf);
220 ssize_t (*store)(struct class_device *, const char * buf, size_t count); 234 ssize_t (*store)(struct class_device *, const char *buf, size_t count);
221}; 235};
222 236
223#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \ 237#define CLASS_DEVICE_ATTR(_name, _mode, _show, _store) \
224struct class_device_attribute class_device_attr_##_name = \ 238struct class_device_attribute class_device_attr_##_name = \
225 __ATTR(_name,_mode,_show,_store) 239 __ATTR(_name, _mode, _show, _store)
226 240
227extern int __must_check class_device_create_file(struct class_device *, 241extern int __must_check class_device_create_file(struct class_device *,
228 const struct class_device_attribute *); 242 const struct class_device_attribute *);
@@ -255,26 +269,24 @@ struct class_device {
255 struct list_head node; 269 struct list_head node;
256 270
257 struct kobject kobj; 271 struct kobject kobj;
258 struct class * class; /* required */ 272 struct class *class;
259 dev_t devt; /* dev_t, creates the sysfs "dev" */ 273 dev_t devt;
260 struct device * dev; /* not necessary, but nice to have */ 274 struct device *dev;
261 void * class_data; /* class-specific data */ 275 void *class_data;
262 struct class_device *parent; /* parent of this child device, if there is one */ 276 struct class_device *parent;
263 struct attribute_group ** groups; /* optional groups */ 277 struct attribute_group **groups;
264 278
265 void (*release)(struct class_device *dev); 279 void (*release)(struct class_device *dev);
266 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env); 280 int (*uevent)(struct class_device *dev, struct kobj_uevent_env *env);
267 char class_id[BUS_ID_SIZE]; /* unique to this class */ 281 char class_id[BUS_ID_SIZE];
268}; 282};
269 283
270static inline void * 284static inline void *class_get_devdata(struct class_device *dev)
271class_get_devdata (struct class_device *dev)
272{ 285{
273 return dev->class_data; 286 return dev->class_data;
274} 287}
275 288
276static inline void 289static inline void class_set_devdata(struct class_device *dev, void *data)
277class_set_devdata (struct class_device *dev, void *data)
278{ 290{
279 dev->class_data = data; 291 dev->class_data = data;
280} 292}
@@ -286,10 +298,10 @@ extern void class_device_initialize(struct class_device *);
286extern int __must_check class_device_add(struct class_device *); 298extern int __must_check class_device_add(struct class_device *);
287extern void class_device_del(struct class_device *); 299extern void class_device_del(struct class_device *);
288 300
289extern struct class_device * class_device_get(struct class_device *); 301extern struct class_device *class_device_get(struct class_device *);
290extern void class_device_put(struct class_device *); 302extern void class_device_put(struct class_device *);
291 303
292extern void class_device_remove_file(struct class_device *, 304extern void class_device_remove_file(struct class_device *,
293 const struct class_device_attribute *); 305 const struct class_device_attribute *);
294extern int __must_check class_device_create_bin_file(struct class_device *, 306extern int __must_check class_device_create_bin_file(struct class_device *,
295 struct bin_attribute *); 307 struct bin_attribute *);
@@ -316,7 +328,7 @@ extern struct class_device *class_device_create(struct class *cls,
316 dev_t devt, 328 dev_t devt,
317 struct device *device, 329 struct device *device,
318 const char *fmt, ...) 330 const char *fmt, ...)
319 __attribute__((format(printf,5,6))); 331 __attribute__((format(printf, 5, 6)));
320extern void class_device_destroy(struct class *cls, dev_t devt); 332extern void class_device_destroy(struct class *cls, dev_t devt);
321 333
322/* 334/*
@@ -333,8 +345,8 @@ struct device_type {
333 struct attribute_group **groups; 345 struct attribute_group **groups;
334 int (*uevent)(struct device *dev, struct kobj_uevent_env *env); 346 int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
335 void (*release)(struct device *dev); 347 void (*release)(struct device *dev);
336 int (*suspend)(struct device * dev, pm_message_t state); 348 int (*suspend)(struct device *dev, pm_message_t state);
337 int (*resume)(struct device * dev); 349 int (*resume)(struct device *dev);
338}; 350};
339 351
340/* interface for exporting device attributes */ 352/* interface for exporting device attributes */
@@ -346,18 +358,19 @@ struct device_attribute {
346 const char *buf, size_t count); 358 const char *buf, size_t count);
347}; 359};
348 360
349#define DEVICE_ATTR(_name,_mode,_show,_store) \ 361#define DEVICE_ATTR(_name, _mode, _show, _store) \
350struct device_attribute dev_attr_##_name = __ATTR(_name,_mode,_show,_store) 362struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)
351 363
352extern int __must_check device_create_file(struct device *device, 364extern int __must_check device_create_file(struct device *device,
353 struct device_attribute * entry); 365 struct device_attribute *entry);
354extern void device_remove_file(struct device * dev, struct device_attribute * attr); 366extern void device_remove_file(struct device *dev,
367 struct device_attribute *attr);
355extern int __must_check device_create_bin_file(struct device *dev, 368extern int __must_check device_create_bin_file(struct device *dev,
356 struct bin_attribute *attr); 369 struct bin_attribute *attr);
357extern void device_remove_bin_file(struct device *dev, 370extern void device_remove_bin_file(struct device *dev,
358 struct bin_attribute *attr); 371 struct bin_attribute *attr);
359extern int device_schedule_callback_owner(struct device *dev, 372extern int device_schedule_callback_owner(struct device *dev,
360 void (*func)(struct device *), struct module *owner); 373 void (*func)(struct device *dev), struct module *owner);
361 374
362/* This is a macro to avoid include problems with THIS_MODULE */ 375/* This is a macro to avoid include problems with THIS_MODULE */
363#define device_schedule_callback(dev, func) \ 376#define device_schedule_callback(dev, func) \
@@ -368,21 +381,21 @@ typedef void (*dr_release_t)(struct device *dev, void *res);
368typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data); 381typedef int (*dr_match_t)(struct device *dev, void *res, void *match_data);
369 382
370#ifdef CONFIG_DEBUG_DEVRES 383#ifdef CONFIG_DEBUG_DEVRES
371extern void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp, 384extern void *__devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
372 const char *name); 385 const char *name);
373#define devres_alloc(release, size, gfp) \ 386#define devres_alloc(release, size, gfp) \
374 __devres_alloc(release, size, gfp, #release) 387 __devres_alloc(release, size, gfp, #release)
375#else 388#else
376extern void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp); 389extern void *devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
377#endif 390#endif
378extern void devres_free(void *res); 391extern void devres_free(void *res);
379extern void devres_add(struct device *dev, void *res); 392extern void devres_add(struct device *dev, void *res);
380extern void * devres_find(struct device *dev, dr_release_t release, 393extern void *devres_find(struct device *dev, dr_release_t release,
381 dr_match_t match, void *match_data);
382extern void * devres_get(struct device *dev, void *new_res,
383 dr_match_t match, void *match_data); 394 dr_match_t match, void *match_data);
384extern void * devres_remove(struct device *dev, dr_release_t release, 395extern void *devres_get(struct device *dev, void *new_res,
385 dr_match_t match, void *match_data); 396 dr_match_t match, void *match_data);
397extern void *devres_remove(struct device *dev, dr_release_t release,
398 dr_match_t match, void *match_data);
386extern int devres_destroy(struct device *dev, dr_release_t release, 399extern int devres_destroy(struct device *dev, dr_release_t release,
387 dr_match_t match, void *match_data); 400 dr_match_t match, void *match_data);
388 401
@@ -399,7 +412,7 @@ extern void devm_kfree(struct device *dev, void *p);
399 412
400struct device { 413struct device {
401 struct klist klist_children; 414 struct klist klist_children;
402 struct klist_node knode_parent; /* node in sibling list */ 415 struct klist_node knode_parent; /* node in sibling list */
403 struct klist_node knode_driver; 416 struct klist_node knode_driver;
404 struct klist_node knode_bus; 417 struct klist_node knode_bus;
405 struct device *parent; 418 struct device *parent;
@@ -414,7 +427,7 @@ struct device {
414 * its driver. 427 * its driver.
415 */ 428 */
416 429
417 struct bus_type * bus; /* type of bus device is on */ 430 struct bus_type *bus; /* type of bus device is on */
418 struct device_driver *driver; /* which driver has allocated this 431 struct device_driver *driver; /* which driver has allocated this
419 device */ 432 device */
420 void *driver_data; /* data private to the driver */ 433 void *driver_data; /* data private to the driver */
@@ -445,10 +458,10 @@ struct device {
445 /* class_device migration path */ 458 /* class_device migration path */
446 struct list_head node; 459 struct list_head node;
447 struct class *class; 460 struct class *class;
448 dev_t devt; /* dev_t, creates the sysfs "dev" */ 461 dev_t devt; /* dev_t, creates the sysfs "dev" */
449 struct attribute_group **groups; /* optional groups */ 462 struct attribute_group **groups; /* optional groups */
450 463
451 void (*release)(struct device * dev); 464 void (*release)(struct device *dev);
452}; 465};
453 466
454#ifdef CONFIG_NUMA 467#ifdef CONFIG_NUMA
@@ -470,14 +483,12 @@ static inline void set_dev_node(struct device *dev, int node)
470} 483}
471#endif 484#endif
472 485
473static inline void * 486static inline void *dev_get_drvdata(struct device *dev)
474dev_get_drvdata (struct device *dev)
475{ 487{
476 return dev->driver_data; 488 return dev->driver_data;
477} 489}
478 490
479static inline void 491static inline void dev_set_drvdata(struct device *dev, void *data)
480dev_set_drvdata (struct device *dev, void *data)
481{ 492{
482 dev->driver_data = data; 493 dev->driver_data = data;
483} 494}
@@ -492,15 +503,15 @@ void driver_init(void);
492/* 503/*
493 * High level routines for use by the bus drivers 504 * High level routines for use by the bus drivers
494 */ 505 */
495extern int __must_check device_register(struct device * dev); 506extern int __must_check device_register(struct device *dev);
496extern void device_unregister(struct device * dev); 507extern void device_unregister(struct device *dev);
497extern void device_initialize(struct device * dev); 508extern void device_initialize(struct device *dev);
498extern int __must_check device_add(struct device * dev); 509extern int __must_check device_add(struct device *dev);
499extern void device_del(struct device * dev); 510extern void device_del(struct device *dev);
500extern int device_for_each_child(struct device *, void *, 511extern int device_for_each_child(struct device *dev, void *data,
501 int (*fn)(struct device *, void *)); 512 int (*fn)(struct device *dev, void *data));
502extern struct device *device_find_child(struct device *, void *data, 513extern struct device *device_find_child(struct device *dev, void *data,
503 int (*match)(struct device *, void *)); 514 int (*match)(struct device *dev, void *data));
504extern int device_rename(struct device *dev, char *new_name); 515extern int device_rename(struct device *dev, char *new_name);
505extern int device_move(struct device *dev, struct device *new_parent); 516extern int device_move(struct device *dev, struct device *new_parent);
506 517
@@ -509,8 +520,8 @@ extern int device_move(struct device *dev, struct device *new_parent);
509 * for information on use. 520 * for information on use.
510 */ 521 */
511extern int __must_check device_bind_driver(struct device *dev); 522extern int __must_check device_bind_driver(struct device *dev);
512extern void device_release_driver(struct device * dev); 523extern void device_release_driver(struct device *dev);
513extern int __must_check device_attach(struct device * dev); 524extern int __must_check device_attach(struct device *dev);
514extern int __must_check driver_attach(struct device_driver *drv); 525extern int __must_check driver_attach(struct device_driver *drv);
515extern int __must_check device_reprobe(struct device *dev); 526extern int __must_check device_reprobe(struct device *dev);
516 527
@@ -519,8 +530,16 @@ extern int __must_check device_reprobe(struct device *dev);
519 */ 530 */
520extern struct device *device_create(struct class *cls, struct device *parent, 531extern struct device *device_create(struct class *cls, struct device *parent,
521 dev_t devt, const char *fmt, ...) 532 dev_t devt, const char *fmt, ...)
522 __attribute__((format(printf,4,5))); 533 __attribute__((format(printf, 4, 5)));
523extern void device_destroy(struct class *cls, dev_t devt); 534extern void device_destroy(struct class *cls, dev_t devt);
535#ifdef CONFIG_PM_SLEEP
536extern void destroy_suspended_device(struct class *cls, dev_t devt);
537#else /* !CONFIG_PM_SLEEP */
538static inline void destroy_suspended_device(struct class *cls, dev_t devt)
539{
540 device_destroy(cls, devt);
541}
542#endif /* !CONFIG_PM_SLEEP */
524 543
525/* 544/*
526 * Platform "fixup" functions - allow the platform to have their say 545 * Platform "fixup" functions - allow the platform to have their say
@@ -528,17 +547,17 @@ extern void device_destroy(struct class *cls, dev_t devt);
528 * know about. 547 * know about.
529 */ 548 */
530/* Notify platform of device discovery */ 549/* Notify platform of device discovery */
531extern int (*platform_notify)(struct device * dev); 550extern int (*platform_notify)(struct device *dev);
532 551
533extern int (*platform_notify_remove)(struct device * dev); 552extern int (*platform_notify_remove)(struct device *dev);
534 553
535 554
536/** 555/**
537 * get_device - atomically increment the reference count for the device. 556 * get_device - atomically increment the reference count for the device.
538 * 557 *
539 */ 558 */
540extern struct device * get_device(struct device * dev); 559extern struct device *get_device(struct device *dev);
541extern void put_device(struct device * dev); 560extern void put_device(struct device *dev);
542 561
543 562
544/* drivers/base/power/shutdown.c */ 563/* drivers/base/power/shutdown.c */
@@ -547,22 +566,33 @@ extern void device_shutdown(void);
547/* drivers/base/sys.c */ 566/* drivers/base/sys.c */
548extern void sysdev_shutdown(void); 567extern void sysdev_shutdown(void);
549 568
550
551/* drivers/base/firmware.c */
552extern int __must_check firmware_register(struct kset *);
553extern void firmware_unregister(struct kset *);
554
555/* debugging and troubleshooting/diagnostic helpers. */ 569/* debugging and troubleshooting/diagnostic helpers. */
556extern const char *dev_driver_string(struct device *dev); 570extern const char *dev_driver_string(struct device *dev);
557#define dev_printk(level, dev, format, arg...) \ 571#define dev_printk(level, dev, format, arg...) \
558 printk(level "%s %s: " format , dev_driver_string(dev) , (dev)->bus_id , ## arg) 572 printk(level "%s %s: " format , dev_driver_string(dev) , \
573 (dev)->bus_id , ## arg)
574
575#define dev_emerg(dev, format, arg...) \
576 dev_printk(KERN_EMERG , dev , format , ## arg)
577#define dev_alert(dev, format, arg...) \
578 dev_printk(KERN_ALERT , dev , format , ## arg)
579#define dev_crit(dev, format, arg...) \
580 dev_printk(KERN_CRIT , dev , format , ## arg)
581#define dev_err(dev, format, arg...) \
582 dev_printk(KERN_ERR , dev , format , ## arg)
583#define dev_warn(dev, format, arg...) \
584 dev_printk(KERN_WARNING , dev , format , ## arg)
585#define dev_notice(dev, format, arg...) \
586 dev_printk(KERN_NOTICE , dev , format , ## arg)
587#define dev_info(dev, format, arg...) \
588 dev_printk(KERN_INFO , dev , format , ## arg)
559 589
560#ifdef DEBUG 590#ifdef DEBUG
561#define dev_dbg(dev, format, arg...) \ 591#define dev_dbg(dev, format, arg...) \
562 dev_printk(KERN_DEBUG , dev , format , ## arg) 592 dev_printk(KERN_DEBUG , dev , format , ## arg)
563#else 593#else
564static inline int __attribute__ ((format (printf, 2, 3))) 594static inline int __attribute__ ((format (printf, 2, 3)))
565dev_dbg(struct device * dev, const char * fmt, ...) 595dev_dbg(struct device *dev, const char *fmt, ...)
566{ 596{
567 return 0; 597 return 0;
568} 598}
@@ -572,21 +602,12 @@ dev_dbg(struct device * dev, const char * fmt, ...)
572#define dev_vdbg dev_dbg 602#define dev_vdbg dev_dbg
573#else 603#else
574static inline int __attribute__ ((format (printf, 2, 3))) 604static inline int __attribute__ ((format (printf, 2, 3)))
575dev_vdbg(struct device * dev, const char * fmt, ...) 605dev_vdbg(struct device *dev, const char *fmt, ...)
576{ 606{
577 return 0; 607 return 0;
578} 608}
579#endif 609#endif
580 610
581#define dev_err(dev, format, arg...) \
582 dev_printk(KERN_ERR , dev , format , ## arg)
583#define dev_info(dev, format, arg...) \
584 dev_printk(KERN_INFO , dev , format , ## arg)
585#define dev_warn(dev, format, arg...) \
586 dev_printk(KERN_WARNING , dev , format , ## arg)
587#define dev_notice(dev, format, arg...) \
588 dev_printk(KERN_NOTICE , dev , format , ## arg)
589
590/* Create alias, so I can be autoloaded. */ 611/* Create alias, so I can be autoloaded. */
591#define MODULE_ALIAS_CHARDEV(major,minor) \ 612#define MODULE_ALIAS_CHARDEV(major,minor) \
592 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) 613 MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
diff --git a/include/linux/dlm.h b/include/linux/dlm.h
index be9d278761e0..c743fbc769db 100644
--- a/include/linux/dlm.h
+++ b/include/linux/dlm.h
@@ -19,148 +19,12 @@
19 * routines and structures to use DLM lockspaces 19 * routines and structures to use DLM lockspaces
20 */ 20 */
21 21
22/* 22/* Lock levels and flags are here */
23 * Lock Modes 23#include <linux/dlmconstants.h>
24 */
25 24
26#define DLM_LOCK_IV -1 /* invalid */
27#define DLM_LOCK_NL 0 /* null */
28#define DLM_LOCK_CR 1 /* concurrent read */
29#define DLM_LOCK_CW 2 /* concurrent write */
30#define DLM_LOCK_PR 3 /* protected read */
31#define DLM_LOCK_PW 4 /* protected write */
32#define DLM_LOCK_EX 5 /* exclusive */
33
34/*
35 * Maximum size in bytes of a dlm_lock name
36 */
37 25
38#define DLM_RESNAME_MAXLEN 64 26#define DLM_RESNAME_MAXLEN 64
39 27
40/*
41 * Flags to dlm_lock
42 *
43 * DLM_LKF_NOQUEUE
44 *
45 * Do not queue the lock request on the wait queue if it cannot be granted
46 * immediately. If the lock cannot be granted because of this flag, DLM will
47 * either return -EAGAIN from the dlm_lock call or will return 0 from
48 * dlm_lock and -EAGAIN in the lock status block when the AST is executed.
49 *
50 * DLM_LKF_CANCEL
51 *
52 * Used to cancel a pending lock request or conversion. A converting lock is
53 * returned to its previously granted mode.
54 *
55 * DLM_LKF_CONVERT
56 *
57 * Indicates a lock conversion request. For conversions the name and namelen
58 * are ignored and the lock ID in the LKSB is used to identify the lock.
59 *
60 * DLM_LKF_VALBLK
61 *
62 * Requests DLM to return the current contents of the lock value block in the
63 * lock status block. When this flag is set in a lock conversion from PW or EX
64 * modes, DLM assigns the value specified in the lock status block to the lock
65 * value block of the lock resource. The LVB is a DLM_LVB_LEN size array
66 * containing application-specific information.
67 *
68 * DLM_LKF_QUECVT
69 *
70 * Force a conversion request to be queued, even if it is compatible with
71 * the granted modes of other locks on the same resource.
72 *
73 * DLM_LKF_IVVALBLK
74 *
75 * Invalidate the lock value block.
76 *
77 * DLM_LKF_CONVDEADLK
78 *
79 * Allows the dlm to resolve conversion deadlocks internally by demoting the
80 * granted mode of a converting lock to NL. The DLM_SBF_DEMOTED flag is
81 * returned for a conversion that's been effected by this.
82 *
83 * DLM_LKF_PERSISTENT
84 *
85 * Only relevant to locks originating in userspace. A persistent lock will not
86 * be removed if the process holding the lock exits.
87 *
88 * DLM_LKF_NODLCKWT
89 *
90 * Do not cancel the lock if it gets into conversion deadlock.
91 * Exclude this lock from being monitored due to DLM_LSFL_TIMEWARN.
92 *
93 * DLM_LKF_NODLCKBLK
94 *
95 * net yet implemented
96 *
97 * DLM_LKF_EXPEDITE
98 *
99 * Used only with new requests for NL mode locks. Tells the lock manager
100 * to grant the lock, ignoring other locks in convert and wait queues.
101 *
102 * DLM_LKF_NOQUEUEBAST
103 *
104 * Send blocking AST's before returning -EAGAIN to the caller. It is only
105 * used along with the NOQUEUE flag. Blocking AST's are not sent for failed
106 * NOQUEUE requests otherwise.
107 *
108 * DLM_LKF_HEADQUE
109 *
110 * Add a lock to the head of the convert or wait queue rather than the tail.
111 *
112 * DLM_LKF_NOORDER
113 *
114 * Disregard the standard grant order rules and grant a lock as soon as it
115 * is compatible with other granted locks.
116 *
117 * DLM_LKF_ORPHAN
118 *
119 * not yet implemented
120 *
121 * DLM_LKF_ALTPR
122 *
123 * If the requested mode cannot be granted immediately, try to grant the lock
124 * in PR mode instead. If this alternate mode is granted instead of the
125 * requested mode, DLM_SBF_ALTMODE is returned in the lksb.
126 *
127 * DLM_LKF_ALTCW
128 *
129 * The same as ALTPR, but the alternate mode is CW.
130 *
131 * DLM_LKF_FORCEUNLOCK
132 *
133 * Unlock the lock even if it is converting or waiting or has sublocks.
134 * Only really for use by the userland device.c code.
135 *
136 */
137
138#define DLM_LKF_NOQUEUE 0x00000001
139#define DLM_LKF_CANCEL 0x00000002
140#define DLM_LKF_CONVERT 0x00000004
141#define DLM_LKF_VALBLK 0x00000008
142#define DLM_LKF_QUECVT 0x00000010
143#define DLM_LKF_IVVALBLK 0x00000020
144#define DLM_LKF_CONVDEADLK 0x00000040
145#define DLM_LKF_PERSISTENT 0x00000080
146#define DLM_LKF_NODLCKWT 0x00000100
147#define DLM_LKF_NODLCKBLK 0x00000200
148#define DLM_LKF_EXPEDITE 0x00000400
149#define DLM_LKF_NOQUEUEBAST 0x00000800
150#define DLM_LKF_HEADQUE 0x00001000
151#define DLM_LKF_NOORDER 0x00002000
152#define DLM_LKF_ORPHAN 0x00004000
153#define DLM_LKF_ALTPR 0x00008000
154#define DLM_LKF_ALTCW 0x00010000
155#define DLM_LKF_FORCEUNLOCK 0x00020000
156#define DLM_LKF_TIMEOUT 0x00040000
157
158/*
159 * Some return codes that are not in errno.h
160 */
161
162#define DLM_ECANCEL 0x10001
163#define DLM_EUNLOCK 0x10002
164 28
165typedef void dlm_lockspace_t; 29typedef void dlm_lockspace_t;
166 30
diff --git a/include/linux/dlmconstants.h b/include/linux/dlmconstants.h
new file mode 100644
index 000000000000..fddb3d3ff321
--- /dev/null
+++ b/include/linux/dlmconstants.h
@@ -0,0 +1,159 @@
1/******************************************************************************
2*******************************************************************************
3**
4** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
6**
7** This copyrighted material is made available to anyone wishing to use,
8** modify, copy, or redistribute it subject to the terms and conditions
9** of the GNU General Public License v.2.
10**
11*******************************************************************************
12******************************************************************************/
13
14#ifndef __DLMCONSTANTS_DOT_H__
15#define __DLMCONSTANTS_DOT_H__
16
17/*
18 * Constants used by DLM interface.
19 */
20
21/*
22 * Lock Modes
23 */
24
25#define DLM_LOCK_IV (-1) /* invalid */
26#define DLM_LOCK_NL 0 /* null */
27#define DLM_LOCK_CR 1 /* concurrent read */
28#define DLM_LOCK_CW 2 /* concurrent write */
29#define DLM_LOCK_PR 3 /* protected read */
30#define DLM_LOCK_PW 4 /* protected write */
31#define DLM_LOCK_EX 5 /* exclusive */
32
33
34/*
35 * Flags to dlm_lock
36 *
37 * DLM_LKF_NOQUEUE
38 *
39 * Do not queue the lock request on the wait queue if it cannot be granted
40 * immediately. If the lock cannot be granted because of this flag, DLM will
41 * either return -EAGAIN from the dlm_lock call or will return 0 from
42 * dlm_lock and -EAGAIN in the lock status block when the AST is executed.
43 *
44 * DLM_LKF_CANCEL
45 *
46 * Used to cancel a pending lock request or conversion. A converting lock is
47 * returned to its previously granted mode.
48 *
49 * DLM_LKF_CONVERT
50 *
51 * Indicates a lock conversion request. For conversions the name and namelen
52 * are ignored and the lock ID in the LKSB is used to identify the lock.
53 *
54 * DLM_LKF_VALBLK
55 *
56 * Requests DLM to return the current contents of the lock value block in the
57 * lock status block. When this flag is set in a lock conversion from PW or EX
58 * modes, DLM assigns the value specified in the lock status block to the lock
59 * value block of the lock resource. The LVB is a DLM_LVB_LEN size array
60 * containing application-specific information.
61 *
62 * DLM_LKF_QUECVT
63 *
64 * Force a conversion request to be queued, even if it is compatible with
65 * the granted modes of other locks on the same resource.
66 *
67 * DLM_LKF_IVVALBLK
68 *
69 * Invalidate the lock value block.
70 *
71 * DLM_LKF_CONVDEADLK
72 *
73 * Allows the dlm to resolve conversion deadlocks internally by demoting the
74 * granted mode of a converting lock to NL. The DLM_SBF_DEMOTED flag is
75 * returned for a conversion that's been effected by this.
76 *
77 * DLM_LKF_PERSISTENT
78 *
79 * Only relevant to locks originating in userspace. A persistent lock will not
80 * be removed if the process holding the lock exits.
81 *
82 * DLM_LKF_NODLCKWT
83 *
84 * Do not cancel the lock if it gets into conversion deadlock.
85 * Exclude this lock from being monitored due to DLM_LSFL_TIMEWARN.
86 *
87 * DLM_LKF_NODLCKBLK
88 *
89 * net yet implemented
90 *
91 * DLM_LKF_EXPEDITE
92 *
93 * Used only with new requests for NL mode locks. Tells the lock manager
94 * to grant the lock, ignoring other locks in convert and wait queues.
95 *
96 * DLM_LKF_NOQUEUEBAST
97 *
98 * Send blocking AST's before returning -EAGAIN to the caller. It is only
99 * used along with the NOQUEUE flag. Blocking AST's are not sent for failed
100 * NOQUEUE requests otherwise.
101 *
102 * DLM_LKF_HEADQUE
103 *
104 * Add a lock to the head of the convert or wait queue rather than the tail.
105 *
106 * DLM_LKF_NOORDER
107 *
108 * Disregard the standard grant order rules and grant a lock as soon as it
109 * is compatible with other granted locks.
110 *
111 * DLM_LKF_ORPHAN
112 *
113 * not yet implemented
114 *
115 * DLM_LKF_ALTPR
116 *
117 * If the requested mode cannot be granted immediately, try to grant the lock
118 * in PR mode instead. If this alternate mode is granted instead of the
119 * requested mode, DLM_SBF_ALTMODE is returned in the lksb.
120 *
121 * DLM_LKF_ALTCW
122 *
123 * The same as ALTPR, but the alternate mode is CW.
124 *
125 * DLM_LKF_FORCEUNLOCK
126 *
127 * Unlock the lock even if it is converting or waiting or has sublocks.
128 * Only really for use by the userland device.c code.
129 *
130 */
131
132#define DLM_LKF_NOQUEUE 0x00000001
133#define DLM_LKF_CANCEL 0x00000002
134#define DLM_LKF_CONVERT 0x00000004
135#define DLM_LKF_VALBLK 0x00000008
136#define DLM_LKF_QUECVT 0x00000010
137#define DLM_LKF_IVVALBLK 0x00000020
138#define DLM_LKF_CONVDEADLK 0x00000040
139#define DLM_LKF_PERSISTENT 0x00000080
140#define DLM_LKF_NODLCKWT 0x00000100
141#define DLM_LKF_NODLCKBLK 0x00000200
142#define DLM_LKF_EXPEDITE 0x00000400
143#define DLM_LKF_NOQUEUEBAST 0x00000800
144#define DLM_LKF_HEADQUE 0x00001000
145#define DLM_LKF_NOORDER 0x00002000
146#define DLM_LKF_ORPHAN 0x00004000
147#define DLM_LKF_ALTPR 0x00008000
148#define DLM_LKF_ALTCW 0x00010000
149#define DLM_LKF_FORCEUNLOCK 0x00020000
150#define DLM_LKF_TIMEOUT 0x00040000
151
152/*
153 * Some return codes that are not in errno.h
154 */
155
156#define DLM_ECANCEL 0x10001
157#define DLM_EUNLOCK 0x10002
158
159#endif /* __DLMCONSTANTS_DOT_H__ */
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index a3b6035b6c86..55c9a6952f44 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -132,7 +132,7 @@ struct dma_chan {
132 132
133 /* sysfs */ 133 /* sysfs */
134 int chan_id; 134 int chan_id;
135 struct class_device class_dev; 135 struct device dev;
136 136
137 struct kref refcount; 137 struct kref refcount;
138 int slow_ref; 138 int slow_ref;
@@ -142,6 +142,7 @@ struct dma_chan {
142 struct dma_chan_percpu *local; 142 struct dma_chan_percpu *local;
143}; 143};
144 144
145#define to_dma_chan(p) container_of(p, struct dma_chan, dev)
145 146
146void dma_chan_cleanup(struct kref *kref); 147void dma_chan_cleanup(struct kref *kref);
147 148
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index 00fc7a9c35ec..5b42a659a308 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -78,6 +78,8 @@ extern const struct dmi_device * dmi_find_device(int type, const char *name,
78extern void dmi_scan_machine(void); 78extern void dmi_scan_machine(void);
79extern int dmi_get_year(int field); 79extern int dmi_get_year(int field);
80extern int dmi_name_in_vendors(const char *str); 80extern int dmi_name_in_vendors(const char *str);
81extern int dmi_available;
82extern char *dmi_get_slot(int slot);
81 83
82#else 84#else
83 85
@@ -87,6 +89,8 @@ static inline const struct dmi_device * dmi_find_device(int type, const char *na
87 const struct dmi_device *from) { return NULL; } 89 const struct dmi_device *from) { return NULL; }
88static inline int dmi_get_year(int year) { return 0; } 90static inline int dmi_get_year(int year) { return 0; }
89static inline int dmi_name_in_vendors(const char *s) { return 0; } 91static inline int dmi_name_in_vendors(const char *s) { return 0; }
92#define dmi_available 0
93static inline char *dmi_get_slot(int slot) { return NULL; }
90 94
91#endif 95#endif
92 96
diff --git a/include/linux/elevator.h b/include/linux/elevator.h
index e8f42133a616..639624b55fbe 100644
--- a/include/linux/elevator.h
+++ b/include/linux/elevator.h
@@ -119,7 +119,7 @@ extern void elv_put_request(struct request_queue *, struct request *);
119/* 119/*
120 * io scheduler registration 120 * io scheduler registration
121 */ 121 */
122extern int elv_register(struct elevator_type *); 122extern void elv_register(struct elevator_type *);
123extern void elv_unregister(struct elevator_type *); 123extern void elv_unregister(struct elevator_type *);
124 124
125/* 125/*
diff --git a/include/linux/elf.h b/include/linux/elf.h
index 576e83bd6d88..7ceb24d87c1a 100644
--- a/include/linux/elf.h
+++ b/include/linux/elf.h
@@ -355,6 +355,7 @@ typedef struct elf64_shdr {
355#define NT_AUXV 6 355#define NT_AUXV 6
356#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */ 356#define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/common.h */
357#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ 357#define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */
358#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
358 359
359 360
360/* Note header in a PT_NOTE section */ 361/* Note header in a PT_NOTE section */
diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h
index e831759b2fb5..278e3ef05336 100644
--- a/include/linux/elfnote.h
+++ b/include/linux/elfnote.h
@@ -76,7 +76,7 @@
76 typeof(desc) _desc \ 76 typeof(desc) _desc \
77 __attribute__((aligned(sizeof(Elf##size##_Word)))); \ 77 __attribute__((aligned(sizeof(Elf##size##_Word)))); \
78 } _ELFNOTE_PASTE(_note_, unique) \ 78 } _ELFNOTE_PASTE(_note_, unique) \
79 __attribute_used__ \ 79 __used \
80 __attribute__((section(".note." name), \ 80 __attribute__((section(".note." name), \
81 aligned(sizeof(Elf##size##_Word)), \ 81 aligned(sizeof(Elf##size##_Word)), \
82 unused)) = { \ 82 unused)) = { \
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index d2a96cbf4f0e..cf79853967ff 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -32,18 +32,13 @@
32 * On x86-64 make the 64bit structure have the same alignment as the 32 * On x86-64 make the 64bit structure have the same alignment as the
33 * 32bit structure. This makes 32bit emulation easier. 33 * 32bit structure. This makes 32bit emulation easier.
34 * 34 *
35 * UML/x86_64 needs the same packing as x86_64 - UML + UML_X86 + 35 * UML/x86_64 needs the same packing as x86_64
36 * 64_BIT adds up to UML/x86_64.
37 */ 36 */
38#ifdef __x86_64__ 37#ifdef __x86_64__
39#define EPOLL_PACKED __attribute__((packed)) 38#define EPOLL_PACKED __attribute__((packed))
40#else 39#else
41#if defined(CONFIG_UML) && defined(CONFIG_UML_X86) && defined(CONFIG_64BIT)
42#define EPOLL_PACKED __attribute__((packed))
43#else
44#define EPOLL_PACKED 40#define EPOLL_PACKED
45#endif 41#endif
46#endif
47 42
48struct epoll_event { 43struct epoll_event {
49 __u32 events; 44 __u32 events;
diff --git a/include/linux/ext2_fs.h b/include/linux/ext2_fs.h
index 0f6c86c634fd..84cec2aa9f1e 100644
--- a/include/linux/ext2_fs.h
+++ b/include/linux/ext2_fs.h
@@ -563,11 +563,4 @@ enum {
563 ~EXT2_DIR_ROUND) 563 ~EXT2_DIR_ROUND)
564#define EXT2_MAX_REC_LEN ((1<<16)-1) 564#define EXT2_MAX_REC_LEN ((1<<16)-1)
565 565
566static inline ext2_fsblk_t
567ext2_group_first_block_no(struct super_block *sb, unsigned long group_no)
568{
569 return group_no * (ext2_fsblk_t)EXT2_BLOCKS_PER_GROUP(sb) +
570 le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block);
571}
572
573#endif /* _LINUX_EXT2_FS_H */ 566#endif /* _LINUX_EXT2_FS_H */
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index 64134456ed8c..241c01cb92b2 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -656,6 +656,26 @@ struct ext3_dir_entry_2 {
656#define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1) 656#define EXT3_DIR_ROUND (EXT3_DIR_PAD - 1)
657#define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \ 657#define EXT3_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT3_DIR_ROUND) & \
658 ~EXT3_DIR_ROUND) 658 ~EXT3_DIR_ROUND)
659#define EXT3_MAX_REC_LEN ((1<<16)-1)
660
661static inline unsigned ext3_rec_len_from_disk(__le16 dlen)
662{
663 unsigned len = le16_to_cpu(dlen);
664
665 if (len == EXT3_MAX_REC_LEN)
666 return 1 << 16;
667 return len;
668}
669
670static inline __le16 ext3_rec_len_to_disk(unsigned len)
671{
672 if (len == (1 << 16))
673 return cpu_to_le16(EXT3_MAX_REC_LEN);
674 else if (len > (1 << 16))
675 BUG();
676 return cpu_to_le16(len);
677}
678
659/* 679/*
660 * Hash Tree Directory indexing 680 * Hash Tree Directory indexing
661 * (c) Daniel Phillips, 2001 681 * (c) Daniel Phillips, 2001
diff --git a/include/linux/ext4_fs.h b/include/linux/ext4_fs.h
index 97dd409d5f4a..1852313fc7c7 100644
--- a/include/linux/ext4_fs.h
+++ b/include/linux/ext4_fs.h
@@ -20,6 +20,8 @@
20#include <linux/blkdev.h> 20#include <linux/blkdev.h>
21#include <linux/magic.h> 21#include <linux/magic.h>
22 22
23#include <linux/ext4_fs_i.h>
24
23/* 25/*
24 * The second extended filesystem constants/structures 26 * The second extended filesystem constants/structures
25 */ 27 */
@@ -51,6 +53,50 @@
51#define ext4_debug(f, a...) do {} while (0) 53#define ext4_debug(f, a...) do {} while (0)
52#endif 54#endif
53 55
56#define EXT4_MULTIBLOCK_ALLOCATOR 1
57
58/* prefer goal again. length */
59#define EXT4_MB_HINT_MERGE 1
60/* blocks already reserved */
61#define EXT4_MB_HINT_RESERVED 2
62/* metadata is being allocated */
63#define EXT4_MB_HINT_METADATA 4
64/* first blocks in the file */
65#define EXT4_MB_HINT_FIRST 8
66/* search for the best chunk */
67#define EXT4_MB_HINT_BEST 16
68/* data is being allocated */
69#define EXT4_MB_HINT_DATA 32
70/* don't preallocate (for tails) */
71#define EXT4_MB_HINT_NOPREALLOC 64
72/* allocate for locality group */
73#define EXT4_MB_HINT_GROUP_ALLOC 128
74/* allocate goal blocks or none */
75#define EXT4_MB_HINT_GOAL_ONLY 256
76/* goal is meaningful */
77#define EXT4_MB_HINT_TRY_GOAL 512
78
79struct ext4_allocation_request {
80 /* target inode for block we're allocating */
81 struct inode *inode;
82 /* logical block in target inode */
83 ext4_lblk_t logical;
84 /* phys. target (a hint) */
85 ext4_fsblk_t goal;
86 /* the closest logical allocated block to the left */
87 ext4_lblk_t lleft;
88 /* phys. block for ^^^ */
89 ext4_fsblk_t pleft;
90 /* the closest logical allocated block to the right */
91 ext4_lblk_t lright;
92 /* phys. block for ^^^ */
93 ext4_fsblk_t pright;
94 /* how many blocks we want to allocate */
95 unsigned long len;
96 /* flags. see above EXT4_MB_HINT_* */
97 unsigned long flags;
98};
99
54/* 100/*
55 * Special inodes numbers 101 * Special inodes numbers
56 */ 102 */
@@ -73,8 +119,8 @@
73 * Macro-instructions used to manage several block sizes 119 * Macro-instructions used to manage several block sizes
74 */ 120 */
75#define EXT4_MIN_BLOCK_SIZE 1024 121#define EXT4_MIN_BLOCK_SIZE 1024
76#define EXT4_MAX_BLOCK_SIZE 4096 122#define EXT4_MAX_BLOCK_SIZE 65536
77#define EXT4_MIN_BLOCK_LOG_SIZE 10 123#define EXT4_MIN_BLOCK_LOG_SIZE 10
78#ifdef __KERNEL__ 124#ifdef __KERNEL__
79# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize) 125# define EXT4_BLOCK_SIZE(s) ((s)->s_blocksize)
80#else 126#else
@@ -118,6 +164,11 @@ struct ext4_group_desc
118 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */ 164 __le32 bg_block_bitmap_hi; /* Blocks bitmap block MSB */
119 __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */ 165 __le32 bg_inode_bitmap_hi; /* Inodes bitmap block MSB */
120 __le32 bg_inode_table_hi; /* Inodes table block MSB */ 166 __le32 bg_inode_table_hi; /* Inodes table block MSB */
167 __le16 bg_free_blocks_count_hi;/* Free blocks count MSB */
168 __le16 bg_free_inodes_count_hi;/* Free inodes count MSB */
169 __le16 bg_used_dirs_count_hi; /* Directories count MSB */
170 __le16 bg_itable_unused_hi; /* Unused inodes count MSB */
171 __u32 bg_reserved2[3];
121}; 172};
122 173
123#define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */ 174#define EXT4_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not in use */
@@ -178,8 +229,9 @@ struct ext4_group_desc
178#define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */ 229#define EXT4_NOTAIL_FL 0x00008000 /* file tail should not be merged */
179#define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */ 230#define EXT4_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
180#define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/ 231#define EXT4_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
181#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */ 232#define EXT4_HUGE_FILE_FL 0x00040000 /* Set to each huge file */
182#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */ 233#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
234#define EXT4_RESERVED_FL 0x80000000 /* reserved for ext4 lib */
183 235
184#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */ 236#define EXT4_FL_USER_VISIBLE 0x000BDFFF /* User visible flags */
185#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */ 237#define EXT4_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
@@ -237,6 +289,7 @@ struct ext4_new_group_data {
237#endif 289#endif
238#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long) 290#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
239#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long) 291#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
292#define EXT4_IOC_MIGRATE _IO('f', 7)
240 293
241/* 294/*
242 * ioctl commands in 32 bit emulation 295 * ioctl commands in 32 bit emulation
@@ -275,18 +328,18 @@ struct ext4_mount_options {
275struct ext4_inode { 328struct ext4_inode {
276 __le16 i_mode; /* File mode */ 329 __le16 i_mode; /* File mode */
277 __le16 i_uid; /* Low 16 bits of Owner Uid */ 330 __le16 i_uid; /* Low 16 bits of Owner Uid */
278 __le32 i_size; /* Size in bytes */ 331 __le32 i_size_lo; /* Size in bytes */
279 __le32 i_atime; /* Access time */ 332 __le32 i_atime; /* Access time */
280 __le32 i_ctime; /* Inode Change time */ 333 __le32 i_ctime; /* Inode Change time */
281 __le32 i_mtime; /* Modification time */ 334 __le32 i_mtime; /* Modification time */
282 __le32 i_dtime; /* Deletion Time */ 335 __le32 i_dtime; /* Deletion Time */
283 __le16 i_gid; /* Low 16 bits of Group Id */ 336 __le16 i_gid; /* Low 16 bits of Group Id */
284 __le16 i_links_count; /* Links count */ 337 __le16 i_links_count; /* Links count */
285 __le32 i_blocks; /* Blocks count */ 338 __le32 i_blocks_lo; /* Blocks count */
286 __le32 i_flags; /* File flags */ 339 __le32 i_flags; /* File flags */
287 union { 340 union {
288 struct { 341 struct {
289 __u32 l_i_reserved1; 342 __le32 l_i_version;
290 } linux1; 343 } linux1;
291 struct { 344 struct {
292 __u32 h_i_translator; 345 __u32 h_i_translator;
@@ -297,12 +350,12 @@ struct ext4_inode {
297 } osd1; /* OS dependent 1 */ 350 } osd1; /* OS dependent 1 */
298 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */ 351 __le32 i_block[EXT4_N_BLOCKS];/* Pointers to blocks */
299 __le32 i_generation; /* File version (for NFS) */ 352 __le32 i_generation; /* File version (for NFS) */
300 __le32 i_file_acl; /* File ACL */ 353 __le32 i_file_acl_lo; /* File ACL */
301 __le32 i_dir_acl; /* Directory ACL */ 354 __le32 i_size_high;
302 __le32 i_obso_faddr; /* Obsoleted fragment address */ 355 __le32 i_obso_faddr; /* Obsoleted fragment address */
303 union { 356 union {
304 struct { 357 struct {
305 __le16 l_i_reserved1; /* Obsoleted fragment number/size which are removed in ext4 */ 358 __le16 l_i_blocks_high; /* were l_i_reserved1 */
306 __le16 l_i_file_acl_high; 359 __le16 l_i_file_acl_high;
307 __le16 l_i_uid_high; /* these 2 fields */ 360 __le16 l_i_uid_high; /* these 2 fields */
308 __le16 l_i_gid_high; /* were reserved2[0] */ 361 __le16 l_i_gid_high; /* were reserved2[0] */
@@ -328,9 +381,9 @@ struct ext4_inode {
328 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */ 381 __le32 i_atime_extra; /* extra Access time (nsec << 2 | epoch) */
329 __le32 i_crtime; /* File Creation time */ 382 __le32 i_crtime; /* File Creation time */
330 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */ 383 __le32 i_crtime_extra; /* extra FileCreationtime (nsec << 2 | epoch) */
384 __le32 i_version_hi; /* high 32 bits for 64-bit version */
331}; 385};
332 386
333#define i_size_high i_dir_acl
334 387
335#define EXT4_EPOCH_BITS 2 388#define EXT4_EPOCH_BITS 2
336#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1) 389#define EXT4_EPOCH_MASK ((1 << EXT4_EPOCH_BITS) - 1)
@@ -402,9 +455,12 @@ do { \
402 raw_inode->xtime ## _extra); \ 455 raw_inode->xtime ## _extra); \
403} while (0) 456} while (0)
404 457
458#define i_disk_version osd1.linux1.l_i_version
459
405#if defined(__KERNEL__) || defined(__linux__) 460#if defined(__KERNEL__) || defined(__linux__)
406#define i_reserved1 osd1.linux1.l_i_reserved1 461#define i_reserved1 osd1.linux1.l_i_reserved1
407#define i_file_acl_high osd2.linux2.l_i_file_acl_high 462#define i_file_acl_high osd2.linux2.l_i_file_acl_high
463#define i_blocks_high osd2.linux2.l_i_blocks_high
408#define i_uid_low i_uid 464#define i_uid_low i_uid
409#define i_gid_low i_gid 465#define i_gid_low i_gid
410#define i_uid_high osd2.linux2.l_i_uid_high 466#define i_uid_high osd2.linux2.l_i_uid_high
@@ -461,7 +517,10 @@ do { \
461#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */ 517#define EXT4_MOUNT_USRQUOTA 0x100000 /* "old" user quota */
462#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */ 518#define EXT4_MOUNT_GRPQUOTA 0x200000 /* "old" group quota */
463#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */ 519#define EXT4_MOUNT_EXTENTS 0x400000 /* Extents support */
464 520#define EXT4_MOUNT_JOURNAL_CHECKSUM 0x800000 /* Journal checksums */
521#define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT 0x1000000 /* Journal Async Commit */
522#define EXT4_MOUNT_I_VERSION 0x2000000 /* i_version support */
523#define EXT4_MOUNT_MBALLOC 0x4000000 /* Buddy allocation support */
465/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */ 524/* Compatibility, for having both ext2_fs.h and ext4_fs.h included at once */
466#ifndef _LINUX_EXT2_FS_H 525#ifndef _LINUX_EXT2_FS_H
467#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt 526#define clear_opt(o, opt) o &= ~EXT4_MOUNT_##opt
@@ -481,6 +540,7 @@ do { \
481#define ext4_test_bit ext2_test_bit 540#define ext4_test_bit ext2_test_bit
482#define ext4_find_first_zero_bit ext2_find_first_zero_bit 541#define ext4_find_first_zero_bit ext2_find_first_zero_bit
483#define ext4_find_next_zero_bit ext2_find_next_zero_bit 542#define ext4_find_next_zero_bit ext2_find_next_zero_bit
543#define ext4_find_next_bit ext2_find_next_bit
484 544
485/* 545/*
486 * Maximal mount counts between two filesystem checks 546 * Maximal mount counts between two filesystem checks
@@ -671,6 +731,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
671#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 731#define EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
672#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 732#define EXT4_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
673#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 733#define EXT4_FEATURE_RO_COMPAT_BTREE_DIR 0x0004
734#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
674#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010 735#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
675#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020 736#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
676#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040 737#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
@@ -682,6 +743,7 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
682#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010 743#define EXT4_FEATURE_INCOMPAT_META_BG 0x0010
683#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */ 744#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* extents support */
684#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 745#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
746#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
685#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 747#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
686 748
687#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR 749#define EXT4_FEATURE_COMPAT_SUPP EXT2_FEATURE_COMPAT_EXT_ATTR
@@ -696,7 +758,8 @@ static inline int ext4_valid_inum(struct super_block *sb, unsigned long ino)
696 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \ 758 EXT4_FEATURE_RO_COMPAT_GDT_CSUM| \
697 EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \ 759 EXT4_FEATURE_RO_COMPAT_DIR_NLINK | \
698 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \ 760 EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE | \
699 EXT4_FEATURE_RO_COMPAT_BTREE_DIR) 761 EXT4_FEATURE_RO_COMPAT_BTREE_DIR |\
762 EXT4_FEATURE_RO_COMPAT_HUGE_FILE)
700 763
701/* 764/*
702 * Default values for user and/or group using reserved blocks 765 * Default values for user and/or group using reserved blocks
@@ -767,6 +830,26 @@ struct ext4_dir_entry_2 {
767#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1) 830#define EXT4_DIR_ROUND (EXT4_DIR_PAD - 1)
768#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \ 831#define EXT4_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT4_DIR_ROUND) & \
769 ~EXT4_DIR_ROUND) 832 ~EXT4_DIR_ROUND)
833#define EXT4_MAX_REC_LEN ((1<<16)-1)
834
835static inline unsigned ext4_rec_len_from_disk(__le16 dlen)
836{
837 unsigned len = le16_to_cpu(dlen);
838
839 if (len == EXT4_MAX_REC_LEN)
840 return 1 << 16;
841 return len;
842}
843
844static inline __le16 ext4_rec_len_to_disk(unsigned len)
845{
846 if (len == (1 << 16))
847 return cpu_to_le16(EXT4_MAX_REC_LEN);
848 else if (len > (1 << 16))
849 BUG();
850 return cpu_to_le16(len);
851}
852
770/* 853/*
771 * Hash Tree Directory indexing 854 * Hash Tree Directory indexing
772 * (c) Daniel Phillips, 2001 855 * (c) Daniel Phillips, 2001
@@ -810,7 +893,7 @@ struct ext4_iloc
810{ 893{
811 struct buffer_head *bh; 894 struct buffer_head *bh;
812 unsigned long offset; 895 unsigned long offset;
813 unsigned long block_group; 896 ext4_group_t block_group;
814}; 897};
815 898
816static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc) 899static inline struct ext4_inode *ext4_raw_inode(struct ext4_iloc *iloc)
@@ -835,7 +918,7 @@ struct dir_private_info {
835 918
836/* calculate the first block number of the group */ 919/* calculate the first block number of the group */
837static inline ext4_fsblk_t 920static inline ext4_fsblk_t
838ext4_group_first_block_no(struct super_block *sb, unsigned long group_no) 921ext4_group_first_block_no(struct super_block *sb, ext4_group_t group_no)
839{ 922{
840 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) + 923 return group_no * (ext4_fsblk_t)EXT4_BLOCKS_PER_GROUP(sb) +
841 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block); 924 le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block);
@@ -866,21 +949,24 @@ extern unsigned int ext4_block_group(struct super_block *sb,
866 ext4_fsblk_t blocknr); 949 ext4_fsblk_t blocknr);
867extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb, 950extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,
868 ext4_fsblk_t blocknr); 951 ext4_fsblk_t blocknr);
869extern int ext4_bg_has_super(struct super_block *sb, int group); 952extern int ext4_bg_has_super(struct super_block *sb, ext4_group_t group);
870extern unsigned long ext4_bg_num_gdb(struct super_block *sb, int group); 953extern unsigned long ext4_bg_num_gdb(struct super_block *sb,
954 ext4_group_t group);
871extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode, 955extern ext4_fsblk_t ext4_new_block (handle_t *handle, struct inode *inode,
872 ext4_fsblk_t goal, int *errp); 956 ext4_fsblk_t goal, int *errp);
873extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode, 957extern ext4_fsblk_t ext4_new_blocks (handle_t *handle, struct inode *inode,
874 ext4_fsblk_t goal, unsigned long *count, int *errp); 958 ext4_fsblk_t goal, unsigned long *count, int *errp);
959extern ext4_fsblk_t ext4_new_blocks_old(handle_t *handle, struct inode *inode,
960 ext4_fsblk_t goal, unsigned long *count, int *errp);
875extern void ext4_free_blocks (handle_t *handle, struct inode *inode, 961extern void ext4_free_blocks (handle_t *handle, struct inode *inode,
876 ext4_fsblk_t block, unsigned long count); 962 ext4_fsblk_t block, unsigned long count, int metadata);
877extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb, 963extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
878 ext4_fsblk_t block, unsigned long count, 964 ext4_fsblk_t block, unsigned long count,
879 unsigned long *pdquot_freed_blocks); 965 unsigned long *pdquot_freed_blocks);
880extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *); 966extern ext4_fsblk_t ext4_count_free_blocks (struct super_block *);
881extern void ext4_check_blocks_bitmap (struct super_block *); 967extern void ext4_check_blocks_bitmap (struct super_block *);
882extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb, 968extern struct ext4_group_desc * ext4_get_group_desc(struct super_block * sb,
883 unsigned int block_group, 969 ext4_group_t block_group,
884 struct buffer_head ** bh); 970 struct buffer_head ** bh);
885extern int ext4_should_retry_alloc(struct super_block *sb, int *retries); 971extern int ext4_should_retry_alloc(struct super_block *sb, int *retries);
886extern void ext4_init_block_alloc_info(struct inode *); 972extern void ext4_init_block_alloc_info(struct inode *);
@@ -911,15 +997,32 @@ extern unsigned long ext4_count_dirs (struct super_block *);
911extern void ext4_check_inodes_bitmap (struct super_block *); 997extern void ext4_check_inodes_bitmap (struct super_block *);
912extern unsigned long ext4_count_free (struct buffer_head *, unsigned); 998extern unsigned long ext4_count_free (struct buffer_head *, unsigned);
913 999
1000/* mballoc.c */
1001extern long ext4_mb_stats;
1002extern long ext4_mb_max_to_scan;
1003extern int ext4_mb_init(struct super_block *, int);
1004extern int ext4_mb_release(struct super_block *);
1005extern ext4_fsblk_t ext4_mb_new_blocks(handle_t *,
1006 struct ext4_allocation_request *, int *);
1007extern int ext4_mb_reserve_blocks(struct super_block *, int);
1008extern void ext4_mb_discard_inode_preallocations(struct inode *);
1009extern int __init init_ext4_mballoc(void);
1010extern void exit_ext4_mballoc(void);
1011extern void ext4_mb_free_blocks(handle_t *, struct inode *,
1012 unsigned long, unsigned long, int, unsigned long *);
1013
914 1014
915/* inode.c */ 1015/* inode.c */
916int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, 1016int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode,
917 struct buffer_head *bh, ext4_fsblk_t blocknr); 1017 struct buffer_head *bh, ext4_fsblk_t blocknr);
918struct buffer_head * ext4_getblk (handle_t *, struct inode *, long, int, int *); 1018struct buffer_head *ext4_getblk(handle_t *, struct inode *,
919struct buffer_head * ext4_bread (handle_t *, struct inode *, int, int, int *); 1019 ext4_lblk_t, int, int *);
1020struct buffer_head *ext4_bread(handle_t *, struct inode *,
1021 ext4_lblk_t, int, int *);
920int ext4_get_blocks_handle(handle_t *handle, struct inode *inode, 1022int ext4_get_blocks_handle(handle_t *handle, struct inode *inode,
921 sector_t iblock, unsigned long maxblocks, struct buffer_head *bh_result, 1023 ext4_lblk_t iblock, unsigned long maxblocks,
922 int create, int extend_disksize); 1024 struct buffer_head *bh_result,
1025 int create, int extend_disksize);
923 1026
924extern void ext4_read_inode (struct inode *); 1027extern void ext4_read_inode (struct inode *);
925extern int ext4_write_inode (struct inode *, int); 1028extern int ext4_write_inode (struct inode *, int);
@@ -943,6 +1046,9 @@ extern int ext4_ioctl (struct inode *, struct file *, unsigned int,
943 unsigned long); 1046 unsigned long);
944extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long); 1047extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);
945 1048
1049/* migrate.c */
1050extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
1051 unsigned long);
946/* namei.c */ 1052/* namei.c */
947extern int ext4_orphan_add(handle_t *, struct inode *); 1053extern int ext4_orphan_add(handle_t *, struct inode *);
948extern int ext4_orphan_del(handle_t *, struct inode *); 1054extern int ext4_orphan_del(handle_t *, struct inode *);
@@ -965,6 +1071,12 @@ extern void ext4_abort (struct super_block *, const char *, const char *, ...)
965extern void ext4_warning (struct super_block *, const char *, const char *, ...) 1071extern void ext4_warning (struct super_block *, const char *, const char *, ...)
966 __attribute__ ((format (printf, 3, 4))); 1072 __attribute__ ((format (printf, 3, 4)));
967extern void ext4_update_dynamic_rev (struct super_block *sb); 1073extern void ext4_update_dynamic_rev (struct super_block *sb);
1074extern int ext4_update_compat_feature(handle_t *handle, struct super_block *sb,
1075 __u32 compat);
1076extern int ext4_update_rocompat_feature(handle_t *handle,
1077 struct super_block *sb, __u32 rocompat);
1078extern int ext4_update_incompat_feature(handle_t *handle,
1079 struct super_block *sb, __u32 incompat);
968extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, 1080extern ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
969 struct ext4_group_desc *bg); 1081 struct ext4_group_desc *bg);
970extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb, 1082extern ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
@@ -1017,6 +1129,29 @@ static inline void ext4_r_blocks_count_set(struct ext4_super_block *es,
1017 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32); 1129 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
1018} 1130}
1019 1131
1132static inline loff_t ext4_isize(struct ext4_inode *raw_inode)
1133{
1134 return ((loff_t)le32_to_cpu(raw_inode->i_size_high) << 32) |
1135 le32_to_cpu(raw_inode->i_size_lo);
1136}
1137
1138static inline void ext4_isize_set(struct ext4_inode *raw_inode, loff_t i_size)
1139{
1140 raw_inode->i_size_lo = cpu_to_le32(i_size);
1141 raw_inode->i_size_high = cpu_to_le32(i_size >> 32);
1142}
1143
1144static inline
1145struct ext4_group_info *ext4_get_group_info(struct super_block *sb,
1146 ext4_group_t group)
1147{
1148 struct ext4_group_info ***grp_info;
1149 long indexv, indexh;
1150 grp_info = EXT4_SB(sb)->s_group_info;
1151 indexv = group >> (EXT4_DESC_PER_BLOCK_BITS(sb));
1152 indexh = group & ((EXT4_DESC_PER_BLOCK(sb)) - 1);
1153 return grp_info[indexv][indexh];
1154}
1020 1155
1021 1156
1022#define ext4_std_error(sb, errno) \ 1157#define ext4_std_error(sb, errno) \
@@ -1048,7 +1183,7 @@ extern const struct inode_operations ext4_fast_symlink_inode_operations;
1048extern int ext4_ext_tree_init(handle_t *handle, struct inode *); 1183extern int ext4_ext_tree_init(handle_t *handle, struct inode *);
1049extern int ext4_ext_writepage_trans_blocks(struct inode *, int); 1184extern int ext4_ext_writepage_trans_blocks(struct inode *, int);
1050extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode, 1185extern int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
1051 ext4_fsblk_t iblock, 1186 ext4_lblk_t iblock,
1052 unsigned long max_blocks, struct buffer_head *bh_result, 1187 unsigned long max_blocks, struct buffer_head *bh_result,
1053 int create, int extend_disksize); 1188 int create, int extend_disksize);
1054extern void ext4_ext_truncate(struct inode *, struct page *); 1189extern void ext4_ext_truncate(struct inode *, struct page *);
@@ -1056,19 +1191,10 @@ extern void ext4_ext_init(struct super_block *);
1056extern void ext4_ext_release(struct super_block *); 1191extern void ext4_ext_release(struct super_block *);
1057extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset, 1192extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
1058 loff_t len); 1193 loff_t len);
1059static inline int 1194extern int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode,
1060ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block, 1195 sector_t block, unsigned long max_blocks,
1061 unsigned long max_blocks, struct buffer_head *bh, 1196 struct buffer_head *bh, int create,
1062 int create, int extend_disksize) 1197 int extend_disksize);
1063{
1064 if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)
1065 return ext4_ext_get_blocks(handle, inode, block, max_blocks,
1066 bh, create, extend_disksize);
1067 return ext4_get_blocks_handle(handle, inode, block, max_blocks, bh,
1068 create, extend_disksize);
1069}
1070
1071
1072#endif /* __KERNEL__ */ 1198#endif /* __KERNEL__ */
1073 1199
1074#endif /* _LINUX_EXT4_FS_H */ 1200#endif /* _LINUX_EXT4_FS_H */
diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
index d2045a26195d..697da4bce6c5 100644
--- a/include/linux/ext4_fs_extents.h
+++ b/include/linux/ext4_fs_extents.h
@@ -124,20 +124,6 @@ struct ext4_ext_path {
124#define EXT4_EXT_CACHE_GAP 1 124#define EXT4_EXT_CACHE_GAP 1
125#define EXT4_EXT_CACHE_EXTENT 2 125#define EXT4_EXT_CACHE_EXTENT 2
126 126
127/*
128 * to be called by ext4_ext_walk_space()
129 * negative retcode - error
130 * positive retcode - signal for ext4_ext_walk_space(), see below
131 * callback must return valid extent (passed or newly created)
132 */
133typedef int (*ext_prepare_callback)(struct inode *, struct ext4_ext_path *,
134 struct ext4_ext_cache *,
135 void *);
136
137#define EXT_CONTINUE 0
138#define EXT_BREAK 1
139#define EXT_REPEAT 2
140
141 127
142#define EXT_MAX_BLOCK 0xffffffff 128#define EXT_MAX_BLOCK 0xffffffff
143 129
@@ -226,6 +212,8 @@ static inline int ext4_ext_get_actual_len(struct ext4_extent *ext)
226 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN)); 212 (le16_to_cpu(ext->ee_len) - EXT_INIT_MAX_LEN));
227} 213}
228 214
215extern ext4_fsblk_t idx_pblock(struct ext4_extent_idx *);
216extern void ext4_ext_store_pblock(struct ext4_extent *, ext4_fsblk_t);
229extern int ext4_extent_tree_init(handle_t *, struct inode *); 217extern int ext4_extent_tree_init(handle_t *, struct inode *);
230extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *); 218extern int ext4_ext_calc_credits_for_insert(struct inode *, struct ext4_ext_path *);
231extern int ext4_ext_try_to_merge(struct inode *inode, 219extern int ext4_ext_try_to_merge(struct inode *inode,
@@ -233,8 +221,11 @@ extern int ext4_ext_try_to_merge(struct inode *inode,
233 struct ext4_extent *); 221 struct ext4_extent *);
234extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *); 222extern unsigned int ext4_ext_check_overlap(struct inode *, struct ext4_extent *, struct ext4_ext_path *);
235extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *); 223extern int ext4_ext_insert_extent(handle_t *, struct inode *, struct ext4_ext_path *, struct ext4_extent *);
236extern int ext4_ext_walk_space(struct inode *, unsigned long, unsigned long, ext_prepare_callback, void *); 224extern struct ext4_ext_path *ext4_ext_find_extent(struct inode *, ext4_lblk_t,
237extern struct ext4_ext_path * ext4_ext_find_extent(struct inode *, int, struct ext4_ext_path *); 225 struct ext4_ext_path *);
238 226extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
227 ext4_lblk_t *, ext4_fsblk_t *);
228extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *,
229 ext4_lblk_t *, ext4_fsblk_t *);
239#endif /* _LINUX_EXT4_EXTENTS */ 230#endif /* _LINUX_EXT4_EXTENTS */
240 231
diff --git a/include/linux/ext4_fs_i.h b/include/linux/ext4_fs_i.h
index 86ddfe2089f3..d5508d3cf290 100644
--- a/include/linux/ext4_fs_i.h
+++ b/include/linux/ext4_fs_i.h
@@ -27,6 +27,12 @@ typedef int ext4_grpblk_t;
27/* data type for filesystem-wide blocks number */ 27/* data type for filesystem-wide blocks number */
28typedef unsigned long long ext4_fsblk_t; 28typedef unsigned long long ext4_fsblk_t;
29 29
30/* data type for file logical block number */
31typedef __u32 ext4_lblk_t;
32
33/* data type for block group number */
34typedef unsigned long ext4_group_t;
35
30struct ext4_reserve_window { 36struct ext4_reserve_window {
31 ext4_fsblk_t _rsv_start; /* First byte reserved */ 37 ext4_fsblk_t _rsv_start; /* First byte reserved */
32 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */ 38 ext4_fsblk_t _rsv_end; /* Last byte reserved or 0 */
@@ -48,7 +54,7 @@ struct ext4_block_alloc_info {
48 * most-recently-allocated block in this file. 54 * most-recently-allocated block in this file.
49 * We use this for detecting linearly ascending allocation requests. 55 * We use this for detecting linearly ascending allocation requests.
50 */ 56 */
51 __u32 last_alloc_logical_block; 57 ext4_lblk_t last_alloc_logical_block;
52 /* 58 /*
53 * Was i_next_alloc_goal in ext4_inode_info 59 * Was i_next_alloc_goal in ext4_inode_info
54 * is the *physical* companion to i_next_alloc_block. 60 * is the *physical* companion to i_next_alloc_block.
@@ -67,7 +73,7 @@ struct ext4_block_alloc_info {
67 */ 73 */
68struct ext4_ext_cache { 74struct ext4_ext_cache {
69 ext4_fsblk_t ec_start; 75 ext4_fsblk_t ec_start;
70 __u32 ec_block; 76 ext4_lblk_t ec_block;
71 __u32 ec_len; /* must be 32bit to return holes */ 77 __u32 ec_len; /* must be 32bit to return holes */
72 __u32 ec_type; 78 __u32 ec_type;
73}; 79};
@@ -79,7 +85,6 @@ struct ext4_inode_info {
79 __le32 i_data[15]; /* unconverted */ 85 __le32 i_data[15]; /* unconverted */
80 __u32 i_flags; 86 __u32 i_flags;
81 ext4_fsblk_t i_file_acl; 87 ext4_fsblk_t i_file_acl;
82 __u32 i_dir_acl;
83 __u32 i_dtime; 88 __u32 i_dtime;
84 89
85 /* 90 /*
@@ -89,13 +94,13 @@ struct ext4_inode_info {
89 * place a file's data blocks near its inode block, and new inodes 94 * place a file's data blocks near its inode block, and new inodes
90 * near to their parent directory's inode. 95 * near to their parent directory's inode.
91 */ 96 */
92 __u32 i_block_group; 97 ext4_group_t i_block_group;
93 __u32 i_state; /* Dynamic state flags for ext4 */ 98 __u32 i_state; /* Dynamic state flags for ext4 */
94 99
95 /* block reservation info */ 100 /* block reservation info */
96 struct ext4_block_alloc_info *i_block_alloc_info; 101 struct ext4_block_alloc_info *i_block_alloc_info;
97 102
98 __u32 i_dir_start_lookup; 103 ext4_lblk_t i_dir_start_lookup;
99#ifdef CONFIG_EXT4DEV_FS_XATTR 104#ifdef CONFIG_EXT4DEV_FS_XATTR
100 /* 105 /*
101 * Extended attributes can be read independently of the main file 106 * Extended attributes can be read independently of the main file
@@ -134,16 +139,16 @@ struct ext4_inode_info {
134 __u16 i_extra_isize; 139 __u16 i_extra_isize;
135 140
136 /* 141 /*
137 * truncate_mutex is for serialising ext4_truncate() against 142 * i_data_sem is for serialising ext4_truncate() against
138 * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's 143 * ext4_getblock(). In the 2.4 ext2 design, great chunks of inode's
139 * data tree are chopped off during truncate. We can't do that in 144 * data tree are chopped off during truncate. We can't do that in
140 * ext4 because whenever we perform intermediate commits during 145 * ext4 because whenever we perform intermediate commits during
141 * truncate, the inode and all the metadata blocks *must* be in a 146 * truncate, the inode and all the metadata blocks *must* be in a
142 * consistent state which allows truncation of the orphans to restart 147 * consistent state which allows truncation of the orphans to restart
143 * during recovery. Hence we must fix the get_block-vs-truncate race 148 * during recovery. Hence we must fix the get_block-vs-truncate race
144 * by other means, so we have truncate_mutex. 149 * by other means, so we have i_data_sem.
145 */ 150 */
146 struct mutex truncate_mutex; 151 struct rw_semaphore i_data_sem;
147 struct inode vfs_inode; 152 struct inode vfs_inode;
148 153
149 unsigned long i_ext_generation; 154 unsigned long i_ext_generation;
@@ -153,6 +158,10 @@ struct ext4_inode_info {
153 * struct timespec i_{a,c,m}time in the generic inode. 158 * struct timespec i_{a,c,m}time in the generic inode.
154 */ 159 */
155 struct timespec i_crtime; 160 struct timespec i_crtime;
161
162 /* mballoc */
163 struct list_head i_prealloc_list;
164 spinlock_t i_prealloc_lock;
156}; 165};
157 166
158#endif /* _LINUX_EXT4_FS_I */ 167#endif /* _LINUX_EXT4_FS_I */
diff --git a/include/linux/ext4_fs_sb.h b/include/linux/ext4_fs_sb.h
index b40e827cd495..abaae2c8cccf 100644
--- a/include/linux/ext4_fs_sb.h
+++ b/include/linux/ext4_fs_sb.h
@@ -35,9 +35,10 @@ struct ext4_sb_info {
35 unsigned long s_itb_per_group; /* Number of inode table blocks per group */ 35 unsigned long s_itb_per_group; /* Number of inode table blocks per group */
36 unsigned long s_gdb_count; /* Number of group descriptor blocks */ 36 unsigned long s_gdb_count; /* Number of group descriptor blocks */
37 unsigned long s_desc_per_block; /* Number of group descriptors per block */ 37 unsigned long s_desc_per_block; /* Number of group descriptors per block */
38 unsigned long s_groups_count; /* Number of groups in the fs */ 38 ext4_group_t s_groups_count; /* Number of groups in the fs */
39 unsigned long s_overhead_last; /* Last calculated overhead */ 39 unsigned long s_overhead_last; /* Last calculated overhead */
40 unsigned long s_blocks_last; /* Last seen block count */ 40 unsigned long s_blocks_last; /* Last seen block count */
41 loff_t s_bitmap_maxbytes; /* max bytes for bitmap files */
41 struct buffer_head * s_sbh; /* Buffer containing the super block */ 42 struct buffer_head * s_sbh; /* Buffer containing the super block */
42 struct ext4_super_block * s_es; /* Pointer to the super block in the buffer */ 43 struct ext4_super_block * s_es; /* Pointer to the super block in the buffer */
43 struct buffer_head ** s_group_desc; 44 struct buffer_head ** s_group_desc;
@@ -90,6 +91,58 @@ struct ext4_sb_info {
90 unsigned long s_ext_blocks; 91 unsigned long s_ext_blocks;
91 unsigned long s_ext_extents; 92 unsigned long s_ext_extents;
92#endif 93#endif
94
95 /* for buddy allocator */
96 struct ext4_group_info ***s_group_info;
97 struct inode *s_buddy_cache;
98 long s_blocks_reserved;
99 spinlock_t s_reserve_lock;
100 struct list_head s_active_transaction;
101 struct list_head s_closed_transaction;
102 struct list_head s_committed_transaction;
103 spinlock_t s_md_lock;
104 tid_t s_last_transaction;
105 unsigned short *s_mb_offsets, *s_mb_maxs;
106
107 /* tunables */
108 unsigned long s_stripe;
109 unsigned long s_mb_stream_request;
110 unsigned long s_mb_max_to_scan;
111 unsigned long s_mb_min_to_scan;
112 unsigned long s_mb_stats;
113 unsigned long s_mb_order2_reqs;
114 unsigned long s_mb_group_prealloc;
115 /* where last allocation was done - for stream allocation */
116 unsigned long s_mb_last_group;
117 unsigned long s_mb_last_start;
118
119 /* history to debug policy */
120 struct ext4_mb_history *s_mb_history;
121 int s_mb_history_cur;
122 int s_mb_history_max;
123 int s_mb_history_num;
124 struct proc_dir_entry *s_mb_proc;
125 spinlock_t s_mb_history_lock;
126 int s_mb_history_filter;
127
128 /* stats for buddy allocator */
129 spinlock_t s_mb_pa_lock;
130 atomic_t s_bal_reqs; /* number of reqs with len > 1 */
131 atomic_t s_bal_success; /* we found long enough chunks */
132 atomic_t s_bal_allocated; /* in blocks */
133 atomic_t s_bal_ex_scanned; /* total extents scanned */
134 atomic_t s_bal_goals; /* goal hits */
135 atomic_t s_bal_breaks; /* too long searches */
136 atomic_t s_bal_2orders; /* 2^order hits */
137 spinlock_t s_bal_lock;
138 unsigned long s_mb_buddies_generated;
139 unsigned long long s_mb_generation_time;
140 atomic_t s_mb_lost_chunks;
141 atomic_t s_mb_preallocated;
142 atomic_t s_mb_discarded;
143
144 /* locality groups */
145 struct ext4_locality_group *s_locality_groups;
93}; 146};
94 147
95#endif /* _LINUX_EXT4_FS_SB */ 148#endif /* _LINUX_EXT4_FS_SB */
diff --git a/include/linux/f75375s.h b/include/linux/f75375s.h
new file mode 100644
index 000000000000..e99e22500668
--- /dev/null
+++ b/include/linux/f75375s.h
@@ -0,0 +1,21 @@
1/*
2 * f75375s.h - platform data structure for f75375s sensor
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2007, Riku Voipio <riku.voipio@iki.fi>
9 */
10
11#ifndef __LINUX_F75375S_H
12#define __LINUX_F75375S_H
13
14/* We want to set fans spinning on systems where there is no
15 * BIOS to do that for us */
16struct f75375s_platform_data {
17 u8 pwm[2];
18 u8 pwm_enable[2];
19};
20
21#endif /* __LINUX_F75375S_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b3ec4a496d64..a516b6716870 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -124,6 +124,7 @@ extern int dir_notify_enable;
124#define MS_SHARED (1<<20) /* change to shared */ 124#define MS_SHARED (1<<20) /* change to shared */
125#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */ 125#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
126#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */ 126#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
127#define MS_I_VERSION (1<<23) /* Update inode I_version field */
127#define MS_ACTIVE (1<<30) 128#define MS_ACTIVE (1<<30)
128#define MS_NOUSER (1<<31) 129#define MS_NOUSER (1<<31)
129 130
@@ -173,6 +174,7 @@ extern int dir_notify_enable;
173 ((inode)->i_flags & (S_SYNC|S_DIRSYNC))) 174 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
174#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK) 175#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
175#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME) 176#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
177#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
176 178
177#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA) 179#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
178#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND) 180#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
@@ -599,7 +601,7 @@ struct inode {
599 uid_t i_uid; 601 uid_t i_uid;
600 gid_t i_gid; 602 gid_t i_gid;
601 dev_t i_rdev; 603 dev_t i_rdev;
602 unsigned long i_version; 604 u64 i_version;
603 loff_t i_size; 605 loff_t i_size;
604#ifdef __NEED_I_SIZE_ORDERED 606#ifdef __NEED_I_SIZE_ORDERED
605 seqcount_t i_size_seqcount; 607 seqcount_t i_size_seqcount;
@@ -1394,6 +1396,21 @@ static inline void inode_dec_link_count(struct inode *inode)
1394 mark_inode_dirty(inode); 1396 mark_inode_dirty(inode);
1395} 1397}
1396 1398
1399/**
1400 * inode_inc_iversion - increments i_version
1401 * @inode: inode that need to be updated
1402 *
1403 * Every time the inode is modified, the i_version field will be incremented.
1404 * The filesystem has to be mounted with i_version flag
1405 */
1406
1407static inline void inode_inc_iversion(struct inode *inode)
1408{
1409 spin_lock(&inode->i_lock);
1410 inode->i_version++;
1411 spin_unlock(&inode->i_lock);
1412}
1413
1397extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry); 1414extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry);
1398static inline void file_accessed(struct file *file) 1415static inline void file_accessed(struct file *file)
1399{ 1416{
@@ -1476,7 +1493,7 @@ extern void drop_collected_mounts(struct vfsmount *);
1476extern int vfs_statfs(struct dentry *, struct kstatfs *); 1493extern int vfs_statfs(struct dentry *, struct kstatfs *);
1477 1494
1478/* /sys/fs */ 1495/* /sys/fs */
1479extern struct kset fs_subsys; 1496extern struct kobject *fs_kobj;
1480 1497
1481#define FLOCK_VERIFY_READ 1 1498#define FLOCK_VERIFY_READ 1
1482#define FLOCK_VERIFY_WRITE 2 1499#define FLOCK_VERIFY_WRITE 2
diff --git a/include/linux/fuse.h b/include/linux/fuse.h
index d0c437028c80..5c86f1196c3a 100644
--- a/include/linux/fuse.h
+++ b/include/linux/fuse.h
@@ -16,6 +16,7 @@
16 * - add lk_flags in fuse_lk_in 16 * - add lk_flags in fuse_lk_in
17 * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in 17 * - add lock_owner field to fuse_setattr_in, fuse_read_in and fuse_write_in
18 * - add blksize field to fuse_attr 18 * - add blksize field to fuse_attr
19 * - add file flags field to fuse_read_in and fuse_write_in
19 */ 20 */
20 21
21#include <asm/types.h> 22#include <asm/types.h>
@@ -280,6 +281,8 @@ struct fuse_read_in {
280 __u32 size; 281 __u32 size;
281 __u32 read_flags; 282 __u32 read_flags;
282 __u64 lock_owner; 283 __u64 lock_owner;
284 __u32 flags;
285 __u32 padding;
283}; 286};
284 287
285#define FUSE_COMPAT_WRITE_IN_SIZE 24 288#define FUSE_COMPAT_WRITE_IN_SIZE 24
@@ -290,6 +293,8 @@ struct fuse_write_in {
290 __u32 size; 293 __u32 size;
291 __u32 write_flags; 294 __u32 write_flags;
292 __u64 lock_owner; 295 __u64 lock_owner;
296 __u32 flags;
297 __u32 padding;
293}; 298};
294 299
295struct fuse_write_out { 300struct fuse_write_out {
diff --git a/include/linux/futex.h b/include/linux/futex.h
index 99650353adfa..90048fb28a38 100644
--- a/include/linux/futex.h
+++ b/include/linux/futex.h
@@ -1,8 +1,12 @@
1#ifndef _LINUX_FUTEX_H 1#ifndef _LINUX_FUTEX_H
2#define _LINUX_FUTEX_H 2#define _LINUX_FUTEX_H
3 3
4#include <linux/sched.h> 4#include <linux/compiler.h>
5#include <linux/types.h>
5 6
7struct inode;
8struct mm_struct;
9struct task_struct;
6union ktime; 10union ktime;
7 11
8/* Second argument to futex syscall */ 12/* Second argument to futex syscall */
@@ -17,6 +21,8 @@ union ktime;
17#define FUTEX_LOCK_PI 6 21#define FUTEX_LOCK_PI 6
18#define FUTEX_UNLOCK_PI 7 22#define FUTEX_UNLOCK_PI 7
19#define FUTEX_TRYLOCK_PI 8 23#define FUTEX_TRYLOCK_PI 8
24#define FUTEX_WAIT_BITSET 9
25#define FUTEX_WAKE_BITSET 10
20 26
21#define FUTEX_PRIVATE_FLAG 128 27#define FUTEX_PRIVATE_FLAG 128
22#define FUTEX_CMD_MASK ~FUTEX_PRIVATE_FLAG 28#define FUTEX_CMD_MASK ~FUTEX_PRIVATE_FLAG
@@ -29,6 +35,8 @@ union ktime;
29#define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG) 35#define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG)
30#define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG) 36#define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG)
31#define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG) 37#define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG)
38#define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITS | FUTEX_PRIVATE_FLAG)
39#define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITS | FUTEX_PRIVATE_FLAG)
32 40
33/* 41/*
34 * Support for robust futexes: the kernel cleans up held futexes at 42 * Support for robust futexes: the kernel cleans up held futexes at
@@ -107,6 +115,12 @@ struct robust_list_head {
107 */ 115 */
108#define ROBUST_LIST_LIMIT 2048 116#define ROBUST_LIST_LIMIT 2048
109 117
118/*
119 * bitset with all bits set for the FUTEX_xxx_BITSET OPs to request a
120 * match of any bit.
121 */
122#define FUTEX_BITSET_MATCH_ANY 0xffffffff
123
110#ifdef __KERNEL__ 124#ifdef __KERNEL__
111long do_futex(u32 __user *uaddr, int op, u32 val, union ktime *timeout, 125long do_futex(u32 __user *uaddr, int op, u32 val, union ktime *timeout,
112 u32 __user *uaddr2, u32 val2, u32 val3); 126 u32 __user *uaddr2, u32 val2, u32 val3);
@@ -149,10 +163,6 @@ union futex_key {
149 int offset; 163 int offset;
150 } both; 164 } both;
151}; 165};
152int get_futex_key(u32 __user *uaddr, struct rw_semaphore *shared,
153 union futex_key *key);
154void get_futex_key_refs(union futex_key *key);
155void drop_futex_key_refs(union futex_key *key);
156 166
157#ifdef CONFIG_FUTEX 167#ifdef CONFIG_FUTEX
158extern void exit_robust_list(struct task_struct *curr); 168extern void exit_robust_list(struct task_struct *curr);
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index a47b8025d399..1dbea0ac5693 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -10,9 +10,19 @@
10 */ 10 */
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/kdev_t.h>
13 14
14#ifdef CONFIG_BLOCK 15#ifdef CONFIG_BLOCK
15 16
17#define kobj_to_dev(k) container_of(k, struct device, kobj)
18#define dev_to_disk(device) container_of(device, struct gendisk, dev)
19#define dev_to_part(device) container_of(device, struct hd_struct, dev)
20
21extern struct device_type disk_type;
22extern struct device_type part_type;
23extern struct kobject *block_depr;
24extern struct class block_class;
25
16enum { 26enum {
17/* These three have identical behaviour; use the second one if DOS FDISK gets 27/* These three have identical behaviour; use the second one if DOS FDISK gets
18 confused about extended/logical partitions starting past cylinder 1023. */ 28 confused about extended/logical partitions starting past cylinder 1023. */
@@ -84,7 +94,7 @@ struct partition {
84struct hd_struct { 94struct hd_struct {
85 sector_t start_sect; 95 sector_t start_sect;
86 sector_t nr_sects; 96 sector_t nr_sects;
87 struct kobject kobj; 97 struct device dev;
88 struct kobject *holder_dir; 98 struct kobject *holder_dir;
89 unsigned ios[2], sectors[2]; /* READs and WRITEs */ 99 unsigned ios[2], sectors[2]; /* READs and WRITEs */
90 int policy, partno; 100 int policy, partno;
@@ -117,15 +127,14 @@ struct gendisk {
117 * disks that can't be partitioned. */ 127 * disks that can't be partitioned. */
118 char disk_name[32]; /* name of major driver */ 128 char disk_name[32]; /* name of major driver */
119 struct hd_struct **part; /* [indexed by minor] */ 129 struct hd_struct **part; /* [indexed by minor] */
120 int part_uevent_suppress;
121 struct block_device_operations *fops; 130 struct block_device_operations *fops;
122 struct request_queue *queue; 131 struct request_queue *queue;
123 void *private_data; 132 void *private_data;
124 sector_t capacity; 133 sector_t capacity;
125 134
126 int flags; 135 int flags;
127 struct device *driverfs_dev; 136 struct device *driverfs_dev; // FIXME: remove
128 struct kobject kobj; 137 struct device dev;
129 struct kobject *holder_dir; 138 struct kobject *holder_dir;
130 struct kobject *slave_dir; 139 struct kobject *slave_dir;
131 140
@@ -143,13 +152,6 @@ struct gendisk {
143 struct work_struct async_notify; 152 struct work_struct async_notify;
144}; 153};
145 154
146/* Structure for sysfs attributes on block devices */
147struct disk_attribute {
148 struct attribute attr;
149 ssize_t (*show)(struct gendisk *, char *);
150 ssize_t (*store)(struct gendisk *, const char *, size_t);
151};
152
153/* 155/*
154 * Macros to operate on percpu disk statistics: 156 * Macros to operate on percpu disk statistics:
155 * 157 *
@@ -411,7 +413,8 @@ struct unixware_disklabel {
411#define ADDPART_FLAG_RAID 1 413#define ADDPART_FLAG_RAID 1
412#define ADDPART_FLAG_WHOLEDISK 2 414#define ADDPART_FLAG_WHOLEDISK 2
413 415
414char *disk_name (struct gendisk *hd, int part, char *buf); 416extern dev_t blk_lookup_devt(const char *name);
417extern char *disk_name (struct gendisk *hd, int part, char *buf);
415 418
416extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 419extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
417extern void add_partition(struct gendisk *, int, sector_t, sector_t, int); 420extern void add_partition(struct gendisk *, int, sector_t, sector_t, int);
@@ -423,12 +426,12 @@ extern struct gendisk *alloc_disk(int minors);
423extern struct kobject *get_disk(struct gendisk *disk); 426extern struct kobject *get_disk(struct gendisk *disk);
424extern void put_disk(struct gendisk *disk); 427extern void put_disk(struct gendisk *disk);
425extern void genhd_media_change_notify(struct gendisk *disk); 428extern void genhd_media_change_notify(struct gendisk *disk);
426extern void blk_register_region(dev_t dev, unsigned long range, 429extern void blk_register_region(dev_t devt, unsigned long range,
427 struct module *module, 430 struct module *module,
428 struct kobject *(*probe)(dev_t, int *, void *), 431 struct kobject *(*probe)(dev_t, int *, void *),
429 int (*lock)(dev_t, void *), 432 int (*lock)(dev_t, void *),
430 void *data); 433 void *data);
431extern void blk_unregister_region(dev_t dev, unsigned long range); 434extern void blk_unregister_region(dev_t devt, unsigned long range);
432 435
433static inline struct block_device *bdget_disk(struct gendisk *disk, int index) 436static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
434{ 437{
@@ -441,6 +444,12 @@ static inline struct block_device *bdget_disk(struct gendisk *disk, int index)
441 444
442static inline void printk_all_partitions(void) { } 445static inline void printk_all_partitions(void) { }
443 446
447static inline dev_t blk_lookup_devt(const char *name)
448{
449 dev_t devt = MKDEV(0, 0);
450 return devt;
451}
452
444#endif /* CONFIG_BLOCK */ 453#endif /* CONFIG_BLOCK */
445 454
446#endif 455#endif
diff --git a/include/linux/hardirq.h b/include/linux/hardirq.h
index 8d302298a161..2961ec788046 100644
--- a/include/linux/hardirq.h
+++ b/include/linux/hardirq.h
@@ -72,11 +72,7 @@
72#define in_softirq() (softirq_count()) 72#define in_softirq() (softirq_count())
73#define in_interrupt() (irq_count()) 73#define in_interrupt() (irq_count())
74 74
75#if defined(CONFIG_PREEMPT) && !defined(CONFIG_PREEMPT_BKL) 75#define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)
76# define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != kernel_locked())
77#else
78# define in_atomic() ((preempt_count() & ~PREEMPT_ACTIVE) != 0)
79#endif
80 76
81#ifdef CONFIG_PREEMPT 77#ifdef CONFIG_PREEMPT
82# define PREEMPT_CHECK_OFFSET 1 78# define PREEMPT_CHECK_OFFSET 1
diff --git a/include/linux/hdreg.h b/include/linux/hdreg.h
index 818c6afc1091..3882013d29ea 100644
--- a/include/linux/hdreg.h
+++ b/include/linux/hdreg.h
@@ -44,7 +44,9 @@
44 44
45/* Bits for HD_ERROR */ 45/* Bits for HD_ERROR */
46#define MARK_ERR 0x01 /* Bad address mark */ 46#define MARK_ERR 0x01 /* Bad address mark */
47#define ILI_ERR 0x01 /* Illegal Length Indication (ATAPI) */
47#define TRK0_ERR 0x02 /* couldn't find track 0 */ 48#define TRK0_ERR 0x02 /* couldn't find track 0 */
49#define EOM_ERR 0x02 /* End Of Media (ATAPI) */
48#define ABRT_ERR 0x04 /* Command aborted */ 50#define ABRT_ERR 0x04 /* Command aborted */
49#define MCR_ERR 0x08 /* media change request */ 51#define MCR_ERR 0x08 /* media change request */
50#define ID_ERR 0x10 /* ID field not found */ 52#define ID_ERR 0x10 /* ID field not found */
@@ -52,6 +54,7 @@
52#define ECC_ERR 0x40 /* Uncorrectable ECC error */ 54#define ECC_ERR 0x40 /* Uncorrectable ECC error */
53#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */ 55#define BBD_ERR 0x80 /* pre-EIDE meaning: block marked bad */
54#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */ 56#define ICRC_ERR 0x80 /* new meaning: CRC error during transfer */
57#define LFS_ERR 0xf0 /* Last Failed Sense (ATAPI) */
55 58
56/* Bits of HD_NSECTOR */ 59/* Bits of HD_NSECTOR */
57#define CD 0x01 60#define CD 0x01
@@ -70,13 +73,13 @@
70#define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(__u8)) 73#define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(__u8))
71#define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(__u8)) 74#define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(__u8))
72 75
73#define IDE_DRIVE_TASK_INVALID -1
74#define IDE_DRIVE_TASK_NO_DATA 0 76#define IDE_DRIVE_TASK_NO_DATA 0
77#ifndef __KERNEL__
78#define IDE_DRIVE_TASK_INVALID -1
75#define IDE_DRIVE_TASK_SET_XFER 1 79#define IDE_DRIVE_TASK_SET_XFER 1
76
77#define IDE_DRIVE_TASK_IN 2 80#define IDE_DRIVE_TASK_IN 2
78
79#define IDE_DRIVE_TASK_OUT 3 81#define IDE_DRIVE_TASK_OUT 3
82#endif
80#define IDE_DRIVE_TASK_RAW_WRITE 4 83#define IDE_DRIVE_TASK_RAW_WRITE 4
81 84
82/* 85/*
@@ -87,10 +90,10 @@
87#ifndef __KERNEL__ 90#ifndef __KERNEL__
88#define IDE_TASKFILE_STD_OUT_FLAGS 0xFE 91#define IDE_TASKFILE_STD_OUT_FLAGS 0xFE
89#define IDE_HOB_STD_OUT_FLAGS 0x3C 92#define IDE_HOB_STD_OUT_FLAGS 0x3C
90#endif
91 93
92typedef unsigned char task_ioreg_t; 94typedef unsigned char task_ioreg_t;
93typedef unsigned long sata_ioreg_t; 95typedef unsigned long sata_ioreg_t;
96#endif
94 97
95typedef union ide_reg_valid_s { 98typedef union ide_reg_valid_s {
96 unsigned all : 16; 99 unsigned all : 16;
@@ -116,8 +119,8 @@ typedef union ide_reg_valid_s {
116} ide_reg_valid_t; 119} ide_reg_valid_t;
117 120
118typedef struct ide_task_request_s { 121typedef struct ide_task_request_s {
119 task_ioreg_t io_ports[8]; 122 __u8 io_ports[8];
120 task_ioreg_t hob_ports[8]; 123 __u8 hob_ports[8]; /* bytes 6 and 7 are unused */
121 ide_reg_valid_t out_flags; 124 ide_reg_valid_t out_flags;
122 ide_reg_valid_t in_flags; 125 ide_reg_valid_t in_flags;
123 int data_phase; 126 int data_phase;
@@ -133,36 +136,35 @@ typedef struct ide_ioctl_request_s {
133} ide_ioctl_request_t; 136} ide_ioctl_request_t;
134 137
135struct hd_drive_cmd_hdr { 138struct hd_drive_cmd_hdr {
136 task_ioreg_t command; 139 __u8 command;
137 task_ioreg_t sector_number; 140 __u8 sector_number;
138 task_ioreg_t feature; 141 __u8 feature;
139 task_ioreg_t sector_count; 142 __u8 sector_count;
140}; 143};
141 144
145#ifndef __KERNEL__
142typedef struct hd_drive_task_hdr { 146typedef struct hd_drive_task_hdr {
143 task_ioreg_t data; 147 __u8 data;
144 task_ioreg_t feature; 148 __u8 feature;
145 task_ioreg_t sector_count; 149 __u8 sector_count;
146 task_ioreg_t sector_number; 150 __u8 sector_number;
147 task_ioreg_t low_cylinder; 151 __u8 low_cylinder;
148 task_ioreg_t high_cylinder; 152 __u8 high_cylinder;
149 task_ioreg_t device_head; 153 __u8 device_head;
150 task_ioreg_t command; 154 __u8 command;
151} task_struct_t; 155} task_struct_t;
152 156
153typedef struct hd_drive_hob_hdr { 157typedef struct hd_drive_hob_hdr {
154 task_ioreg_t data; 158 __u8 data;
155 task_ioreg_t feature; 159 __u8 feature;
156 task_ioreg_t sector_count; 160 __u8 sector_count;
157 task_ioreg_t sector_number; 161 __u8 sector_number;
158 task_ioreg_t low_cylinder; 162 __u8 low_cylinder;
159 task_ioreg_t high_cylinder; 163 __u8 high_cylinder;
160 task_ioreg_t device_head; 164 __u8 device_head;
161 task_ioreg_t control; 165 __u8 control;
162} hob_struct_t; 166} hob_struct_t;
163 167#endif
164#define TASKFILE_INVALID 0x7fff
165#define TASKFILE_48 0x8000
166 168
167#define TASKFILE_NO_DATA 0x0000 169#define TASKFILE_NO_DATA 0x0000
168 170
@@ -178,12 +180,16 @@ typedef struct hd_drive_hob_hdr {
178#define TASKFILE_IN_DMAQ 0x0080 180#define TASKFILE_IN_DMAQ 0x0080
179#define TASKFILE_OUT_DMAQ 0x0100 181#define TASKFILE_OUT_DMAQ 0x0100
180 182
183#ifndef __KERNEL__
181#define TASKFILE_P_IN 0x0200 184#define TASKFILE_P_IN 0x0200
182#define TASKFILE_P_OUT 0x0400 185#define TASKFILE_P_OUT 0x0400
183#define TASKFILE_P_IN_DMA 0x0800 186#define TASKFILE_P_IN_DMA 0x0800
184#define TASKFILE_P_OUT_DMA 0x1000 187#define TASKFILE_P_OUT_DMA 0x1000
185#define TASKFILE_P_IN_DMAQ 0x2000 188#define TASKFILE_P_IN_DMAQ 0x2000
186#define TASKFILE_P_OUT_DMAQ 0x4000 189#define TASKFILE_P_OUT_DMAQ 0x4000
190#define TASKFILE_48 0x8000
191#define TASKFILE_INVALID 0x7fff
192#endif
187 193
188/* ATA/ATAPI Commands pre T13 Spec */ 194/* ATA/ATAPI Commands pre T13 Spec */
189#define WIN_NOP 0x00 195#define WIN_NOP 0x00
@@ -700,8 +706,10 @@ struct hd_driveid {
700 */ 706 */
701#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */ 707#define IDE_NICE_DSC_OVERLAP (0) /* per the DSC overlap protocol */
702#define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */ 708#define IDE_NICE_ATAPI_OVERLAP (1) /* not supported yet */
703#define IDE_NICE_0 (2) /* when sure that it won't affect us */
704#define IDE_NICE_1 (3) /* when probably won't affect us much */ 709#define IDE_NICE_1 (3) /* when probably won't affect us much */
710#ifndef __KERNEL__
711#define IDE_NICE_0 (2) /* when sure that it won't affect us */
705#define IDE_NICE_2 (4) /* when we know it's on our expense */ 712#define IDE_NICE_2 (4) /* when we know it's on our expense */
713#endif
706 714
707#endif /* _LINUX_HDREG_H */ 715#endif /* _LINUX_HDREG_H */
diff --git a/include/linux/hdsmart.h b/include/linux/hdsmart.h
index 7974a47fe582..e69192159d40 100644
--- a/include/linux/hdsmart.h
+++ b/include/linux/hdsmart.h
@@ -17,6 +17,7 @@
17#ifndef _LINUX_HDSMART_H 17#ifndef _LINUX_HDSMART_H
18#define _LINUX_HDSMART_H 18#define _LINUX_HDSMART_H
19 19
20#ifndef __KERNEL
20#define OFFLINE_FULL_SCAN 0 21#define OFFLINE_FULL_SCAN 0
21#define SHORT_SELF_TEST 1 22#define SHORT_SELF_TEST 1
22#define EXTEND_SELF_TEST 2 23#define EXTEND_SELF_TEST 2
@@ -120,5 +121,6 @@ typedef struct ata_smart_selftestlog_s {
120 unsigned char resevered[2]; 121 unsigned char resevered[2];
121 unsigned char chksum; 122 unsigned char chksum;
122} __attribute__ ((packed)) ata_smart_selftestlog_t; 123} __attribute__ ((packed)) ata_smart_selftestlog_t;
124#endif /* __KERNEL__ *
123 125
124#endif /* _LINUX_HDSMART_H */ 126#endif /* _LINUX_HDSMART_H */
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 6e35b92b1d2c..3902690647b0 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -267,10 +267,10 @@ struct hid_item {
267#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100 267#define HID_QUIRK_2WHEEL_MOUSE_HACK_5 0x00000100
268#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200 268#define HID_QUIRK_2WHEEL_MOUSE_HACK_ON 0x00000200
269#define HID_QUIRK_MIGHTYMOUSE 0x00000400 269#define HID_QUIRK_MIGHTYMOUSE 0x00000400
270#define HID_QUIRK_POWERBOOK_HAS_FN 0x00000800 270#define HID_QUIRK_APPLE_HAS_FN 0x00000800
271#define HID_QUIRK_POWERBOOK_FN_ON 0x00001000 271#define HID_QUIRK_APPLE_FN_ON 0x00001000
272#define HID_QUIRK_INVERT_HWHEEL 0x00002000 272#define HID_QUIRK_INVERT_HWHEEL 0x00002000
273#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD 0x00004000 273#define HID_QUIRK_APPLE_ISO_KEYBOARD 0x00004000
274#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000 274#define HID_QUIRK_BAD_RELATIVE_KEYS 0x00008000
275#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000 275#define HID_QUIRK_SKIP_OUTPUT_REPORTS 0x00010000
276#define HID_QUIRK_IGNORE_MOUSE 0x00020000 276#define HID_QUIRK_IGNORE_MOUSE 0x00020000
@@ -281,6 +281,9 @@ struct hid_item {
281#define HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL 0x00400000 281#define HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL 0x00400000
282#define HID_QUIRK_LOGITECH_EXPANDED_KEYMAP 0x00800000 282#define HID_QUIRK_LOGITECH_EXPANDED_KEYMAP 0x00800000
283#define HID_QUIRK_IGNORE_HIDINPUT 0x01000000 283#define HID_QUIRK_IGNORE_HIDINPUT 0x01000000
284#define HID_QUIRK_2WHEEL_MOUSE_HACK_B8 0x02000000
285#define HID_QUIRK_HWHEEL_WHEEL_INVERT 0x04000000
286#define HID_QUIRK_MICROSOFT_KEYS 0x08000000
284 287
285/* 288/*
286 * Separate quirks for runtime report descriptor fixup 289 * Separate quirks for runtime report descriptor fixup
@@ -291,6 +294,8 @@ struct hid_item {
291#define HID_QUIRK_RDESC_SWAPPED_MIN_MAX 0x00000004 294#define HID_QUIRK_RDESC_SWAPPED_MIN_MAX 0x00000004
292#define HID_QUIRK_RDESC_PETALYNX 0x00000008 295#define HID_QUIRK_RDESC_PETALYNX 0x00000008
293#define HID_QUIRK_RDESC_MACBOOK_JIS 0x00000010 296#define HID_QUIRK_RDESC_MACBOOK_JIS 0x00000010
297#define HID_QUIRK_RDESC_BUTTON_CONSUMER 0x00000020
298#define HID_QUIRK_RDESC_SAMSUNG_REMOTE 0x00000040
294 299
295/* 300/*
296 * This is the global environment of the parser. This information is 301 * This is the global environment of the parser. This information is
@@ -456,6 +461,8 @@ struct hid_device { /* device report descriptor */
456 461
457 void *driver_data; 462 void *driver_data;
458 463
464 __s32 delayed_value; /* For A4 Tech mice hwheel quirk */
465
459 /* device-specific function pointers */ 466 /* device-specific function pointers */
460 int (*hidinput_input_event) (struct input_dev *, unsigned int, unsigned int, int); 467 int (*hidinput_input_event) (struct input_dev *, unsigned int, unsigned int, int);
461 int (*hid_open) (struct hid_device *); 468 int (*hid_open) (struct hid_device *);
@@ -469,7 +476,7 @@ struct hid_device { /* device report descriptor */
469 /* handler for raw output data, used by hidraw */ 476 /* handler for raw output data, used by hidraw */
470 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t); 477 int (*hid_output_raw_report) (struct hid_device *, __u8 *, size_t);
471#ifdef CONFIG_USB_HIDINPUT_POWERBOOK 478#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
472 unsigned long pb_pressed_fn[BITS_TO_LONGS(KEY_CNT)]; 479 unsigned long apple_pressed_fn[BITS_TO_LONGS(KEY_CNT)];
473 unsigned long pb_pressed_numlock[BITS_TO_LONGS(KEY_CNT)]; 480 unsigned long pb_pressed_numlock[BITS_TO_LONGS(KEY_CNT)];
474#endif 481#endif
475}; 482};
@@ -520,6 +527,9 @@ extern void hidinput_disconnect(struct hid_device *);
520int hid_set_field(struct hid_field *, unsigned, __s32); 527int hid_set_field(struct hid_field *, unsigned, __s32);
521int hid_input_report(struct hid_device *, int type, u8 *, int, int); 528int hid_input_report(struct hid_device *, int type, u8 *, int, int);
522int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field); 529int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
530int hidinput_mapping_quirks(struct hid_usage *, struct input_dev *, unsigned long **, int *);
531void hidinput_event_quirks(struct hid_device *, struct hid_field *, struct hid_usage *, __s32);
532int hidinput_apple_event(struct hid_device *, struct input_dev *, struct hid_usage *, __s32);
523void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt); 533void hid_input_field(struct hid_device *hid, struct hid_field *field, __u8 *data, int interrupt);
524void hid_output_report(struct hid_report *report, __u8 *data); 534void hid_output_report(struct hid_report *report, __u8 *data);
525void hid_free_device(struct hid_device *device); 535void hid_free_device(struct hid_device *device);
diff --git a/include/linux/hpet.h b/include/linux/hpet.h
index 707f7cb9e795..9cd94bfd07e5 100644
--- a/include/linux/hpet.h
+++ b/include/linux/hpet.h
@@ -64,7 +64,7 @@ struct hpet {
64 */ 64 */
65 65
66#define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL) 66#define Tn_INT_ROUTE_CAP_MASK (0xffffffff00000000ULL)
67#define Tn_INI_ROUTE_CAP_SHIFT (32UL) 67#define Tn_INT_ROUTE_CAP_SHIFT (32UL)
68#define Tn_FSB_INT_DELCAP_MASK (0x8000UL) 68#define Tn_FSB_INT_DELCAP_MASK (0x8000UL)
69#define Tn_FSB_INT_DELCAP_SHIFT (15) 69#define Tn_FSB_INT_DELCAP_SHIFT (15)
70#define Tn_FSB_EN_CNF_MASK (0x4000UL) 70#define Tn_FSB_EN_CNF_MASK (0x4000UL)
@@ -115,9 +115,6 @@ static inline void hpet_reserve_timer(struct hpet_data *hd, int timer)
115} 115}
116 116
117int hpet_alloc(struct hpet_data *); 117int hpet_alloc(struct hpet_data *);
118int hpet_register(struct hpet_task *, int);
119int hpet_unregister(struct hpet_task *);
120int hpet_control(struct hpet_task *, unsigned int, unsigned long);
121 118
122#endif /* __KERNEL__ */ 119#endif /* __KERNEL__ */
123 120
diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 7a9398e19704..49067f14fac1 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -115,10 +115,8 @@ struct hrtimer {
115 enum hrtimer_restart (*function)(struct hrtimer *); 115 enum hrtimer_restart (*function)(struct hrtimer *);
116 struct hrtimer_clock_base *base; 116 struct hrtimer_clock_base *base;
117 unsigned long state; 117 unsigned long state;
118#ifdef CONFIG_HIGH_RES_TIMERS
119 enum hrtimer_cb_mode cb_mode; 118 enum hrtimer_cb_mode cb_mode;
120 struct list_head cb_entry; 119 struct list_head cb_entry;
121#endif
122#ifdef CONFIG_TIMER_STATS 120#ifdef CONFIG_TIMER_STATS
123 void *start_site; 121 void *start_site;
124 char start_comm[16]; 122 char start_comm[16];
@@ -194,10 +192,10 @@ struct hrtimer_cpu_base {
194 spinlock_t lock; 192 spinlock_t lock;
195 struct lock_class_key lock_key; 193 struct lock_class_key lock_key;
196 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES]; 194 struct hrtimer_clock_base clock_base[HRTIMER_MAX_CLOCK_BASES];
195 struct list_head cb_pending;
197#ifdef CONFIG_HIGH_RES_TIMERS 196#ifdef CONFIG_HIGH_RES_TIMERS
198 ktime_t expires_next; 197 ktime_t expires_next;
199 int hres_active; 198 int hres_active;
200 struct list_head cb_pending;
201 unsigned long nr_events; 199 unsigned long nr_events;
202#endif 200#endif
203}; 201};
@@ -217,6 +215,11 @@ static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)
217 return timer->base->get_time(); 215 return timer->base->get_time();
218} 216}
219 217
218static inline int hrtimer_is_hres_active(struct hrtimer *timer)
219{
220 return timer->base->cpu_base->hres_active;
221}
222
220/* 223/*
221 * The resolution of the clocks. The resolution value is returned in 224 * The resolution of the clocks. The resolution value is returned in
222 * the clock_getres() system call to give application programmers an 225 * the clock_getres() system call to give application programmers an
@@ -248,6 +251,10 @@ static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)
248 return timer->base->softirq_time; 251 return timer->base->softirq_time;
249} 252}
250 253
254static inline int hrtimer_is_hres_active(struct hrtimer *timer)
255{
256 return 0;
257}
251#endif 258#endif
252 259
253extern ktime_t ktime_get(void); 260extern ktime_t ktime_get(void);
@@ -310,6 +317,7 @@ extern void hrtimer_init_sleeper(struct hrtimer_sleeper *sl,
310 317
311/* Soft interrupt function to run the hrtimer queues: */ 318/* Soft interrupt function to run the hrtimer queues: */
312extern void hrtimer_run_queues(void); 319extern void hrtimer_run_queues(void);
320extern void hrtimer_run_pending(void);
313 321
314/* Bootup initialization: */ 322/* Bootup initialization: */
315extern void __init hrtimers_init(void); 323extern void __init hrtimers_init(void);
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index ea0f50bfbe03..30d606afcafe 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -19,7 +19,7 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
19int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); 19int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
20int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *); 20int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
21int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *); 21int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
22int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int); 22int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int, int);
23void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long); 23void unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
24void __unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long); 24void __unmap_hugepage_range(struct vm_area_struct *, unsigned long, unsigned long);
25int hugetlb_prefault(struct address_space *, struct vm_area_struct *); 25int hugetlb_prefault(struct address_space *, struct vm_area_struct *);
@@ -33,7 +33,7 @@ void hugetlb_unreserve_pages(struct inode *inode, long offset, long freed);
33 33
34extern unsigned long max_huge_pages; 34extern unsigned long max_huge_pages;
35extern unsigned long hugepages_treat_as_movable; 35extern unsigned long hugepages_treat_as_movable;
36extern int hugetlb_dynamic_pool; 36extern unsigned long nr_overcommit_huge_pages;
37extern const unsigned long hugetlb_zero, hugetlb_infinity; 37extern const unsigned long hugetlb_zero, hugetlb_infinity;
38extern int sysctl_hugetlb_shm_group; 38extern int sysctl_hugetlb_shm_group;
39 39
@@ -106,7 +106,7 @@ static inline unsigned long hugetlb_total_pages(void)
106 return 0; 106 return 0;
107} 107}
108 108
109#define follow_hugetlb_page(m,v,p,vs,a,b,i) ({ BUG(); 0; }) 109#define follow_hugetlb_page(m,v,p,vs,a,b,i,w) ({ BUG(); 0; })
110#define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL) 110#define follow_huge_addr(mm, addr, write) ERR_PTR(-EINVAL)
111#define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; }) 111#define copy_hugetlb_page_range(src, dst, vma) ({ BUG(); 0; })
112#define hugetlb_prefault(mapping, vma) ({ BUG(); 0; }) 112#define hugetlb_prefault(mapping, vma) ({ BUG(); 0; })
@@ -165,8 +165,10 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
165extern const struct file_operations hugetlbfs_file_operations; 165extern const struct file_operations hugetlbfs_file_operations;
166extern struct vm_operations_struct hugetlb_vm_ops; 166extern struct vm_operations_struct hugetlb_vm_ops;
167struct file *hugetlb_file_setup(const char *name, size_t); 167struct file *hugetlb_file_setup(const char *name, size_t);
168int hugetlb_get_quota(struct address_space *mapping); 168int hugetlb_get_quota(struct address_space *mapping, long delta);
169void hugetlb_put_quota(struct address_space *mapping); 169void hugetlb_put_quota(struct address_space *mapping, long delta);
170
171#define BLOCKS_PER_HUGEPAGE (HPAGE_SIZE / 512)
170 172
171static inline int is_file_hugepages(struct file *file) 173static inline int is_file_hugepages(struct file *file)
172{ 174{
diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h
index 21ea7610e177..85d11916e9ea 100644
--- a/include/linux/hw_random.h
+++ b/include/linux/hw_random.h
@@ -33,7 +33,7 @@ struct hwrng {
33 const char *name; 33 const char *name;
34 int (*init)(struct hwrng *rng); 34 int (*init)(struct hwrng *rng);
35 void (*cleanup)(struct hwrng *rng); 35 void (*cleanup)(struct hwrng *rng);
36 int (*data_present)(struct hwrng *rng); 36 int (*data_present)(struct hwrng *rng, int wait);
37 int (*data_read)(struct hwrng *rng, u32 *data); 37 int (*data_read)(struct hwrng *rng, u32 *data);
38 unsigned long priv; 38 unsigned long priv;
39 39
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 88c81403eb3f..f922b060158b 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -23,29 +23,23 @@
23#ifndef LINUX_I2C_ID_H 23#ifndef LINUX_I2C_ID_H
24#define LINUX_I2C_ID_H 24#define LINUX_I2C_ID_H
25 25
26/* Please note that I2C driver IDs are optional. They are only needed if a
27 legacy chip driver needs to identify a bus or a bus driver needs to
28 identify a legacy client. If you don't need them, just don't set them. */
29
26/* 30/*
27 * ---- Driver types ----------------------------------------------------- 31 * ---- Driver types -----------------------------------------------------
28 */ 32 */
29 33
30#define I2C_DRIVERID_MSP3400 1 34#define I2C_DRIVERID_MSP3400 1
31#define I2C_DRIVERID_TUNER 2 35#define I2C_DRIVERID_TUNER 2
32#define I2C_DRIVERID_VIDEOTEX 3 /* please rename */
33#define I2C_DRIVERID_TDA8425 4 /* stereo sound processor */ 36#define I2C_DRIVERID_TDA8425 4 /* stereo sound processor */
34#define I2C_DRIVERID_TEA6420 5 /* audio matrix switch */ 37#define I2C_DRIVERID_TEA6420 5 /* audio matrix switch */
35#define I2C_DRIVERID_TEA6415C 6 /* video matrix switch */ 38#define I2C_DRIVERID_TEA6415C 6 /* video matrix switch */
36#define I2C_DRIVERID_TDA9840 7 /* stereo sound processor */ 39#define I2C_DRIVERID_TDA9840 7 /* stereo sound processor */
37#define I2C_DRIVERID_SAA7111A 8 /* video input processor */ 40#define I2C_DRIVERID_SAA7111A 8 /* video input processor */
38#define I2C_DRIVERID_SAA5281 9 /* videotext decoder */
39#define I2C_DRIVERID_SAA7112 10 /* video decoder, image scaler */
40#define I2C_DRIVERID_SAA7120 11 /* video encoder */
41#define I2C_DRIVERID_SAA7121 12 /* video encoder */
42#define I2C_DRIVERID_SAA7185B 13 /* video encoder */ 41#define I2C_DRIVERID_SAA7185B 13 /* video encoder */
43#define I2C_DRIVERID_CH7003 14 /* digital pc to tv encoder */
44#define I2C_DRIVERID_PCF8574A 15 /* i2c expander - 8 bit in/out */
45#define I2C_DRIVERID_PCF8582C 16 /* eeprom */
46#define I2C_DRIVERID_AT24Cxx 17 /* eeprom 1/2/4/8/16 K */
47#define I2C_DRIVERID_TEA6300 18 /* audio mixer */ 42#define I2C_DRIVERID_TEA6300 18 /* audio mixer */
48#define I2C_DRIVERID_BT829 19 /* pc to tv encoder */
49#define I2C_DRIVERID_TDA9850 20 /* audio mixer */ 43#define I2C_DRIVERID_TDA9850 20 /* audio mixer */
50#define I2C_DRIVERID_TDA9855 21 /* audio mixer */ 44#define I2C_DRIVERID_TDA9855 21 /* audio mixer */
51#define I2C_DRIVERID_SAA7110 22 /* video decoder */ 45#define I2C_DRIVERID_SAA7110 22 /* video decoder */
@@ -56,42 +50,19 @@
56#define I2C_DRIVERID_TDA7432 27 /* Stereo sound processor */ 50#define I2C_DRIVERID_TDA7432 27 /* Stereo sound processor */
57#define I2C_DRIVERID_TVMIXER 28 /* Mixer driver for tv cards */ 51#define I2C_DRIVERID_TVMIXER 28 /* Mixer driver for tv cards */
58#define I2C_DRIVERID_TVAUDIO 29 /* Generic TV sound driver */ 52#define I2C_DRIVERID_TVAUDIO 29 /* Generic TV sound driver */
59#define I2C_DRIVERID_DPL3518 30 /* Dolby decoder chip */
60#define I2C_DRIVERID_TDA9873 31 /* TV sound decoder chip */ 53#define I2C_DRIVERID_TDA9873 31 /* TV sound decoder chip */
61#define I2C_DRIVERID_TDA9875 32 /* TV sound decoder chip */ 54#define I2C_DRIVERID_TDA9875 32 /* TV sound decoder chip */
62#define I2C_DRIVERID_PIC16C54_PV9 33 /* Audio mux/ir receiver */ 55#define I2C_DRIVERID_PIC16C54_PV9 33 /* Audio mux/ir receiver */
63
64#define I2C_DRIVERID_SBATT 34 /* Smart Battery Device */
65#define I2C_DRIVERID_SBS 35 /* SB System Manager */
66#define I2C_DRIVERID_VES1893 36 /* VLSI DVB-S decoder */
67#define I2C_DRIVERID_VES1820 37 /* VLSI DVB-C decoder */
68#define I2C_DRIVERID_SAA7113 38 /* video decoder */
69#define I2C_DRIVERID_TDA8444 39 /* octuple 6-bit DAC */
70#define I2C_DRIVERID_BT819 40 /* video decoder */ 56#define I2C_DRIVERID_BT819 40 /* video decoder */
71#define I2C_DRIVERID_BT856 41 /* video encoder */ 57#define I2C_DRIVERID_BT856 41 /* video encoder */
72#define I2C_DRIVERID_VPX3220 42 /* video decoder+vbi/vtxt */ 58#define I2C_DRIVERID_VPX3220 42 /* video decoder+vbi/vtxt */
73#define I2C_DRIVERID_DRP3510 43 /* ADR decoder (Astra Radio) */
74#define I2C_DRIVERID_SP5055 44 /* Satellite tuner */
75#define I2C_DRIVERID_STV0030 45 /* Multipurpose switch */
76#define I2C_DRIVERID_SAA7108 46 /* video decoder, image scaler */
77#define I2C_DRIVERID_DS1307 47 /* DS1307 real time clock */
78#define I2C_DRIVERID_ADV7175 48 /* ADV 7175/7176 video encoder */ 59#define I2C_DRIVERID_ADV7175 48 /* ADV 7175/7176 video encoder */
79#define I2C_DRIVERID_SAA7114 49 /* video decoder */ 60#define I2C_DRIVERID_SAA7114 49 /* video decoder */
80#define I2C_DRIVERID_ZR36120 50 /* Zoran 36120 video encoder */
81#define I2C_DRIVERID_24LC32A 51 /* Microchip 24LC32A 32k EEPROM */
82#define I2C_DRIVERID_STM41T00 52 /* real time clock */
83#define I2C_DRIVERID_UDA1342 53 /* UDA1342 audio codec */
84#define I2C_DRIVERID_ADV7170 54 /* video encoder */ 61#define I2C_DRIVERID_ADV7170 54 /* video encoder */
85#define I2C_DRIVERID_MAX1617 56 /* temp sensor */
86#define I2C_DRIVERID_SAA7191 57 /* video decoder */ 62#define I2C_DRIVERID_SAA7191 57 /* video decoder */
87#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */ 63#define I2C_DRIVERID_INDYCAM 58 /* SGI IndyCam */
88#define I2C_DRIVERID_BT832 59 /* CMOS camera video processor */
89#define I2C_DRIVERID_TDA9887 60 /* TDA988x IF-PLL demodulator */
90#define I2C_DRIVERID_OVCAMCHIP 61 /* OmniVision CMOS image sens. */ 64#define I2C_DRIVERID_OVCAMCHIP 61 /* OmniVision CMOS image sens. */
91#define I2C_DRIVERID_TDA7313 62 /* TDA7313 audio processor */
92#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */ 65#define I2C_DRIVERID_MAX6900 63 /* MAX6900 real-time clock */
93#define I2C_DRIVERID_SAA7114H 64 /* video decoder */
94#define I2C_DRIVERID_DS1374 65 /* DS1374 real time clock */
95#define I2C_DRIVERID_TDA9874 66 /* TV sound decoder */ 66#define I2C_DRIVERID_TDA9874 66 /* TV sound decoder */
96#define I2C_DRIVERID_SAA6752HS 67 /* MPEG2 encoder */ 67#define I2C_DRIVERID_SAA6752HS 67 /* MPEG2 encoder */
97#define I2C_DRIVERID_TVEEPROM 68 /* TV EEPROM */ 68#define I2C_DRIVERID_TVEEPROM 68 /* TV EEPROM */
@@ -110,7 +81,6 @@
110#define I2C_DRIVERID_DS1672 81 /* Dallas/Maxim DS1672 RTC */ 81#define I2C_DRIVERID_DS1672 81 /* Dallas/Maxim DS1672 RTC */
111#define I2C_DRIVERID_X1205 82 /* Xicor/Intersil X1205 RTC */ 82#define I2C_DRIVERID_X1205 82 /* Xicor/Intersil X1205 RTC */
112#define I2C_DRIVERID_PCF8563 83 /* Philips PCF8563 RTC */ 83#define I2C_DRIVERID_PCF8563 83 /* Philips PCF8563 RTC */
113#define I2C_DRIVERID_RS5C372 84 /* Ricoh RS5C372 RTC */
114#define I2C_DRIVERID_BT866 85 /* Conexant bt866 video encoder */ 84#define I2C_DRIVERID_BT866 85 /* Conexant bt866 video encoder */
115#define I2C_DRIVERID_KS0127 86 /* Samsung ks0127 video decoder */ 85#define I2C_DRIVERID_KS0127 86 /* Samsung ks0127 video decoder */
116#define I2C_DRIVERID_TLV320AIC23B 87 /* TI TLV320AIC23B audio codec */ 86#define I2C_DRIVERID_TLV320AIC23B 87 /* TI TLV320AIC23B audio codec */
@@ -121,10 +91,10 @@
121#define I2C_DRIVERID_LM4857 92 /* LM4857 Audio Amplifier */ 91#define I2C_DRIVERID_LM4857 92 /* LM4857 Audio Amplifier */
122#define I2C_DRIVERID_VP27SMPX 93 /* Panasonic VP27s tuner internal MPX */ 92#define I2C_DRIVERID_VP27SMPX 93 /* Panasonic VP27s tuner internal MPX */
123#define I2C_DRIVERID_CS4270 94 /* Cirrus Logic 4270 audio codec */ 93#define I2C_DRIVERID_CS4270 94 /* Cirrus Logic 4270 audio codec */
94#define I2C_DRIVERID_M52790 95 /* Mitsubishi M52790SP/FP AV switch */
95#define I2C_DRIVERID_CS5345 96 /* cs5345 audio processor */
124 96
125#define I2C_DRIVERID_I2CDEV 900 97#define I2C_DRIVERID_I2CDEV 900
126#define I2C_DRIVERID_ARP 902 /* SMBus ARP Client */
127#define I2C_DRIVERID_ALERT 903 /* SMBus Alert Responder Client */
128 98
129/* IDs -- Use DRIVERIDs 1000-1999 for sensors. 99/* IDs -- Use DRIVERIDs 1000-1999 for sensors.
130 These were originally in sensors.h in the lm_sensors package */ 100 These were originally in sensors.h in the lm_sensors package */
@@ -170,24 +140,16 @@
170 140
171/* --- Bit algorithm adapters */ 141/* --- Bit algorithm adapters */
172#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */ 142#define I2C_HW_B_LP 0x010000 /* Parallel port Philips style */
173#define I2C_HW_B_SER 0x010002 /* Serial line interface */
174#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */ 143#define I2C_HW_B_BT848 0x010005 /* BT848 video boards */
175#define I2C_HW_B_WNV 0x010006 /* Winnov Videums */
176#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */ 144#define I2C_HW_B_VIA 0x010007 /* Via vt82c586b */
177#define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */ 145#define I2C_HW_B_HYDRA 0x010008 /* Apple Hydra Mac I/O */
178#define I2C_HW_B_G400 0x010009 /* Matrox G400 */ 146#define I2C_HW_B_G400 0x010009 /* Matrox G400 */
179#define I2C_HW_B_I810 0x01000a /* Intel I810 */ 147#define I2C_HW_B_I810 0x01000a /* Intel I810 */
180#define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */ 148#define I2C_HW_B_VOO 0x01000b /* 3dfx Voodoo 3 / Banshee */
181#define I2C_HW_B_PPORT 0x01000c /* Primitive parallel port adapter */
182#define I2C_HW_B_SAVG 0x01000d /* Savage 4 */
183#define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */ 149#define I2C_HW_B_SCX200 0x01000e /* Nat'l Semi SCx200 I2C */
184#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */ 150#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */
185#define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */ 151#define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */
186#define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */
187#define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */
188#define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */
189#define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */ 152#define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */
190#define I2C_HW_B_IXP4XX 0x010017 /* GPIO on IXP4XX systems */
191#define I2C_HW_B_S3VIA 0x010018 /* S3Via ProSavage adapter */ 153#define I2C_HW_B_S3VIA 0x010018 /* S3Via ProSavage adapter */
192#define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */ 154#define I2C_HW_B_ZR36067 0x010019 /* Zoran-36057/36067 based boards */
193#define I2C_HW_B_PCILYNX 0x01001a /* TI PCILynx I2C adapter */ 155#define I2C_HW_B_PCILYNX 0x01001a /* TI PCILynx I2C adapter */
@@ -201,22 +163,11 @@
201#define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */ 163#define I2C_HW_B_CX23885 0x010022 /* conexant 23885 based tv cards (bus1) */
202 164
203/* --- PCF 8584 based algorithms */ 165/* --- PCF 8584 based algorithms */
204#define I2C_HW_P_LP 0x020000 /* Parallel port interface */
205#define I2C_HW_P_ISA 0x020001 /* generic ISA Bus inteface card */
206#define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */ 166#define I2C_HW_P_ELEK 0x020002 /* Elektor ISA Bus inteface card */
207 167
208/* --- PCA 9564 based algorithms */ 168/* --- PCA 9564 based algorithms */
209#define I2C_HW_A_ISA 0x1a0000 /* generic ISA Bus interface card */ 169#define I2C_HW_A_ISA 0x1a0000 /* generic ISA Bus interface card */
210 170
211/* --- ACPI Embedded controller algorithms */
212#define I2C_HW_ACPI_EC 0x1f0000
213
214/* --- MPC824x PowerPC adapters */
215#define I2C_HW_MPC824X 0x100001 /* Motorola 8240 / 8245 */
216
217/* --- MPC8xx PowerPC adapters */
218#define I2C_HW_MPC8XX_EPON 0x110000 /* Eponymous MPC8xx I2C adapter */
219
220/* --- PowerPC on-chip adapters */ 171/* --- PowerPC on-chip adapters */
221#define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */ 172#define I2C_HW_OCP 0x120000 /* IBM on-chip I2C adapter */
222 173
@@ -225,7 +176,6 @@
225 176
226/* --- SGI adapters */ 177/* --- SGI adapters */
227#define I2C_HW_SGI_VINO 0x160000 178#define I2C_HW_SGI_VINO 0x160000
228#define I2C_HW_SGI_MACE 0x160001
229 179
230/* --- XSCALE on-chip adapters */ 180/* --- XSCALE on-chip adapters */
231#define I2C_HW_IOP3XX 0x140000 181#define I2C_HW_IOP3XX 0x140000
@@ -249,17 +199,10 @@
249#define I2C_HW_SMBUS_W9968CF 0x04000d 199#define I2C_HW_SMBUS_W9968CF 0x04000d
250#define I2C_HW_SMBUS_OV511 0x04000e /* OV511(+) USB 1.1 webcam ICs */ 200#define I2C_HW_SMBUS_OV511 0x04000e /* OV511(+) USB 1.1 webcam ICs */
251#define I2C_HW_SMBUS_OV518 0x04000f /* OV518(+) USB 1.1 webcam ICs */ 201#define I2C_HW_SMBUS_OV518 0x04000f /* OV518(+) USB 1.1 webcam ICs */
252#define I2C_HW_SMBUS_OV519 0x040010 /* OV519 USB 1.1 webcam IC */
253#define I2C_HW_SMBUS_OVFX2 0x040011 /* Cypress/OmniVision FX2 webcam */ 202#define I2C_HW_SMBUS_OVFX2 0x040011 /* Cypress/OmniVision FX2 webcam */
254#define I2C_HW_SMBUS_CAFE 0x040012 /* Marvell 88ALP01 "CAFE" cam */ 203#define I2C_HW_SMBUS_CAFE 0x040012 /* Marvell 88ALP01 "CAFE" cam */
255#define I2C_HW_SMBUS_ALI1563 0x040013 204#define I2C_HW_SMBUS_ALI1563 0x040013
256 205
257/* --- ISA pseudo-adapter */
258#define I2C_HW_ISA 0x050000
259
260/* --- IPMB adapter */
261#define I2C_HW_IPMB 0x0c0000
262
263/* --- MCP107 adapter */ 206/* --- MCP107 adapter */
264#define I2C_HW_MPC107 0x0d0000 207#define I2C_HW_MPC107 0x0d0000
265 208
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 8033e6b33271..76014f8f3c60 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -140,7 +140,6 @@ struct i2c_driver {
140 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg); 140 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
141 141
142 struct device_driver driver; 142 struct device_driver driver;
143 struct list_head list;
144}; 143};
145#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver) 144#define to_i2c_driver(d) container_of(d, struct i2c_driver, driver)
146 145
@@ -155,12 +154,11 @@ struct i2c_driver {
155 * generic enough to hide second-sourcing and compatible revisions. 154 * generic enough to hide second-sourcing and compatible revisions.
156 * @adapter: manages the bus segment hosting this I2C device 155 * @adapter: manages the bus segment hosting this I2C device
157 * @driver: device's driver, hence pointer to access routines 156 * @driver: device's driver, hence pointer to access routines
158 * @usage_count: counts current number of users of this client
159 * @dev: Driver model device node for the slave. 157 * @dev: Driver model device node for the slave.
160 * @irq: indicates the IRQ generated by this device (if any) 158 * @irq: indicates the IRQ generated by this device (if any)
161 * @driver_name: Identifies new-style driver used with this device; also 159 * @driver_name: Identifies new-style driver used with this device; also
162 * used as the module name for hotplug/coldplug modprobe support. 160 * used as the module name for hotplug/coldplug modprobe support.
163 * @list: list of active/busy clients 161 * @list: list of active/busy clients (DEPRECATED)
164 * @released: used to synchronize client releases & detaches and references 162 * @released: used to synchronize client releases & detaches and references
165 * 163 *
166 * An i2c_client identifies a single device (i.e. chip) connected to an 164 * An i2c_client identifies a single device (i.e. chip) connected to an
@@ -175,16 +173,16 @@ struct i2c_client {
175 char name[I2C_NAME_SIZE]; 173 char name[I2C_NAME_SIZE];
176 struct i2c_adapter *adapter; /* the adapter we sit on */ 174 struct i2c_adapter *adapter; /* the adapter we sit on */
177 struct i2c_driver *driver; /* and our access routines */ 175 struct i2c_driver *driver; /* and our access routines */
178 int usage_count; /* How many accesses currently */
179 /* to the client */
180 struct device dev; /* the device structure */ 176 struct device dev; /* the device structure */
181 int irq; /* irq issued by device (or -1) */ 177 int irq; /* irq issued by device (or -1) */
182 char driver_name[KOBJ_NAME_LEN]; 178 char driver_name[KOBJ_NAME_LEN];
183 struct list_head list; 179 struct list_head list; /* DEPRECATED */
184 struct completion released; 180 struct completion released;
185}; 181};
186#define to_i2c_client(d) container_of(d, struct i2c_client, dev) 182#define to_i2c_client(d) container_of(d, struct i2c_client, dev)
187 183
184extern struct i2c_client *i2c_verify_client(struct device *dev);
185
188static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj) 186static inline struct i2c_client *kobj_to_i2c_client(struct kobject *kobj)
189{ 187{
190 struct device * const dev = container_of(kobj, struct device, kobj); 188 struct device * const dev = container_of(kobj, struct device, kobj);
@@ -261,6 +259,12 @@ i2c_new_probed_device(struct i2c_adapter *adap,
261 struct i2c_board_info *info, 259 struct i2c_board_info *info,
262 unsigned short const *addr_list); 260 unsigned short const *addr_list);
263 261
262/* For devices that use several addresses, use i2c_new_dummy() to make
263 * client handles for the extra addresses.
264 */
265extern struct i2c_client *
266i2c_new_dummy(struct i2c_adapter *adap, u16 address, const char *type);
267
264extern void i2c_unregister_device(struct i2c_client *); 268extern void i2c_unregister_device(struct i2c_client *);
265 269
266/* Mainboard arch_initcall() code should register all its I2C devices. 270/* Mainboard arch_initcall() code should register all its I2C devices.
@@ -319,8 +323,7 @@ struct i2c_adapter {
319 struct device dev; /* the adapter device */ 323 struct device dev; /* the adapter device */
320 324
321 int nr; 325 int nr;
322 struct list_head clients; 326 struct list_head clients; /* DEPRECATED */
323 struct list_head list;
324 char name[48]; 327 char name[48];
325 struct completion dev_released; 328 struct completion dev_released;
326}; 329};
@@ -357,10 +360,10 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
357 * command line 360 * command line
358 */ 361 */
359struct i2c_client_address_data { 362struct i2c_client_address_data {
360 unsigned short *normal_i2c; 363 const unsigned short *normal_i2c;
361 unsigned short *probe; 364 const unsigned short *probe;
362 unsigned short *ignore; 365 const unsigned short *ignore;
363 unsigned short **forces; 366 const unsigned short * const *forces;
364}; 367};
365 368
366/* Internal numbers to terminate lists */ 369/* Internal numbers to terminate lists */
@@ -389,28 +392,20 @@ static inline int i2c_add_driver(struct i2c_driver *driver)
389extern int i2c_attach_client(struct i2c_client *); 392extern int i2c_attach_client(struct i2c_client *);
390extern int i2c_detach_client(struct i2c_client *); 393extern int i2c_detach_client(struct i2c_client *);
391 394
392/* Should be used to make sure that client-struct is valid and that it 395extern struct i2c_client *i2c_use_client(struct i2c_client *client);
393 is okay to access the i2c-client. 396extern void i2c_release_client(struct i2c_client *client);
394 returns -ENODEV if client has gone in the meantime */
395extern int i2c_use_client(struct i2c_client *);
396extern int i2c_release_client(struct i2c_client *);
397 397
398/* call the i2c_client->command() of all attached clients with 398/* call the i2c_client->command() of all attached clients with
399 * the given arguments */ 399 * the given arguments */
400extern void i2c_clients_command(struct i2c_adapter *adap, 400extern void i2c_clients_command(struct i2c_adapter *adap,
401 unsigned int cmd, void *arg); 401 unsigned int cmd, void *arg);
402 402
403/* returns -EBUSY if address has been taken, 0 if not. Note that the only
404 other place at which this is called is within i2c_attach_client; so
405 you can cheat by simply not registering. Not recommended, of course! */
406extern int i2c_check_addr (struct i2c_adapter *adapter, int addr);
407
408/* Detect function. It iterates over all possible addresses itself. 403/* Detect function. It iterates over all possible addresses itself.
409 * It will only call found_proc if some client is connected at the 404 * It will only call found_proc if some client is connected at the
410 * specific address (unless a 'force' matched); 405 * specific address (unless a 'force' matched);
411 */ 406 */
412extern int i2c_probe(struct i2c_adapter *adapter, 407extern int i2c_probe(struct i2c_adapter *adapter,
413 struct i2c_client_address_data *address_data, 408 const struct i2c_client_address_data *address_data,
414 int (*found_proc) (struct i2c_adapter *, int, int)); 409 int (*found_proc) (struct i2c_adapter *, int, int));
415 410
416extern struct i2c_adapter* i2c_get_adapter(int id); 411extern struct i2c_adapter* i2c_get_adapter(int id);
@@ -603,104 +598,93 @@ I2C_CLIENT_MODULE_PARM(probe, "List of adapter,address pairs to scan " \
603 "additionally"); \ 598 "additionally"); \
604I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \ 599I2C_CLIENT_MODULE_PARM(ignore, "List of adapter,address pairs not to " \
605 "scan"); \ 600 "scan"); \
606static struct i2c_client_address_data addr_data = { \ 601const static struct i2c_client_address_data addr_data = { \
607 .normal_i2c = normal_i2c, \ 602 .normal_i2c = normal_i2c, \
608 .probe = probe, \ 603 .probe = probe, \
609 .ignore = ignore, \ 604 .ignore = ignore, \
610 .forces = forces, \ 605 .forces = forces, \
611} 606}
612 607
608#define I2C_CLIENT_FORCE_TEXT \
609 "List of adapter,address pairs to boldly assume to be present"
610
613/* These are the ones you want to use in your own drivers. Pick the one 611/* These are the ones you want to use in your own drivers. Pick the one
614 which matches the number of devices the driver differenciates between. */ 612 which matches the number of devices the driver differenciates between. */
615#define I2C_CLIENT_INSMOD \ 613#define I2C_CLIENT_INSMOD \
616 I2C_CLIENT_MODULE_PARM(force, \ 614I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
617 "List of adapter,address pairs to boldly assume " \ 615static const unsigned short * const forces[] = { force, NULL }; \
618 "to be present"); \
619 static unsigned short *forces[] = { \
620 force, \
621 NULL \
622 }; \
623I2C_CLIENT_INSMOD_COMMON 616I2C_CLIENT_INSMOD_COMMON
624 617
625#define I2C_CLIENT_INSMOD_1(chip1) \ 618#define I2C_CLIENT_INSMOD_1(chip1) \
626enum chips { any_chip, chip1 }; \ 619enum chips { any_chip, chip1 }; \
627I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 620I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
628 "boldly assume to be present"); \
629I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 621I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
630static unsigned short *forces[] = { force, force_##chip1, NULL }; \ 622static const unsigned short * const forces[] = { force, \
623 force_##chip1, NULL }; \
631I2C_CLIENT_INSMOD_COMMON 624I2C_CLIENT_INSMOD_COMMON
632 625
633#define I2C_CLIENT_INSMOD_2(chip1, chip2) \ 626#define I2C_CLIENT_INSMOD_2(chip1, chip2) \
634enum chips { any_chip, chip1, chip2 }; \ 627enum chips { any_chip, chip1, chip2 }; \
635I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 628I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
636 "boldly assume to be present"); \
637I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 629I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
638I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 630I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
639static unsigned short *forces[] = { force, force_##chip1, \ 631static const unsigned short * const forces[] = { force, \
640 force_##chip2, NULL }; \ 632 force_##chip1, force_##chip2, NULL }; \
641I2C_CLIENT_INSMOD_COMMON 633I2C_CLIENT_INSMOD_COMMON
642 634
643#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \ 635#define I2C_CLIENT_INSMOD_3(chip1, chip2, chip3) \
644enum chips { any_chip, chip1, chip2, chip3 }; \ 636enum chips { any_chip, chip1, chip2, chip3 }; \
645I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 637I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
646 "boldly assume to be present"); \
647I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 638I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
648I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 639I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
649I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 640I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
650static unsigned short *forces[] = { force, force_##chip1, \ 641static const unsigned short * const forces[] = { force, \
651 force_##chip2, force_##chip3, \ 642 force_##chip1, force_##chip2, force_##chip3, NULL }; \
652 NULL }; \
653I2C_CLIENT_INSMOD_COMMON 643I2C_CLIENT_INSMOD_COMMON
654 644
655#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \ 645#define I2C_CLIENT_INSMOD_4(chip1, chip2, chip3, chip4) \
656enum chips { any_chip, chip1, chip2, chip3, chip4 }; \ 646enum chips { any_chip, chip1, chip2, chip3, chip4 }; \
657I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 647I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
658 "boldly assume to be present"); \
659I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 648I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
660I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 649I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
661I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 650I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
662I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 651I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
663static unsigned short *forces[] = { force, force_##chip1, \ 652static const unsigned short * const forces[] = { force, \
664 force_##chip2, force_##chip3, \ 653 force_##chip1, force_##chip2, force_##chip3, \
665 force_##chip4, NULL}; \ 654 force_##chip4, NULL}; \
666I2C_CLIENT_INSMOD_COMMON 655I2C_CLIENT_INSMOD_COMMON
667 656
668#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \ 657#define I2C_CLIENT_INSMOD_5(chip1, chip2, chip3, chip4, chip5) \
669enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \ 658enum chips { any_chip, chip1, chip2, chip3, chip4, chip5 }; \
670I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 659I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
671 "boldly assume to be present"); \
672I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 660I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
673I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 661I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
674I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 662I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
675I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 663I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
676I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 664I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
677static unsigned short *forces[] = { force, force_##chip1, \ 665static const unsigned short * const forces[] = { force, \
678 force_##chip2, force_##chip3, \ 666 force_##chip1, force_##chip2, force_##chip3, \
679 force_##chip4, force_##chip5, \ 667 force_##chip4, force_##chip5, NULL }; \
680 NULL }; \
681I2C_CLIENT_INSMOD_COMMON 668I2C_CLIENT_INSMOD_COMMON
682 669
683#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \ 670#define I2C_CLIENT_INSMOD_6(chip1, chip2, chip3, chip4, chip5, chip6) \
684enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \ 671enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6 }; \
685I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 672I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
686 "boldly assume to be present"); \
687I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 673I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
688I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 674I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
689I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 675I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
690I2C_CLIENT_MODULE_PARM_FORCE(chip4); \ 676I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
691I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 677I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
692I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 678I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
693static unsigned short *forces[] = { force, force_##chip1, \ 679static const unsigned short * const forces[] = { force, \
694 force_##chip2, force_##chip3, \ 680 force_##chip1, force_##chip2, force_##chip3, \
695 force_##chip4, force_##chip5, \ 681 force_##chip4, force_##chip5, force_##chip6, NULL }; \
696 force_##chip6, NULL }; \
697I2C_CLIENT_INSMOD_COMMON 682I2C_CLIENT_INSMOD_COMMON
698 683
699#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \ 684#define I2C_CLIENT_INSMOD_7(chip1, chip2, chip3, chip4, chip5, chip6, chip7) \
700enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 685enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
701 chip7 }; \ 686 chip7 }; \
702I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 687I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
703 "boldly assume to be present"); \
704I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 688I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
705I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 689I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
706I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 690I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
@@ -708,18 +692,16 @@ I2C_CLIENT_MODULE_PARM_FORCE(chip4); \
708I2C_CLIENT_MODULE_PARM_FORCE(chip5); \ 692I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
709I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 693I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
710I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ 694I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
711static unsigned short *forces[] = { force, force_##chip1, \ 695static const unsigned short * const forces[] = { force, \
712 force_##chip2, force_##chip3, \ 696 force_##chip1, force_##chip2, force_##chip3, \
713 force_##chip4, force_##chip5, \ 697 force_##chip4, force_##chip5, force_##chip6, \
714 force_##chip6, force_##chip7, \ 698 force_##chip7, NULL }; \
715 NULL }; \
716I2C_CLIENT_INSMOD_COMMON 699I2C_CLIENT_INSMOD_COMMON
717 700
718#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \ 701#define I2C_CLIENT_INSMOD_8(chip1, chip2, chip3, chip4, chip5, chip6, chip7, chip8) \
719enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \ 702enum chips { any_chip, chip1, chip2, chip3, chip4, chip5, chip6, \
720 chip7, chip8 }; \ 703 chip7, chip8 }; \
721I2C_CLIENT_MODULE_PARM(force, "List of adapter,address pairs to " \ 704I2C_CLIENT_MODULE_PARM(force, I2C_CLIENT_FORCE_TEXT); \
722 "boldly assume to be present"); \
723I2C_CLIENT_MODULE_PARM_FORCE(chip1); \ 705I2C_CLIENT_MODULE_PARM_FORCE(chip1); \
724I2C_CLIENT_MODULE_PARM_FORCE(chip2); \ 706I2C_CLIENT_MODULE_PARM_FORCE(chip2); \
725I2C_CLIENT_MODULE_PARM_FORCE(chip3); \ 707I2C_CLIENT_MODULE_PARM_FORCE(chip3); \
@@ -728,11 +710,10 @@ I2C_CLIENT_MODULE_PARM_FORCE(chip5); \
728I2C_CLIENT_MODULE_PARM_FORCE(chip6); \ 710I2C_CLIENT_MODULE_PARM_FORCE(chip6); \
729I2C_CLIENT_MODULE_PARM_FORCE(chip7); \ 711I2C_CLIENT_MODULE_PARM_FORCE(chip7); \
730I2C_CLIENT_MODULE_PARM_FORCE(chip8); \ 712I2C_CLIENT_MODULE_PARM_FORCE(chip8); \
731static unsigned short *forces[] = { force, force_##chip1, \ 713static const unsigned short * const forces[] = { force, \
732 force_##chip2, force_##chip3, \ 714 force_##chip1, force_##chip2, force_##chip3, \
733 force_##chip4, force_##chip5, \ 715 force_##chip4, force_##chip5, force_##chip6, \
734 force_##chip6, force_##chip7, \ 716 force_##chip7, force_##chip8, NULL }; \
735 force_##chip8, NULL }; \
736I2C_CLIENT_INSMOD_COMMON 717I2C_CLIENT_INSMOD_COMMON
737#endif /* __KERNEL__ */ 718#endif /* __KERNEL__ */
738#endif /* _LINUX_I2C_H */ 719#endif /* _LINUX_I2C_H */
diff --git a/include/asm-arm/arch-omap/tps65010.h b/include/linux/i2c/tps65010.h
index b9aa2b3a3909..7021635ed6a0 100644
--- a/include/asm-arm/arch-omap/tps65010.h
+++ b/include/linux/i2c/tps65010.h
@@ -1,4 +1,4 @@
1/* linux/include/asm-arm/arch-omap/tps65010.h 1/* linux/i2c/tps65010.h
2 * 2 *
3 * Functions to access TPS65010 power management device. 3 * Functions to access TPS65010 power management device.
4 * 4 *
@@ -25,8 +25,8 @@
25 * 675 Mass Ave, Cambridge, MA 02139, USA. 25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27 27
28#ifndef __ASM_ARCH_TPS65010_H 28#ifndef __LINUX_I2C_TPS65010_H
29#define __ASM_ARCH_TPS65010_H 29#define __LINUX_I2C_TPS65010_H
30 30
31/* 31/*
32 * ---------------------------------------------------------------------------- 32 * ----------------------------------------------------------------------------
@@ -152,5 +152,5 @@ extern int tps65010_config_vregs1(unsigned value);
152 */ 152 */
153extern int tps65013_set_low_pwr(unsigned mode); 153extern int tps65013_set_low_pwr(unsigned mode);
154 154
155#endif /* __ASM_ARCH_TPS65010_H */ 155#endif /* __LINUX_I2C_TPS65010_H */
156 156
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 4ed4777bba67..367c17084a28 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -9,7 +9,6 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/ioport.h> 10#include <linux/ioport.h>
11#include <linux/hdreg.h> 11#include <linux/hdreg.h>
12#include <linux/hdsmart.h>
13#include <linux/blkdev.h> 12#include <linux/blkdev.h>
14#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
15#include <linux/interrupt.h> 14#include <linux/interrupt.h>
@@ -27,25 +26,10 @@
27#include <asm/semaphore.h> 26#include <asm/semaphore.h>
28#include <asm/mutex.h> 27#include <asm/mutex.h>
29 28
30/****************************************************************************** 29#if defined(CRIS) || defined(FRV)
31 * IDE driver configuration options (play with these as desired): 30# define SUPPORT_VLB_SYNC 0
32 * 31#else
33 * REALLY_SLOW_IO can be defined in ide.c and ide-cd.c, if necessary 32# define SUPPORT_VLB_SYNC 1
34 */
35#define INITIAL_MULT_COUNT 0 /* off=0; on=2,4,8,16,32, etc.. */
36
37#ifndef SUPPORT_SLOW_DATA_PORTS /* 1 to support slow data ports */
38#define SUPPORT_SLOW_DATA_PORTS 1 /* 0 to reduce kernel size */
39#endif
40#ifndef SUPPORT_VLB_SYNC /* 1 to support weird 32-bit chips */
41#define SUPPORT_VLB_SYNC 1 /* 0 to reduce kernel size */
42#endif
43#ifndef OK_TO_RESET_CONTROLLER /* 1 needed for good error recovery */
44#define OK_TO_RESET_CONTROLLER 1 /* 0 for use with AH2372A/B interface */
45#endif
46
47#ifndef DISABLE_IRQ_NOSYNC
48#define DISABLE_IRQ_NOSYNC 0
49#endif 33#endif
50 34
51/* 35/*
@@ -55,10 +39,6 @@
55 39
56#define IDE_NO_IRQ (-1) 40#define IDE_NO_IRQ (-1)
57 41
58/*
59 * "No user-serviceable parts" beyond this point :)
60 *****************************************************************************/
61
62typedef unsigned char byte; /* used everywhere */ 42typedef unsigned char byte; /* used everywhere */
63 43
64/* 44/*
@@ -103,8 +83,6 @@ typedef unsigned char byte; /* used everywhere */
103#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET 83#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
104#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET 84#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
105 85
106#define IDE_CONTROL_OFFSET_HOB (7)
107
108#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET]) 86#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
109#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET]) 87#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
110#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET]) 88#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
@@ -128,25 +106,18 @@ typedef unsigned char byte; /* used everywhere */
128#define BAD_W_STAT (BAD_R_STAT | WRERR_STAT) 106#define BAD_W_STAT (BAD_R_STAT | WRERR_STAT)
129#define BAD_STAT (BAD_R_STAT | DRQ_STAT) 107#define BAD_STAT (BAD_R_STAT | DRQ_STAT)
130#define DRIVE_READY (READY_STAT | SEEK_STAT) 108#define DRIVE_READY (READY_STAT | SEEK_STAT)
131#define DATA_READY (DRQ_STAT)
132 109
133#define BAD_CRC (ABRT_ERR | ICRC_ERR) 110#define BAD_CRC (ABRT_ERR | ICRC_ERR)
134 111
135#define SATA_NR_PORTS (3) /* 16 possible ?? */ 112#define SATA_NR_PORTS (3) /* 16 possible ?? */
136 113
137#define SATA_STATUS_OFFSET (0) 114#define SATA_STATUS_OFFSET (0)
138#define SATA_STATUS_REG (HWIF(drive)->sata_scr[SATA_STATUS_OFFSET])
139#define SATA_ERROR_OFFSET (1) 115#define SATA_ERROR_OFFSET (1)
140#define SATA_ERROR_REG (HWIF(drive)->sata_scr[SATA_ERROR_OFFSET])
141#define SATA_CONTROL_OFFSET (2) 116#define SATA_CONTROL_OFFSET (2)
142#define SATA_CONTROL_REG (HWIF(drive)->sata_scr[SATA_CONTROL_OFFSET])
143 117
144#define SATA_MISC_OFFSET (0) 118#define SATA_MISC_OFFSET (0)
145#define SATA_MISC_REG (HWIF(drive)->sata_misc[SATA_MISC_OFFSET])
146#define SATA_PHY_OFFSET (1) 119#define SATA_PHY_OFFSET (1)
147#define SATA_PHY_REG (HWIF(drive)->sata_misc[SATA_PHY_OFFSET])
148#define SATA_IEN_OFFSET (2) 120#define SATA_IEN_OFFSET (2)
149#define SATA_IEN_REG (HWIF(drive)->sata_misc[SATA_IEN_OFFSET])
150 121
151/* 122/*
152 * Our Physical Region Descriptor (PRD) table should be large enough 123 * Our Physical Region Descriptor (PRD) table should be large enough
@@ -219,8 +190,12 @@ typedef struct hw_regs_s {
219} hw_regs_t; 190} hw_regs_t;
220 191
221struct hwif_s * ide_find_port(unsigned long); 192struct hwif_s * ide_find_port(unsigned long);
193struct hwif_s *ide_deprecated_find_port(unsigned long);
194void ide_init_port_data(struct hwif_s *, unsigned int);
195void ide_init_port_hw(struct hwif_s *, hw_regs_t *);
222 196
223int ide_register_hw(hw_regs_t *, void (*)(struct hwif_s *), int, 197struct ide_drive_s;
198int ide_register_hw(hw_regs_t *, void (*)(struct ide_drive_s *),
224 struct hwif_s **); 199 struct hwif_s **);
225 200
226void ide_setup_ports( hw_regs_t *hw, 201void ide_setup_ports( hw_regs_t *hw,
@@ -327,47 +302,16 @@ static inline void ide_init_hwif_ports(hw_regs_t *hw,
327typedef union { 302typedef union {
328 unsigned all : 8; 303 unsigned all : 8;
329 struct { 304 struct {
330#if defined(__LITTLE_ENDIAN_BITFIELD)
331 unsigned set_geometry : 1; 305 unsigned set_geometry : 1;
332 unsigned recalibrate : 1; 306 unsigned recalibrate : 1;
333 unsigned set_multmode : 1; 307 unsigned set_multmode : 1;
334 unsigned set_tune : 1; 308 unsigned set_tune : 1;
335 unsigned serviced : 1; 309 unsigned serviced : 1;
336 unsigned reserved : 3; 310 unsigned reserved : 3;
337#elif defined(__BIG_ENDIAN_BITFIELD)
338 unsigned reserved : 3;
339 unsigned serviced : 1;
340 unsigned set_tune : 1;
341 unsigned set_multmode : 1;
342 unsigned recalibrate : 1;
343 unsigned set_geometry : 1;
344#else
345#error "Please fix <asm/byteorder.h>"
346#endif
347 } b; 311 } b;
348} special_t; 312} special_t;
349 313
350/* 314/*
351 * ATA DATA Register Special.
352 * ATA NSECTOR Count Register().
353 * ATAPI Byte Count Register.
354 */
355typedef union {
356 unsigned all :16;
357 struct {
358#if defined(__LITTLE_ENDIAN_BITFIELD)
359 unsigned low :8; /* LSB */
360 unsigned high :8; /* MSB */
361#elif defined(__BIG_ENDIAN_BITFIELD)
362 unsigned high :8; /* MSB */
363 unsigned low :8; /* LSB */
364#else
365#error "Please fix <asm/byteorder.h>"
366#endif
367 } b;
368} ata_nsector_t, ata_data_t, atapi_bcount_t;
369
370/*
371 * ATA-IDE Select Register, aka Device-Head 315 * ATA-IDE Select Register, aka Device-Head
372 * 316 *
373 * head : always zeros here 317 * head : always zeros here
@@ -398,131 +342,6 @@ typedef union {
398} select_t, ata_select_t; 342} select_t, ata_select_t;
399 343
400/* 344/*
401 * The ATA-IDE Status Register.
402 * The ATAPI Status Register.
403 *
404 * check : Error occurred
405 * idx : Index Error
406 * corr : Correctable error occurred
407 * drq : Data is request by the device
408 * dsc : Disk Seek Complete : ata
409 * : Media access command finished : atapi
410 * df : Device Fault : ata
411 * : Reserved : atapi
412 * drdy : Ready, Command Mode Capable : ata
413 * : Ignored for ATAPI commands : atapi
414 * bsy : Disk is Busy
415 * : The device has access to the command block
416 */
417typedef union {
418 unsigned all :8;
419 struct {
420#if defined(__LITTLE_ENDIAN_BITFIELD)
421 unsigned check :1;
422 unsigned idx :1;
423 unsigned corr :1;
424 unsigned drq :1;
425 unsigned dsc :1;
426 unsigned df :1;
427 unsigned drdy :1;
428 unsigned bsy :1;
429#elif defined(__BIG_ENDIAN_BITFIELD)
430 unsigned bsy :1;
431 unsigned drdy :1;
432 unsigned df :1;
433 unsigned dsc :1;
434 unsigned drq :1;
435 unsigned corr :1;
436 unsigned idx :1;
437 unsigned check :1;
438#else
439#error "Please fix <asm/byteorder.h>"
440#endif
441 } b;
442} ata_status_t, atapi_status_t;
443
444/*
445 * ATAPI Feature Register
446 *
447 * dma : Using DMA or PIO
448 * reserved321 : Reserved
449 * reserved654 : Reserved (Tag Type)
450 * reserved7 : Reserved
451 */
452typedef union {
453 unsigned all :8;
454 struct {
455#if defined(__LITTLE_ENDIAN_BITFIELD)
456 unsigned dma :1;
457 unsigned reserved321 :3;
458 unsigned reserved654 :3;
459 unsigned reserved7 :1;
460#elif defined(__BIG_ENDIAN_BITFIELD)
461 unsigned reserved7 :1;
462 unsigned reserved654 :3;
463 unsigned reserved321 :3;
464 unsigned dma :1;
465#else
466#error "Please fix <asm/byteorder.h>"
467#endif
468 } b;
469} atapi_feature_t;
470
471/*
472 * ATAPI Interrupt Reason Register.
473 *
474 * cod : Information transferred is command (1) or data (0)
475 * io : The device requests us to read (1) or write (0)
476 * reserved : Reserved
477 */
478typedef union {
479 unsigned all :8;
480 struct {
481#if defined(__LITTLE_ENDIAN_BITFIELD)
482 unsigned cod :1;
483 unsigned io :1;
484 unsigned reserved :6;
485#elif defined(__BIG_ENDIAN_BITFIELD)
486 unsigned reserved :6;
487 unsigned io :1;
488 unsigned cod :1;
489#else
490#error "Please fix <asm/byteorder.h>"
491#endif
492 } b;
493} atapi_ireason_t;
494
495/*
496 * The ATAPI error register.
497 *
498 * ili : Illegal Length Indication
499 * eom : End Of Media Detected
500 * abrt : Aborted command - As defined by ATA
501 * mcr : Media Change Requested - As defined by ATA
502 * sense_key : Sense key of the last failed packet command
503 */
504typedef union {
505 unsigned all :8;
506 struct {
507#if defined(__LITTLE_ENDIAN_BITFIELD)
508 unsigned ili :1;
509 unsigned eom :1;
510 unsigned abrt :1;
511 unsigned mcr :1;
512 unsigned sense_key :4;
513#elif defined(__BIG_ENDIAN_BITFIELD)
514 unsigned sense_key :4;
515 unsigned mcr :1;
516 unsigned abrt :1;
517 unsigned eom :1;
518 unsigned ili :1;
519#else
520#error "Please fix <asm/byteorder.h>"
521#endif
522 } b;
523} atapi_error_t;
524
525/*
526 * Status returned from various ide_ functions 345 * Status returned from various ide_ functions
527 */ 346 */
528typedef enum { 347typedef enum {
@@ -568,7 +387,6 @@ typedef struct ide_drive_s {
568 u8 state; /* retry state */ 387 u8 state; /* retry state */
569 u8 waiting_for_dma; /* dma currently in progress */ 388 u8 waiting_for_dma; /* dma currently in progress */
570 u8 unmask; /* okay to unmask other irqs */ 389 u8 unmask; /* okay to unmask other irqs */
571 u8 bswap; /* byte swap data */
572 u8 noflush; /* don't attempt flushes */ 390 u8 noflush; /* don't attempt flushes */
573 u8 dsc_overlap; /* DSC overlap */ 391 u8 dsc_overlap; /* DSC overlap */
574 u8 nice1; /* give potential excess bandwidth */ 392 u8 nice1; /* give potential excess bandwidth */
@@ -583,8 +401,6 @@ typedef struct ide_drive_s {
583 unsigned no_unmask : 1; /* disallow setting unmask bit */ 401 unsigned no_unmask : 1; /* disallow setting unmask bit */
584 unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ 402 unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */
585 unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ 403 unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */
586 unsigned nice0 : 1; /* give obvious excess bandwidth */
587 unsigned nice2 : 1; /* give a share in our own bandwidth */
588 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ 404 unsigned doorlocking : 1; /* for removable only: door lock/unlock works */
589 unsigned nodma : 1; /* disallow DMA */ 405 unsigned nodma : 1; /* disallow DMA */
590 unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */ 406 unsigned autotune : 2; /* 0=default, 1=autotune, 2=noautotune */
@@ -664,7 +480,6 @@ typedef struct hwif_s {
664 u8 major; /* our major number */ 480 u8 major; /* our major number */
665 u8 index; /* 0 for ide0; 1 for ide1; ... */ 481 u8 index; /* 0 for ide0; 1 for ide1; ... */
666 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ 482 u8 channel; /* for dual-port chips: 0=primary, 1=secondary */
667 u8 straight8; /* Alan's straight 8 check */
668 u8 bus_state; /* power state of the IDE bus */ 483 u8 bus_state; /* power state of the IDE bus */
669 484
670 u32 host_flags; 485 u32 host_flags;
@@ -679,7 +494,8 @@ typedef struct hwif_s {
679 494
680 hwif_chipset_t chipset; /* sub-module for tuning.. */ 495 hwif_chipset_t chipset; /* sub-module for tuning.. */
681 496
682 struct pci_dev *pci_dev; /* for pci chipsets */ 497 struct device *dev;
498
683 const struct ide_port_info *cds; /* chipset device struct */ 499 const struct ide_port_info *cds; /* chipset device struct */
684 500
685 ide_ack_intr_t *ack_intr; 501 ide_ack_intr_t *ack_intr;
@@ -689,6 +505,8 @@ typedef struct hwif_s {
689#if 0 505#if 0
690 ide_hwif_ops_t *hwifops; 506 ide_hwif_ops_t *hwifops;
691#else 507#else
508 /* host specific initialization of devices on a port */
509 void (*port_init_devs)(struct hwif_s *);
692 /* routine to program host for PIO mode */ 510 /* routine to program host for PIO mode */
693 void (*set_pio_mode)(ide_drive_t *, const u8); 511 void (*set_pio_mode)(ide_drive_t *, const u8);
694 /* routine to program host for DMA mode */ 512 /* routine to program host for DMA mode */
@@ -701,19 +519,17 @@ typedef struct hwif_s {
701 void (*pre_reset)(ide_drive_t *); 519 void (*pre_reset)(ide_drive_t *);
702 /* routine to reset controller after a disk reset */ 520 /* routine to reset controller after a disk reset */
703 void (*resetproc)(ide_drive_t *); 521 void (*resetproc)(ide_drive_t *);
704 /* special interrupt handling for shared pci interrupts */
705 void (*intrproc)(ide_drive_t *);
706 /* special host masking for drive selection */ 522 /* special host masking for drive selection */
707 void (*maskproc)(ide_drive_t *, int); 523 void (*maskproc)(ide_drive_t *, int);
708 /* check host's drive quirk list */ 524 /* check host's drive quirk list */
709 int (*quirkproc)(ide_drive_t *); 525 void (*quirkproc)(ide_drive_t *);
710 /* driver soft-power interface */ 526 /* driver soft-power interface */
711 int (*busproc)(ide_drive_t *, int); 527 int (*busproc)(ide_drive_t *, int);
712#endif 528#endif
713 u8 (*mdma_filter)(ide_drive_t *); 529 u8 (*mdma_filter)(ide_drive_t *);
714 u8 (*udma_filter)(ide_drive_t *); 530 u8 (*udma_filter)(ide_drive_t *);
715 531
716 void (*fixup)(struct hwif_s *); 532 u8 (*cable_detect)(struct hwif_s *);
717 533
718 void (*ata_input_data)(ide_drive_t *, void *, u32); 534 void (*ata_input_data)(ide_drive_t *, void *, u32);
719 void (*ata_output_data)(ide_drive_t *, void *, u32); 535 void (*ata_output_data)(ide_drive_t *, void *, u32);
@@ -721,16 +537,13 @@ typedef struct hwif_s {
721 void (*atapi_input_bytes)(ide_drive_t *, void *, u32); 537 void (*atapi_input_bytes)(ide_drive_t *, void *, u32);
722 void (*atapi_output_bytes)(ide_drive_t *, void *, u32); 538 void (*atapi_output_bytes)(ide_drive_t *, void *, u32);
723 539
540 void (*dma_host_set)(ide_drive_t *, int);
724 int (*dma_setup)(ide_drive_t *); 541 int (*dma_setup)(ide_drive_t *);
725 void (*dma_exec_cmd)(ide_drive_t *, u8); 542 void (*dma_exec_cmd)(ide_drive_t *, u8);
726 void (*dma_start)(ide_drive_t *); 543 void (*dma_start)(ide_drive_t *);
727 int (*ide_dma_end)(ide_drive_t *drive); 544 int (*ide_dma_end)(ide_drive_t *drive);
728 int (*ide_dma_on)(ide_drive_t *drive);
729 void (*dma_off_quietly)(ide_drive_t *drive);
730 int (*ide_dma_test_irq)(ide_drive_t *drive); 545 int (*ide_dma_test_irq)(ide_drive_t *drive);
731 void (*ide_dma_clear_irq)(ide_drive_t *drive); 546 void (*ide_dma_clear_irq)(ide_drive_t *drive);
732 void (*dma_host_on)(ide_drive_t *drive);
733 void (*dma_host_off)(ide_drive_t *drive);
734 void (*dma_lost_irq)(ide_drive_t *drive); 547 void (*dma_lost_irq)(ide_drive_t *drive);
735 void (*dma_timeout)(ide_drive_t *drive); 548 void (*dma_timeout)(ide_drive_t *drive);
736 549
@@ -766,7 +579,6 @@ typedef struct hwif_s {
766 int rqsize; /* max sectors per request */ 579 int rqsize; /* max sectors per request */
767 int irq; /* our irq number */ 580 int irq; /* our irq number */
768 581
769 unsigned long dma_master; /* reference base addr dmabase */
770 unsigned long dma_base; /* base addr for dma ports */ 582 unsigned long dma_base; /* base addr for dma ports */
771 unsigned long dma_command; /* dma command register */ 583 unsigned long dma_command; /* dma command register */
772 unsigned long dma_vendor1; /* dma vendor 1 register */ 584 unsigned long dma_vendor1; /* dma vendor 1 register */
@@ -786,10 +598,9 @@ typedef struct hwif_s {
786 unsigned serialized : 1; /* serialized all channel operation */ 598 unsigned serialized : 1; /* serialized all channel operation */
787 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 599 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */
788 unsigned reset : 1; /* reset after probe */ 600 unsigned reset : 1; /* reset after probe */
789 unsigned auto_poll : 1; /* supports nop auto-poll */
790 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 601 unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
791 unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */
792 unsigned mmio : 1; /* host uses MMIO */ 602 unsigned mmio : 1; /* host uses MMIO */
603 unsigned straight8 : 1; /* Alan's straight 8 check */
793 604
794 struct device gendev; 605 struct device gendev;
795 struct completion gendev_rel_comp; /* To deal with device release() */ 606 struct completion gendev_rel_comp; /* To deal with device release() */
@@ -806,15 +617,16 @@ typedef struct hwif_s {
806/* 617/*
807 * internal ide interrupt handler type 618 * internal ide interrupt handler type
808 */ 619 */
809typedef ide_startstop_t (ide_pre_handler_t)(ide_drive_t *, struct request *);
810typedef ide_startstop_t (ide_handler_t)(ide_drive_t *); 620typedef ide_startstop_t (ide_handler_t)(ide_drive_t *);
811typedef int (ide_expiry_t)(ide_drive_t *); 621typedef int (ide_expiry_t)(ide_drive_t *);
812 622
623/* used by ide-cd, ide-floppy, etc. */
624typedef void (xfer_func_t)(ide_drive_t *, void *, u32);
625
813typedef struct hwgroup_s { 626typedef struct hwgroup_s {
814 /* irq handler, if active */ 627 /* irq handler, if active */
815 ide_startstop_t (*handler)(ide_drive_t *); 628 ide_startstop_t (*handler)(ide_drive_t *);
816 /* irq handler, suspended if active */ 629
817 ide_startstop_t (*handler_save)(ide_drive_t *);
818 /* BOOL: protects all fields below */ 630 /* BOOL: protects all fields below */
819 volatile int busy; 631 volatile int busy;
820 /* BOOL: wake us up on timer expiry */ 632 /* BOOL: wake us up on timer expiry */
@@ -829,25 +641,18 @@ typedef struct hwgroup_s {
829 /* ptr to current hwif in linked-list */ 641 /* ptr to current hwif in linked-list */
830 ide_hwif_t *hwif; 642 ide_hwif_t *hwif;
831 643
832 /* for pci chipsets */
833 struct pci_dev *pci_dev;
834
835 /* current request */ 644 /* current request */
836 struct request *rq; 645 struct request *rq;
646
837 /* failsafe timer */ 647 /* failsafe timer */
838 struct timer_list timer; 648 struct timer_list timer;
839 /* local copy of current write rq */
840 struct request wrq;
841 /* timeout value during long polls */ 649 /* timeout value during long polls */
842 unsigned long poll_timeout; 650 unsigned long poll_timeout;
843 /* queried upon timeouts */ 651 /* queried upon timeouts */
844 int (*expiry)(ide_drive_t *); 652 int (*expiry)(ide_drive_t *);
845 /* ide_system_bus_speed */ 653
846 int pio_clock;
847 int req_gen; 654 int req_gen;
848 int req_gen_timer; 655 int req_gen_timer;
849
850 unsigned char cmd_buf[4];
851} ide_hwgroup_t; 656} ide_hwgroup_t;
852 657
853typedef struct ide_driver_s ide_driver_t; 658typedef struct ide_driver_s ide_driver_t;
@@ -901,6 +706,7 @@ typedef struct {
901void proc_ide_create(void); 706void proc_ide_create(void);
902void proc_ide_destroy(void); 707void proc_ide_destroy(void);
903void ide_proc_register_port(ide_hwif_t *); 708void ide_proc_register_port(ide_hwif_t *);
709void ide_proc_port_register_devices(ide_hwif_t *);
904void ide_proc_unregister_port(ide_hwif_t *); 710void ide_proc_unregister_port(ide_hwif_t *);
905void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 711void ide_proc_register_driver(ide_drive_t *, ide_driver_t *);
906void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 712void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *);
@@ -933,6 +739,7 @@ void ide_pci_create_host_proc(const char *, get_info_t *);
933static inline void proc_ide_create(void) { ; } 739static inline void proc_ide_create(void) { ; }
934static inline void proc_ide_destroy(void) { ; } 740static inline void proc_ide_destroy(void) { ; }
935static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } 741static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; }
742static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; }
936static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 743static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
937static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 744static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
938static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 745static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
@@ -1020,7 +827,8 @@ int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq,
1020 827
1021extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry); 828extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry);
1022 829
1023extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *); 830void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int,
831 ide_expiry_t *);
1024 832
1025ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); 833ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);
1026 834
@@ -1031,14 +839,7 @@ ide_startstop_t __ide_abort(ide_drive_t *, struct request *);
1031extern ide_startstop_t ide_abort(ide_drive_t *, const char *); 839extern ide_startstop_t ide_abort(ide_drive_t *, const char *);
1032 840
1033extern void ide_fix_driveid(struct hd_driveid *); 841extern void ide_fix_driveid(struct hd_driveid *);
1034/* 842
1035 * ide_fixstring() cleans up and (optionally) byte-swaps a text string,
1036 * removing leading/trailing blanks and compressing internal blanks.
1037 * It is primarily used to tidy up the model name/number fields as
1038 * returned by the WIN_[P]IDENTIFY commands.
1039 *
1040 * (s, bytecount, byteswap)
1041 */
1042extern void ide_fixstring(u8 *, const int, const int); 843extern void ide_fixstring(u8 *, const int, const int);
1043 844
1044int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 845int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);
@@ -1061,60 +862,124 @@ extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);
1061 862
1062extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 863extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);
1063 864
1064/* 865enum {
1065 * Issue ATA command and wait for completion. 866 IDE_TFLAG_LBA48 = (1 << 0),
1066 * Use for implementing commands in kernel 867 IDE_TFLAG_NO_SELECT_MASK = (1 << 1),
1067 * 868 IDE_TFLAG_FLAGGED = (1 << 2),
1068 * (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf) 869 IDE_TFLAG_OUT_DATA = (1 << 3),
1069 */ 870 IDE_TFLAG_OUT_HOB_FEATURE = (1 << 4),
1070extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *); 871 IDE_TFLAG_OUT_HOB_NSECT = (1 << 5),
872 IDE_TFLAG_OUT_HOB_LBAL = (1 << 6),
873 IDE_TFLAG_OUT_HOB_LBAM = (1 << 7),
874 IDE_TFLAG_OUT_HOB_LBAH = (1 << 8),
875 IDE_TFLAG_OUT_HOB = IDE_TFLAG_OUT_HOB_FEATURE |
876 IDE_TFLAG_OUT_HOB_NSECT |
877 IDE_TFLAG_OUT_HOB_LBAL |
878 IDE_TFLAG_OUT_HOB_LBAM |
879 IDE_TFLAG_OUT_HOB_LBAH,
880 IDE_TFLAG_OUT_FEATURE = (1 << 9),
881 IDE_TFLAG_OUT_NSECT = (1 << 10),
882 IDE_TFLAG_OUT_LBAL = (1 << 11),
883 IDE_TFLAG_OUT_LBAM = (1 << 12),
884 IDE_TFLAG_OUT_LBAH = (1 << 13),
885 IDE_TFLAG_OUT_TF = IDE_TFLAG_OUT_FEATURE |
886 IDE_TFLAG_OUT_NSECT |
887 IDE_TFLAG_OUT_LBAL |
888 IDE_TFLAG_OUT_LBAM |
889 IDE_TFLAG_OUT_LBAH,
890 IDE_TFLAG_OUT_DEVICE = (1 << 14),
891 IDE_TFLAG_WRITE = (1 << 15),
892 IDE_TFLAG_FLAGGED_SET_IN_FLAGS = (1 << 16),
893 IDE_TFLAG_IN_DATA = (1 << 17),
894 IDE_TFLAG_CUSTOM_HANDLER = (1 << 18),
895 IDE_TFLAG_DMA_PIO_FALLBACK = (1 << 19),
896 IDE_TFLAG_IN_HOB_FEATURE = (1 << 20),
897 IDE_TFLAG_IN_HOB_NSECT = (1 << 21),
898 IDE_TFLAG_IN_HOB_LBAL = (1 << 22),
899 IDE_TFLAG_IN_HOB_LBAM = (1 << 23),
900 IDE_TFLAG_IN_HOB_LBAH = (1 << 24),
901 IDE_TFLAG_IN_HOB_LBA = IDE_TFLAG_IN_HOB_LBAL |
902 IDE_TFLAG_IN_HOB_LBAM |
903 IDE_TFLAG_IN_HOB_LBAH,
904 IDE_TFLAG_IN_HOB = IDE_TFLAG_IN_HOB_FEATURE |
905 IDE_TFLAG_IN_HOB_NSECT |
906 IDE_TFLAG_IN_HOB_LBA,
907 IDE_TFLAG_IN_NSECT = (1 << 25),
908 IDE_TFLAG_IN_LBAL = (1 << 26),
909 IDE_TFLAG_IN_LBAM = (1 << 27),
910 IDE_TFLAG_IN_LBAH = (1 << 28),
911 IDE_TFLAG_IN_LBA = IDE_TFLAG_IN_LBAL |
912 IDE_TFLAG_IN_LBAM |
913 IDE_TFLAG_IN_LBAH,
914 IDE_TFLAG_IN_TF = IDE_TFLAG_IN_NSECT |
915 IDE_TFLAG_IN_LBA,
916 IDE_TFLAG_IN_DEVICE = (1 << 29),
917 IDE_TFLAG_HOB = IDE_TFLAG_OUT_HOB |
918 IDE_TFLAG_IN_HOB,
919 IDE_TFLAG_TF = IDE_TFLAG_OUT_TF |
920 IDE_TFLAG_IN_TF,
921 IDE_TFLAG_DEVICE = IDE_TFLAG_OUT_DEVICE |
922 IDE_TFLAG_IN_DEVICE,
923 /* force 16-bit I/O operations */
924 IDE_TFLAG_IO_16BIT = (1 << 30),
925};
926
927struct ide_taskfile {
928 u8 hob_data; /* 0: high data byte (for TASKFILE IOCTL) */
929
930 u8 hob_feature; /* 1-5: additional data to support LBA48 */
931 u8 hob_nsect;
932 u8 hob_lbal;
933 u8 hob_lbam;
934 u8 hob_lbah;
935
936 u8 data; /* 6: low data byte (for TASKFILE IOCTL) */
937
938 union { /*  7: */
939 u8 error; /* read: error */
940 u8 feature; /* write: feature */
941 };
942
943 u8 nsect; /* 8: number of sectors */
944 u8 lbal; /* 9: LBA low */
945 u8 lbam; /* 10: LBA mid */
946 u8 lbah; /* 11: LBA high */
947
948 u8 device; /* 12: device select */
949
950 union { /* 13: */
951 u8 status; /*  read: status  */
952 u8 command; /* write: command */
953 };
954};
1071 955
1072typedef struct ide_task_s { 956typedef struct ide_task_s {
1073/* 957 union {
1074 * struct hd_drive_task_hdr tf; 958 struct ide_taskfile tf;
1075 * task_struct_t tf; 959 u8 tf_array[14];
1076 * struct hd_drive_hob_hdr hobf; 960 };
1077 * hob_struct_t hobf; 961 u32 tf_flags;
1078 */
1079 task_ioreg_t tfRegister[8];
1080 task_ioreg_t hobRegister[8];
1081 ide_reg_valid_t tf_out_flags;
1082 ide_reg_valid_t tf_in_flags;
1083 int data_phase; 962 int data_phase;
1084 int command_type;
1085 ide_pre_handler_t *prehandler;
1086 ide_handler_t *handler;
1087 struct request *rq; /* copy of request */ 963 struct request *rq; /* copy of request */
1088 void *special; /* valid_t generally */ 964 void *special; /* valid_t generally */
1089} ide_task_t; 965} ide_task_t;
1090 966
1091extern u32 ide_read_24(ide_drive_t *); 967void ide_tf_load(ide_drive_t *, ide_task_t *);
968void ide_tf_read(ide_drive_t *, ide_task_t *);
1092 969
1093extern void SELECT_DRIVE(ide_drive_t *); 970extern void SELECT_DRIVE(ide_drive_t *);
1094extern void SELECT_INTERRUPT(ide_drive_t *);
1095extern void SELECT_MASK(ide_drive_t *, int); 971extern void SELECT_MASK(ide_drive_t *, int);
1096extern void QUIRK_LIST(ide_drive_t *);
1097 972
1098extern int drive_is_ready(ide_drive_t *); 973extern int drive_is_ready(ide_drive_t *);
1099 974
1100/* 975void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8);
1101 * taskfile io for disks for now...and builds request from ide_ioctl
1102 */
1103extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
1104 976
1105/* 977ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);
1106 * Special Flagged Register Validation Caller
1107 */
1108extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);
1109 978
1110extern ide_startstop_t set_multmode_intr(ide_drive_t *); 979void task_end_request(ide_drive_t *, struct request *, u8);
1111extern ide_startstop_t set_geometry_intr(ide_drive_t *);
1112extern ide_startstop_t recal_intr(ide_drive_t *);
1113extern ide_startstop_t task_no_data_intr(ide_drive_t *);
1114extern ide_startstop_t task_in_intr(ide_drive_t *);
1115extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);
1116 980
1117extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *); 981int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16);
982int ide_no_data_taskfile(ide_drive_t *, ide_task_t *);
1118 983
1119int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); 984int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
1120int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); 985int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);
@@ -1123,10 +988,8 @@ int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);
1123extern int system_bus_clock(void); 988extern int system_bus_clock(void);
1124 989
1125extern int ide_driveid_update(ide_drive_t *); 990extern int ide_driveid_update(ide_drive_t *);
1126extern int ide_ata66_check(ide_drive_t *, ide_task_t *);
1127extern int ide_config_drive_speed(ide_drive_t *, u8); 991extern int ide_config_drive_speed(ide_drive_t *, u8);
1128extern u8 eighty_ninty_three (ide_drive_t *); 992extern u8 eighty_ninty_three (ide_drive_t *);
1129extern int set_transfer(ide_drive_t *, ide_task_t *);
1130extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *); 993extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *);
1131 994
1132extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); 995extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout);
@@ -1140,10 +1003,8 @@ extern void do_ide_request(struct request_queue *);
1140 1003
1141void ide_init_disk(struct gendisk *, ide_drive_t *); 1004void ide_init_disk(struct gendisk *, ide_drive_t *);
1142 1005
1143extern int ideprobe_init(void);
1144
1145#ifdef CONFIG_IDEPCI_PCIBUS_ORDER 1006#ifdef CONFIG_IDEPCI_PCIBUS_ORDER
1146extern void ide_scan_pcibus(int scan_direction) __init; 1007extern int ide_scan_direction;
1147extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name); 1008extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name);
1148#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME) 1009#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME)
1149#else 1010#else
@@ -1153,6 +1014,13 @@ extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *o
1153void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *); 1014void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *);
1154void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1015void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);
1155 1016
1017#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1018void ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *);
1019#else
1020static inline void ide_hwif_setup_dma(ide_hwif_t *hwif,
1021 const struct ide_port_info *d) { }
1022#endif
1023
1156extern void default_hwif_iops(ide_hwif_t *); 1024extern void default_hwif_iops(ide_hwif_t *);
1157extern void default_hwif_mmiops(ide_hwif_t *); 1025extern void default_hwif_mmiops(ide_hwif_t *);
1158extern void default_hwif_transport(ide_hwif_t *); 1026extern void default_hwif_transport(ide_hwif_t *);
@@ -1189,7 +1057,7 @@ enum {
1189 IDE_HFLAG_NO_SET_MODE = (1 << 9), 1057 IDE_HFLAG_NO_SET_MODE = (1 << 9),
1190 /* trust BIOS for programming chipset/device for DMA */ 1058 /* trust BIOS for programming chipset/device for DMA */
1191 IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10), 1059 IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10),
1192 /* host uses VDMA */ 1060 /* host uses VDMA (tied with IDE_HFLAG_CS5520 for now) */
1193 IDE_HFLAG_VDMA = (1 << 11), 1061 IDE_HFLAG_VDMA = (1 << 11),
1194 /* ATAPI DMA is unsupported */ 1062 /* ATAPI DMA is unsupported */
1195 IDE_HFLAG_NO_ATAPI_DMA = (1 << 12), 1063 IDE_HFLAG_NO_ATAPI_DMA = (1 << 12),
@@ -1199,8 +1067,10 @@ enum {
1199 IDE_HFLAG_NO_DMA = (1 << 14), 1067 IDE_HFLAG_NO_DMA = (1 << 14),
1200 /* check if host is PCI IDE device before allowing DMA */ 1068 /* check if host is PCI IDE device before allowing DMA */
1201 IDE_HFLAG_NO_AUTODMA = (1 << 15), 1069 IDE_HFLAG_NO_AUTODMA = (1 << 15),
1070 /* don't autotune PIO */
1071 IDE_HFLAG_NO_AUTOTUNE = (1 << 16),
1202 /* host is CS5510/CS5520 */ 1072 /* host is CS5510/CS5520 */
1203 IDE_HFLAG_CS5520 = (1 << 16), 1073 IDE_HFLAG_CS5520 = IDE_HFLAG_VDMA,
1204 /* no LBA48 */ 1074 /* no LBA48 */
1205 IDE_HFLAG_NO_LBA48 = (1 << 17), 1075 IDE_HFLAG_NO_LBA48 = (1 << 17),
1206 /* no LBA48 DMA */ 1076 /* no LBA48 DMA */
@@ -1219,6 +1089,17 @@ enum {
1219 IDE_HFLAG_IO_32BIT = (1 << 24), 1089 IDE_HFLAG_IO_32BIT = (1 << 24),
1220 /* unmask IRQs */ 1090 /* unmask IRQs */
1221 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1091 IDE_HFLAG_UNMASK_IRQS = (1 << 25),
1092 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26),
1093 /* host is CY82C693 */
1094 IDE_HFLAG_CY82C693 = (1 << 27),
1095 /* force host out of "simplex" mode */
1096 IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28),
1097 /* DSC overlap is unsupported */
1098 IDE_HFLAG_NO_DSC = (1 << 29),
1099 /* never use 32-bit I/O ops */
1100 IDE_HFLAG_NO_IO_32BIT = (1 << 30),
1101 /* never unmask IRQs */
1102 IDE_HFLAG_NO_UNMASK_IRQS = (1 << 31),
1222}; 1103};
1223 1104
1224#ifdef CONFIG_BLK_DEV_OFFBOARD 1105#ifdef CONFIG_BLK_DEV_OFFBOARD
@@ -1233,10 +1114,9 @@ struct ide_port_info {
1233 void (*init_iops)(ide_hwif_t *); 1114 void (*init_iops)(ide_hwif_t *);
1234 void (*init_hwif)(ide_hwif_t *); 1115 void (*init_hwif)(ide_hwif_t *);
1235 void (*init_dma)(ide_hwif_t *, unsigned long); 1116 void (*init_dma)(ide_hwif_t *, unsigned long);
1236 void (*fixup)(ide_hwif_t *);
1237 ide_pci_enablebit_t enablebits[2]; 1117 ide_pci_enablebit_t enablebits[2];
1238 hwif_chipset_t chipset; 1118 hwif_chipset_t chipset;
1239 unsigned int extra; 1119 u8 extra;
1240 u32 host_flags; 1120 u32 host_flags;
1241 u8 pio_mask; 1121 u8 pio_mask;
1242 u8 swdma_mask; 1122 u8 swdma_mask;
@@ -1262,6 +1142,7 @@ int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *);
1262 1142
1263#ifdef CONFIG_BLK_DEV_IDEDMA 1143#ifdef CONFIG_BLK_DEV_IDEDMA
1264int __ide_dma_bad_drive(ide_drive_t *); 1144int __ide_dma_bad_drive(ide_drive_t *);
1145int ide_id_dma_bug(ide_drive_t *);
1265 1146
1266u8 ide_find_dma_mode(ide_drive_t *, u8); 1147u8 ide_find_dma_mode(ide_drive_t *, u8);
1267 1148
@@ -1270,22 +1151,22 @@ static inline u8 ide_max_dma_mode(ide_drive_t *drive)
1270 return ide_find_dma_mode(drive, XFER_UDMA_6); 1151 return ide_find_dma_mode(drive, XFER_UDMA_6);
1271} 1152}
1272 1153
1154void ide_dma_off_quietly(ide_drive_t *);
1273void ide_dma_off(ide_drive_t *); 1155void ide_dma_off(ide_drive_t *);
1274void ide_dma_verbose(ide_drive_t *); 1156void ide_dma_on(ide_drive_t *);
1275int ide_set_dma(ide_drive_t *); 1157int ide_set_dma(ide_drive_t *);
1158void ide_check_dma_crc(ide_drive_t *);
1276ide_startstop_t ide_dma_intr(ide_drive_t *); 1159ide_startstop_t ide_dma_intr(ide_drive_t *);
1277 1160
1161int ide_build_sglist(ide_drive_t *, struct request *);
1162void ide_destroy_dmatable(ide_drive_t *);
1163
1278#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1164#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
1279extern int ide_build_sglist(ide_drive_t *, struct request *);
1280extern int ide_build_dmatable(ide_drive_t *, struct request *); 1165extern int ide_build_dmatable(ide_drive_t *, struct request *);
1281extern void ide_destroy_dmatable(ide_drive_t *);
1282extern int ide_release_dma(ide_hwif_t *); 1166extern int ide_release_dma(ide_hwif_t *);
1283extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int); 1167extern void ide_setup_dma(ide_hwif_t *, unsigned long);
1284 1168
1285void ide_dma_host_off(ide_drive_t *); 1169void ide_dma_host_set(ide_drive_t *, int);
1286void ide_dma_off_quietly(ide_drive_t *);
1287void ide_dma_host_on(ide_drive_t *);
1288extern int __ide_dma_on(ide_drive_t *);
1289extern int ide_dma_setup(ide_drive_t *); 1170extern int ide_dma_setup(ide_drive_t *);
1290extern void ide_dma_start(ide_drive_t *); 1171extern void ide_dma_start(ide_drive_t *);
1291extern int __ide_dma_end(ide_drive_t *); 1172extern int __ide_dma_end(ide_drive_t *);
@@ -1294,11 +1175,15 @@ extern void ide_dma_timeout(ide_drive_t *);
1294#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ 1175#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */
1295 1176
1296#else 1177#else
1178static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; }
1297static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; } 1179static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; }
1298static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; } 1180static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; }
1181static inline void ide_dma_off_quietly(ide_drive_t *drive) { ; }
1299static inline void ide_dma_off(ide_drive_t *drive) { ; } 1182static inline void ide_dma_off(ide_drive_t *drive) { ; }
1183static inline void ide_dma_on(ide_drive_t *drive) { ; }
1300static inline void ide_dma_verbose(ide_drive_t *drive) { ; } 1184static inline void ide_dma_verbose(ide_drive_t *drive) { ; }
1301static inline int ide_set_dma(ide_drive_t *drive) { return 1; } 1185static inline int ide_set_dma(ide_drive_t *drive) { return 1; }
1186static inline void ide_check_dma_crc(ide_drive_t *drive) { ; }
1302#endif /* CONFIG_BLK_DEV_IDEDMA */ 1187#endif /* CONFIG_BLK_DEV_IDEDMA */
1303 1188
1304#ifndef CONFIG_BLK_DEV_IDEDMA_PCI 1189#ifndef CONFIG_BLK_DEV_IDEDMA_PCI
@@ -1310,25 +1195,29 @@ extern int ide_acpi_exec_tfs(ide_drive_t *drive);
1310extern void ide_acpi_get_timing(ide_hwif_t *hwif); 1195extern void ide_acpi_get_timing(ide_hwif_t *hwif);
1311extern void ide_acpi_push_timing(ide_hwif_t *hwif); 1196extern void ide_acpi_push_timing(ide_hwif_t *hwif);
1312extern void ide_acpi_init(ide_hwif_t *hwif); 1197extern void ide_acpi_init(ide_hwif_t *hwif);
1198void ide_acpi_port_init_devices(ide_hwif_t *);
1313extern void ide_acpi_set_state(ide_hwif_t *hwif, int on); 1199extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);
1314#else 1200#else
1315static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; } 1201static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
1316static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; } 1202static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
1317static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; } 1203static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
1318static inline void ide_acpi_init(ide_hwif_t *hwif) { ; } 1204static inline void ide_acpi_init(ide_hwif_t *hwif) { ; }
1205static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; }
1319static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} 1206static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
1320#endif 1207#endif
1321 1208
1209void ide_remove_port_from_hwgroup(ide_hwif_t *);
1322extern int ide_hwif_request_regions(ide_hwif_t *hwif); 1210extern int ide_hwif_request_regions(ide_hwif_t *hwif);
1323extern void ide_hwif_release_regions(ide_hwif_t* hwif); 1211extern void ide_hwif_release_regions(ide_hwif_t* hwif);
1324extern void ide_unregister (unsigned int index); 1212void ide_unregister(unsigned int, int, int);
1325 1213
1326void ide_register_region(struct gendisk *); 1214void ide_register_region(struct gendisk *);
1327void ide_unregister_region(struct gendisk *); 1215void ide_unregister_region(struct gendisk *);
1328 1216
1329void ide_undecoded_slave(ide_hwif_t *); 1217void ide_undecoded_slave(ide_drive_t *);
1330 1218
1331int ide_device_add(u8 idx[4]); 1219int ide_device_add_all(u8 *idx, const struct ide_port_info *);
1220int ide_device_add(u8 idx[4], const struct ide_port_info *);
1332 1221
1333static inline void *ide_get_hwifdata (ide_hwif_t * hwif) 1222static inline void *ide_get_hwifdata (ide_hwif_t * hwif)
1334{ 1223{
@@ -1340,8 +1229,7 @@ static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data)
1340 hwif->hwif_data = data; 1229 hwif->hwif_data = data;
1341} 1230}
1342 1231
1343/* ide-lib.c */ 1232const char *ide_xfer_verbose(u8 mode);
1344extern char *ide_xfer_verbose(u8 xfer_rate);
1345extern void ide_toggle_bounce(ide_drive_t *drive, int on); 1233extern void ide_toggle_bounce(ide_drive_t *drive, int on);
1346extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); 1234extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);
1347 1235
@@ -1363,6 +1251,7 @@ static inline int ide_dev_is_sata(struct hd_driveid *id)
1363 return 0; 1251 return 0;
1364} 1252}
1365 1253
1254u64 ide_get_lba_addr(struct ide_taskfile *, int);
1366u8 ide_dump_status(ide_drive_t *, const char *, u8); 1255u8 ide_dump_status(ide_drive_t *, const char *, u8);
1367 1256
1368typedef struct ide_pio_timings_s { 1257typedef struct ide_pio_timings_s {
@@ -1412,9 +1301,14 @@ extern struct bus_type ide_bus_type;
1412#define ide_id_has_flush_cache_ext(id) \ 1301#define ide_id_has_flush_cache_ext(id) \
1413 (((id)->cfs_enable_2 & 0x2400) == 0x2400) 1302 (((id)->cfs_enable_2 & 0x2400) == 0x2400)
1414 1303
1304static inline void ide_dump_identify(u8 *id)
1305{
1306 print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0);
1307}
1308
1415static inline int hwif_to_node(ide_hwif_t *hwif) 1309static inline int hwif_to_node(ide_hwif_t *hwif)
1416{ 1310{
1417 struct pci_dev *dev = hwif->pci_dev; 1311 struct pci_dev *dev = to_pci_dev(hwif->dev);
1418 return dev ? pcibus_to_node(dev->bus) : -1; 1312 return dev ? pcibus_to_node(dev->bus) : -1;
1419} 1313}
1420 1314
@@ -1425,4 +1319,9 @@ static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive)
1425 return &hwif->drives[(drive->dn ^ 1) & 1]; 1319 return &hwif->drives[(drive->dn ^ 1) & 1];
1426} 1320}
1427 1321
1322static inline void ide_set_irq(ide_drive_t *drive, int on)
1323{
1324 drive->hwif->OUTB(drive->ctl | (on ? 0 : 2), IDE_CONTROL_REG);
1325}
1326
1428#endif /* _IDE_H */ 1327#endif /* _IDE_H */
diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h
index 30621c27159f..5de6d911cdf7 100644
--- a/include/linux/ieee80211.h
+++ b/include/linux/ieee80211.h
@@ -54,6 +54,8 @@
54#define IEEE80211_STYPE_ACTION 0x00D0 54#define IEEE80211_STYPE_ACTION 0x00D0
55 55
56/* control */ 56/* control */
57#define IEEE80211_STYPE_BACK_REQ 0x0080
58#define IEEE80211_STYPE_BACK 0x0090
57#define IEEE80211_STYPE_PSPOLL 0x00A0 59#define IEEE80211_STYPE_PSPOLL 0x00A0
58#define IEEE80211_STYPE_RTS 0x00B0 60#define IEEE80211_STYPE_RTS 0x00B0
59#define IEEE80211_STYPE_CTS 0x00C0 61#define IEEE80211_STYPE_CTS 0x00C0
@@ -81,18 +83,18 @@
81 83
82 84
83/* miscellaneous IEEE 802.11 constants */ 85/* miscellaneous IEEE 802.11 constants */
84#define IEEE80211_MAX_FRAG_THRESHOLD 2346 86#define IEEE80211_MAX_FRAG_THRESHOLD 2352
85#define IEEE80211_MAX_RTS_THRESHOLD 2347 87#define IEEE80211_MAX_RTS_THRESHOLD 2353
86#define IEEE80211_MAX_AID 2007 88#define IEEE80211_MAX_AID 2007
87#define IEEE80211_MAX_TIM_LEN 251 89#define IEEE80211_MAX_TIM_LEN 251
88#define IEEE80211_MAX_DATA_LEN 2304
89/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section 90/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section
90 6.2.1.1.2. 91 6.2.1.1.2.
91 92
92 The figure in section 7.1.2 suggests a body size of up to 2312 93 802.11e clarifies the figure in section 7.1.2. The frame body is
93 bytes is allowed, which is a bit confusing, I suspect this 94 up to 2304 octets long (maximum MSDU size) plus any crypt overhead. */
94 represents the 2304 bytes of real data, plus a possible 8 bytes of 95#define IEEE80211_MAX_DATA_LEN 2304
95 WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ 96/* 30 byte 4 addr hdr, 2 byte QoS, 2304 byte MSDU, 12 byte crypt, 4 byte FCS */
97#define IEEE80211_MAX_FRAME_LEN 2352
96 98
97#define IEEE80211_MAX_SSID_LEN 32 99#define IEEE80211_MAX_SSID_LEN 32
98 100
@@ -185,6 +187,25 @@ struct ieee80211_mgmt {
185 u8 new_chan; 187 u8 new_chan;
186 u8 switch_count; 188 u8 switch_count;
187 } __attribute__((packed)) chan_switch; 189 } __attribute__((packed)) chan_switch;
190 struct{
191 u8 action_code;
192 u8 dialog_token;
193 __le16 capab;
194 __le16 timeout;
195 __le16 start_seq_num;
196 } __attribute__((packed)) addba_req;
197 struct{
198 u8 action_code;
199 u8 dialog_token;
200 __le16 status;
201 __le16 capab;
202 __le16 timeout;
203 } __attribute__((packed)) addba_resp;
204 struct{
205 u8 action_code;
206 __le16 params;
207 __le16 reason_code;
208 } __attribute__((packed)) delba;
188 } u; 209 } u;
189 } __attribute__ ((packed)) action; 210 } __attribute__ ((packed)) action;
190 } u; 211 } u;
@@ -205,6 +226,66 @@ struct ieee80211_cts {
205 u8 ra[6]; 226 u8 ra[6];
206} __attribute__ ((packed)); 227} __attribute__ ((packed));
207 228
229/**
230 * struct ieee80211_bar - HT Block Ack Request
231 *
232 * This structure refers to "HT BlockAckReq" as
233 * described in 802.11n draft section 7.2.1.7.1
234 */
235struct ieee80211_bar {
236 __le16 frame_control;
237 __le16 duration;
238 __u8 ra[6];
239 __u8 ta[6];
240 __le16 control;
241 __le16 start_seq_num;
242} __attribute__((packed));
243
244/**
245 * struct ieee80211_ht_cap - HT capabilities
246 *
247 * This structure refers to "HT capabilities element" as
248 * described in 802.11n draft section 7.3.2.52
249 */
250struct ieee80211_ht_cap {
251 __le16 cap_info;
252 u8 ampdu_params_info;
253 u8 supp_mcs_set[16];
254 __le16 extended_ht_cap_info;
255 __le32 tx_BF_cap_info;
256 u8 antenna_selection_info;
257} __attribute__ ((packed));
258
259/**
260 * struct ieee80211_ht_cap - HT additional information
261 *
262 * This structure refers to "HT information element" as
263 * described in 802.11n draft section 7.3.2.53
264 */
265struct ieee80211_ht_addt_info {
266 u8 control_chan;
267 u8 ht_param;
268 __le16 operation_mode;
269 __le16 stbc_param;
270 u8 basic_set[16];
271} __attribute__ ((packed));
272
273/* 802.11n HT capabilities masks */
274#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002
275#define IEEE80211_HT_CAP_MIMO_PS 0x000C
276#define IEEE80211_HT_CAP_GRN_FLD 0x0010
277#define IEEE80211_HT_CAP_SGI_20 0x0020
278#define IEEE80211_HT_CAP_SGI_40 0x0040
279#define IEEE80211_HT_CAP_DELAY_BA 0x0400
280#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800
281#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03
282#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C
283/* 802.11n HT IE masks */
284#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03
285#define IEEE80211_HT_IE_CHA_WIDTH 0x04
286#define IEEE80211_HT_IE_HT_PROTECTION 0x0003
287#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004
288#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010
208 289
209/* Authentication algorithms */ 290/* Authentication algorithms */
210#define WLAN_AUTH_OPEN 0 291#define WLAN_AUTH_OPEN 0
@@ -271,6 +352,18 @@ enum ieee80211_statuscode {
271 WLAN_STATUS_UNSUPP_RSN_VERSION = 44, 352 WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
272 WLAN_STATUS_INVALID_RSN_IE_CAP = 45, 353 WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
273 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, 354 WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
355 /* 802.11e */
356 WLAN_STATUS_UNSPECIFIED_QOS = 32,
357 WLAN_STATUS_ASSOC_DENIED_NOBANDWIDTH = 33,
358 WLAN_STATUS_ASSOC_DENIED_LOWACK = 34,
359 WLAN_STATUS_ASSOC_DENIED_UNSUPP_QOS = 35,
360 WLAN_STATUS_REQUEST_DECLINED = 37,
361 WLAN_STATUS_INVALID_QOS_PARAM = 38,
362 WLAN_STATUS_CHANGE_TSPEC = 39,
363 WLAN_STATUS_WAIT_TS_DELAY = 47,
364 WLAN_STATUS_NO_DIRECT_LINK = 48,
365 WLAN_STATUS_STA_NOT_PRESENT = 49,
366 WLAN_STATUS_STA_NOT_QSTA = 50,
274}; 367};
275 368
276 369
@@ -301,6 +394,16 @@ enum ieee80211_reasoncode {
301 WLAN_REASON_INVALID_RSN_IE_CAP = 22, 394 WLAN_REASON_INVALID_RSN_IE_CAP = 22,
302 WLAN_REASON_IEEE8021X_FAILED = 23, 395 WLAN_REASON_IEEE8021X_FAILED = 23,
303 WLAN_REASON_CIPHER_SUITE_REJECTED = 24, 396 WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
397 /* 802.11e */
398 WLAN_REASON_DISASSOC_UNSPECIFIED_QOS = 32,
399 WLAN_REASON_DISASSOC_QAP_NO_BANDWIDTH = 33,
400 WLAN_REASON_DISASSOC_LOW_ACK = 34,
401 WLAN_REASON_DISASSOC_QAP_EXCEED_TXOP = 35,
402 WLAN_REASON_QSTA_LEAVE_QBSS = 36,
403 WLAN_REASON_QSTA_NOT_USE = 37,
404 WLAN_REASON_QSTA_REQUIRE_SETUP = 38,
405 WLAN_REASON_QSTA_TIMEOUT = 39,
406 WLAN_REASON_QSTA_CIPHER_NOT_SUPP = 45,
304}; 407};
305 408
306 409
@@ -319,6 +422,15 @@ enum ieee80211_eid {
319 WLAN_EID_HP_PARAMS = 8, 422 WLAN_EID_HP_PARAMS = 8,
320 WLAN_EID_HP_TABLE = 9, 423 WLAN_EID_HP_TABLE = 9,
321 WLAN_EID_REQUEST = 10, 424 WLAN_EID_REQUEST = 10,
425 /* 802.11e */
426 WLAN_EID_QBSS_LOAD = 11,
427 WLAN_EID_EDCA_PARAM_SET = 12,
428 WLAN_EID_TSPEC = 13,
429 WLAN_EID_TCLAS = 14,
430 WLAN_EID_SCHEDULE = 15,
431 WLAN_EID_TS_DELAY = 43,
432 WLAN_EID_TCLAS_PROCESSING = 44,
433 WLAN_EID_QOS_CAPA = 46,
322 /* 802.11h */ 434 /* 802.11h */
323 WLAN_EID_PWR_CONSTRAINT = 32, 435 WLAN_EID_PWR_CONSTRAINT = 32,
324 WLAN_EID_PWR_CAPABILITY = 33, 436 WLAN_EID_PWR_CAPABILITY = 33,
@@ -333,6 +445,9 @@ enum ieee80211_eid {
333 /* 802.11g */ 445 /* 802.11g */
334 WLAN_EID_ERP_INFO = 42, 446 WLAN_EID_ERP_INFO = 42,
335 WLAN_EID_EXT_SUPP_RATES = 50, 447 WLAN_EID_EXT_SUPP_RATES = 50,
448 /* 802.11n */
449 WLAN_EID_HT_CAPABILITY = 45,
450 WLAN_EID_HT_EXTRA_INFO = 61,
336 /* 802.11i */ 451 /* 802.11i */
337 WLAN_EID_RSN = 48, 452 WLAN_EID_RSN = 48,
338 WLAN_EID_WPA = 221, 453 WLAN_EID_WPA = 221,
@@ -341,6 +456,32 @@ enum ieee80211_eid {
341 WLAN_EID_QOS_PARAMETER = 222 456 WLAN_EID_QOS_PARAMETER = 222
342}; 457};
343 458
459/* Action category code */
460enum ieee80211_category {
461 WLAN_CATEGORY_SPECTRUM_MGMT = 0,
462 WLAN_CATEGORY_QOS = 1,
463 WLAN_CATEGORY_DLS = 2,
464 WLAN_CATEGORY_BACK = 3,
465 WLAN_CATEGORY_WMM = 17,
466};
467
468/* BACK action code */
469enum ieee80211_back_actioncode {
470 WLAN_ACTION_ADDBA_REQ = 0,
471 WLAN_ACTION_ADDBA_RESP = 1,
472 WLAN_ACTION_DELBA = 2,
473};
474
475/* BACK (block-ack) parties */
476enum ieee80211_back_parties {
477 WLAN_BACK_RECIPIENT = 0,
478 WLAN_BACK_INITIATOR = 1,
479 WLAN_BACK_TIMER = 2,
480};
481
482/* A-MSDU 802.11n */
483#define IEEE80211_QOS_CONTROL_A_MSDU_PRESENT 0x0080
484
344/* cipher suite selectors */ 485/* cipher suite selectors */
345#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00 486#define WLAN_CIPHER_SUITE_USE_GROUP 0x000FAC00
346#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01 487#define WLAN_CIPHER_SUITE_WEP40 0x000FAC01
diff --git a/include/linux/if.h b/include/linux/if.h
index 32bf419351f1..5c9d1fa93fef 100644
--- a/include/linux/if.h
+++ b/include/linux/if.h
@@ -50,7 +50,9 @@
50#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ 50#define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
51#define IFF_DORMANT 0x20000 /* driver signals dormant */ 51#define IFF_DORMANT 0x20000 /* driver signals dormant */
52 52
53#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|\ 53#define IFF_ECHO 0x40000 /* echo sent packets */
54
55#define IFF_VOLATILE (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_ECHO|\
54 IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT) 56 IFF_MASTER|IFF_SLAVE|IFF_RUNNING|IFF_LOWER_UP|IFF_DORMANT)
55 57
56/* Private (from user) interface flags (netdevice->priv_flags). */ 58/* Private (from user) interface flags (netdevice->priv_flags). */
@@ -61,6 +63,7 @@
61#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */ 63#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */
62#define IFF_BONDING 0x20 /* bonding master or slave */ 64#define IFF_BONDING 0x20 /* bonding master or slave */
63#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */ 65#define IFF_SLAVE_NEEDARP 0x40 /* need ARPs for validation */
66#define IFF_ISATAP 0x80 /* ISATAP interface (RFC4214) */
64 67
65#define IF_GET_IFACE 0x0001 /* for querying only */ 68#define IF_GET_IFACE 0x0001 /* for querying only */
66#define IF_GET_PROTO 0x0002 69#define IF_GET_PROTO 0x0002
diff --git a/include/linux/if_addrlabel.h b/include/linux/if_addrlabel.h
new file mode 100644
index 000000000000..9fe79c95dd28
--- /dev/null
+++ b/include/linux/if_addrlabel.h
@@ -0,0 +1,32 @@
1/*
2 * if_addrlabel.h - netlink interface for address labels
3 *
4 * Copyright (C)2007 USAGI/WIDE Project, All Rights Reserved.
5 *
6 * Authors:
7 * YOSHIFUJI Hideaki @ USAGI/WIDE <yoshfuji@linux-ipv6.org>
8 */
9
10#ifndef __LINUX_IF_ADDRLABEL_H
11#define __LINUX_IF_ADDRLABEL_H
12
13struct ifaddrlblmsg
14{
15 __u8 ifal_family; /* Address family */
16 __u8 __ifal_reserved; /* Reserved */
17 __u8 ifal_prefixlen; /* Prefix length */
18 __u8 ifal_flags; /* Flags */
19 __u32 ifal_index; /* Link index */
20 __u32 ifal_seq; /* sequence number */
21};
22
23enum
24{
25 IFAL_ADDRESS = 1,
26 IFAL_LABEL = 2,
27 __IFAL_MAX
28};
29
30#define IFAL_MAX (__IFAL_MAX - 1)
31
32#endif
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index ed7b93c3083a..296e8e86e91d 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -52,6 +52,7 @@
52#define ARPHRD_ROSE 270 52#define ARPHRD_ROSE 270
53#define ARPHRD_X25 271 /* CCITT X.25 */ 53#define ARPHRD_X25 271 /* CCITT X.25 */
54#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */ 54#define ARPHRD_HWX25 272 /* Boards with X.25 in firmware */
55#define ARPHRD_CAN 280 /* Controller Area Network */
55#define ARPHRD_PPP 512 56#define ARPHRD_PPP 512
56#define ARPHRD_CISCO 513 /* Cisco HDLC */ 57#define ARPHRD_CISCO 513 /* Cisco HDLC */
57#define ARPHRD_HDLC ARPHRD_CISCO 58#define ARPHRD_HDLC ARPHRD_CISCO
diff --git a/include/linux/if_bonding.h b/include/linux/if_bonding.h
index 84598fa2e9de..65c2d247068b 100644
--- a/include/linux/if_bonding.h
+++ b/include/linux/if_bonding.h
@@ -85,7 +85,8 @@
85 85
86/* hashing types */ 86/* hashing types */
87#define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */ 87#define BOND_XMIT_POLICY_LAYER2 0 /* layer 2 (MAC only), default */
88#define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ MAC) */ 88#define BOND_XMIT_POLICY_LAYER34 1 /* layer 3+4 (IP ^ (TCP || UDP)) */
89#define BOND_XMIT_POLICY_LAYER23 2 /* layer 2+3 (IP ^ MAC) */
89 90
90typedef struct ifbond { 91typedef struct ifbond {
91 __s32 bond_mode; 92 __s32 bond_mode;
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 5f9297793661..e157c1399b61 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -90,6 +90,7 @@
90#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ 90#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
91#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ 91#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
92#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ 92#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
93#define ETH_P_CAN 0x000C /* Controller Area Network */
93#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ 94#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
94#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ 95#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */
95#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ 96#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
@@ -123,12 +124,15 @@ int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
123extern struct ctl_table ether_table[]; 124extern struct ctl_table ether_table[];
124#endif 125#endif
125 126
127extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
128
126/* 129/*
127 * Display a 6 byte device address (MAC) in a readable format. 130 * Display a 6 byte device address (MAC) in a readable format.
128 */ 131 */
132extern char *print_mac(char *buf, const unsigned char *addr);
129#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" 133#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
130extern char *print_mac(char *buf, const u8 *addr); 134#define MAC_BUF_SIZE 18
131#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused 135#define DECLARE_MAC_BUF(var) char var[MAC_BUF_SIZE] __maybe_unused
132 136
133#endif 137#endif
134 138
diff --git a/include/linux/if_frad.h b/include/linux/if_frad.h
index f272a80caa3e..5c34240de746 100644
--- a/include/linux/if_frad.h
+++ b/include/linux/if_frad.h
@@ -137,7 +137,7 @@ struct frhdr
137 137
138 unsigned char NLPID; 138 unsigned char NLPID;
139 unsigned char OUI[3]; 139 unsigned char OUI[3];
140 unsigned short PID; 140 __be16 PID;
141 141
142#define IP_NLPID pad 142#define IP_NLPID pad
143} __attribute__((packed)); 143} __attribute__((packed));
diff --git a/include/linux/if_shaper.h b/include/linux/if_shaper.h
deleted file mode 100644
index 3b1b7ba19825..000000000000
--- a/include/linux/if_shaper.h
+++ /dev/null
@@ -1,51 +0,0 @@
1#ifndef __LINUX_SHAPER_H
2#define __LINUX_SHAPER_H
3
4#ifdef __KERNEL__
5
6#define SHAPER_QLEN 10
7/*
8 * This is a bit speed dependent (read it shouldn't be a constant!)
9 *
10 * 5 is about right for 28.8 upwards. Below that double for every
11 * halving of speed or so. - ie about 20 for 9600 baud.
12 */
13#define SHAPER_LATENCY (5*HZ)
14#define SHAPER_MAXSLIP 2
15#define SHAPER_BURST (HZ/50) /* Good for >128K then */
16
17struct shaper
18{
19 struct sk_buff_head sendq;
20 __u32 bytespertick;
21 __u32 bitspersec;
22 __u32 shapelatency;
23 __u32 shapeclock;
24 unsigned long recovery; /* Time we can next clock a packet out on
25 an empty queue */
26 spinlock_t lock;
27 struct net_device *dev;
28 struct net_device_stats* (*get_stats)(struct net_device *dev);
29 struct timer_list timer;
30};
31
32#endif
33
34#define SHAPER_SET_DEV 0x0001
35#define SHAPER_SET_SPEED 0x0002
36#define SHAPER_GET_DEV 0x0003
37#define SHAPER_GET_SPEED 0x0004
38
39struct shaperconf
40{
41 __u16 ss_cmd;
42 union
43 {
44 char ssu_name[14];
45 __u32 ssu_speed;
46 } ss_u;
47#define ss_speed ss_u.ssu_speed
48#define ss_name ss_u.ssu_name
49};
50
51#endif
diff --git a/include/linux/if_tr.h b/include/linux/if_tr.h
index 046e9d95ba9a..5bcec8b2c5e2 100644
--- a/include/linux/if_tr.h
+++ b/include/linux/if_tr.h
@@ -49,9 +49,6 @@ static inline struct trh_hdr *tr_hdr(const struct sk_buff *skb)
49{ 49{
50 return (struct trh_hdr *)skb_mac_header(skb); 50 return (struct trh_hdr *)skb_mac_header(skb);
51} 51}
52#ifdef CONFIG_SYSCTL
53extern struct ctl_table tr_table[];
54#endif
55#endif 52#endif
56 53
57/* This is an Token-Ring LLC structure */ 54/* This is an Token-Ring LLC structure */
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
index 33e489d5bb33..72f1c5f47be3 100644
--- a/include/linux/if_tun.h
+++ b/include/linux/if_tun.h
@@ -21,6 +21,8 @@
21/* Uncomment to enable debugging */ 21/* Uncomment to enable debugging */
22/* #define TUN_DEBUG 1 */ 22/* #define TUN_DEBUG 1 */
23 23
24#include <linux/types.h>
25
24#ifdef __KERNEL__ 26#ifdef __KERNEL__
25 27
26#ifdef TUN_DEBUG 28#ifdef TUN_DEBUG
@@ -88,7 +90,7 @@ struct tun_struct {
88 90
89struct tun_pi { 91struct tun_pi {
90 unsigned short flags; 92 unsigned short flags;
91 unsigned short proto; 93 __be16 proto;
92}; 94};
93#define TUN_PKT_STRIP 0x0001 95#define TUN_PKT_STRIP 0x0001
94 96
diff --git a/include/linux/if_tunnel.h b/include/linux/if_tunnel.h
index 660b5010c2d9..228eb4eb3129 100644
--- a/include/linux/if_tunnel.h
+++ b/include/linux/if_tunnel.h
@@ -17,6 +17,9 @@
17#define GRE_FLAGS __constant_htons(0x00F8) 17#define GRE_FLAGS __constant_htons(0x00F8)
18#define GRE_VERSION __constant_htons(0x0007) 18#define GRE_VERSION __constant_htons(0x0007)
19 19
20/* i_flags values for SIT mode */
21#define SIT_ISATAP 0x0001
22
20struct ip_tunnel_parm 23struct ip_tunnel_parm
21{ 24{
22 char name[IFNAMSIZ]; 25 char name[IFNAMSIZ];
diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 976d4b1067d1..34f40efc7607 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -16,11 +16,6 @@
16#ifdef __KERNEL__ 16#ifdef __KERNEL__
17 17
18/* externally defined structs */ 18/* externally defined structs */
19struct vlan_group;
20struct net_device;
21struct packet_type;
22struct vlan_collection;
23struct vlan_dev_info;
24struct hlist_node; 19struct hlist_node;
25 20
26#include <linux/netdevice.h> 21#include <linux/netdevice.h>
@@ -39,12 +34,30 @@ struct hlist_node;
39#define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */ 34#define VLAN_ETH_DATA_LEN 1500 /* Max. octets in payload */
40#define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */ 35#define VLAN_ETH_FRAME_LEN 1518 /* Max. octets in frame sans FCS */
41 36
37/*
38 * struct vlan_hdr - vlan header
39 * @h_vlan_TCI: priority and VLAN ID
40 * @h_vlan_encapsulated_proto: packet type ID or len
41 */
42struct vlan_hdr {
43 __be16 h_vlan_TCI;
44 __be16 h_vlan_encapsulated_proto;
45};
46
47/**
48 * struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr)
49 * @h_dest: destination ethernet address
50 * @h_source: source ethernet address
51 * @h_vlan_proto: ethernet protocol (always 0x8100)
52 * @h_vlan_TCI: priority and VLAN ID
53 * @h_vlan_encapsulated_proto: packet type ID or len
54 */
42struct vlan_ethhdr { 55struct vlan_ethhdr {
43 unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ 56 unsigned char h_dest[ETH_ALEN];
44 unsigned char h_source[ETH_ALEN]; /* source ether addr */ 57 unsigned char h_source[ETH_ALEN];
45 __be16 h_vlan_proto; /* Should always be 0x8100 */ 58 __be16 h_vlan_proto;
46 __be16 h_vlan_TCI; /* Encapsulates priority and VLAN ID */ 59 __be16 h_vlan_TCI;
47 __be16 h_vlan_encapsulated_proto; /* packet type ID field (or len) */ 60 __be16 h_vlan_encapsulated_proto;
48}; 61};
49 62
50#include <linux/skbuff.h> 63#include <linux/skbuff.h>
@@ -54,18 +67,11 @@ static inline struct vlan_ethhdr *vlan_eth_hdr(const struct sk_buff *skb)
54 return (struct vlan_ethhdr *)skb_mac_header(skb); 67 return (struct vlan_ethhdr *)skb_mac_header(skb);
55} 68}
56 69
57struct vlan_hdr {
58 __be16 h_vlan_TCI; /* Encapsulates priority and VLAN ID */
59 __be16 h_vlan_encapsulated_proto; /* packet type ID field (or len) */
60};
61
62#define VLAN_VID_MASK 0xfff 70#define VLAN_VID_MASK 0xfff
63 71
64/* found in socket.c */ 72/* found in socket.c */
65extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *)); 73extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
66 74
67#define VLAN_NAME "vlan"
68
69/* if this changes, algorithm will have to be reworked because this 75/* if this changes, algorithm will have to be reworked because this
70 * depends on completely exhausting the VLAN identifier space. Thus 76 * depends on completely exhausting the VLAN identifier space. Thus
71 * it gives constant time look-up, but in many cases it wastes memory. 77 * it gives constant time look-up, but in many cases it wastes memory.
@@ -76,19 +82,22 @@ extern void vlan_ioctl_set(int (*hook)(struct net *, void __user *));
76 82
77struct vlan_group { 83struct vlan_group {
78 int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */ 84 int real_dev_ifindex; /* The ifindex of the ethernet(like) device the vlan is attached to. */
85 unsigned int nr_vlans;
79 struct hlist_node hlist; /* linked list */ 86 struct hlist_node hlist; /* linked list */
80 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS]; 87 struct net_device **vlan_devices_arrays[VLAN_GROUP_ARRAY_SPLIT_PARTS];
81 struct rcu_head rcu; 88 struct rcu_head rcu;
82}; 89};
83 90
84static inline struct net_device *vlan_group_get_device(struct vlan_group *vg, int vlan_id) 91static inline struct net_device *vlan_group_get_device(struct vlan_group *vg,
92 unsigned int vlan_id)
85{ 93{
86 struct net_device **array; 94 struct net_device **array;
87 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN]; 95 array = vg->vlan_devices_arrays[vlan_id / VLAN_GROUP_ARRAY_PART_LEN];
88 return array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN]; 96 return array[vlan_id % VLAN_GROUP_ARRAY_PART_LEN];
89} 97}
90 98
91static inline void vlan_group_set_device(struct vlan_group *vg, int vlan_id, 99static inline void vlan_group_set_device(struct vlan_group *vg,
100 unsigned int vlan_id,
92 struct net_device *dev) 101 struct net_device *dev)
93{ 102{
94 struct net_device **array; 103 struct net_device **array;
@@ -132,22 +141,18 @@ struct vlan_dev_info {
132 struct proc_dir_entry *dent; /* Holds the proc data */ 141 struct proc_dir_entry *dent; /* Holds the proc data */
133 unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */ 142 unsigned long cnt_inc_headroom_on_tx; /* How many times did we have to grow the skb on TX. */
134 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */ 143 unsigned long cnt_encap_on_xmit; /* How many times did we have to encapsulate the skb on TX. */
135 struct net_device_stats dev_stats; /* Device stats (rx-bytes, tx-pkts, etc...) */
136}; 144};
137 145
138#define VLAN_DEV_INFO(x) ((struct vlan_dev_info *)(x->priv)) 146static inline struct vlan_dev_info *vlan_dev_info(const struct net_device *dev)
139
140/* inline functions */
141
142static inline struct net_device_stats *vlan_dev_get_stats(struct net_device *dev)
143{ 147{
144 return &(VLAN_DEV_INFO(dev)->dev_stats); 148 return netdev_priv(dev);
145} 149}
146 150
151/* inline functions */
147static inline __u32 vlan_get_ingress_priority(struct net_device *dev, 152static inline __u32 vlan_get_ingress_priority(struct net_device *dev,
148 unsigned short vlan_tag) 153 unsigned short vlan_tag)
149{ 154{
150 struct vlan_dev_info *vip = VLAN_DEV_INFO(dev); 155 struct vlan_dev_info *vip = vlan_dev_info(dev);
151 156
152 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7]; 157 return vip->ingress_priority_map[(vlan_tag >> 13) & 0x7];
153} 158}
@@ -188,7 +193,7 @@ static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
188 193
189 skb->dev->last_rx = jiffies; 194 skb->dev->last_rx = jiffies;
190 195
191 stats = vlan_dev_get_stats(skb->dev); 196 stats = &skb->dev->stats;
192 stats->rx_packets++; 197 stats->rx_packets++;
193 stats->rx_bytes += skb->len; 198 stats->rx_bytes += skb->len;
194 199
@@ -266,12 +271,12 @@ static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short
266 memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN); 271 memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
267 272
268 /* first, the ethernet type */ 273 /* first, the ethernet type */
269 veth->h_vlan_proto = __constant_htons(ETH_P_8021Q); 274 veth->h_vlan_proto = htons(ETH_P_8021Q);
270 275
271 /* now, the tag */ 276 /* now, the tag */
272 veth->h_vlan_TCI = htons(tag); 277 veth->h_vlan_TCI = htons(tag);
273 278
274 skb->protocol = __constant_htons(ETH_P_8021Q); 279 skb->protocol = htons(ETH_P_8021Q);
275 skb->mac_header -= VLAN_HLEN; 280 skb->mac_header -= VLAN_HLEN;
276 skb->network_header -= VLAN_HLEN; 281 skb->network_header -= VLAN_HLEN;
277 282
@@ -326,7 +331,7 @@ static inline int __vlan_get_tag(struct sk_buff *skb, unsigned short *tag)
326{ 331{
327 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data; 332 struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb->data;
328 333
329 if (veth->h_vlan_proto != __constant_htons(ETH_P_8021Q)) { 334 if (veth->h_vlan_proto != htons(ETH_P_8021Q)) {
330 return -EINVAL; 335 return -EINVAL;
331 } 336 }
332 337
diff --git a/include/linux/in.h b/include/linux/in.h
index 3975cbf52f20..70c6df882694 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -246,13 +246,69 @@ struct sockaddr_in {
246#include <asm/byteorder.h> 246#include <asm/byteorder.h>
247 247
248#ifdef __KERNEL__ 248#ifdef __KERNEL__
249/* Some random defines to make it easier in the kernel.. */
250#define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000))
251#define MULTICAST(x) (((x) & htonl(0xf0000000)) == htonl(0xe0000000))
252#define BADCLASS(x) (((x) & htonl(0xf0000000)) == htonl(0xf0000000))
253#define ZERONET(x) (((x) & htonl(0xff000000)) == htonl(0x00000000))
254#define LOCAL_MCAST(x) (((x) & htonl(0xFFFFFF00)) == htonl(0xE0000000))
255 249
250static inline bool ipv4_is_loopback(__be32 addr)
251{
252 return (addr & htonl(0xff000000)) == htonl(0x7f000000);
253}
254
255static inline bool ipv4_is_multicast(__be32 addr)
256{
257 return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
258}
259
260static inline bool ipv4_is_local_multicast(__be32 addr)
261{
262 return (addr & htonl(0xffffff00)) == htonl(0xe0000000);
263}
264
265static inline bool ipv4_is_lbcast(__be32 addr)
266{
267 /* limited broadcast */
268 return addr == INADDR_BROADCAST;
269}
270
271static inline bool ipv4_is_zeronet(__be32 addr)
272{
273 return (addr & htonl(0xff000000)) == htonl(0x00000000);
274}
275
276/* Special-Use IPv4 Addresses (RFC3330) */
277
278static inline bool ipv4_is_private_10(__be32 addr)
279{
280 return (addr & htonl(0xff000000)) == htonl(0x0a000000);
281}
282
283static inline bool ipv4_is_private_172(__be32 addr)
284{
285 return (addr & htonl(0xfff00000)) == htonl(0xac100000);
286}
287
288static inline bool ipv4_is_private_192(__be32 addr)
289{
290 return (addr & htonl(0xffff0000)) == htonl(0xc0a80000);
291}
292
293static inline bool ipv4_is_linklocal_169(__be32 addr)
294{
295 return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000);
296}
297
298static inline bool ipv4_is_anycast_6to4(__be32 addr)
299{
300 return (addr & htonl(0xffffff00)) == htonl(0xc0586300);
301}
302
303static inline bool ipv4_is_test_192(__be32 addr)
304{
305 return (addr & htonl(0xffffff00)) == htonl(0xc0000200);
306}
307
308static inline bool ipv4_is_test_198(__be32 addr)
309{
310 return (addr & htonl(0xfffe0000)) == htonl(0xc6120000);
311}
256#endif 312#endif
257 313
258#endif /* _LINUX_IN_H */ 314#endif /* _LINUX_IN_H */
diff --git a/include/linux/inet_lro.h b/include/linux/inet_lro.h
index 1246d46abbc0..80335b7d77c5 100644
--- a/include/linux/inet_lro.h
+++ b/include/linux/inet_lro.h
@@ -91,6 +91,9 @@ struct net_lro_mgr {
91 int max_desc; /* Max number of LRO descriptors */ 91 int max_desc; /* Max number of LRO descriptors */
92 int max_aggr; /* Max number of LRO packets to be aggregated */ 92 int max_aggr; /* Max number of LRO packets to be aggregated */
93 93
94 int frag_align_pad; /* Padding required to properly align layer 3
95 * headers in generated skb when using frags */
96
94 struct net_lro_desc *lro_arr; /* Array of LRO descriptors */ 97 struct net_lro_desc *lro_arr; /* Array of LRO descriptors */
95 98
96 /* 99 /*
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index d83fee2dc643..fc4e3db649e8 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -17,8 +17,6 @@ struct ipv4_devconf
17 DECLARE_BITMAP(state, __NET_IPV4_CONF_MAX - 1); 17 DECLARE_BITMAP(state, __NET_IPV4_CONF_MAX - 1);
18}; 18};
19 19
20extern struct ipv4_devconf ipv4_devconf;
21
22struct in_device 20struct in_device
23{ 21{
24 struct net_device *dev; 22 struct net_device *dev;
@@ -44,7 +42,8 @@ struct in_device
44}; 42};
45 43
46#define IPV4_DEVCONF(cnf, attr) ((cnf).data[NET_IPV4_CONF_ ## attr - 1]) 44#define IPV4_DEVCONF(cnf, attr) ((cnf).data[NET_IPV4_CONF_ ## attr - 1])
47#define IPV4_DEVCONF_ALL(attr) IPV4_DEVCONF(ipv4_devconf, attr) 45#define IPV4_DEVCONF_ALL(net, attr) \
46 IPV4_DEVCONF((*(net)->ipv4.devconf_all), attr)
48 47
49static inline int ipv4_devconf_get(struct in_device *in_dev, int index) 48static inline int ipv4_devconf_get(struct in_device *in_dev, int index)
50{ 49{
@@ -71,16 +70,17 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev)
71 ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val)) 70 ipv4_devconf_set((in_dev), NET_IPV4_CONF_ ## attr, (val))
72 71
73#define IN_DEV_ANDCONF(in_dev, attr) \ 72#define IN_DEV_ANDCONF(in_dev, attr) \
74 (IPV4_DEVCONF_ALL(attr) && IN_DEV_CONF_GET((in_dev), attr)) 73 (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr) && \
74 IN_DEV_CONF_GET((in_dev), attr))
75#define IN_DEV_ORCONF(in_dev, attr) \ 75#define IN_DEV_ORCONF(in_dev, attr) \
76 (IPV4_DEVCONF_ALL(attr) || IN_DEV_CONF_GET((in_dev), attr)) 76 (IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr) || \
77 IN_DEV_CONF_GET((in_dev), attr))
77#define IN_DEV_MAXCONF(in_dev, attr) \ 78#define IN_DEV_MAXCONF(in_dev, attr) \
78 (max(IPV4_DEVCONF_ALL(attr), IN_DEV_CONF_GET((in_dev), attr))) 79 (max(IPV4_DEVCONF_ALL(in_dev->dev->nd_net, attr), \
80 IN_DEV_CONF_GET((in_dev), attr)))
79 81
80#define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING) 82#define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING)
81#define IN_DEV_MFORWARD(in_dev) (IPV4_DEVCONF_ALL(MC_FORWARDING) && \ 83#define IN_DEV_MFORWARD(in_dev) IN_DEV_ANDCONF((in_dev), MC_FORWARDING)
82 IPV4_DEVCONF((in_dev)->cnf, \
83 MC_FORWARDING))
84#define IN_DEV_RPFILTER(in_dev) IN_DEV_ANDCONF((in_dev), RP_FILTER) 84#define IN_DEV_RPFILTER(in_dev) IN_DEV_ANDCONF((in_dev), RP_FILTER)
85#define IN_DEV_SOURCE_ROUTE(in_dev) IN_DEV_ANDCONF((in_dev), \ 85#define IN_DEV_SOURCE_ROUTE(in_dev) IN_DEV_ANDCONF((in_dev), \
86 ACCEPT_SOURCE_ROUTE) 86 ACCEPT_SOURCE_ROUTE)
@@ -127,15 +127,14 @@ struct in_ifaddr
127extern int register_inetaddr_notifier(struct notifier_block *nb); 127extern int register_inetaddr_notifier(struct notifier_block *nb);
128extern int unregister_inetaddr_notifier(struct notifier_block *nb); 128extern int unregister_inetaddr_notifier(struct notifier_block *nb);
129 129
130extern struct net_device *ip_dev_find(__be32 addr); 130extern struct net_device *ip_dev_find(struct net *net, __be32 addr);
131extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b); 131extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
132extern int devinet_ioctl(unsigned int cmd, void __user *); 132extern int devinet_ioctl(unsigned int cmd, void __user *);
133extern void devinet_init(void); 133extern void devinet_init(void);
134extern struct in_device *inetdev_by_index(int); 134extern struct in_device *inetdev_by_index(struct net *, int);
135extern __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope); 135extern __be32 inet_select_addr(const struct net_device *dev, __be32 dst, int scope);
136extern __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local, int scope); 136extern __be32 inet_confirm_addr(struct in_device *in_dev, __be32 dst, __be32 local, int scope);
137extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, __be32 mask); 137extern struct in_ifaddr *inet_ifa_byprefix(struct in_device *in_dev, __be32 prefix, __be32 mask);
138extern void inet_forward_change(void);
139 138
140static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa) 139static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
141{ 140{
diff --git a/include/linux/init.h b/include/linux/init.h
index 5141381a7527..2efbda016741 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -40,10 +40,10 @@
40 40
41/* These are for everybody (although not all archs will actually 41/* These are for everybody (although not all archs will actually
42 discard it in modules) */ 42 discard it in modules) */
43#define __init __attribute__ ((__section__ (".init.text"))) __cold 43#define __init __section(.init.text) __cold
44#define __initdata __attribute__ ((__section__ (".init.data"))) 44#define __initdata __section(.init.data)
45#define __exitdata __attribute__ ((__section__(".exit.data"))) 45#define __exitdata __section(.exit.data)
46#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) 46#define __exit_call __used __section(.exitcall.exit)
47 47
48/* modpost check for section mismatches during the kernel build. 48/* modpost check for section mismatches during the kernel build.
49 * A section mismatch happens when there are references from a 49 * A section mismatch happens when there are references from a
@@ -52,25 +52,81 @@
52 * when early init has completed so all such references are potential bugs. 52 * when early init has completed so all such references are potential bugs.
53 * For exit sections the same issue exists. 53 * For exit sections the same issue exists.
54 * The following markers are used for the cases where the reference to 54 * The following markers are used for the cases where the reference to
55 * the init/exit section (code or data) is valid and will teach modpost 55 * the *init / *exit section (code or data) is valid and will teach
56 * not to issue a warning. 56 * modpost not to issue a warning.
57 * The markers follow same syntax rules as __init / __initdata. */ 57 * The markers follow same syntax rules as __init / __initdata. */
58#define __init_refok noinline __attribute__ ((__section__ (".text.init.refok"))) 58#define __ref __section(.ref.text) noinline
59#define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) 59#define __refdata __section(.ref.data)
60#define __exit_refok noinline __attribute__ ((__section__ (".exit.text.refok"))) 60#define __refconst __section(.ref.rodata)
61
62/* backward compatibility note
63 * A few places hardcode the old section names:
64 * .text.init.refok
65 * .data.init.refok
66 * .exit.text.refok
67 * They should be converted to use the defines from this file
68 */
69
70/* compatibility defines */
71#define __init_refok __ref
72#define __initdata_refok __refdata
73#define __exit_refok __ref
74
61 75
62#ifdef MODULE 76#ifdef MODULE
63#define __exit __attribute__ ((__section__(".exit.text"))) __cold 77#define __exitused
64#else 78#else
65#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold 79#define __exitused __used
66#endif 80#endif
67 81
82#define __exit __section(.exit.text) __exitused __cold
83
84/* Used for HOTPLUG */
85#define __devinit __section(.devinit.text) __cold
86#define __devinitdata __section(.devinit.data)
87#define __devinitconst __section(.devinit.rodata)
88#define __devexit __section(.devexit.text) __exitused __cold
89#define __devexitdata __section(.devexit.data)
90#define __devexitconst __section(.devexit.rodata)
91
92/* Used for HOTPLUG_CPU */
93#define __cpuinit __section(.cpuinit.text) __cold
94#define __cpuinitdata __section(.cpuinit.data)
95#define __cpuinitconst __section(.cpuinit.rodata)
96#define __cpuexit __section(.cpuexit.text) __exitused __cold
97#define __cpuexitdata __section(.cpuexit.data)
98#define __cpuexitconst __section(.cpuexit.rodata)
99
100/* Used for MEMORY_HOTPLUG */
101#define __meminit __section(.meminit.text) __cold
102#define __meminitdata __section(.meminit.data)
103#define __meminitconst __section(.meminit.rodata)
104#define __memexit __section(.memexit.text) __exitused __cold
105#define __memexitdata __section(.memexit.data)
106#define __memexitconst __section(.memexit.rodata)
107
68/* For assembly routines */ 108/* For assembly routines */
69#define __INIT .section ".init.text","ax" 109#define __INIT .section ".init.text","ax"
70#define __INIT_REFOK .section ".text.init.refok","ax"
71#define __FINIT .previous 110#define __FINIT .previous
111
72#define __INITDATA .section ".init.data","aw" 112#define __INITDATA .section ".init.data","aw"
73#define __INITDATA_REFOK .section ".data.init.refok","aw" 113
114#define __DEVINIT .section ".devinit.text", "ax"
115#define __DEVINITDATA .section ".devinit.data", "aw"
116
117#define __CPUINIT .section ".cpuinit.text", "ax"
118#define __CPUINITDATA .section ".cpuinit.data", "aw"
119
120#define __MEMINIT .section ".meminit.text", "ax"
121#define __MEMINITDATA .section ".meminit.data", "aw"
122
123/* silence warnings when references are OK */
124#define __REF .section ".ref.text", "ax"
125#define __REFDATA .section ".ref.data", "aw"
126#define __REFCONST .section ".ref.rodata", "aw"
127/* backward compatibility */
128#define __INIT_REFOK .section __REF
129#define __INITDATA_REFOK .section __REFDATA
74 130
75#ifndef __ASSEMBLY__ 131#ifndef __ASSEMBLY__
76/* 132/*
@@ -108,7 +164,7 @@ void prepare_namespace(void);
108 */ 164 */
109 165
110#define __define_initcall(level,fn,id) \ 166#define __define_initcall(level,fn,id) \
111 static initcall_t __initcall_##fn##id __attribute_used__ \ 167 static initcall_t __initcall_##fn##id __used \
112 __attribute__((__section__(".initcall" level ".init"))) = fn 168 __attribute__((__section__(".initcall" level ".init"))) = fn
113 169
114/* 170/*
@@ -142,11 +198,11 @@ void prepare_namespace(void);
142 198
143#define console_initcall(fn) \ 199#define console_initcall(fn) \
144 static initcall_t __initcall_##fn \ 200 static initcall_t __initcall_##fn \
145 __attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn 201 __used __section(.con_initcall.init) = fn
146 202
147#define security_initcall(fn) \ 203#define security_initcall(fn) \
148 static initcall_t __initcall_##fn \ 204 static initcall_t __initcall_##fn \
149 __attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn 205 __used __section(.security_initcall.init) = fn
150 206
151struct obs_kernel_param { 207struct obs_kernel_param {
152 const char *str; 208 const char *str;
@@ -163,8 +219,7 @@ struct obs_kernel_param {
163#define __setup_param(str, unique_id, fn, early) \ 219#define __setup_param(str, unique_id, fn, early) \
164 static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \ 220 static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \
165 static struct obs_kernel_param __setup_##unique_id \ 221 static struct obs_kernel_param __setup_##unique_id \
166 __attribute_used__ \ 222 __used __section(.init.setup) \
167 __attribute__((__section__(".init.setup"))) \
168 __attribute__((aligned((sizeof(long))))) \ 223 __attribute__((aligned((sizeof(long))))) \
169 = { __setup_str_##unique_id, fn, early } 224 = { __setup_str_##unique_id, fn, early }
170 225
@@ -242,7 +297,7 @@ void __init parse_early_param(void);
242#endif 297#endif
243 298
244/* Data marked not to be saved by software suspend */ 299/* Data marked not to be saved by software suspend */
245#define __nosavedata __attribute__ ((__section__ (".data.nosave"))) 300#define __nosavedata __section(.data.nosave)
246 301
247/* This means "can be init if no module support, otherwise module load 302/* This means "can be init if no module support, otherwise module load
248 may call it." */ 303 may call it." */
@@ -254,43 +309,6 @@ void __init parse_early_param(void);
254#define __initdata_or_module __initdata 309#define __initdata_or_module __initdata
255#endif /*CONFIG_MODULES*/ 310#endif /*CONFIG_MODULES*/
256 311
257#ifdef CONFIG_HOTPLUG
258#define __devinit
259#define __devinitdata
260#define __devexit
261#define __devexitdata
262#else
263#define __devinit __init
264#define __devinitdata __initdata
265#define __devexit __exit
266#define __devexitdata __exitdata
267#endif
268
269#ifdef CONFIG_HOTPLUG_CPU
270#define __cpuinit
271#define __cpuinitdata
272#define __cpuexit
273#define __cpuexitdata
274#else
275#define __cpuinit __init
276#define __cpuinitdata __initdata
277#define __cpuexit __exit
278#define __cpuexitdata __exitdata
279#endif
280
281#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_ACPI_HOTPLUG_MEMORY) \
282 || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE)
283#define __meminit
284#define __meminitdata
285#define __memexit
286#define __memexitdata
287#else
288#define __meminit __init
289#define __meminitdata __initdata
290#define __memexit __exit
291#define __memexitdata __exitdata
292#endif
293
294/* Functions marked as __devexit may be discarded at kernel link time, depending 312/* Functions marked as __devexit may be discarded at kernel link time, depending
295 on config options. Newer versions of binutils detect references from 313 on config options. Newer versions of binutils detect references from
296 retained sections to discarded sections and flag an error. Pointers to 314 retained sections to discarded sections and flag an error. Pointers to
diff --git a/include/linux/init_ohci1394_dma.h b/include/linux/init_ohci1394_dma.h
new file mode 100644
index 000000000000..3c03a4bba5e4
--- /dev/null
+++ b/include/linux/init_ohci1394_dma.h
@@ -0,0 +1,4 @@
1#ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT
2extern int __initdata init_ohci1394_dma_early;
3extern void __init init_ohci1394_dma_on_all_controllers(void);
4#endif
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index cae35b6b9aec..f42663eaf655 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -114,6 +114,13 @@ extern struct group_info init_groups;
114 .pid = &init_struct_pid, \ 114 .pid = &init_struct_pid, \
115} 115}
116 116
117#ifdef CONFIG_AUDITSYSCALL
118#define INIT_IDS \
119 .loginuid = -1, \
120 .sessionid = -1,
121#else
122#define INIT_IDS
123#endif
117/* 124/*
118 * INIT_TASK is used to set up the first task table, touch at 125 * INIT_TASK is used to set up the first task table, touch at
119 * your own risk!. Base=0, limit=0x1fffff (=2MB) 126 * your own risk!. Base=0, limit=0x1fffff (=2MB)
@@ -132,9 +139,11 @@ extern struct group_info init_groups;
132 .cpus_allowed = CPU_MASK_ALL, \ 139 .cpus_allowed = CPU_MASK_ALL, \
133 .mm = NULL, \ 140 .mm = NULL, \
134 .active_mm = &init_mm, \ 141 .active_mm = &init_mm, \
135 .run_list = LIST_HEAD_INIT(tsk.run_list), \ 142 .rt = { \
136 .ioprio = 0, \ 143 .run_list = LIST_HEAD_INIT(tsk.rt.run_list), \
137 .time_slice = HZ, \ 144 .time_slice = HZ, \
145 .nr_cpus_allowed = NR_CPUS, \
146 }, \
138 .tasks = LIST_HEAD_INIT(tsk.tasks), \ 147 .tasks = LIST_HEAD_INIT(tsk.tasks), \
139 .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \ 148 .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \
140 .ptrace_list = LIST_HEAD_INIT(tsk.ptrace_list), \ 149 .ptrace_list = LIST_HEAD_INIT(tsk.ptrace_list), \
@@ -171,6 +180,7 @@ extern struct group_info init_groups;
171 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \ 180 [PIDTYPE_SID] = INIT_PID_LINK(PIDTYPE_SID), \
172 }, \ 181 }, \
173 .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \ 182 .dirties = INIT_PROP_LOCAL_SINGLE(dirties), \
183 INIT_IDS \
174 INIT_TRACE_IRQFLAGS \ 184 INIT_TRACE_IRQFLAGS \
175 INIT_LOCKDEP \ 185 INIT_LOCKDEP \
176} 186}
diff --git a/include/linux/input.h b/include/linux/input.h
index 62268929856c..056a17a4f34f 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -371,6 +371,8 @@ struct input_absinfo {
371#define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */ 371#define KEY_BRIGHTNESS_ZERO 244 /* brightness off, use ambient */
372#define KEY_DISPLAY_OFF 245 /* display device to off state */ 372#define KEY_DISPLAY_OFF 245 /* display device to off state */
373 373
374#define KEY_WIMAX 246
375
374#define BTN_MISC 0x100 376#define BTN_MISC 0x100
375#define BTN_0 0x100 377#define BTN_0 0x100
376#define BTN_1 0x101 378#define BTN_1 0x101
@@ -527,6 +529,14 @@ struct input_absinfo {
527#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */ 529#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */
528#define KEY_LOGOFF 0x1b1 /* AL Logoff */ 530#define KEY_LOGOFF 0x1b1 /* AL Logoff */
529 531
532#define KEY_DOLLAR 0x1b2
533#define KEY_EURO 0x1b3
534
535#define KEY_FRAMEBACK 0x1b4 /* Consumer - transport controls */
536#define KEY_FRAMEFORWARD 0x1b5
537
538#define KEY_CONTEXT_MENU 0x1b6 /* GenDesc - system context menu */
539
530#define KEY_DEL_EOL 0x1c0 540#define KEY_DEL_EOL 0x1c0
531#define KEY_DEL_EOS 0x1c1 541#define KEY_DEL_EOS 0x1c1
532#define KEY_INS_LINE 0x1c2 542#define KEY_INS_LINE 0x1c2
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 2306920fa388..c3db4a00f1fa 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -256,6 +256,7 @@ enum
256#ifdef CONFIG_HIGH_RES_TIMERS 256#ifdef CONFIG_HIGH_RES_TIMERS
257 HRTIMER_SOFTIRQ, 257 HRTIMER_SOFTIRQ,
258#endif 258#endif
259 RCU_SOFTIRQ, /* Preferable RCU should always be the last softirq */
259}; 260};
260 261
261/* softirq mask and active fields moved to irq_cpustat_t in 262/* softirq mask and active fields moved to irq_cpustat_t in
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h
new file mode 100644
index 000000000000..593b222d9dcc
--- /dev/null
+++ b/include/linux/iocontext.h
@@ -0,0 +1,95 @@
1#ifndef IOCONTEXT_H
2#define IOCONTEXT_H
3
4#include <linux/radix-tree.h>
5
6/*
7 * This is the per-process anticipatory I/O scheduler state.
8 */
9struct as_io_context {
10 spinlock_t lock;
11
12 void (*dtor)(struct as_io_context *aic); /* destructor */
13 void (*exit)(struct as_io_context *aic); /* called on task exit */
14
15 unsigned long state;
16 atomic_t nr_queued; /* queued reads & sync writes */
17 atomic_t nr_dispatched; /* number of requests gone to the drivers */
18
19 /* IO History tracking */
20 /* Thinktime */
21 unsigned long last_end_request;
22 unsigned long ttime_total;
23 unsigned long ttime_samples;
24 unsigned long ttime_mean;
25 /* Layout pattern */
26 unsigned int seek_samples;
27 sector_t last_request_pos;
28 u64 seek_total;
29 sector_t seek_mean;
30};
31
32struct cfq_queue;
33struct cfq_io_context {
34 void *key;
35 unsigned long dead_key;
36
37 struct cfq_queue *cfqq[2];
38
39 struct io_context *ioc;
40
41 unsigned long last_end_request;
42 sector_t last_request_pos;
43
44 unsigned long ttime_total;
45 unsigned long ttime_samples;
46 unsigned long ttime_mean;
47
48 unsigned int seek_samples;
49 u64 seek_total;
50 sector_t seek_mean;
51
52 struct list_head queue_list;
53
54 void (*dtor)(struct io_context *); /* destructor */
55 void (*exit)(struct io_context *); /* called on task exit */
56};
57
58/*
59 * I/O subsystem state of the associated processes. It is refcounted
60 * and kmalloc'ed. These could be shared between processes.
61 */
62struct io_context {
63 atomic_t refcount;
64 atomic_t nr_tasks;
65
66 /* all the fields below are protected by this lock */
67 spinlock_t lock;
68
69 unsigned short ioprio;
70 unsigned short ioprio_changed;
71
72 /*
73 * For request batching
74 */
75 unsigned long last_waited; /* Time last woken after wait for request */
76 int nr_batch_requests; /* Number of requests left in the batch */
77
78 struct as_io_context *aic;
79 struct radix_tree_root radix_root;
80 void *ioc_data;
81};
82
83static inline struct io_context *ioc_task_link(struct io_context *ioc)
84{
85 /*
86 * if ref count is zero, don't allow sharing (ioc is going away, it's
87 * a race).
88 */
89 if (ioc && atomic_inc_not_zero(&ioc->refcount))
90 return ioc;
91
92 return NULL;
93}
94
95#endif
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 6187a8567bc7..605d237364d2 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -8,6 +8,7 @@
8#ifndef _LINUX_IOPORT_H 8#ifndef _LINUX_IOPORT_H
9#define _LINUX_IOPORT_H 9#define _LINUX_IOPORT_H
10 10
11#ifndef __ASSEMBLY__
11#include <linux/compiler.h> 12#include <linux/compiler.h>
12#include <linux/types.h> 13#include <linux/types.h>
13/* 14/*
@@ -153,4 +154,5 @@ extern struct resource * __devm_request_region(struct device *dev,
153extern void __devm_release_region(struct device *dev, struct resource *parent, 154extern void __devm_release_region(struct device *dev, struct resource *parent,
154 resource_size_t start, resource_size_t n); 155 resource_size_t start, resource_size_t n);
155 156
157#endif /* __ASSEMBLY__ */
156#endif /* _LINUX_IOPORT_H */ 158#endif /* _LINUX_IOPORT_H */
diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index baf29387cab4..2a3bb1bb7433 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -2,6 +2,7 @@
2#define IOPRIO_H 2#define IOPRIO_H
3 3
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/iocontext.h>
5 6
6/* 7/*
7 * Gives us 8 prio classes with 13-bits of data for each class 8 * Gives us 8 prio classes with 13-bits of data for each class
@@ -45,18 +46,18 @@ enum {
45 * the cpu scheduler nice value to an io priority 46 * the cpu scheduler nice value to an io priority
46 */ 47 */
47#define IOPRIO_NORM (4) 48#define IOPRIO_NORM (4)
48static inline int task_ioprio(struct task_struct *task) 49static inline int task_ioprio(struct io_context *ioc)
49{ 50{
50 if (ioprio_valid(task->ioprio)) 51 if (ioprio_valid(ioc->ioprio))
51 return IOPRIO_PRIO_DATA(task->ioprio); 52 return IOPRIO_PRIO_DATA(ioc->ioprio);
52 53
53 return IOPRIO_NORM; 54 return IOPRIO_NORM;
54} 55}
55 56
56static inline int task_ioprio_class(struct task_struct *task) 57static inline int task_ioprio_class(struct io_context *ioc)
57{ 58{
58 if (ioprio_valid(task->ioprio)) 59 if (ioprio_valid(ioc->ioprio))
59 return IOPRIO_PRIO_CLASS(task->ioprio); 60 return IOPRIO_PRIO_CLASS(ioc->ioprio);
60 61
61 return IOPRIO_CLASS_BE; 62 return IOPRIO_CLASS_BE;
62} 63}
diff --git a/include/linux/ipmi_smi.h b/include/linux/ipmi_smi.h
index 56ae438ae510..6e8cec503380 100644
--- a/include/linux/ipmi_smi.h
+++ b/include/linux/ipmi_smi.h
@@ -173,7 +173,7 @@ static inline int ipmi_demangle_device_id(const unsigned char *data,
173 id->firmware_revision_2 = data[3]; 173 id->firmware_revision_2 = data[3];
174 id->ipmi_version = data[4]; 174 id->ipmi_version = data[4];
175 id->additional_device_support = data[5]; 175 id->additional_device_support = data[5];
176 if (data_len >= 6) { 176 if (data_len >= 11) {
177 id->manufacturer_id = (data[6] | (data[7] << 8) | 177 id->manufacturer_id = (data[6] | (data[7] << 8) |
178 (data[8] << 16)); 178 (data[8] << 16));
179 id->product_id = data[9] | (data[10] << 8); 179 id->product_id = data[9] | (data[10] << 8);
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 5d35a4cc3bff..4aaefc349a4b 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -457,14 +457,22 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
457#define inet_v6_ipv6only(__sk) 0 457#define inet_v6_ipv6only(__sk) 0
458#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ 458#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
459 459
460#define INET6_MATCH(__sk, __hash, __saddr, __daddr, __ports, __dif)\ 460#define INET6_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\
461 (((__sk)->sk_hash == (__hash)) && \ 461 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
462 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 462 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
463 ((__sk)->sk_family == AF_INET6) && \ 463 ((__sk)->sk_family == AF_INET6) && \
464 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \ 464 ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \
465 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \ 465 ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \
466 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 466 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
467 467
468#define INET6_TW_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif) \
469 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
470 (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \
471 ((__sk)->sk_family == PF_INET6) && \
472 (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \
473 (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_rcv_saddr, (__daddr))) && \
474 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
475
468#endif /* __KERNEL__ */ 476#endif /* __KERNEL__ */
469 477
470#endif /* _IPV6_H */ 478#endif /* _IPV6_H */
diff --git a/include/linux/irq.h b/include/linux/irq.h
index efc88538b2ba..4669be080617 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -339,6 +339,13 @@ extern void
339__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, 339__set_irq_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
340 const char *name); 340 const char *name);
341 341
342/* caller has locked the irq_desc and both params are valid */
343static inline void __set_irq_handler_unlocked(int irq,
344 irq_flow_handler_t handler)
345{
346 irq_desc[irq].handle_irq = handler;
347}
348
342/* 349/*
343 * Set a highlevel flow handler for a given IRQ: 350 * Set a highlevel flow handler for a given IRQ:
344 */ 351 */
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 16e7ed855a18..d9ecd13393b0 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -439,6 +439,8 @@ struct transaction_s
439 /* 439 /*
440 * Transaction's current state 440 * Transaction's current state
441 * [no locking - only kjournald alters this] 441 * [no locking - only kjournald alters this]
442 * [j_list_lock] guards transition of a transaction into T_FINISHED
443 * state and subsequent call of __journal_drop_transaction()
442 * FIXME: needs barriers 444 * FIXME: needs barriers
443 * KLUDGE: [use j_state_lock] 445 * KLUDGE: [use j_state_lock]
444 */ 446 */
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 06ef11457051..2cbf6fdb1799 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -149,6 +149,28 @@ typedef struct journal_header_s
149 __be32 h_sequence; 149 __be32 h_sequence;
150} journal_header_t; 150} journal_header_t;
151 151
152/*
153 * Checksum types.
154 */
155#define JBD2_CRC32_CHKSUM 1
156#define JBD2_MD5_CHKSUM 2
157#define JBD2_SHA1_CHKSUM 3
158
159#define JBD2_CRC32_CHKSUM_SIZE 4
160
161#define JBD2_CHECKSUM_BYTES (32 / sizeof(u32))
162/*
163 * Commit block header for storing transactional checksums:
164 */
165struct commit_header {
166 __be32 h_magic;
167 __be32 h_blocktype;
168 __be32 h_sequence;
169 unsigned char h_chksum_type;
170 unsigned char h_chksum_size;
171 unsigned char h_padding[2];
172 __be32 h_chksum[JBD2_CHECKSUM_BYTES];
173};
152 174
153/* 175/*
154 * The block tag: used to describe a single buffer in the journal. 176 * The block tag: used to describe a single buffer in the journal.
@@ -242,31 +264,25 @@ typedef struct journal_superblock_s
242 ((j)->j_format_version >= 2 && \ 264 ((j)->j_format_version >= 2 && \
243 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask)))) 265 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
244 266
245#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001 267#define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001
246#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 268
269#define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001
270#define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002
271#define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004
247 272
248/* Features known to this kernel version: */ 273/* Features known to this kernel version: */
249#define JBD2_KNOWN_COMPAT_FEATURES 0 274#define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM
250#define JBD2_KNOWN_ROCOMPAT_FEATURES 0 275#define JBD2_KNOWN_ROCOMPAT_FEATURES 0
251#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ 276#define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \
252 JBD2_FEATURE_INCOMPAT_64BIT) 277 JBD2_FEATURE_INCOMPAT_64BIT | \
278 JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT)
253 279
254#ifdef __KERNEL__ 280#ifdef __KERNEL__
255 281
256#include <linux/fs.h> 282#include <linux/fs.h>
257#include <linux/sched.h> 283#include <linux/sched.h>
258 284
259#define JBD2_ASSERTIONS 285#define J_ASSERT(assert) BUG_ON(!(assert))
260#ifdef JBD2_ASSERTIONS
261#define J_ASSERT(assert) \
262do { \
263 if (!(assert)) { \
264 printk (KERN_EMERG \
265 "Assertion failure in %s() at %s:%d: \"%s\"\n", \
266 __FUNCTION__, __FILE__, __LINE__, # assert); \
267 BUG(); \
268 } \
269} while (0)
270 286
271#if defined(CONFIG_BUFFER_DEBUG) 287#if defined(CONFIG_BUFFER_DEBUG)
272void buffer_assertion_failure(struct buffer_head *bh); 288void buffer_assertion_failure(struct buffer_head *bh);
@@ -282,10 +298,6 @@ void buffer_assertion_failure(struct buffer_head *bh);
282#define J_ASSERT_JH(jh, expr) J_ASSERT(expr) 298#define J_ASSERT_JH(jh, expr) J_ASSERT(expr)
283#endif 299#endif
284 300
285#else
286#define J_ASSERT(assert) do { } while (0)
287#endif /* JBD2_ASSERTIONS */
288
289#if defined(JBD2_PARANOID_IOFAIL) 301#if defined(JBD2_PARANOID_IOFAIL)
290#define J_EXPECT(expr, why...) J_ASSERT(expr) 302#define J_EXPECT(expr, why...) J_ASSERT(expr)
291#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr) 303#define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr)
@@ -406,9 +418,23 @@ struct handle_s
406 unsigned int h_sync: 1; /* sync-on-close */ 418 unsigned int h_sync: 1; /* sync-on-close */
407 unsigned int h_jdata: 1; /* force data journaling */ 419 unsigned int h_jdata: 1; /* force data journaling */
408 unsigned int h_aborted: 1; /* fatal error on handle */ 420 unsigned int h_aborted: 1; /* fatal error on handle */
421
422#ifdef CONFIG_DEBUG_LOCK_ALLOC
423 struct lockdep_map h_lockdep_map;
424#endif
409}; 425};
410 426
411 427
428/*
429 * Some stats for checkpoint phase
430 */
431struct transaction_chp_stats_s {
432 unsigned long cs_chp_time;
433 unsigned long cs_forced_to_close;
434 unsigned long cs_written;
435 unsigned long cs_dropped;
436};
437
412/* The transaction_t type is the guts of the journaling mechanism. It 438/* The transaction_t type is the guts of the journaling mechanism. It
413 * tracks a compound transaction through its various states: 439 * tracks a compound transaction through its various states:
414 * 440 *
@@ -456,6 +482,8 @@ struct transaction_s
456 /* 482 /*
457 * Transaction's current state 483 * Transaction's current state
458 * [no locking - only kjournald2 alters this] 484 * [no locking - only kjournald2 alters this]
485 * [j_list_lock] guards transition of a transaction into T_FINISHED
486 * state and subsequent call of __jbd2_journal_drop_transaction()
459 * FIXME: needs barriers 487 * FIXME: needs barriers
460 * KLUDGE: [use j_state_lock] 488 * KLUDGE: [use j_state_lock]
461 */ 489 */
@@ -544,6 +572,21 @@ struct transaction_s
544 spinlock_t t_handle_lock; 572 spinlock_t t_handle_lock;
545 573
546 /* 574 /*
575 * Longest time some handle had to wait for running transaction
576 */
577 unsigned long t_max_wait;
578
579 /*
580 * When transaction started
581 */
582 unsigned long t_start;
583
584 /*
585 * Checkpointing stats [j_checkpoint_sem]
586 */
587 struct transaction_chp_stats_s t_chp_stats;
588
589 /*
547 * Number of outstanding updates running on this transaction 590 * Number of outstanding updates running on this transaction
548 * [t_handle_lock] 591 * [t_handle_lock]
549 */ 592 */
@@ -574,6 +617,39 @@ struct transaction_s
574 617
575}; 618};
576 619
620struct transaction_run_stats_s {
621 unsigned long rs_wait;
622 unsigned long rs_running;
623 unsigned long rs_locked;
624 unsigned long rs_flushing;
625 unsigned long rs_logging;
626
627 unsigned long rs_handle_count;
628 unsigned long rs_blocks;
629 unsigned long rs_blocks_logged;
630};
631
632struct transaction_stats_s {
633 int ts_type;
634 unsigned long ts_tid;
635 union {
636 struct transaction_run_stats_s run;
637 struct transaction_chp_stats_s chp;
638 } u;
639};
640
641#define JBD2_STATS_RUN 1
642#define JBD2_STATS_CHECKPOINT 2
643
644static inline unsigned long
645jbd2_time_diff(unsigned long start, unsigned long end)
646{
647 if (end >= start)
648 return end - start;
649
650 return end + (MAX_JIFFY_OFFSET - start);
651}
652
577/** 653/**
578 * struct journal_s - The journal_s type is the concrete type associated with 654 * struct journal_s - The journal_s type is the concrete type associated with
579 * journal_t. 655 * journal_t.
@@ -635,6 +711,12 @@ struct transaction_s
635 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the 711 * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the
636 * number that will fit in j_blocksize 712 * number that will fit in j_blocksize
637 * @j_last_sync_writer: most recent pid which did a synchronous write 713 * @j_last_sync_writer: most recent pid which did a synchronous write
714 * @j_history: Buffer storing the transactions statistics history
715 * @j_history_max: Maximum number of transactions in the statistics history
716 * @j_history_cur: Current number of transactions in the statistics history
717 * @j_history_lock: Protect the transactions statistics history
718 * @j_proc_entry: procfs entry for the jbd statistics directory
719 * @j_stats: Overall statistics
638 * @j_private: An opaque pointer to fs-private information. 720 * @j_private: An opaque pointer to fs-private information.
639 */ 721 */
640 722
@@ -827,6 +909,19 @@ struct journal_s
827 pid_t j_last_sync_writer; 909 pid_t j_last_sync_writer;
828 910
829 /* 911 /*
912 * Journal statistics
913 */
914 struct transaction_stats_s *j_history;
915 int j_history_max;
916 int j_history_cur;
917 /*
918 * Protect the transactions statistics history
919 */
920 spinlock_t j_history_lock;
921 struct proc_dir_entry *j_proc_entry;
922 struct transaction_stats_s j_stats;
923
924 /*
830 * An opaque pointer to fs-private information. ext3 puts its 925 * An opaque pointer to fs-private information. ext3 puts its
831 * superblock pointer here 926 * superblock pointer here
832 */ 927 */
@@ -932,6 +1027,8 @@ extern int jbd2_journal_check_available_features
932 (journal_t *, unsigned long, unsigned long, unsigned long); 1027 (journal_t *, unsigned long, unsigned long, unsigned long);
933extern int jbd2_journal_set_features 1028extern int jbd2_journal_set_features
934 (journal_t *, unsigned long, unsigned long, unsigned long); 1029 (journal_t *, unsigned long, unsigned long, unsigned long);
1030extern void jbd2_journal_clear_features
1031 (journal_t *, unsigned long, unsigned long, unsigned long);
935extern int jbd2_journal_create (journal_t *); 1032extern int jbd2_journal_create (journal_t *);
936extern int jbd2_journal_load (journal_t *journal); 1033extern int jbd2_journal_load (journal_t *journal);
937extern void jbd2_journal_destroy (journal_t *); 1034extern void jbd2_journal_destroy (journal_t *);
diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
index 8b080024bbc1..7ba9e47bf061 100644
--- a/include/linux/jiffies.h
+++ b/include/linux/jiffies.h
@@ -29,6 +29,12 @@
29# define SHIFT_HZ 9 29# define SHIFT_HZ 9
30#elif HZ >= 768 && HZ < 1536 30#elif HZ >= 768 && HZ < 1536
31# define SHIFT_HZ 10 31# define SHIFT_HZ 10
32#elif HZ >= 1536 && HZ < 3072
33# define SHIFT_HZ 11
34#elif HZ >= 3072 && HZ < 6144
35# define SHIFT_HZ 12
36#elif HZ >= 6144 && HZ < 12288
37# define SHIFT_HZ 13
32#else 38#else
33# error You lose. 39# error You lose.
34#endif 40#endif
diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
index f73de6fb5c68..82de2fb62cb7 100644
--- a/include/linux/kallsyms.h
+++ b/include/linux/kallsyms.h
@@ -6,6 +6,7 @@
6#define _LINUX_KALLSYMS_H 6#define _LINUX_KALLSYMS_H
7 7
8#include <linux/errno.h> 8#include <linux/errno.h>
9#include <linux/stddef.h>
9 10
10#define KSYM_NAME_LEN 128 11#define KSYM_NAME_LEN 128
11#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \ 12#define KSYM_SYMBOL_LEN (sizeof("%s+%#lx/%#lx [%s]") + (KSYM_NAME_LEN - 1) + \
diff --git a/include/linux/kd.h b/include/linux/kd.h
index c91fc0c9c495..15f2853ea58f 100644
--- a/include/linux/kd.h
+++ b/include/linux/kd.h
@@ -126,7 +126,7 @@ struct kbdiacrs {
126#define KDSKBDIACR 0x4B4B /* write kernel accent table */ 126#define KDSKBDIACR 0x4B4B /* write kernel accent table */
127 127
128struct kbdiacruc { 128struct kbdiacruc {
129 __u32 diacr, base, result; 129 unsigned int diacr, base, result;
130}; 130};
131struct kbdiacrsuc { 131struct kbdiacrsuc {
132 unsigned int kb_cnt; /* number of entries in following array */ 132 unsigned int kb_cnt; /* number of entries in following array */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 94bc99656963..ff356b2ee478 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -105,8 +105,8 @@ struct user;
105 * supposed to. 105 * supposed to.
106 */ 106 */
107#ifdef CONFIG_PREEMPT_VOLUNTARY 107#ifdef CONFIG_PREEMPT_VOLUNTARY
108extern int cond_resched(void); 108extern int _cond_resched(void);
109# define might_resched() cond_resched() 109# define might_resched() _cond_resched()
110#else 110#else
111# define might_resched() do { } while (0) 111# define might_resched() do { } while (0)
112#endif 112#endif
@@ -194,6 +194,9 @@ static inline int log_buf_read(int idx) { return 0; }
194static inline int log_buf_copy(char *dest, int idx, int len) { return 0; } 194static inline int log_buf_copy(char *dest, int idx, int len) { return 0; }
195#endif 195#endif
196 196
197extern void __attribute__((format(printf, 1, 2)))
198 early_printk(const char *fmt, ...);
199
197unsigned long int_sqrt(unsigned long); 200unsigned long int_sqrt(unsigned long);
198 201
199extern int printk_ratelimit(void); 202extern int printk_ratelimit(void);
diff --git a/include/linux/key.h b/include/linux/key.h
index fcdbd5ed227b..a70b8a8f2005 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -290,7 +290,7 @@ extern void key_init(void);
290#define key_get(k) ({ NULL; }) 290#define key_get(k) ({ NULL; })
291#define key_put(k) do { } while(0) 291#define key_put(k) do { } while(0)
292#define key_ref_put(k) do { } while(0) 292#define key_ref_put(k) do { } while(0)
293#define make_key_ref(k) ({ NULL; }) 293#define make_key_ref(k, p) ({ NULL; })
294#define key_ref_to_ptr(k) ({ NULL; }) 294#define key_ref_to_ptr(k) ({ NULL; })
295#define is_key_possessed(k) 0 295#define is_key_possessed(k) 0
296#define alloc_uid_keyring(u,c) 0 296#define alloc_uid_keyring(u,c) 0
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index 4a0d27f475d7..caa3f411f15d 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -3,15 +3,14 @@
3 * 3 *
4 * Copyright (c) 2002-2003 Patrick Mochel 4 * Copyright (c) 2002-2003 Patrick Mochel
5 * Copyright (c) 2002-2003 Open Source Development Labs 5 * Copyright (c) 2002-2003 Open Source Development Labs
6 * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com> 6 * Copyright (c) 2006-2008 Greg Kroah-Hartman <greg@kroah.com>
7 * Copyright (c) 2006-2007 Novell Inc. 7 * Copyright (c) 2006-2008 Novell Inc.
8 * 8 *
9 * This file is released under the GPLv2. 9 * This file is released under the GPLv2.
10 * 10 *
11 *
12 * Please read Documentation/kobject.txt before using the kobject 11 * Please read Documentation/kobject.txt before using the kobject
13 * interface, ESPECIALLY the parts about reference counts and object 12 * interface, ESPECIALLY the parts about reference counts and object
14 * destructors. 13 * destructors.
15 */ 14 */
16 15
17#ifndef _KOBJECT_H_ 16#ifndef _KOBJECT_H_
@@ -61,48 +60,54 @@ enum kobject_action {
61}; 60};
62 61
63struct kobject { 62struct kobject {
64 const char * k_name; 63 const char *name;
65 struct kref kref; 64 struct kref kref;
66 struct list_head entry; 65 struct list_head entry;
67 struct kobject * parent; 66 struct kobject *parent;
68 struct kset * kset; 67 struct kset *kset;
69 struct kobj_type * ktype; 68 struct kobj_type *ktype;
70 struct sysfs_dirent * sd; 69 struct sysfs_dirent *sd;
70 unsigned int state_initialized:1;
71 unsigned int state_in_sysfs:1;
72 unsigned int state_add_uevent_sent:1;
73 unsigned int state_remove_uevent_sent:1;
71}; 74};
72 75
73extern int kobject_set_name(struct kobject *, const char *, ...) 76extern int kobject_set_name(struct kobject *kobj, const char *name, ...)
74 __attribute__((format(printf,2,3))); 77 __attribute__((format(printf, 2, 3)));
75 78
76static inline const char * kobject_name(const struct kobject * kobj) 79static inline const char *kobject_name(const struct kobject *kobj)
77{ 80{
78 return kobj->k_name; 81 return kobj->name;
79} 82}
80 83
81extern void kobject_init(struct kobject *); 84extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype);
82extern void kobject_cleanup(struct kobject *); 85extern int __must_check kobject_add(struct kobject *kobj,
86 struct kobject *parent,
87 const char *fmt, ...);
88extern int __must_check kobject_init_and_add(struct kobject *kobj,
89 struct kobj_type *ktype,
90 struct kobject *parent,
91 const char *fmt, ...);
92
93extern void kobject_del(struct kobject *kobj);
83 94
84extern int __must_check kobject_add(struct kobject *); 95extern struct kobject * __must_check kobject_create(void);
85extern void kobject_del(struct kobject *); 96extern struct kobject * __must_check kobject_create_and_add(const char *name,
97 struct kobject *parent);
86 98
87extern int __must_check kobject_rename(struct kobject *, const char *new_name); 99extern int __must_check kobject_rename(struct kobject *, const char *new_name);
88extern int __must_check kobject_move(struct kobject *, struct kobject *); 100extern int __must_check kobject_move(struct kobject *, struct kobject *);
89 101
90extern int __must_check kobject_register(struct kobject *); 102extern struct kobject *kobject_get(struct kobject *kobj);
91extern void kobject_unregister(struct kobject *); 103extern void kobject_put(struct kobject *kobj);
92
93extern struct kobject * kobject_get(struct kobject *);
94extern void kobject_put(struct kobject *);
95
96extern struct kobject *kobject_kset_add_dir(struct kset *kset,
97 struct kobject *, const char *);
98extern struct kobject *kobject_add_dir(struct kobject *, const char *);
99 104
100extern char * kobject_get_path(struct kobject *, gfp_t); 105extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);
101 106
102struct kobj_type { 107struct kobj_type {
103 void (*release)(struct kobject *); 108 void (*release)(struct kobject *kobj);
104 struct sysfs_ops * sysfs_ops; 109 struct sysfs_ops *sysfs_ops;
105 struct attribute ** default_attrs; 110 struct attribute **default_attrs;
106}; 111};
107 112
108struct kobj_uevent_env { 113struct kobj_uevent_env {
@@ -119,6 +124,16 @@ struct kset_uevent_ops {
119 struct kobj_uevent_env *env); 124 struct kobj_uevent_env *env);
120}; 125};
121 126
127struct kobj_attribute {
128 struct attribute attr;
129 ssize_t (*show)(struct kobject *kobj, struct kobj_attribute *attr,
130 char *buf);
131 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
132 const char *buf, size_t count);
133};
134
135extern struct sysfs_ops kobj_sysfs_ops;
136
122/** 137/**
123 * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem. 138 * struct kset - a set of kobjects of a specific type, belonging to a specific subsystem.
124 * 139 *
@@ -128,7 +143,6 @@ struct kset_uevent_ops {
128 * define the attribute callbacks and other common events that happen to 143 * define the attribute callbacks and other common events that happen to
129 * a kobject. 144 * a kobject.
130 * 145 *
131 * @ktype: the struct kobj_type for this specific kset
132 * @list: the list of all kobjects for this kset 146 * @list: the list of all kobjects for this kset
133 * @list_lock: a lock for iterating over the kobjects 147 * @list_lock: a lock for iterating over the kobjects
134 * @kobj: the embedded kobject for this kset (recursion, isn't it fun...) 148 * @kobj: the embedded kobject for this kset (recursion, isn't it fun...)
@@ -138,99 +152,49 @@ struct kset_uevent_ops {
138 * desired. 152 * desired.
139 */ 153 */
140struct kset { 154struct kset {
141 struct kobj_type *ktype; 155 struct list_head list;
142 struct list_head list; 156 spinlock_t list_lock;
143 spinlock_t list_lock; 157 struct kobject kobj;
144 struct kobject kobj; 158 struct kset_uevent_ops *uevent_ops;
145 struct kset_uevent_ops *uevent_ops;
146}; 159};
147 160
161extern void kset_init(struct kset *kset);
162extern int __must_check kset_register(struct kset *kset);
163extern void kset_unregister(struct kset *kset);
164extern struct kset * __must_check kset_create_and_add(const char *name,
165 struct kset_uevent_ops *u,
166 struct kobject *parent_kobj);
148 167
149extern void kset_init(struct kset * k); 168static inline struct kset *to_kset(struct kobject *kobj)
150extern int __must_check kset_add(struct kset * k);
151extern int __must_check kset_register(struct kset * k);
152extern void kset_unregister(struct kset * k);
153
154static inline struct kset * to_kset(struct kobject * kobj)
155{ 169{
156 return kobj ? container_of(kobj,struct kset,kobj) : NULL; 170 return kobj ? container_of(kobj, struct kset, kobj) : NULL;
157} 171}
158 172
159static inline struct kset * kset_get(struct kset * k) 173static inline struct kset *kset_get(struct kset *k)
160{ 174{
161 return k ? to_kset(kobject_get(&k->kobj)) : NULL; 175 return k ? to_kset(kobject_get(&k->kobj)) : NULL;
162} 176}
163 177
164static inline void kset_put(struct kset * k) 178static inline void kset_put(struct kset *k)
165{ 179{
166 kobject_put(&k->kobj); 180 kobject_put(&k->kobj);
167} 181}
168 182
169static inline struct kobj_type * get_ktype(struct kobject * k) 183static inline struct kobj_type *get_ktype(struct kobject *kobj)
170{ 184{
171 if (k->kset && k->kset->ktype) 185 return kobj->ktype;
172 return k->kset->ktype;
173 else
174 return k->ktype;
175} 186}
176 187
177extern struct kobject * kset_find_obj(struct kset *, const char *); 188extern struct kobject *kset_find_obj(struct kset *, const char *);
178
179
180/*
181 * Use this when initializing an embedded kset with no other
182 * fields to initialize.
183 */
184#define set_kset_name(str) .kset = { .kobj = { .k_name = str } }
185
186
187#define decl_subsys(_name,_type,_uevent_ops) \
188struct kset _name##_subsys = { \
189 .kobj = { .k_name = __stringify(_name) }, \
190 .ktype = _type, \
191 .uevent_ops =_uevent_ops, \
192}
193#define decl_subsys_name(_varname,_name,_type,_uevent_ops) \
194struct kset _varname##_subsys = { \
195 .kobj = { .k_name = __stringify(_name) }, \
196 .ktype = _type, \
197 .uevent_ops =_uevent_ops, \
198}
199
200/* The global /sys/kernel/ subsystem for people to chain off of */
201extern struct kset kernel_subsys;
202/* The global /sys/hypervisor/ subsystem */
203extern struct kset hypervisor_subsys;
204
205/*
206 * Helpers for setting the kset of registered objects.
207 * Often, a registered object belongs to a kset embedded in a
208 * subsystem. These do no magic, just make the resulting code
209 * easier to follow.
210 */
211
212/**
213 * kobj_set_kset_s(obj,subsys) - set kset for embedded kobject.
214 * @obj: ptr to some object type.
215 * @subsys: a subsystem object (not a ptr).
216 *
217 * Can be used for any object type with an embedded ->kobj.
218 */
219
220#define kobj_set_kset_s(obj,subsys) \
221 (obj)->kobj.kset = &(subsys)
222
223extern int __must_check subsystem_register(struct kset *);
224extern void subsystem_unregister(struct kset *);
225
226struct subsys_attribute {
227 struct attribute attr;
228 ssize_t (*show)(struct kset *, char *);
229 ssize_t (*store)(struct kset *, const char *, size_t);
230};
231 189
232extern int __must_check subsys_create_file(struct kset *, 190/* The global /sys/kernel/ kobject for people to chain off of */
233 struct subsys_attribute *); 191extern struct kobject *kernel_kobj;
192/* The global /sys/hypervisor/ kobject for people to chain off of */
193extern struct kobject *hypervisor_kobj;
194/* The global /sys/power/ kobject for people to chain off of */
195extern struct kobject *power_kobj;
196/* The global /sys/firmware/ kobject for people to chain off of */
197extern struct kobject *firmware_kobj;
234 198
235#if defined(CONFIG_HOTPLUG) 199#if defined(CONFIG_HOTPLUG)
236int kobject_uevent(struct kobject *kobj, enum kobject_action action); 200int kobject_uevent(struct kobject *kobj, enum kobject_action action);
@@ -243,18 +207,20 @@ int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...)
243int kobject_action_type(const char *buf, size_t count, 207int kobject_action_type(const char *buf, size_t count,
244 enum kobject_action *type); 208 enum kobject_action *type);
245#else 209#else
246static inline int kobject_uevent(struct kobject *kobj, enum kobject_action action) 210static inline int kobject_uevent(struct kobject *kobj,
211 enum kobject_action action)
247{ return 0; } 212{ return 0; }
248static inline int kobject_uevent_env(struct kobject *kobj, 213static inline int kobject_uevent_env(struct kobject *kobj,
249 enum kobject_action action, 214 enum kobject_action action,
250 char *envp[]) 215 char *envp[])
251{ return 0; } 216{ return 0; }
252 217
253static inline int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) 218static inline int add_uevent_var(struct kobj_uevent_env *env,
219 const char *format, ...)
254{ return 0; } 220{ return 0; }
255 221
256static inline int kobject_action_type(const char *buf, size_t count, 222static inline int kobject_action_type(const char *buf, size_t count,
257 enum kobject_action *type) 223 enum kobject_action *type)
258{ return -EINVAL; } 224{ return -EINVAL; }
259#endif 225#endif
260 226
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 81891581e89b..6168c0a44172 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -182,6 +182,15 @@ static inline void kretprobe_assert(struct kretprobe_instance *ri,
182 } 182 }
183} 183}
184 184
185#ifdef CONFIG_KPROBES_SANITY_TEST
186extern int init_test_probes(void);
187#else
188static inline int init_test_probes(void)
189{
190 return 0;
191}
192#endif /* CONFIG_KPROBES_SANITY_TEST */
193
185extern spinlock_t kretprobe_lock; 194extern spinlock_t kretprobe_lock;
186extern struct mutex kprobe_mutex; 195extern struct mutex kprobe_mutex;
187extern int arch_prepare_kprobe(struct kprobe *p); 196extern int arch_prepare_kprobe(struct kprobe *p);
@@ -227,6 +236,7 @@ void unregister_kretprobe(struct kretprobe *rp);
227 236
228void kprobe_flush_task(struct task_struct *tk); 237void kprobe_flush_task(struct task_struct *tk);
229void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head); 238void recycle_rp_inst(struct kretprobe_instance *ri, struct hlist_head *head);
239
230#else /* CONFIG_KPROBES */ 240#else /* CONFIG_KPROBES */
231 241
232#define __kprobes /**/ 242#define __kprobes /**/
diff --git a/include/linux/kref.h b/include/linux/kref.h
index 6fee3539893f..5d185635786e 100644
--- a/include/linux/kref.h
+++ b/include/linux/kref.h
@@ -24,6 +24,7 @@ struct kref {
24 atomic_t refcount; 24 atomic_t refcount;
25}; 25};
26 26
27void kref_set(struct kref *kref, int num);
27void kref_init(struct kref *kref); 28void kref_init(struct kref *kref);
28void kref_get(struct kref *kref); 29void kref_get(struct kref *kref);
29int kref_put(struct kref *kref, void (*release) (struct kref *kref)); 30int kref_put(struct kref *kref, void (*release) (struct kref *kref));
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 057a7f34ee36..4de4fd2d8607 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -9,12 +9,10 @@
9 9
10#include <asm/types.h> 10#include <asm/types.h>
11#include <linux/ioctl.h> 11#include <linux/ioctl.h>
12#include <asm/kvm.h>
12 13
13#define KVM_API_VERSION 12 14#define KVM_API_VERSION 12
14 15
15/* Architectural interrupt line count. */
16#define KVM_NR_INTERRUPTS 256
17
18/* for KVM_CREATE_MEMORY_REGION */ 16/* for KVM_CREATE_MEMORY_REGION */
19struct kvm_memory_region { 17struct kvm_memory_region {
20 __u32 slot; 18 __u32 slot;
@@ -23,17 +21,19 @@ struct kvm_memory_region {
23 __u64 memory_size; /* bytes */ 21 __u64 memory_size; /* bytes */
24}; 22};
25 23
26/* for kvm_memory_region::flags */ 24/* for KVM_SET_USER_MEMORY_REGION */
27#define KVM_MEM_LOG_DIRTY_PAGES 1UL 25struct kvm_userspace_memory_region {
28 26 __u32 slot;
29struct kvm_memory_alias {
30 __u32 slot; /* this has a different namespace than memory slots */
31 __u32 flags; 27 __u32 flags;
32 __u64 guest_phys_addr; 28 __u64 guest_phys_addr;
33 __u64 memory_size; 29 __u64 memory_size; /* bytes */
34 __u64 target_phys_addr; 30 __u64 userspace_addr; /* start of the userspace allocated memory */
35}; 31};
36 32
33/* for kvm_memory_region::flags */
34#define KVM_MEM_LOG_DIRTY_PAGES 1UL
35
36
37/* for KVM_IRQ_LINE */ 37/* for KVM_IRQ_LINE */
38struct kvm_irq_level { 38struct kvm_irq_level {
39 /* 39 /*
@@ -45,62 +45,18 @@ struct kvm_irq_level {
45 __u32 level; 45 __u32 level;
46}; 46};
47 47
48/* for KVM_GET_IRQCHIP and KVM_SET_IRQCHIP */
49struct kvm_pic_state {
50 __u8 last_irr; /* edge detection */
51 __u8 irr; /* interrupt request register */
52 __u8 imr; /* interrupt mask register */
53 __u8 isr; /* interrupt service register */
54 __u8 priority_add; /* highest irq priority */
55 __u8 irq_base;
56 __u8 read_reg_select;
57 __u8 poll;
58 __u8 special_mask;
59 __u8 init_state;
60 __u8 auto_eoi;
61 __u8 rotate_on_auto_eoi;
62 __u8 special_fully_nested_mode;
63 __u8 init4; /* true if 4 byte init */
64 __u8 elcr; /* PIIX edge/trigger selection */
65 __u8 elcr_mask;
66};
67
68#define KVM_IOAPIC_NUM_PINS 24
69struct kvm_ioapic_state {
70 __u64 base_address;
71 __u32 ioregsel;
72 __u32 id;
73 __u32 irr;
74 __u32 pad;
75 union {
76 __u64 bits;
77 struct {
78 __u8 vector;
79 __u8 delivery_mode:3;
80 __u8 dest_mode:1;
81 __u8 delivery_status:1;
82 __u8 polarity:1;
83 __u8 remote_irr:1;
84 __u8 trig_mode:1;
85 __u8 mask:1;
86 __u8 reserve:7;
87 __u8 reserved[4];
88 __u8 dest_id;
89 } fields;
90 } redirtbl[KVM_IOAPIC_NUM_PINS];
91};
92
93#define KVM_IRQCHIP_PIC_MASTER 0
94#define KVM_IRQCHIP_PIC_SLAVE 1
95#define KVM_IRQCHIP_IOAPIC 2
96 48
97struct kvm_irqchip { 49struct kvm_irqchip {
98 __u32 chip_id; 50 __u32 chip_id;
99 __u32 pad; 51 __u32 pad;
100 union { 52 union {
101 char dummy[512]; /* reserving space */ 53 char dummy[512]; /* reserving space */
54#ifdef CONFIG_X86
102 struct kvm_pic_state pic; 55 struct kvm_pic_state pic;
56#endif
57#if defined(CONFIG_X86) || defined(CONFIG_IA64)
103 struct kvm_ioapic_state ioapic; 58 struct kvm_ioapic_state ioapic;
59#endif
104 } chip; 60 } chip;
105}; 61};
106 62
@@ -116,6 +72,7 @@ struct kvm_irqchip {
116#define KVM_EXIT_FAIL_ENTRY 9 72#define KVM_EXIT_FAIL_ENTRY 9
117#define KVM_EXIT_INTR 10 73#define KVM_EXIT_INTR 10
118#define KVM_EXIT_SET_TPR 11 74#define KVM_EXIT_SET_TPR 11
75#define KVM_EXIT_TPR_ACCESS 12
119 76
120/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */ 77/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
121struct kvm_run { 78struct kvm_run {
@@ -174,90 +131,17 @@ struct kvm_run {
174 __u32 longmode; 131 __u32 longmode;
175 __u32 pad; 132 __u32 pad;
176 } hypercall; 133 } hypercall;
134 /* KVM_EXIT_TPR_ACCESS */
135 struct {
136 __u64 rip;
137 __u32 is_write;
138 __u32 pad;
139 } tpr_access;
177 /* Fix the size of the union. */ 140 /* Fix the size of the union. */
178 char padding[256]; 141 char padding[256];
179 }; 142 };
180}; 143};
181 144
182/* for KVM_GET_REGS and KVM_SET_REGS */
183struct kvm_regs {
184 /* out (KVM_GET_REGS) / in (KVM_SET_REGS) */
185 __u64 rax, rbx, rcx, rdx;
186 __u64 rsi, rdi, rsp, rbp;
187 __u64 r8, r9, r10, r11;
188 __u64 r12, r13, r14, r15;
189 __u64 rip, rflags;
190};
191
192/* for KVM_GET_FPU and KVM_SET_FPU */
193struct kvm_fpu {
194 __u8 fpr[8][16];
195 __u16 fcw;
196 __u16 fsw;
197 __u8 ftwx; /* in fxsave format */
198 __u8 pad1;
199 __u16 last_opcode;
200 __u64 last_ip;
201 __u64 last_dp;
202 __u8 xmm[16][16];
203 __u32 mxcsr;
204 __u32 pad2;
205};
206
207/* for KVM_GET_LAPIC and KVM_SET_LAPIC */
208#define KVM_APIC_REG_SIZE 0x400
209struct kvm_lapic_state {
210 char regs[KVM_APIC_REG_SIZE];
211};
212
213struct kvm_segment {
214 __u64 base;
215 __u32 limit;
216 __u16 selector;
217 __u8 type;
218 __u8 present, dpl, db, s, l, g, avl;
219 __u8 unusable;
220 __u8 padding;
221};
222
223struct kvm_dtable {
224 __u64 base;
225 __u16 limit;
226 __u16 padding[3];
227};
228
229/* for KVM_GET_SREGS and KVM_SET_SREGS */
230struct kvm_sregs {
231 /* out (KVM_GET_SREGS) / in (KVM_SET_SREGS) */
232 struct kvm_segment cs, ds, es, fs, gs, ss;
233 struct kvm_segment tr, ldt;
234 struct kvm_dtable gdt, idt;
235 __u64 cr0, cr2, cr3, cr4, cr8;
236 __u64 efer;
237 __u64 apic_base;
238 __u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
239};
240
241struct kvm_msr_entry {
242 __u32 index;
243 __u32 reserved;
244 __u64 data;
245};
246
247/* for KVM_GET_MSRS and KVM_SET_MSRS */
248struct kvm_msrs {
249 __u32 nmsrs; /* number of msrs in entries */
250 __u32 pad;
251
252 struct kvm_msr_entry entries[0];
253};
254
255/* for KVM_GET_MSR_INDEX_LIST */
256struct kvm_msr_list {
257 __u32 nmsrs; /* number of msrs in entries */
258 __u32 indices[0];
259};
260
261/* for KVM_TRANSLATE */ 145/* for KVM_TRANSLATE */
262struct kvm_translation { 146struct kvm_translation {
263 /* in */ 147 /* in */
@@ -302,28 +186,24 @@ struct kvm_dirty_log {
302 }; 186 };
303}; 187};
304 188
305struct kvm_cpuid_entry {
306 __u32 function;
307 __u32 eax;
308 __u32 ebx;
309 __u32 ecx;
310 __u32 edx;
311 __u32 padding;
312};
313
314/* for KVM_SET_CPUID */
315struct kvm_cpuid {
316 __u32 nent;
317 __u32 padding;
318 struct kvm_cpuid_entry entries[0];
319};
320
321/* for KVM_SET_SIGNAL_MASK */ 189/* for KVM_SET_SIGNAL_MASK */
322struct kvm_signal_mask { 190struct kvm_signal_mask {
323 __u32 len; 191 __u32 len;
324 __u8 sigset[0]; 192 __u8 sigset[0];
325}; 193};
326 194
195/* for KVM_TPR_ACCESS_REPORTING */
196struct kvm_tpr_access_ctl {
197 __u32 enabled;
198 __u32 flags;
199 __u32 reserved[8];
200};
201
202/* for KVM_SET_VAPIC_ADDR */
203struct kvm_vapic_addr {
204 __u64 vapic_addr;
205};
206
327#define KVMIO 0xAE 207#define KVMIO 0xAE
328 208
329/* 209/*
@@ -347,11 +227,21 @@ struct kvm_signal_mask {
347 */ 227 */
348#define KVM_CAP_IRQCHIP 0 228#define KVM_CAP_IRQCHIP 0
349#define KVM_CAP_HLT 1 229#define KVM_CAP_HLT 1
230#define KVM_CAP_MMU_SHADOW_CACHE_CONTROL 2
231#define KVM_CAP_USER_MEMORY 3
232#define KVM_CAP_SET_TSS_ADDR 4
233#define KVM_CAP_EXT_CPUID 5
234#define KVM_CAP_VAPIC 6
350 235
351/* 236/*
352 * ioctls for VM fds 237 * ioctls for VM fds
353 */ 238 */
354#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region) 239#define KVM_SET_MEMORY_REGION _IOW(KVMIO, 0x40, struct kvm_memory_region)
240#define KVM_SET_NR_MMU_PAGES _IO(KVMIO, 0x44)
241#define KVM_GET_NR_MMU_PAGES _IO(KVMIO, 0x45)
242#define KVM_SET_USER_MEMORY_REGION _IOW(KVMIO, 0x46,\
243 struct kvm_userspace_memory_region)
244#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
355/* 245/*
356 * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns 246 * KVM_CREATE_VCPU receives as a parameter the vcpu slot, and returns
357 * a vcpu fd. 247 * a vcpu fd.
@@ -359,6 +249,7 @@ struct kvm_signal_mask {
359#define KVM_CREATE_VCPU _IO(KVMIO, 0x41) 249#define KVM_CREATE_VCPU _IO(KVMIO, 0x41)
360#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log) 250#define KVM_GET_DIRTY_LOG _IOW(KVMIO, 0x42, struct kvm_dirty_log)
361#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias) 251#define KVM_SET_MEMORY_ALIAS _IOW(KVMIO, 0x43, struct kvm_memory_alias)
252#define KVM_GET_SUPPORTED_CPUID _IOWR(KVMIO, 0x48, struct kvm_cpuid2)
362/* Device model IOC */ 253/* Device model IOC */
363#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60) 254#define KVM_CREATE_IRQCHIP _IO(KVMIO, 0x60)
364#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level) 255#define KVM_IRQ_LINE _IOW(KVMIO, 0x61, struct kvm_irq_level)
@@ -384,5 +275,11 @@ struct kvm_signal_mask {
384#define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu) 275#define KVM_SET_FPU _IOW(KVMIO, 0x8d, struct kvm_fpu)
385#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state) 276#define KVM_GET_LAPIC _IOR(KVMIO, 0x8e, struct kvm_lapic_state)
386#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state) 277#define KVM_SET_LAPIC _IOW(KVMIO, 0x8f, struct kvm_lapic_state)
278#define KVM_SET_CPUID2 _IOW(KVMIO, 0x90, struct kvm_cpuid2)
279#define KVM_GET_CPUID2 _IOWR(KVMIO, 0x91, struct kvm_cpuid2)
280/* Available with KVM_CAP_VAPIC */
281#define KVM_TPR_ACCESS_REPORTING _IOWR(KVMIO, 0x92, struct kvm_tpr_access_ctl)
282/* Available with KVM_CAP_VAPIC */
283#define KVM_SET_VAPIC_ADDR _IOW(KVMIO, 0x93, struct kvm_vapic_addr)
387 284
388#endif 285#endif
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
new file mode 100644
index 000000000000..ea4764b0a2f4
--- /dev/null
+++ b/include/linux/kvm_host.h
@@ -0,0 +1,299 @@
1#ifndef __KVM_HOST_H
2#define __KVM_HOST_H
3
4/*
5 * This work is licensed under the terms of the GNU GPL, version 2. See
6 * the COPYING file in the top-level directory.
7 */
8
9#include <linux/types.h>
10#include <linux/hardirq.h>
11#include <linux/list.h>
12#include <linux/mutex.h>
13#include <linux/spinlock.h>
14#include <linux/signal.h>
15#include <linux/sched.h>
16#include <linux/mm.h>
17#include <linux/preempt.h>
18#include <asm/signal.h>
19
20#include <linux/kvm.h>
21#include <linux/kvm_para.h>
22
23#include <linux/kvm_types.h>
24
25#include <asm/kvm_host.h>
26
27#define KVM_MAX_VCPUS 4
28#define KVM_MEMORY_SLOTS 8
29/* memory slots that does not exposed to userspace */
30#define KVM_PRIVATE_MEM_SLOTS 4
31
32#define KVM_PIO_PAGE_OFFSET 1
33
34/*
35 * vcpu->requests bit members
36 */
37#define KVM_REQ_TLB_FLUSH 0
38#define KVM_REQ_MIGRATE_TIMER 1
39#define KVM_REQ_REPORT_TPR_ACCESS 2
40
41struct kvm_vcpu;
42extern struct kmem_cache *kvm_vcpu_cache;
43
44struct kvm_guest_debug {
45 int enabled;
46 unsigned long bp[4];
47 int singlestep;
48};
49
50/*
51 * It would be nice to use something smarter than a linear search, TBD...
52 * Thankfully we dont expect many devices to register (famous last words :),
53 * so until then it will suffice. At least its abstracted so we can change
54 * in one place.
55 */
56struct kvm_io_bus {
57 int dev_count;
58#define NR_IOBUS_DEVS 6
59 struct kvm_io_device *devs[NR_IOBUS_DEVS];
60};
61
62void kvm_io_bus_init(struct kvm_io_bus *bus);
63void kvm_io_bus_destroy(struct kvm_io_bus *bus);
64struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus, gpa_t addr);
65void kvm_io_bus_register_dev(struct kvm_io_bus *bus,
66 struct kvm_io_device *dev);
67
68struct kvm_vcpu {
69 struct kvm *kvm;
70 struct preempt_notifier preempt_notifier;
71 int vcpu_id;
72 struct mutex mutex;
73 int cpu;
74 struct kvm_run *run;
75 int guest_mode;
76 unsigned long requests;
77 struct kvm_guest_debug guest_debug;
78 int fpu_active;
79 int guest_fpu_loaded;
80 wait_queue_head_t wq;
81 int sigset_active;
82 sigset_t sigset;
83 struct kvm_vcpu_stat stat;
84
85#ifdef CONFIG_HAS_IOMEM
86 int mmio_needed;
87 int mmio_read_completed;
88 int mmio_is_write;
89 int mmio_size;
90 unsigned char mmio_data[8];
91 gpa_t mmio_phys_addr;
92#endif
93
94 struct kvm_vcpu_arch arch;
95};
96
97struct kvm_memory_slot {
98 gfn_t base_gfn;
99 unsigned long npages;
100 unsigned long flags;
101 unsigned long *rmap;
102 unsigned long *dirty_bitmap;
103 unsigned long userspace_addr;
104 int user_alloc;
105};
106
107struct kvm {
108 struct mutex lock; /* protects the vcpus array and APIC accesses */
109 spinlock_t mmu_lock;
110 struct mm_struct *mm; /* userspace tied to this vm */
111 int nmemslots;
112 struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS +
113 KVM_PRIVATE_MEM_SLOTS];
114 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
115 struct list_head vm_list;
116 struct file *filp;
117 struct kvm_io_bus mmio_bus;
118 struct kvm_io_bus pio_bus;
119 struct kvm_vm_stat stat;
120 struct kvm_arch arch;
121};
122
123/* The guest did something we don't support. */
124#define pr_unimpl(vcpu, fmt, ...) \
125 do { \
126 if (printk_ratelimit()) \
127 printk(KERN_ERR "kvm: %i: cpu%i " fmt, \
128 current->tgid, (vcpu)->vcpu_id , ## __VA_ARGS__); \
129 } while (0)
130
131#define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt)
132#define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt)
133
134int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
135void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
136
137void vcpu_load(struct kvm_vcpu *vcpu);
138void vcpu_put(struct kvm_vcpu *vcpu);
139
140void decache_vcpus_on_cpu(int cpu);
141
142
143int kvm_init(void *opaque, unsigned int vcpu_size,
144 struct module *module);
145void kvm_exit(void);
146
147#define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
148#define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB)
149static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
150struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);
151
152extern struct page *bad_page;
153
154int is_error_page(struct page *page);
155int kvm_is_error_hva(unsigned long addr);
156int kvm_set_memory_region(struct kvm *kvm,
157 struct kvm_userspace_memory_region *mem,
158 int user_alloc);
159int __kvm_set_memory_region(struct kvm *kvm,
160 struct kvm_userspace_memory_region *mem,
161 int user_alloc);
162int kvm_arch_set_memory_region(struct kvm *kvm,
163 struct kvm_userspace_memory_region *mem,
164 struct kvm_memory_slot old,
165 int user_alloc);
166gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn);
167struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
168void kvm_release_page_clean(struct page *page);
169void kvm_release_page_dirty(struct page *page);
170int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
171 int len);
172int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data,
173 unsigned long len);
174int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
175int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data,
176 int offset, int len);
177int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
178 unsigned long len);
179int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
180int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
181struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
182int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
183void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
184
185void kvm_vcpu_block(struct kvm_vcpu *vcpu);
186void kvm_resched(struct kvm_vcpu *vcpu);
187void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
188void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
189void kvm_flush_remote_tlbs(struct kvm *kvm);
190
191long kvm_arch_dev_ioctl(struct file *filp,
192 unsigned int ioctl, unsigned long arg);
193long kvm_arch_vcpu_ioctl(struct file *filp,
194 unsigned int ioctl, unsigned long arg);
195void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
196void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
197
198int kvm_dev_ioctl_check_extension(long ext);
199
200int kvm_get_dirty_log(struct kvm *kvm,
201 struct kvm_dirty_log *log, int *is_dirty);
202int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
203 struct kvm_dirty_log *log);
204
205int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
206 struct
207 kvm_userspace_memory_region *mem,
208 int user_alloc);
209long kvm_arch_vm_ioctl(struct file *filp,
210 unsigned int ioctl, unsigned long arg);
211void kvm_arch_destroy_vm(struct kvm *kvm);
212
213int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
214int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
215
216int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
217 struct kvm_translation *tr);
218
219int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
220int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
221int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
222 struct kvm_sregs *sregs);
223int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
224 struct kvm_sregs *sregs);
225int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
226 struct kvm_debug_guest *dbg);
227int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
228
229int kvm_arch_init(void *opaque);
230void kvm_arch_exit(void);
231
232int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
233void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu);
234
235void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
236void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
237void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
238struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
239int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu);
240void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu);
241
242int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu);
243void kvm_arch_hardware_enable(void *garbage);
244void kvm_arch_hardware_disable(void *garbage);
245int kvm_arch_hardware_setup(void);
246void kvm_arch_hardware_unsetup(void);
247void kvm_arch_check_processor_compat(void *rtn);
248int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
249
250void kvm_free_physmem(struct kvm *kvm);
251
252struct kvm *kvm_arch_create_vm(void);
253void kvm_arch_destroy_vm(struct kvm *kvm);
254
255int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
256int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
257void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
258
259static inline void kvm_guest_enter(void)
260{
261 account_system_vtime(current);
262 current->flags |= PF_VCPU;
263}
264
265static inline void kvm_guest_exit(void)
266{
267 account_system_vtime(current);
268 current->flags &= ~PF_VCPU;
269}
270
271static inline int memslot_id(struct kvm *kvm, struct kvm_memory_slot *slot)
272{
273 return slot - kvm->memslots;
274}
275
276static inline gpa_t gfn_to_gpa(gfn_t gfn)
277{
278 return (gpa_t)gfn << PAGE_SHIFT;
279}
280
281static inline void kvm_migrate_apic_timer(struct kvm_vcpu *vcpu)
282{
283 set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests);
284}
285
286enum kvm_stat_kind {
287 KVM_STAT_VM,
288 KVM_STAT_VCPU,
289};
290
291struct kvm_stats_debugfs_item {
292 const char *name;
293 int offset;
294 enum kvm_stat_kind kind;
295 struct dentry *dentry;
296};
297extern struct kvm_stats_debugfs_item debugfs_entries[];
298
299#endif
diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
index 3b292565a693..5497aac0d2f8 100644
--- a/include/linux/kvm_para.h
+++ b/include/linux/kvm_para.h
@@ -2,72 +2,30 @@
2#define __LINUX_KVM_PARA_H 2#define __LINUX_KVM_PARA_H
3 3
4/* 4/*
5 * Guest OS interface for KVM paravirtualization 5 * This header file provides a method for making a hypercall to the host
6 * 6 * Architectures should define:
7 * Note: this interface is totally experimental, and is certain to change 7 * - kvm_hypercall0, kvm_hypercall1...
8 * as we make progress. 8 * - kvm_arch_para_features
9 * - kvm_para_available
9 */ 10 */
10 11
11/* 12/* Return values for hypercalls */
12 * Per-VCPU descriptor area shared between guest and host. Writable to 13#define KVM_ENOSYS 1000
13 * both guest and host. Registered with the host by the guest when
14 * a guest acknowledges paravirtual mode.
15 *
16 * NOTE: all addresses are guest-physical addresses (gpa), to make it
17 * easier for the hypervisor to map between the various addresses.
18 */
19struct kvm_vcpu_para_state {
20 /*
21 * API version information for compatibility. If there's any support
22 * mismatch (too old host trying to execute too new guest) then
23 * the host will deny entry into paravirtual mode. Any other
24 * combination (new host + old guest and new host + new guest)
25 * is supposed to work - new host versions will support all old
26 * guest API versions.
27 */
28 u32 guest_version;
29 u32 host_version;
30 u32 size;
31 u32 ret;
32
33 /*
34 * The address of the vm exit instruction (VMCALL or VMMCALL),
35 * which the host will patch according to the CPU model the
36 * VM runs on:
37 */
38 u64 hypercall_gpa;
39
40} __attribute__ ((aligned(PAGE_SIZE)));
41
42#define KVM_PARA_API_VERSION 1
43
44/*
45 * This is used for an RDMSR's ECX parameter to probe for a KVM host.
46 * Hopefully no CPU vendor will use up this number. This is placed well
47 * out of way of the typical space occupied by CPU vendors' MSR indices,
48 * and we think (or at least hope) it wont be occupied in the future
49 * either.
50 */
51#define MSR_KVM_API_MAGIC 0x87655678
52 14
53#define KVM_EINVAL 1 15#define KVM_HC_VAPIC_POLL_IRQ 1
54 16
55/* 17/*
56 * Hypercall calling convention: 18 * hypercalls use architecture specific
57 *
58 * Each hypercall may have 0-6 parameters.
59 *
60 * 64-bit hypercall index is in RAX, goes from 0 to __NR_hypercalls-1
61 *
62 * 64-bit parameters 1-6 are in the standard gcc x86_64 calling convention
63 * order: RDI, RSI, RDX, RCX, R8, R9.
64 *
65 * 32-bit index is EBX, parameters are: EAX, ECX, EDX, ESI, EDI, EBP.
66 * (the first 3 are according to the gcc regparm calling convention)
67 *
68 * No registers are clobbered by the hypercall, except that the
69 * return value is in RAX.
70 */ 19 */
71#define __NR_hypercalls 0 20#include <asm/kvm_para.h>
21
22#ifdef __KERNEL__
23static inline int kvm_para_has_feature(unsigned int feature)
24{
25 if (kvm_arch_para_features() & (1UL << feature))
26 return 1;
27 return 0;
28}
29#endif /* __KERNEL__ */
30#endif /* __LINUX_KVM_PARA_H */
72 31
73#endif
diff --git a/include/linux/kvm_types.h b/include/linux/kvm_types.h
new file mode 100644
index 000000000000..1c4e46decb22
--- /dev/null
+++ b/include/linux/kvm_types.h
@@ -0,0 +1,54 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License.
5 *
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
10 *
11 * You should have received a copy of the GNU General Public License
12 * along with this program; if not, write to the Free Software
13 * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 *
15 */
16
17#ifndef __KVM_TYPES_H__
18#define __KVM_TYPES_H__
19
20#include <asm/types.h>
21
22/*
23 * Address types:
24 *
25 * gva - guest virtual address
26 * gpa - guest physical address
27 * gfn - guest frame number
28 * hva - host virtual address
29 * hpa - host physical address
30 * hfn - host frame number
31 */
32
33typedef unsigned long gva_t;
34typedef u64 gpa_t;
35typedef unsigned long gfn_t;
36
37typedef unsigned long hva_t;
38typedef u64 hpa_t;
39typedef unsigned long hfn_t;
40
41struct kvm_pio_request {
42 unsigned long count;
43 int cur_count;
44 struct page *guest_pages[2];
45 unsigned guest_page_offset;
46 int in;
47 int port;
48 int size;
49 int string;
50 int down;
51 int rep;
52};
53
54#endif /* __KVM_TYPES_H__ */
diff --git a/include/linux/latencytop.h b/include/linux/latencytop.h
new file mode 100644
index 000000000000..901c2d6377a8
--- /dev/null
+++ b/include/linux/latencytop.h
@@ -0,0 +1,44 @@
1/*
2 * latencytop.h: Infrastructure for displaying latency
3 *
4 * (C) Copyright 2008 Intel Corporation
5 * Author: Arjan van de Ven <arjan@linux.intel.com>
6 *
7 */
8
9#ifndef _INCLUDE_GUARD_LATENCYTOP_H_
10#define _INCLUDE_GUARD_LATENCYTOP_H_
11
12#ifdef CONFIG_LATENCYTOP
13
14#define LT_SAVECOUNT 32
15#define LT_BACKTRACEDEPTH 12
16
17struct latency_record {
18 unsigned long backtrace[LT_BACKTRACEDEPTH];
19 unsigned int count;
20 unsigned long time;
21 unsigned long max;
22};
23
24
25struct task_struct;
26
27void account_scheduler_latency(struct task_struct *task, int usecs, int inter);
28
29void clear_all_latency_tracing(struct task_struct *p);
30
31#else
32
33static inline void
34account_scheduler_latency(struct task_struct *task, int usecs, int inter)
35{
36}
37
38static inline void clear_all_latency_tracing(struct task_struct *p)
39{
40}
41
42#endif
43
44#endif
diff --git a/include/linux/leds.h b/include/linux/leds.h
index dc1178f6184b..b4130ff58d0c 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -14,6 +14,7 @@
14 14
15#include <linux/list.h> 15#include <linux/list.h>
16#include <linux/spinlock.h> 16#include <linux/spinlock.h>
17#include <linux/rwsem.h>
17 18
18struct device; 19struct device;
19/* 20/*
@@ -43,7 +44,7 @@ struct led_classdev {
43 44
44#ifdef CONFIG_LEDS_TRIGGERS 45#ifdef CONFIG_LEDS_TRIGGERS
45 /* Protects the trigger data below */ 46 /* Protects the trigger data below */
46 rwlock_t trigger_lock; 47 struct rw_semaphore trigger_lock;
47 48
48 struct led_trigger *trigger; 49 struct led_trigger *trigger;
49 struct list_head trig_list; 50 struct list_head trig_list;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 6fd24e03622e..4374c4277780 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -35,6 +35,7 @@
35#include <linux/workqueue.h> 35#include <linux/workqueue.h>
36#include <scsi/scsi_host.h> 36#include <scsi/scsi_host.h>
37#include <linux/acpi.h> 37#include <linux/acpi.h>
38#include <linux/cdrom.h>
38 39
39/* 40/*
40 * Define if arch has non-standard setup. This is a _PCI_ standard 41 * Define if arch has non-standard setup. This is a _PCI_ standard
@@ -119,6 +120,8 @@ enum {
119 ATA_DEF_BUSY_WAIT = 10000, 120 ATA_DEF_BUSY_WAIT = 10000,
120 ATA_SHORT_PAUSE = (HZ >> 6) + 1, 121 ATA_SHORT_PAUSE = (HZ >> 6) + 1,
121 122
123 ATAPI_MAX_DRAIN = 16 << 10,
124
122 ATA_SHT_EMULATED = 1, 125 ATA_SHT_EMULATED = 1,
123 ATA_SHT_CMD_PER_LUN = 1, 126 ATA_SHT_CMD_PER_LUN = 1,
124 ATA_SHT_THIS_ID = -1, 127 ATA_SHT_THIS_ID = -1,
@@ -133,15 +136,19 @@ enum {
133 ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */ 136 ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */
134 ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ 137 ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */
135 ATA_DFLAG_AN = (1 << 7), /* AN configured */ 138 ATA_DFLAG_AN = (1 << 7), /* AN configured */
139 ATA_DFLAG_HIPM = (1 << 8), /* device supports HIPM */
140 ATA_DFLAG_DIPM = (1 << 9), /* device supports DIPM */
136 ATA_DFLAG_CFG_MASK = (1 << 12) - 1, 141 ATA_DFLAG_CFG_MASK = (1 << 12) - 1,
137 142
138 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */ 143 ATA_DFLAG_PIO = (1 << 12), /* device limited to PIO mode */
139 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */ 144 ATA_DFLAG_NCQ_OFF = (1 << 13), /* device limited to non-NCQ mode */
140 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */ 145 ATA_DFLAG_SPUNDOWN = (1 << 14), /* XXX: for spindown_compat */
141 ATA_DFLAG_INIT_MASK = (1 << 16) - 1, 146 ATA_DFLAG_SLEEPING = (1 << 15), /* device is sleeping */
147 ATA_DFLAG_DUBIOUS_XFER = (1 << 16), /* data transfer not verified */
148 ATA_DFLAG_INIT_MASK = (1 << 24) - 1,
142 149
143 ATA_DFLAG_DETACH = (1 << 16), 150 ATA_DFLAG_DETACH = (1 << 24),
144 ATA_DFLAG_DETACHED = (1 << 17), 151 ATA_DFLAG_DETACHED = (1 << 25),
145 152
146 ATA_DEV_UNKNOWN = 0, /* unknown device */ 153 ATA_DEV_UNKNOWN = 0, /* unknown device */
147 ATA_DEV_ATA = 1, /* ATA device */ 154 ATA_DEV_ATA = 1, /* ATA device */
@@ -185,6 +192,7 @@ enum {
185 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */ 192 ATA_FLAG_ACPI_SATA = (1 << 17), /* need native SATA ACPI layout */
186 ATA_FLAG_AN = (1 << 18), /* controller supports AN */ 193 ATA_FLAG_AN = (1 << 18), /* controller supports AN */
187 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */ 194 ATA_FLAG_PMP = (1 << 19), /* controller supports PMP */
195 ATA_FLAG_IPM = (1 << 20), /* driver can handle IPM */
188 196
189 /* The following flag belongs to ap->pflags but is kept in 197 /* The following flag belongs to ap->pflags but is kept in
190 * ap->flags because it's referenced in many LLDs and will be 198 * ap->flags because it's referenced in many LLDs and will be
@@ -207,16 +215,15 @@ enum {
207 215
208 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */ 216 ATA_PFLAG_SUSPENDED = (1 << 17), /* port is suspended (power) */
209 ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */ 217 ATA_PFLAG_PM_PENDING = (1 << 18), /* PM operation pending */
210 ATA_PFLAG_GTM_VALID = (1 << 19), /* acpi_gtm data valid */ 218 ATA_PFLAG_INIT_GTM_VALID = (1 << 19), /* initial gtm data valid */
211 219
212 /* struct ata_queued_cmd flags */ 220 /* struct ata_queued_cmd flags */
213 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */ 221 ATA_QCFLAG_ACTIVE = (1 << 0), /* cmd not yet ack'd to scsi lyer */
214 ATA_QCFLAG_SG = (1 << 1), /* have s/g table? */ 222 ATA_QCFLAG_DMAMAP = (1 << 1), /* SG table is DMA mapped */
215 ATA_QCFLAG_SINGLE = (1 << 2), /* no s/g, just a single buffer */
216 ATA_QCFLAG_DMAMAP = ATA_QCFLAG_SG | ATA_QCFLAG_SINGLE,
217 ATA_QCFLAG_IO = (1 << 3), /* standard IO command */ 223 ATA_QCFLAG_IO = (1 << 3), /* standard IO command */
218 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */ 224 ATA_QCFLAG_RESULT_TF = (1 << 4), /* result TF requested */
219 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */ 225 ATA_QCFLAG_CLEAR_EXCL = (1 << 5), /* clear excl_link on completion */
226 ATA_QCFLAG_QUIET = (1 << 6), /* don't report device error */
220 227
221 ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */ 228 ATA_QCFLAG_FAILED = (1 << 16), /* cmd failed and is owned by EH */
222 ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */ 229 ATA_QCFLAG_SENSE_VALID = (1 << 17), /* sense data valid */
@@ -234,6 +241,13 @@ enum {
234 ATA_TMOUT_INTERNAL = 30 * HZ, 241 ATA_TMOUT_INTERNAL = 30 * HZ,
235 ATA_TMOUT_INTERNAL_QUICK = 5 * HZ, 242 ATA_TMOUT_INTERNAL_QUICK = 5 * HZ,
236 243
244 /* FIXME: GoVault needs 2s but we can't afford that without
245 * parallel probing. 800ms is enough for iVDR disk
246 * HHD424020F7SV00. Increase to 2secs when parallel probing
247 * is in place.
248 */
249 ATA_TMOUT_FF_WAIT = 4 * HZ / 5,
250
237 /* ATA bus states */ 251 /* ATA bus states */
238 BUS_UNKNOWN = 0, 252 BUS_UNKNOWN = 0,
239 BUS_DMA = 1, 253 BUS_DMA = 1,
@@ -252,19 +266,15 @@ enum {
252 PORT_DISABLED = 2, 266 PORT_DISABLED = 2,
253 267
254 /* encoding various smaller bitmaps into a single 268 /* encoding various smaller bitmaps into a single
255 * unsigned int bitmap 269 * unsigned long bitmap
256 */ 270 */
257 ATA_BITS_PIO = 7, 271 ATA_NR_PIO_MODES = 7,
258 ATA_BITS_MWDMA = 5, 272 ATA_NR_MWDMA_MODES = 5,
259 ATA_BITS_UDMA = 8, 273 ATA_NR_UDMA_MODES = 8,
260 274
261 ATA_SHIFT_PIO = 0, 275 ATA_SHIFT_PIO = 0,
262 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_BITS_PIO, 276 ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES,
263 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_BITS_MWDMA, 277 ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES,
264
265 ATA_MASK_PIO = ((1 << ATA_BITS_PIO) - 1) << ATA_SHIFT_PIO,
266 ATA_MASK_MWDMA = ((1 << ATA_BITS_MWDMA) - 1) << ATA_SHIFT_MWDMA,
267 ATA_MASK_UDMA = ((1 << ATA_BITS_UDMA) - 1) << ATA_SHIFT_UDMA,
268 278
269 /* size of buffer to pad xfers ending on unaligned boundaries */ 279 /* size of buffer to pad xfers ending on unaligned boundaries */
270 ATA_DMA_PAD_SZ = 4, 280 ATA_DMA_PAD_SZ = 4,
@@ -294,6 +304,7 @@ enum {
294 ATA_EHI_RESUME_LINK = (1 << 1), /* resume link (reset modifier) */ 304 ATA_EHI_RESUME_LINK = (1 << 1), /* resume link (reset modifier) */
295 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */ 305 ATA_EHI_NO_AUTOPSY = (1 << 2), /* no autopsy */
296 ATA_EHI_QUIET = (1 << 3), /* be quiet */ 306 ATA_EHI_QUIET = (1 << 3), /* be quiet */
307 ATA_EHI_LPM = (1 << 4), /* link power management action */
297 308
298 ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */ 309 ATA_EHI_DID_SOFTRESET = (1 << 16), /* already soft-reset this port */
299 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */ 310 ATA_EHI_DID_HARDRESET = (1 << 17), /* already soft-reset this port */
@@ -325,12 +336,30 @@ enum {
325 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */ 336 ATA_HORKAGE_BROKEN_HPA = (1 << 4), /* Broken HPA */
326 ATA_HORKAGE_SKIP_PM = (1 << 5), /* Skip PM operations */ 337 ATA_HORKAGE_SKIP_PM = (1 << 5), /* Skip PM operations */
327 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */ 338 ATA_HORKAGE_HPA_SIZE = (1 << 6), /* native size off by one */
339 ATA_HORKAGE_IPM = (1 << 7), /* Link PM problems */
340 ATA_HORKAGE_IVB = (1 << 8), /* cbl det validity bit bugs */
341 ATA_HORKAGE_STUCK_ERR = (1 << 9), /* stuck ERR on next PACKET */
328 342
329 /* DMA mask for user DMA control: User visible values; DO NOT 343 /* DMA mask for user DMA control: User visible values; DO NOT
330 renumber */ 344 renumber */
331 ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */ 345 ATA_DMA_MASK_ATA = (1 << 0), /* DMA on ATA Disk */
332 ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */ 346 ATA_DMA_MASK_ATAPI = (1 << 1), /* DMA on ATAPI */
333 ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */ 347 ATA_DMA_MASK_CFA = (1 << 2), /* DMA on CF Card */
348
349 /* ATAPI command types */
350 ATAPI_READ = 0, /* READs */
351 ATAPI_WRITE = 1, /* WRITEs */
352 ATAPI_READ_CD = 2, /* READ CD [MSF] */
353 ATAPI_MISC = 3, /* the rest */
354};
355
356enum ata_xfer_mask {
357 ATA_MASK_PIO = ((1LU << ATA_NR_PIO_MODES) - 1)
358 << ATA_SHIFT_PIO,
359 ATA_MASK_MWDMA = ((1LU << ATA_NR_MWDMA_MODES) - 1)
360 << ATA_SHIFT_MWDMA,
361 ATA_MASK_UDMA = ((1LU << ATA_NR_UDMA_MODES) - 1)
362 << ATA_SHIFT_UDMA,
334}; 363};
335 364
336enum hsm_task_states { 365enum hsm_task_states {
@@ -370,6 +399,18 @@ typedef int (*ata_reset_fn_t)(struct ata_link *link, unsigned int *classes,
370 unsigned long deadline); 399 unsigned long deadline);
371typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes); 400typedef void (*ata_postreset_fn_t)(struct ata_link *link, unsigned int *classes);
372 401
402/*
403 * host pm policy: If you alter this, you also need to alter libata-scsi.c
404 * (for the ascii descriptions)
405 */
406enum link_pm {
407 NOT_AVAILABLE,
408 MIN_POWER,
409 MAX_PERFORMANCE,
410 MEDIUM_POWER,
411};
412extern struct class_device_attribute class_device_attr_link_power_management_policy;
413
373struct ata_ioports { 414struct ata_ioports {
374 void __iomem *cmd_addr; 415 void __iomem *cmd_addr;
375 void __iomem *data_addr; 416 void __iomem *data_addr;
@@ -417,7 +458,7 @@ struct ata_queued_cmd {
417 unsigned int tag; 458 unsigned int tag;
418 unsigned int n_elem; 459 unsigned int n_elem;
419 unsigned int n_iter; 460 unsigned int n_iter;
420 unsigned int orig_n_elem; 461 unsigned int mapped_n_elem;
421 462
422 int dma_dir; 463 int dma_dir;
423 464
@@ -425,17 +466,18 @@ struct ata_queued_cmd {
425 unsigned int sect_size; 466 unsigned int sect_size;
426 467
427 unsigned int nbytes; 468 unsigned int nbytes;
469 unsigned int raw_nbytes;
428 unsigned int curbytes; 470 unsigned int curbytes;
429 471
430 struct scatterlist *cursg; 472 struct scatterlist *cursg;
431 unsigned int cursg_ofs; 473 unsigned int cursg_ofs;
432 474
475 struct scatterlist *last_sg;
476 struct scatterlist saved_last_sg;
433 struct scatterlist sgent; 477 struct scatterlist sgent;
434 struct scatterlist pad_sgent; 478 struct scatterlist extra_sg[2];
435 void *buf_virt;
436 479
437 /* DO NOT iterate over __sg manually, use ata_for_each_sg() */ 480 struct scatterlist *sg;
438 struct scatterlist *__sg;
439 481
440 unsigned int err_mask; 482 unsigned int err_mask;
441 struct ata_taskfile result_tf; 483 struct ata_taskfile result_tf;
@@ -452,7 +494,7 @@ struct ata_port_stats {
452}; 494};
453 495
454struct ata_ering_entry { 496struct ata_ering_entry {
455 int is_io; 497 unsigned int eflags;
456 unsigned int err_mask; 498 unsigned int err_mask;
457 u64 timestamp; 499 u64 timestamp;
458}; 500};
@@ -470,6 +512,7 @@ struct ata_device {
470 struct scsi_device *sdev; /* attached SCSI device */ 512 struct scsi_device *sdev; /* attached SCSI device */
471#ifdef CONFIG_ATA_ACPI 513#ifdef CONFIG_ATA_ACPI
472 acpi_handle acpi_handle; 514 acpi_handle acpi_handle;
515 union acpi_object *gtf_cache;
473#endif 516#endif
474 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */ 517 /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
475 u64 n_sectors; /* size of device, if ATA */ 518 u64 n_sectors; /* size of device, if ATA */
@@ -491,9 +534,9 @@ struct ata_device {
491 unsigned int cdb_len; 534 unsigned int cdb_len;
492 535
493 /* per-dev xfer mask */ 536 /* per-dev xfer mask */
494 unsigned int pio_mask; 537 unsigned long pio_mask;
495 unsigned int mwdma_mask; 538 unsigned long mwdma_mask;
496 unsigned int udma_mask; 539 unsigned long udma_mask;
497 540
498 /* for CHS addressing */ 541 /* for CHS addressing */
499 u16 cylinders; /* Number of cylinders */ 542 u16 cylinders; /* Number of cylinders */
@@ -529,6 +572,8 @@ struct ata_eh_context {
529 int tries[ATA_MAX_DEVICES]; 572 int tries[ATA_MAX_DEVICES];
530 unsigned int classes[ATA_MAX_DEVICES]; 573 unsigned int classes[ATA_MAX_DEVICES];
531 unsigned int did_probe_mask; 574 unsigned int did_probe_mask;
575 unsigned int saved_ncq_enabled;
576 u8 saved_xfer_mode[ATA_MAX_DEVICES];
532}; 577};
533 578
534struct ata_acpi_drive 579struct ata_acpi_drive
@@ -616,6 +661,7 @@ struct ata_port {
616 661
617 pm_message_t pm_mesg; 662 pm_message_t pm_mesg;
618 int *pm_result; 663 int *pm_result;
664 enum link_pm pm_policy;
619 665
620 struct timer_list fastdrain_timer; 666 struct timer_list fastdrain_timer;
621 unsigned long fastdrain_cnt; 667 unsigned long fastdrain_cnt;
@@ -624,7 +670,7 @@ struct ata_port {
624 670
625#ifdef CONFIG_ATA_ACPI 671#ifdef CONFIG_ATA_ACPI
626 acpi_handle acpi_handle; 672 acpi_handle acpi_handle;
627 struct ata_acpi_gtm acpi_gtm; 673 struct ata_acpi_gtm __acpi_init_gtm; /* use ata_acpi_init_gtm() */
628#endif 674#endif
629 u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */ 675 u8 sector_buf[ATA_SECT_SIZE]; /* owned by EH */
630}; 676};
@@ -654,7 +700,8 @@ struct ata_port_operations {
654 void (*bmdma_setup) (struct ata_queued_cmd *qc); 700 void (*bmdma_setup) (struct ata_queued_cmd *qc);
655 void (*bmdma_start) (struct ata_queued_cmd *qc); 701 void (*bmdma_start) (struct ata_queued_cmd *qc);
656 702
657 void (*data_xfer) (struct ata_device *, unsigned char *, unsigned int, int); 703 unsigned int (*data_xfer) (struct ata_device *dev, unsigned char *buf,
704 unsigned int buflen, int rw);
658 705
659 int (*qc_defer) (struct ata_queued_cmd *qc); 706 int (*qc_defer) (struct ata_queued_cmd *qc);
660 void (*qc_prep) (struct ata_queued_cmd *qc); 707 void (*qc_prep) (struct ata_queued_cmd *qc);
@@ -683,7 +730,8 @@ struct ata_port_operations {
683 730
684 int (*port_suspend) (struct ata_port *ap, pm_message_t mesg); 731 int (*port_suspend) (struct ata_port *ap, pm_message_t mesg);
685 int (*port_resume) (struct ata_port *ap); 732 int (*port_resume) (struct ata_port *ap);
686 733 int (*enable_pm) (struct ata_port *ap, enum link_pm policy);
734 void (*disable_pm) (struct ata_port *ap);
687 int (*port_start) (struct ata_port *ap); 735 int (*port_start) (struct ata_port *ap);
688 void (*port_stop) (struct ata_port *ap); 736 void (*port_stop) (struct ata_port *ap);
689 737
@@ -742,8 +790,6 @@ static inline int ata_port_is_dummy(struct ata_port *ap)
742 790
743extern void sata_print_link_status(struct ata_link *link); 791extern void sata_print_link_status(struct ata_link *link);
744extern void ata_port_probe(struct ata_port *); 792extern void ata_port_probe(struct ata_port *);
745extern void __sata_phy_reset(struct ata_port *ap);
746extern void sata_phy_reset(struct ata_port *ap);
747extern void ata_bus_reset(struct ata_port *ap); 793extern void ata_bus_reset(struct ata_port *ap);
748extern int sata_set_spd(struct ata_link *link); 794extern int sata_set_spd(struct ata_link *link);
749extern int sata_link_debounce(struct ata_link *link, 795extern int sata_link_debounce(struct ata_link *link,
@@ -799,9 +845,8 @@ extern void ata_host_resume(struct ata_host *host);
799extern int ata_ratelimit(void); 845extern int ata_ratelimit(void);
800extern int ata_busy_sleep(struct ata_port *ap, 846extern int ata_busy_sleep(struct ata_port *ap,
801 unsigned long timeout_pat, unsigned long timeout); 847 unsigned long timeout_pat, unsigned long timeout);
848extern void ata_wait_after_reset(struct ata_port *ap, unsigned long deadline);
802extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline); 849extern int ata_wait_ready(struct ata_port *ap, unsigned long deadline);
803extern void ata_port_queue_task(struct ata_port *ap, work_func_t fn,
804 void *data, unsigned long delay);
805extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val, 850extern u32 ata_wait_register(void __iomem *reg, u32 mask, u32 val,
806 unsigned long interval_msec, 851 unsigned long interval_msec,
807 unsigned long timeout_msec); 852 unsigned long timeout_msec);
@@ -816,6 +861,16 @@ extern void ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf);
816extern void ata_tf_to_fis(const struct ata_taskfile *tf, 861extern void ata_tf_to_fis(const struct ata_taskfile *tf,
817 u8 pmp, int is_cmd, u8 *fis); 862 u8 pmp, int is_cmd, u8 *fis);
818extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf); 863extern void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf);
864extern unsigned long ata_pack_xfermask(unsigned long pio_mask,
865 unsigned long mwdma_mask, unsigned long udma_mask);
866extern void ata_unpack_xfermask(unsigned long xfer_mask,
867 unsigned long *pio_mask, unsigned long *mwdma_mask,
868 unsigned long *udma_mask);
869extern u8 ata_xfer_mask2mode(unsigned long xfer_mask);
870extern unsigned long ata_xfer_mode2mask(u8 xfer_mode);
871extern int ata_xfer_mode2shift(unsigned long xfer_mode);
872extern const char *ata_mode_string(unsigned long xfer_mask);
873extern unsigned long ata_id_xfermask(const u16 *id);
819extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device); 874extern void ata_noop_dev_select(struct ata_port *ap, unsigned int device);
820extern void ata_std_dev_select(struct ata_port *ap, unsigned int device); 875extern void ata_std_dev_select(struct ata_port *ap, unsigned int device);
821extern u8 ata_check_status(struct ata_port *ap); 876extern u8 ata_check_status(struct ata_port *ap);
@@ -824,17 +879,15 @@ extern void ata_exec_command(struct ata_port *ap, const struct ata_taskfile *tf)
824extern int ata_port_start(struct ata_port *ap); 879extern int ata_port_start(struct ata_port *ap);
825extern int ata_sff_port_start(struct ata_port *ap); 880extern int ata_sff_port_start(struct ata_port *ap);
826extern irqreturn_t ata_interrupt(int irq, void *dev_instance); 881extern irqreturn_t ata_interrupt(int irq, void *dev_instance);
827extern void ata_data_xfer(struct ata_device *adev, unsigned char *buf, 882extern unsigned int ata_data_xfer(struct ata_device *dev,
828 unsigned int buflen, int write_data); 883 unsigned char *buf, unsigned int buflen, int rw);
829extern void ata_data_xfer_noirq(struct ata_device *adev, unsigned char *buf, 884extern unsigned int ata_data_xfer_noirq(struct ata_device *dev,
830 unsigned int buflen, int write_data); 885 unsigned char *buf, unsigned int buflen, int rw);
831extern int ata_std_qc_defer(struct ata_queued_cmd *qc); 886extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
832extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc); 887extern void ata_dumb_qc_prep(struct ata_queued_cmd *qc);
833extern void ata_qc_prep(struct ata_queued_cmd *qc); 888extern void ata_qc_prep(struct ata_queued_cmd *qc);
834extern void ata_noop_qc_prep(struct ata_queued_cmd *qc); 889extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
835extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc); 890extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
836extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
837 unsigned int buflen);
838extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg, 891extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
839 unsigned int n_elem); 892 unsigned int n_elem);
840extern unsigned int ata_dev_classify(const struct ata_taskfile *tf); 893extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
@@ -843,7 +896,6 @@ extern void ata_id_string(const u16 *id, unsigned char *s,
843 unsigned int ofs, unsigned int len); 896 unsigned int ofs, unsigned int len);
844extern void ata_id_c_string(const u16 *id, unsigned char *s, 897extern void ata_id_c_string(const u16 *id, unsigned char *s,
845 unsigned int ofs, unsigned int len); 898 unsigned int ofs, unsigned int len);
846extern void ata_id_to_dma_mode(struct ata_device *dev, u8 unknown);
847extern void ata_bmdma_setup(struct ata_queued_cmd *qc); 899extern void ata_bmdma_setup(struct ata_queued_cmd *qc);
848extern void ata_bmdma_start(struct ata_queued_cmd *qc); 900extern void ata_bmdma_start(struct ata_queued_cmd *qc);
849extern void ata_bmdma_stop(struct ata_queued_cmd *qc); 901extern void ata_bmdma_stop(struct ata_queued_cmd *qc);
@@ -878,6 +930,7 @@ extern u8 ata_irq_on(struct ata_port *ap);
878extern int ata_cable_40wire(struct ata_port *ap); 930extern int ata_cable_40wire(struct ata_port *ap);
879extern int ata_cable_80wire(struct ata_port *ap); 931extern int ata_cable_80wire(struct ata_port *ap);
880extern int ata_cable_sata(struct ata_port *ap); 932extern int ata_cable_sata(struct ata_port *ap);
933extern int ata_cable_ignore(struct ata_port *ap);
881extern int ata_cable_unknown(struct ata_port *ap); 934extern int ata_cable_unknown(struct ata_port *ap);
882 935
883/* 936/*
@@ -885,11 +938,13 @@ extern int ata_cable_unknown(struct ata_port *ap);
885 */ 938 */
886 939
887extern unsigned int ata_pio_need_iordy(const struct ata_device *); 940extern unsigned int ata_pio_need_iordy(const struct ata_device *);
941extern const struct ata_timing *ata_timing_find_mode(u8 xfer_mode);
888extern int ata_timing_compute(struct ata_device *, unsigned short, 942extern int ata_timing_compute(struct ata_device *, unsigned short,
889 struct ata_timing *, int, int); 943 struct ata_timing *, int, int);
890extern void ata_timing_merge(const struct ata_timing *, 944extern void ata_timing_merge(const struct ata_timing *,
891 const struct ata_timing *, struct ata_timing *, 945 const struct ata_timing *, struct ata_timing *,
892 unsigned int); 946 unsigned int);
947extern u8 ata_timing_cycle2mode(unsigned int xfer_shift, int cycle);
893 948
894enum { 949enum {
895 ATA_TIMING_SETUP = (1 << 0), 950 ATA_TIMING_SETUP = (1 << 0),
@@ -910,11 +965,46 @@ enum {
910 965
911/* libata-acpi.c */ 966/* libata-acpi.c */
912#ifdef CONFIG_ATA_ACPI 967#ifdef CONFIG_ATA_ACPI
913extern int ata_acpi_cbl_80wire(struct ata_port *ap); 968static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
914int ata_acpi_stm(const struct ata_port *ap, struct ata_acpi_gtm *stm); 969{
915int ata_acpi_gtm(const struct ata_port *ap, struct ata_acpi_gtm *stm); 970 if (ap->pflags & ATA_PFLAG_INIT_GTM_VALID)
971 return &ap->__acpi_init_gtm;
972 return NULL;
973}
974int ata_acpi_stm(struct ata_port *ap, const struct ata_acpi_gtm *stm);
975int ata_acpi_gtm(struct ata_port *ap, struct ata_acpi_gtm *stm);
976unsigned long ata_acpi_gtm_xfermask(struct ata_device *dev,
977 const struct ata_acpi_gtm *gtm);
978int ata_acpi_cbl_80wire(struct ata_port *ap, const struct ata_acpi_gtm *gtm);
916#else 979#else
917static inline int ata_acpi_cbl_80wire(struct ata_port *ap) { return 0; } 980static inline const struct ata_acpi_gtm *ata_acpi_init_gtm(struct ata_port *ap)
981{
982 return NULL;
983}
984
985static inline int ata_acpi_stm(const struct ata_port *ap,
986 struct ata_acpi_gtm *stm)
987{
988 return -ENOSYS;
989}
990
991static inline int ata_acpi_gtm(const struct ata_port *ap,
992 struct ata_acpi_gtm *stm)
993{
994 return -ENOSYS;
995}
996
997static inline unsigned int ata_acpi_gtm_xfermask(struct ata_device *dev,
998 const struct ata_acpi_gtm *gtm)
999{
1000 return 0;
1001}
1002
1003static inline int ata_acpi_cbl_80wire(struct ata_port *ap,
1004 const struct ata_acpi_gtm *gtm)
1005{
1006 return 0;
1007}
918#endif 1008#endif
919 1009
920#ifdef CONFIG_PCI 1010#ifdef CONFIG_PCI
@@ -943,8 +1033,12 @@ extern int ata_pci_init_bmdma(struct ata_host *host);
943extern int ata_pci_prepare_sff_host(struct pci_dev *pdev, 1033extern int ata_pci_prepare_sff_host(struct pci_dev *pdev,
944 const struct ata_port_info * const * ppi, 1034 const struct ata_port_info * const * ppi,
945 struct ata_host **r_host); 1035 struct ata_host **r_host);
1036extern int ata_pci_activate_sff_host(struct ata_host *host,
1037 irq_handler_t irq_handler,
1038 struct scsi_host_template *sht);
946extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits); 1039extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
947extern unsigned long ata_pci_default_filter(struct ata_device *, unsigned long); 1040extern unsigned long ata_pci_default_filter(struct ata_device *dev,
1041 unsigned long xfer_mask);
948#endif /* CONFIG_PCI */ 1042#endif /* CONFIG_PCI */
949 1043
950/* 1044/*
@@ -964,8 +1058,6 @@ extern void sata_pmp_do_eh(struct ata_port *ap,
964/* 1058/*
965 * EH 1059 * EH
966 */ 1060 */
967extern void ata_eng_timeout(struct ata_port *ap);
968
969extern void ata_port_schedule_eh(struct ata_port *ap); 1061extern void ata_port_schedule_eh(struct ata_port *ap);
970extern int ata_link_abort(struct ata_link *link); 1062extern int ata_link_abort(struct ata_link *link);
971extern int ata_port_abort(struct ata_port *ap); 1063extern int ata_port_abort(struct ata_port *ap);
@@ -986,18 +1078,18 @@ extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
986 * printk helpers 1078 * printk helpers
987 */ 1079 */
988#define ata_port_printk(ap, lv, fmt, args...) \ 1080#define ata_port_printk(ap, lv, fmt, args...) \
989 printk(lv"ata%u: "fmt, (ap)->print_id , ##args) 1081 printk("%sata%u: "fmt, lv, (ap)->print_id , ##args)
990 1082
991#define ata_link_printk(link, lv, fmt, args...) do { \ 1083#define ata_link_printk(link, lv, fmt, args...) do { \
992 if ((link)->ap->nr_pmp_links) \ 1084 if ((link)->ap->nr_pmp_links) \
993 printk(lv"ata%u.%02u: "fmt, (link)->ap->print_id, \ 1085 printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
994 (link)->pmp , ##args); \ 1086 (link)->pmp , ##args); \
995 else \ 1087 else \
996 printk(lv"ata%u: "fmt, (link)->ap->print_id , ##args); \ 1088 printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \
997 } while(0) 1089 } while(0)
998 1090
999#define ata_dev_printk(dev, lv, fmt, args...) \ 1091#define ata_dev_printk(dev, lv, fmt, args...) \
1000 printk(lv"ata%u.%02u: "fmt, (dev)->link->ap->print_id, \ 1092 printk("%sata%u.%02u: "fmt, lv, (dev)->link->ap->print_id, \
1001 (dev)->link->pmp + (dev)->devno , ##args) 1093 (dev)->link->pmp + (dev)->devno , ##args)
1002 1094
1003/* 1095/*
@@ -1034,35 +1126,6 @@ extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset,
1034 const char *name); 1126 const char *name);
1035#endif 1127#endif
1036 1128
1037/*
1038 * qc helpers
1039 */
1040static inline struct scatterlist *
1041ata_qc_first_sg(struct ata_queued_cmd *qc)
1042{
1043 qc->n_iter = 0;
1044 if (qc->n_elem)
1045 return qc->__sg;
1046 if (qc->pad_len)
1047 return &qc->pad_sgent;
1048 return NULL;
1049}
1050
1051static inline struct scatterlist *
1052ata_qc_next_sg(struct scatterlist *sg, struct ata_queued_cmd *qc)
1053{
1054 if (sg == &qc->pad_sgent)
1055 return NULL;
1056 if (++qc->n_iter < qc->n_elem)
1057 return sg_next(sg);
1058 if (qc->pad_len)
1059 return &qc->pad_sgent;
1060 return NULL;
1061}
1062
1063#define ata_for_each_sg(sg, qc) \
1064 for (sg = ata_qc_first_sg(qc); sg; sg = ata_qc_next_sg(sg, qc))
1065
1066static inline unsigned int ata_tag_valid(unsigned int tag) 1129static inline unsigned int ata_tag_valid(unsigned int tag)
1067{ 1130{
1068 return (tag < ATA_MAX_QUEUE) ? 1 : 0; 1131 return (tag < ATA_MAX_QUEUE) ? 1 : 0;
@@ -1297,15 +1360,17 @@ static inline void ata_tf_init(struct ata_device *dev, struct ata_taskfile *tf)
1297static inline void ata_qc_reinit(struct ata_queued_cmd *qc) 1360static inline void ata_qc_reinit(struct ata_queued_cmd *qc)
1298{ 1361{
1299 qc->dma_dir = DMA_NONE; 1362 qc->dma_dir = DMA_NONE;
1300 qc->__sg = NULL; 1363 qc->sg = NULL;
1301 qc->flags = 0; 1364 qc->flags = 0;
1302 qc->cursg = NULL; 1365 qc->cursg = NULL;
1303 qc->cursg_ofs = 0; 1366 qc->cursg_ofs = 0;
1304 qc->nbytes = qc->curbytes = 0; 1367 qc->nbytes = qc->raw_nbytes = qc->curbytes = 0;
1305 qc->n_elem = 0; 1368 qc->n_elem = 0;
1369 qc->mapped_n_elem = 0;
1306 qc->n_iter = 0; 1370 qc->n_iter = 0;
1307 qc->err_mask = 0; 1371 qc->err_mask = 0;
1308 qc->pad_len = 0; 1372 qc->pad_len = 0;
1373 qc->last_sg = NULL;
1309 qc->sect_size = ATA_SECT_SIZE; 1374 qc->sect_size = ATA_SECT_SIZE;
1310 1375
1311 ata_tf_init(qc->dev, &qc->tf); 1376 ata_tf_init(qc->dev, &qc->tf);
@@ -1322,6 +1387,27 @@ static inline int ata_try_flush_cache(const struct ata_device *dev)
1322 ata_id_has_flush_ext(dev->id); 1387 ata_id_has_flush_ext(dev->id);
1323} 1388}
1324 1389
1390static inline int atapi_cmd_type(u8 opcode)
1391{
1392 switch (opcode) {
1393 case GPCMD_READ_10:
1394 case GPCMD_READ_12:
1395 return ATAPI_READ;
1396
1397 case GPCMD_WRITE_10:
1398 case GPCMD_WRITE_12:
1399 case GPCMD_WRITE_AND_VERIFY_10:
1400 return ATAPI_WRITE;
1401
1402 case GPCMD_READ_CD:
1403 case GPCMD_READ_CD_MSF:
1404 return ATAPI_READ_CD;
1405
1406 default:
1407 return ATAPI_MISC;
1408 }
1409}
1410
1325static inline unsigned int ac_err_mask(u8 status) 1411static inline unsigned int ac_err_mask(u8 status)
1326{ 1412{
1327 if (status & (ATA_BUSY | ATA_DRQ)) 1413 if (status & (ATA_BUSY | ATA_DRQ))
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index ff203dd02919..3faf599ea58e 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -13,6 +13,10 @@
13#define asmlinkage CPP_ASMLINKAGE 13#define asmlinkage CPP_ASMLINKAGE
14#endif 14#endif
15 15
16#ifndef asmregparm
17# define asmregparm
18#endif
19
16#ifndef prevent_tail_call 20#ifndef prevent_tail_call
17# define prevent_tail_call(ret) do { } while (0) 21# define prevent_tail_call(ret) do { } while (0)
18#endif 22#endif
@@ -53,6 +57,10 @@
53 .size name, .-name 57 .size name, .-name
54#endif 58#endif
55 59
60/* If symbol 'name' is treated as a subroutine (gets called, and returns)
61 * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
62 * static analysis tools such as stack depth analyzer.
63 */
56#ifndef ENDPROC 64#ifndef ENDPROC
57#define ENDPROC(name) \ 65#define ENDPROC(name) \
58 .type name, @function; \ 66 .type name, @function; \
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
index 6f1637c61e10..3d25bcd139d1 100644
--- a/include/linux/lockd/bind.h
+++ b/include/linux/lockd/bind.h
@@ -33,9 +33,26 @@ struct nlmsvc_binding {
33extern struct nlmsvc_binding * nlmsvc_ops; 33extern struct nlmsvc_binding * nlmsvc_ops;
34 34
35/* 35/*
36 * Similar to nfs_client_initdata, but without the NFS-specific
37 * rpc_ops field.
38 */
39struct nlmclnt_initdata {
40 const char *hostname;
41 const struct sockaddr *address;
42 size_t addrlen;
43 unsigned short protocol;
44 u32 nfs_version;
45};
46
47/*
36 * Functions exported by the lockd module 48 * Functions exported by the lockd module
37 */ 49 */
38extern int nlmclnt_proc(struct inode *, int, struct file_lock *); 50
51extern struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init);
52extern void nlmclnt_done(struct nlm_host *host);
53
54extern int nlmclnt_proc(struct nlm_host *host, int cmd,
55 struct file_lock *fl);
39extern int lockd_up(int proto); 56extern int lockd_up(int proto);
40extern void lockd_down(void); 57extern void lockd_down(void);
41 58
diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h
index e2d1ce36b367..4babb2a129ac 100644
--- a/include/linux/lockd/lockd.h
+++ b/include/linux/lockd/lockd.h
@@ -173,14 +173,17 @@ void nlmclnt_next_cookie(struct nlm_cookie *);
173/* 173/*
174 * Host cache 174 * Host cache
175 */ 175 */
176struct nlm_host * nlmclnt_lookup_host(const struct sockaddr_in *, int, int, const char *, int); 176struct nlm_host *nlmclnt_lookup_host(const struct sockaddr_in *, int, int,
177struct nlm_host * nlmsvc_lookup_host(struct svc_rqst *, const char *, int); 177 const char *, unsigned int);
178struct nlm_host *nlmsvc_lookup_host(struct svc_rqst *, const char *,
179 unsigned int);
178struct rpc_clnt * nlm_bind_host(struct nlm_host *); 180struct rpc_clnt * nlm_bind_host(struct nlm_host *);
179void nlm_rebind_host(struct nlm_host *); 181void nlm_rebind_host(struct nlm_host *);
180struct nlm_host * nlm_get_host(struct nlm_host *); 182struct nlm_host * nlm_get_host(struct nlm_host *);
181void nlm_release_host(struct nlm_host *); 183void nlm_release_host(struct nlm_host *);
182void nlm_shutdown_hosts(void); 184void nlm_shutdown_hosts(void);
183extern void nlm_host_rebooted(const struct sockaddr_in *, const char *, int, u32); 185extern void nlm_host_rebooted(const struct sockaddr_in *, const char *,
186 unsigned int, u32);
184void nsm_release(struct nsm_handle *); 187void nsm_release(struct nsm_handle *);
185 188
186 189
diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h
index 83a1f9f6237b..df18fa053bcd 100644
--- a/include/linux/lockd/xdr.h
+++ b/include/linux/lockd/xdr.h
@@ -29,7 +29,7 @@ struct svc_rqst;
29/* Lock info passed via NLM */ 29/* Lock info passed via NLM */
30struct nlm_lock { 30struct nlm_lock {
31 char * caller; 31 char * caller;
32 int len; /* length of "caller" */ 32 unsigned int len; /* length of "caller" */
33 struct nfs_fh fh; 33 struct nfs_fh fh;
34 struct xdr_netobj oh; 34 struct xdr_netobj oh;
35 u32 svid; 35 u32 svid;
@@ -78,7 +78,7 @@ struct nlm_res {
78 */ 78 */
79struct nlm_reboot { 79struct nlm_reboot {
80 char * mon; 80 char * mon;
81 int len; 81 unsigned int len;
82 u32 state; 82 u32 state;
83 __be32 addr; 83 __be32 addr;
84 __be32 vers; 84 __be32 vers;
diff --git a/include/linux/m41t00.h b/include/linux/m41t00.h
deleted file mode 100644
index b423360ca38e..000000000000
--- a/include/linux/m41t00.h
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * Definitions for the ST M41T00 family of i2c rtc chips.
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2005, 2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11
12#ifndef _M41T00_H
13#define _M41T00_H
14
15#define M41T00_DRV_NAME "m41t00"
16#define M41T00_I2C_ADDR 0x68
17
18#define M41T00_TYPE_M41T00 0
19#define M41T00_TYPE_M41T81 81
20#define M41T00_TYPE_M41T85 85
21
22struct m41t00_platform_data {
23 u8 type;
24 u8 i2c_addr;
25 u8 sqw_freq;
26};
27
28/* SQW output disabled, this is default value by power on */
29#define M41T00_SQW_DISABLE (0)
30
31#define M41T00_SQW_32KHZ (1<<4) /* 32.768 KHz */
32#define M41T00_SQW_8KHZ (2<<4) /* 8.192 KHz */
33#define M41T00_SQW_4KHZ (3<<4) /* 4.096 KHz */
34#define M41T00_SQW_2KHZ (4<<4) /* 2.048 KHz */
35#define M41T00_SQW_1KHZ (5<<4) /* 1.024 KHz */
36#define M41T00_SQW_512HZ (6<<4) /* 512 Hz */
37#define M41T00_SQW_256HZ (7<<4) /* 256 Hz */
38#define M41T00_SQW_128HZ (8<<4) /* 128 Hz */
39#define M41T00_SQW_64HZ (9<<4) /* 64 Hz */
40#define M41T00_SQW_32HZ (10<<4) /* 32 Hz */
41#define M41T00_SQW_16HZ (11<<4) /* 16 Hz */
42#define M41T00_SQW_8HZ (12<<4) /* 8 Hz */
43#define M41T00_SQW_4HZ (13<<4) /* 4 Hz */
44#define M41T00_SQW_2HZ (14<<4) /* 2 Hz */
45#define M41T00_SQW_1HZ (15<<4) /* 1 Hz */
46
47extern ulong m41t00_get_rtc_time(void);
48extern int m41t00_set_rtc_time(ulong nowtime);
49
50#endif /* _M41T00_H */
diff --git a/include/linux/mc146818rtc.h b/include/linux/mc146818rtc.h
index 580b3f4956ee..2f4e957af656 100644
--- a/include/linux/mc146818rtc.h
+++ b/include/linux/mc146818rtc.h
@@ -109,8 +109,11 @@ struct cmos_rtc_board_info {
109#ifndef ARCH_RTC_LOCATION /* Override by <asm/mc146818rtc.h>? */ 109#ifndef ARCH_RTC_LOCATION /* Override by <asm/mc146818rtc.h>? */
110 110
111#define RTC_IO_EXTENT 0x8 111#define RTC_IO_EXTENT 0x8
112#define RTC_IO_EXTENT_USED 0x2
112#define RTC_IOMAPPED 1 /* Default to I/O mapping. */ 113#define RTC_IOMAPPED 1 /* Default to I/O mapping. */
113 114
115#else
116#define RTC_IO_EXTENT_USED RTC_IO_EXTENT
114#endif /* ARCH_RTC_LOCATION */ 117#endif /* ARCH_RTC_LOCATION */
115 118
116#endif /* _MC146818RTC_H */ 119#endif /* _MC146818RTC_H */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 520238cbae5d..1bba6789a50a 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -33,6 +33,8 @@ extern int sysctl_legacy_va_layout;
33#define sysctl_legacy_va_layout 0 33#define sysctl_legacy_va_layout 0
34#endif 34#endif
35 35
36extern unsigned long mmap_min_addr;
37
36#include <asm/page.h> 38#include <asm/page.h>
37#include <asm/pgtable.h> 39#include <asm/pgtable.h>
38#include <asm/processor.h> 40#include <asm/processor.h>
@@ -513,6 +515,21 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
513} 515}
514 516
515/* 517/*
518 * If a hint addr is less than mmap_min_addr change hint to be as
519 * low as possible but still greater than mmap_min_addr
520 */
521static inline unsigned long round_hint_to_min(unsigned long hint)
522{
523#ifdef CONFIG_SECURITY
524 hint &= PAGE_MASK;
525 if (((void *)hint != NULL) &&
526 (hint < mmap_min_addr))
527 return PAGE_ALIGN(mmap_min_addr);
528#endif
529 return hint;
530}
531
532/*
516 * Some inline functions in vmstat.h depend on page_zone() 533 * Some inline functions in vmstat.h depend on page_zone()
517 */ 534 */
518#include <linux/vmstat.h> 535#include <linux/vmstat.h>
@@ -1101,9 +1118,21 @@ static inline void vm_stat_account(struct mm_struct *mm,
1101} 1118}
1102#endif /* CONFIG_PROC_FS */ 1119#endif /* CONFIG_PROC_FS */
1103 1120
1104#ifndef CONFIG_DEBUG_PAGEALLOC 1121#ifdef CONFIG_DEBUG_PAGEALLOC
1122extern int debug_pagealloc_enabled;
1123
1124extern void kernel_map_pages(struct page *page, int numpages, int enable);
1125
1126static inline void enable_debug_pagealloc(void)
1127{
1128 debug_pagealloc_enabled = 1;
1129}
1130#else
1105static inline void 1131static inline void
1106kernel_map_pages(struct page *page, int numpages, int enable) {} 1132kernel_map_pages(struct page *page, int numpages, int enable) {}
1133static inline void enable_debug_pagealloc(void)
1134{
1135}
1107#endif 1136#endif
1108 1137
1109extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk); 1138extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk);
@@ -1129,6 +1158,7 @@ extern int randomize_va_space;
1129#endif 1158#endif
1130 1159
1131const char * arch_vma_name(struct vm_area_struct *vma); 1160const char * arch_vma_name(struct vm_area_struct *vma);
1161void print_vma_addr(char *prefix, unsigned long rip);
1132 1162
1133struct page *sparse_mem_map_populate(unsigned long pnum, int nid); 1163struct page *sparse_mem_map_populate(unsigned long pnum, int nid);
1134pgd_t *vmemmap_pgd_populate(unsigned long addr, int node); 1164pgd_t *vmemmap_pgd_populate(unsigned long addr, int node);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 125eee1407ff..7ab962fa1d73 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -118,10 +118,6 @@ struct mmc_host {
118 unsigned int removed:1; /* host is being removed */ 118 unsigned int removed:1; /* host is being removed */
119#endif 119#endif
120 120
121 unsigned int mode; /* current card mode of host */
122#define MMC_MODE_MMC 0
123#define MMC_MODE_SD 1
124
125 struct mmc_card *card; /* device attached to this host */ 121 struct mmc_card *card; /* device attached to this host */
126 122
127 wait_queue_head_t wq; 123 wait_queue_head_t wq;
diff --git a/include/linux/module.h b/include/linux/module.h
index 2cbc0b87e329..ac481e2094fd 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -178,7 +178,7 @@ void *__symbol_get_gpl(const char *symbol);
178#define __CRC_SYMBOL(sym, sec) \ 178#define __CRC_SYMBOL(sym, sec) \
179 extern void *__crc_##sym __attribute__((weak)); \ 179 extern void *__crc_##sym __attribute__((weak)); \
180 static const unsigned long __kcrctab_##sym \ 180 static const unsigned long __kcrctab_##sym \
181 __attribute_used__ \ 181 __used \
182 __attribute__((section("__kcrctab" sec), unused)) \ 182 __attribute__((section("__kcrctab" sec), unused)) \
183 = (unsigned long) &__crc_##sym; 183 = (unsigned long) &__crc_##sym;
184#else 184#else
@@ -193,7 +193,7 @@ void *__symbol_get_gpl(const char *symbol);
193 __attribute__((section("__ksymtab_strings"))) \ 193 __attribute__((section("__ksymtab_strings"))) \
194 = MODULE_SYMBOL_PREFIX #sym; \ 194 = MODULE_SYMBOL_PREFIX #sym; \
195 static const struct kernel_symbol __ksymtab_##sym \ 195 static const struct kernel_symbol __ksymtab_##sym \
196 __attribute_used__ \ 196 __used \
197 __attribute__((section("__ksymtab" sec), unused)) \ 197 __attribute__((section("__ksymtab" sec), unused)) \
198 = { (unsigned long)&sym, __kstrtab_##sym } 198 = { (unsigned long)&sym, __kstrtab_##sym }
199 199
@@ -446,11 +446,14 @@ static inline void __module_get(struct module *module)
446 __mod ? __mod->name : "kernel"; \ 446 __mod ? __mod->name : "kernel"; \
447}) 447})
448 448
449/* For kallsyms to ask for address resolution. NULL means not found. */ 449/* For kallsyms to ask for address resolution. namebuf should be at
450const char *module_address_lookup(unsigned long addr, 450 * least KSYM_NAME_LEN long: a pointer to namebuf is returned if
451 unsigned long *symbolsize, 451 * found, otherwise NULL. */
452 unsigned long *offset, 452char *module_address_lookup(unsigned long addr,
453 char **modname); 453 unsigned long *symbolsize,
454 unsigned long *offset,
455 char **modname,
456 char *namebuf);
454int lookup_module_symbol_name(unsigned long addr, char *symname); 457int lookup_module_symbol_name(unsigned long addr, char *symname);
455int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name); 458int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size, unsigned long *offset, char *modname, char *name);
456 459
@@ -516,10 +519,11 @@ static inline void module_put(struct module *module)
516#define module_name(mod) "kernel" 519#define module_name(mod) "kernel"
517 520
518/* For kallsyms to ask for address resolution. NULL means not found. */ 521/* For kallsyms to ask for address resolution. NULL means not found. */
519static inline const char *module_address_lookup(unsigned long addr, 522static inline char *module_address_lookup(unsigned long addr,
520 unsigned long *symbolsize, 523 unsigned long *symbolsize,
521 unsigned long *offset, 524 unsigned long *offset,
522 char **modname) 525 char **modname,
526 char *namebuf)
523{ 527{
524 return NULL; 528 return NULL;
525} 529}
@@ -574,7 +578,9 @@ struct device_driver;
574#ifdef CONFIG_SYSFS 578#ifdef CONFIG_SYSFS
575struct module; 579struct module;
576 580
577extern struct kset module_subsys; 581extern struct kset *module_kset;
582extern struct kobj_type module_ktype;
583extern int module_sysfs_initialized;
578 584
579int mod_sysfs_init(struct module *mod); 585int mod_sysfs_init(struct module *mod);
580int mod_sysfs_setup(struct module *mod, 586int mod_sysfs_setup(struct module *mod,
@@ -607,21 +613,6 @@ static inline void module_remove_modinfo_attrs(struct module *mod)
607 613
608#endif /* CONFIG_SYSFS */ 614#endif /* CONFIG_SYSFS */
609 615
610#if defined(CONFIG_SYSFS) && defined(CONFIG_MODULES)
611
612void module_add_driver(struct module *mod, struct device_driver *drv);
613void module_remove_driver(struct device_driver *drv);
614
615#else /* not both CONFIG_SYSFS && CONFIG_MODULES */
616
617static inline void module_add_driver(struct module *mod, struct device_driver *drv)
618{ }
619
620static inline void module_remove_driver(struct device_driver *drv)
621{ }
622
623#endif
624
625#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x) 616#define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
626 617
627/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */ 618/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index 13410b20600f..8126e55c5bdc 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -18,7 +18,7 @@
18#define __module_cat(a,b) ___module_cat(a,b) 18#define __module_cat(a,b) ___module_cat(a,b)
19#define __MODULE_INFO(tag, name, info) \ 19#define __MODULE_INFO(tag, name, info) \
20static const char __module_cat(name,__LINE__)[] \ 20static const char __module_cat(name,__LINE__)[] \
21 __attribute_used__ \ 21 __used \
22 __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info 22 __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info
23#else /* !MODULE */ 23#else /* !MODULE */
24#define __MODULE_INFO(tag, name, info) 24#define __MODULE_INFO(tag, name, info)
@@ -72,7 +72,7 @@ struct kparam_array
72 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ 72 BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \
73 static const char __param_str_##name[] = prefix #name; \ 73 static const char __param_str_##name[] = prefix #name; \
74 static struct kernel_param const __param_##name \ 74 static struct kernel_param const __param_##name \
75 __attribute_used__ \ 75 __used \
76 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ 76 __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \
77 = { __param_str_##name, perm, set, get, { arg } } 77 = { __param_str_##name, perm, set, get, { arg } }
78 78
diff --git a/include/linux/mroute.h b/include/linux/mroute.h
index 7da2cee8e132..35a8277ec1bd 100644
--- a/include/linux/mroute.h
+++ b/include/linux/mroute.h
@@ -128,6 +128,18 @@ struct igmpmsg
128#ifdef __KERNEL__ 128#ifdef __KERNEL__
129#include <net/sock.h> 129#include <net/sock.h>
130 130
131#ifdef CONFIG_IP_MROUTE
132static inline int ip_mroute_opt(int opt)
133{
134 return (opt >= MRT_BASE) && (opt <= MRT_BASE + 10);
135}
136#else
137static inline int ip_mroute_opt(int opt)
138{
139 return 0;
140}
141#endif
142
131extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int); 143extern int ip_mroute_setsockopt(struct sock *, int, char __user *, int);
132extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); 144extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
133extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); 145extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
diff --git a/include/linux/mutex.h b/include/linux/mutex.h
index 601479772b98..05c590352dd7 100644
--- a/include/linux/mutex.h
+++ b/include/linux/mutex.h
@@ -125,15 +125,20 @@ static inline int fastcall mutex_is_locked(struct mutex *lock)
125extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass); 125extern void mutex_lock_nested(struct mutex *lock, unsigned int subclass);
126extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock, 126extern int __must_check mutex_lock_interruptible_nested(struct mutex *lock,
127 unsigned int subclass); 127 unsigned int subclass);
128extern int __must_check mutex_lock_killable_nested(struct mutex *lock,
129 unsigned int subclass);
128 130
129#define mutex_lock(lock) mutex_lock_nested(lock, 0) 131#define mutex_lock(lock) mutex_lock_nested(lock, 0)
130#define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0) 132#define mutex_lock_interruptible(lock) mutex_lock_interruptible_nested(lock, 0)
133#define mutex_lock_killable(lock) mutex_lock_killable_nested(lock, 0)
131#else 134#else
132extern void fastcall mutex_lock(struct mutex *lock); 135extern void fastcall mutex_lock(struct mutex *lock);
133extern int __must_check fastcall mutex_lock_interruptible(struct mutex *lock); 136extern int __must_check fastcall mutex_lock_interruptible(struct mutex *lock);
137extern int __must_check fastcall mutex_lock_killable(struct mutex *lock);
134 138
135# define mutex_lock_nested(lock, subclass) mutex_lock(lock) 139# define mutex_lock_nested(lock, subclass) mutex_lock(lock)
136# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock) 140# define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock)
141# define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock)
137#endif 142#endif
138 143
139/* 144/*
diff --git a/include/linux/mv643xx.h b/include/linux/mv643xx.h
index d2ae6185f03b..69327b7b4ce4 100644
--- a/include/linux/mv643xx.h
+++ b/include/linux/mv643xx.h
@@ -15,6 +15,7 @@
15 15
16#include <asm/types.h> 16#include <asm/types.h>
17#include <linux/mv643xx_eth.h> 17#include <linux/mv643xx_eth.h>
18#include <linux/mv643xx_i2c.h>
18 19
19/****************************************/ 20/****************************************/
20/* Processor Address Space */ 21/* Processor Address Space */
@@ -863,7 +864,6 @@
863/* I2C Registers */ 864/* I2C Registers */
864/****************************************/ 865/****************************************/
865 866
866#define MV64XXX_I2C_CTLR_NAME "mv64xxx_i2c"
867#define MV64XXX_I2C_OFFSET 0xc000 867#define MV64XXX_I2C_OFFSET 0xc000
868#define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020 868#define MV64XXX_I2C_REG_BLOCK_SIZE 0x0020
869 869
@@ -968,14 +968,6 @@ struct mpsc_pdata {
968 u32 brg_clk_freq; 968 u32 brg_clk_freq;
969}; 969};
970 970
971/* i2c Platform Device, Driver Data */
972struct mv64xxx_i2c_pdata {
973 u32 freq_m;
974 u32 freq_n;
975 u32 timeout; /* In milliseconds */
976 u32 retries;
977};
978
979/* Watchdog Platform Device, Driver Data */ 971/* Watchdog Platform Device, Driver Data */
980#define MV64x60_WDT_NAME "mv64x60_wdt" 972#define MV64x60_WDT_NAME "mv64x60_wdt"
981 973
diff --git a/include/linux/mv643xx_eth.h b/include/linux/mv643xx_eth.h
index 8df230a279a0..30e11aa3c1c9 100644
--- a/include/linux/mv643xx_eth.h
+++ b/include/linux/mv643xx_eth.h
@@ -8,9 +8,9 @@
8#define MV643XX_ETH_NAME "mv643xx_eth" 8#define MV643XX_ETH_NAME "mv643xx_eth"
9#define MV643XX_ETH_SHARED_REGS 0x2000 9#define MV643XX_ETH_SHARED_REGS 0x2000
10#define MV643XX_ETH_SHARED_REGS_SIZE 0x2000 10#define MV643XX_ETH_SHARED_REGS_SIZE 0x2000
11#define MV643XX_ETH_BAR_4 0x220 11#define MV643XX_ETH_BAR_4 0x2220
12#define MV643XX_ETH_SIZE_REG_4 0x224 12#define MV643XX_ETH_SIZE_REG_4 0x2224
13#define MV643XX_ETH_BASE_ADDR_ENABLE_REG 0x0290 13#define MV643XX_ETH_BASE_ADDR_ENABLE_REG 0x2290
14 14
15struct mv643xx_eth_platform_data { 15struct mv643xx_eth_platform_data {
16 int port_number; 16 int port_number;
diff --git a/include/linux/mv643xx_i2c.h b/include/linux/mv643xx_i2c.h
new file mode 100644
index 000000000000..5db5152e9de5
--- /dev/null
+++ b/include/linux/mv643xx_i2c.h
@@ -0,0 +1,22 @@
1/*
2 * This program is free software; you can redistribute it and/or modify it
3 * under the terms of the GNU General Public License as published by the
4 * Free Software Foundation; either version 2 of the License, or (at your
5 * option) any later version.
6 */
7
8#ifndef _MV64XXX_I2C_H_
9#define _MV64XXX_I2C_H_
10
11#include <linux/types.h>
12
13#define MV64XXX_I2C_CTLR_NAME "mv64xxx_i2c"
14
15/* i2c Platform Device, Driver Data */
16struct mv64xxx_i2c_pdata {
17 u32 freq_m;
18 u32 freq_n;
19 u32 timeout; /* In milliseconds */
20};
21
22#endif /*_MV64XXX_I2C_H_*/
diff --git a/include/linux/net.h b/include/linux/net.h
index dd79cdb8c4cf..c414d90e647b 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -22,6 +22,7 @@
22#include <asm/socket.h> 22#include <asm/socket.h>
23 23
24struct poll_table_struct; 24struct poll_table_struct;
25struct pipe_inode_info;
25struct inode; 26struct inode;
26struct net; 27struct net;
27 28
@@ -95,6 +96,12 @@ enum sock_type {
95 96
96#endif /* ARCH_HAS_SOCKET_TYPES */ 97#endif /* ARCH_HAS_SOCKET_TYPES */
97 98
99enum sock_shutdown_cmd {
100 SHUT_RD = 0,
101 SHUT_WR = 1,
102 SHUT_RDWR = 2,
103};
104
98/** 105/**
99 * struct socket - general BSD socket 106 * struct socket - general BSD socket
100 * @state: socket state (%SS_CONNECTED, etc) 107 * @state: socket state (%SS_CONNECTED, etc)
@@ -166,6 +173,8 @@ struct proto_ops {
166 struct vm_area_struct * vma); 173 struct vm_area_struct * vma);
167 ssize_t (*sendpage) (struct socket *sock, struct page *page, 174 ssize_t (*sendpage) (struct socket *sock, struct page *page,
168 int offset, size_t size, int flags); 175 int offset, size_t size, int flags);
176 ssize_t (*splice_read)(struct socket *sock, loff_t *ppos,
177 struct pipe_inode_info *pipe, size_t len, unsigned int flags);
169}; 178};
170 179
171struct net_proto_family { 180struct net_proto_family {
@@ -177,6 +186,13 @@ struct net_proto_family {
177struct iovec; 186struct iovec;
178struct kvec; 187struct kvec;
179 188
189enum {
190 SOCK_WAKE_IO,
191 SOCK_WAKE_WAITD,
192 SOCK_WAKE_SPACE,
193 SOCK_WAKE_URG,
194};
195
180extern int sock_wake_async(struct socket *sk, int how, int band); 196extern int sock_wake_async(struct socket *sk, int how, int band);
181extern int sock_register(const struct net_proto_family *fam); 197extern int sock_register(const struct net_proto_family *fam);
182extern void sock_unregister(int family); 198extern void sock_unregister(int family);
@@ -223,6 +239,8 @@ extern int kernel_setsockopt(struct socket *sock, int level, int optname,
223extern int kernel_sendpage(struct socket *sock, struct page *page, int offset, 239extern int kernel_sendpage(struct socket *sock, struct page *page, int offset,
224 size_t size, int flags); 240 size_t size, int flags);
225extern int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg); 241extern int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg);
242extern int kernel_sock_shutdown(struct socket *sock,
243 enum sock_shutdown_cmd how);
226 244
227#ifndef CONFIG_SMP 245#ifndef CONFIG_SMP
228#define SOCKOPS_WRAPPED(name) name 246#define SOCKOPS_WRAPPED(name) name
@@ -319,7 +337,6 @@ static const struct proto_ops name##_ops = { \
319 337
320#ifdef CONFIG_SYSCTL 338#ifdef CONFIG_SYSCTL
321#include <linux/sysctl.h> 339#include <linux/sysctl.h>
322extern ctl_table net_table[];
323extern int net_msg_cost; 340extern int net_msg_cost;
324extern int net_msg_burst; 341extern int net_msg_burst;
325#endif 342#endif
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9b0c8f12373e..047d432bde55 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -319,21 +319,29 @@ struct napi_struct {
319enum 319enum
320{ 320{
321 NAPI_STATE_SCHED, /* Poll is scheduled */ 321 NAPI_STATE_SCHED, /* Poll is scheduled */
322 NAPI_STATE_DISABLE, /* Disable pending */
322}; 323};
323 324
324extern void FASTCALL(__napi_schedule(struct napi_struct *n)); 325extern void FASTCALL(__napi_schedule(struct napi_struct *n));
325 326
327static inline int napi_disable_pending(struct napi_struct *n)
328{
329 return test_bit(NAPI_STATE_DISABLE, &n->state);
330}
331
326/** 332/**
327 * napi_schedule_prep - check if napi can be scheduled 333 * napi_schedule_prep - check if napi can be scheduled
328 * @n: napi context 334 * @n: napi context
329 * 335 *
330 * Test if NAPI routine is already running, and if not mark 336 * Test if NAPI routine is already running, and if not mark
331 * it as running. This is used as a condition variable 337 * it as running. This is used as a condition variable
332 * insure only one NAPI poll instance runs 338 * insure only one NAPI poll instance runs. We also make
339 * sure there is no pending NAPI disable.
333 */ 340 */
334static inline int napi_schedule_prep(struct napi_struct *n) 341static inline int napi_schedule_prep(struct napi_struct *n)
335{ 342{
336 return !test_and_set_bit(NAPI_STATE_SCHED, &n->state); 343 return !napi_disable_pending(n) &&
344 !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
337} 345}
338 346
339/** 347/**
@@ -389,8 +397,10 @@ static inline void napi_complete(struct napi_struct *n)
389 */ 397 */
390static inline void napi_disable(struct napi_struct *n) 398static inline void napi_disable(struct napi_struct *n)
391{ 399{
400 set_bit(NAPI_STATE_DISABLE, &n->state);
392 while (test_and_set_bit(NAPI_STATE_SCHED, &n->state)) 401 while (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
393 msleep(1); 402 msleep(1);
403 clear_bit(NAPI_STATE_DISABLE, &n->state);
394} 404}
395 405
396/** 406/**
@@ -739,6 +749,16 @@ static inline void *netdev_priv(const struct net_device *dev)
739 */ 749 */
740#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev)) 750#define SET_NETDEV_DEV(net, pdev) ((net)->dev.parent = (pdev))
741 751
752/**
753 * netif_napi_add - initialize a napi context
754 * @dev: network device
755 * @napi: napi context
756 * @poll: polling function
757 * @weight: default weight
758 *
759 * netif_napi_add() must be used to initialize a napi context prior to calling
760 * *any* of the other napi related functions.
761 */
742static inline void netif_napi_add(struct net_device *dev, 762static inline void netif_napi_add(struct net_device *dev,
743 struct napi_struct *napi, 763 struct napi_struct *napi,
744 int (*poll)(struct napi_struct *, int), 764 int (*poll)(struct napi_struct *, int),
@@ -1258,7 +1278,7 @@ static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits)
1258static inline int netif_rx_schedule_prep(struct net_device *dev, 1278static inline int netif_rx_schedule_prep(struct net_device *dev,
1259 struct napi_struct *napi) 1279 struct napi_struct *napi)
1260{ 1280{
1261 return netif_running(dev) && napi_schedule_prep(napi); 1281 return napi_schedule_prep(napi);
1262} 1282}
1263 1283
1264/* Add interface to tail of rx poll list. This assumes that _prep has 1284/* Add interface to tail of rx poll list. This assumes that _prep has
@@ -1267,7 +1287,6 @@ static inline int netif_rx_schedule_prep(struct net_device *dev,
1267static inline void __netif_rx_schedule(struct net_device *dev, 1287static inline void __netif_rx_schedule(struct net_device *dev,
1268 struct napi_struct *napi) 1288 struct napi_struct *napi)
1269{ 1289{
1270 dev_hold(dev);
1271 __napi_schedule(napi); 1290 __napi_schedule(napi);
1272} 1291}
1273 1292
@@ -1298,7 +1317,6 @@ static inline void __netif_rx_complete(struct net_device *dev,
1298 struct napi_struct *napi) 1317 struct napi_struct *napi)
1299{ 1318{
1300 __napi_complete(napi); 1319 __napi_complete(napi);
1301 dev_put(dev);
1302} 1320}
1303 1321
1304/* Remove interface from poll list: it must be in the poll list 1322/* Remove interface from poll list: it must be in the poll list
@@ -1396,12 +1414,16 @@ extern void dev_set_rx_mode(struct net_device *dev);
1396extern void __dev_set_rx_mode(struct net_device *dev); 1414extern void __dev_set_rx_mode(struct net_device *dev);
1397extern int dev_unicast_delete(struct net_device *dev, void *addr, int alen); 1415extern int dev_unicast_delete(struct net_device *dev, void *addr, int alen);
1398extern int dev_unicast_add(struct net_device *dev, void *addr, int alen); 1416extern int dev_unicast_add(struct net_device *dev, void *addr, int alen);
1417extern int dev_unicast_sync(struct net_device *to, struct net_device *from);
1418extern void dev_unicast_unsync(struct net_device *to, struct net_device *from);
1399extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all); 1419extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all);
1400extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly); 1420extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly);
1401extern int dev_mc_sync(struct net_device *to, struct net_device *from); 1421extern int dev_mc_sync(struct net_device *to, struct net_device *from);
1402extern void dev_mc_unsync(struct net_device *to, struct net_device *from); 1422extern void dev_mc_unsync(struct net_device *to, struct net_device *from);
1403extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all); 1423extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all);
1404extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly); 1424extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly);
1425extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1426extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count);
1405extern void dev_set_promiscuity(struct net_device *dev, int inc); 1427extern void dev_set_promiscuity(struct net_device *dev, int inc);
1406extern void dev_set_allmulti(struct net_device *dev, int inc); 1428extern void dev_set_allmulti(struct net_device *dev, int inc);
1407extern void netdev_state_change(struct net_device *dev); 1429extern void netdev_state_change(struct net_device *dev);
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
index 16adac688af5..d74e79bacd2d 100644
--- a/include/linux/netfilter.h
+++ b/include/linux/netfilter.h
@@ -7,6 +7,8 @@
7#include <linux/skbuff.h> 7#include <linux/skbuff.h>
8#include <linux/net.h> 8#include <linux/net.h>
9#include <linux/if.h> 9#include <linux/if.h>
10#include <linux/in.h>
11#include <linux/in6.h>
10#include <linux/wait.h> 12#include <linux/wait.h>
11#include <linux/list.h> 13#include <linux/list.h>
12#endif 14#endif
@@ -39,6 +41,23 @@
39#define NFC_ALTERED 0x8000 41#define NFC_ALTERED 0x8000
40#endif 42#endif
41 43
44enum nf_inet_hooks {
45 NF_INET_PRE_ROUTING,
46 NF_INET_LOCAL_IN,
47 NF_INET_FORWARD,
48 NF_INET_LOCAL_OUT,
49 NF_INET_POST_ROUTING,
50 NF_INET_NUMHOOKS
51};
52
53union nf_inet_addr {
54 u_int32_t all[4];
55 __be32 ip;
56 __be32 ip6[4];
57 struct in_addr in;
58 struct in6_addr in6;
59};
60
42#ifdef __KERNEL__ 61#ifdef __KERNEL__
43#ifdef CONFIG_NETFILTER 62#ifdef CONFIG_NETFILTER
44 63
@@ -92,19 +111,6 @@ struct nf_sockopt_ops
92 struct module *owner; 111 struct module *owner;
93}; 112};
94 113
95/* Each queued (to userspace) skbuff has one of these. */
96struct nf_info
97{
98 /* The ops struct which sent us to userspace. */
99 struct nf_hook_ops *elem;
100
101 /* If we're sent to userspace, this keeps housekeeping info */
102 int pf;
103 unsigned int hook;
104 struct net_device *indev, *outdev;
105 int (*okfn)(struct sk_buff *);
106};
107
108/* Function to register/unregister hook points. */ 114/* Function to register/unregister hook points. */
109int nf_register_hook(struct nf_hook_ops *reg); 115int nf_register_hook(struct nf_hook_ops *reg);
110void nf_unregister_hook(struct nf_hook_ops *reg); 116void nf_unregister_hook(struct nf_hook_ops *reg);
@@ -118,71 +124,12 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg);
118 124
119#ifdef CONFIG_SYSCTL 125#ifdef CONFIG_SYSCTL
120/* Sysctl registration */ 126/* Sysctl registration */
121struct ctl_table_header *nf_register_sysctl_table(struct ctl_table *path, 127extern struct ctl_path nf_net_netfilter_sysctl_path[];
122 struct ctl_table *table); 128extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[];
123void nf_unregister_sysctl_table(struct ctl_table_header *header,
124 struct ctl_table *table);
125extern struct ctl_table nf_net_netfilter_sysctl_path[];
126extern struct ctl_table nf_net_ipv4_netfilter_sysctl_path[];
127#endif /* CONFIG_SYSCTL */ 129#endif /* CONFIG_SYSCTL */
128 130
129extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS]; 131extern struct list_head nf_hooks[NPROTO][NF_MAX_HOOKS];
130 132
131/* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will
132 * disappear once iptables is replaced with pkttables. Please DO NOT use them
133 * for any new code! */
134#define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
135#define NF_LOG_TCPOPT 0x02 /* Log TCP options */
136#define NF_LOG_IPOPT 0x04 /* Log IP options */
137#define NF_LOG_UID 0x08 /* Log UID owning local socket */
138#define NF_LOG_MASK 0x0f
139
140#define NF_LOG_TYPE_LOG 0x01
141#define NF_LOG_TYPE_ULOG 0x02
142
143struct nf_loginfo {
144 u_int8_t type;
145 union {
146 struct {
147 u_int32_t copy_len;
148 u_int16_t group;
149 u_int16_t qthreshold;
150 } ulog;
151 struct {
152 u_int8_t level;
153 u_int8_t logflags;
154 } log;
155 } u;
156};
157
158typedef void nf_logfn(unsigned int pf,
159 unsigned int hooknum,
160 const struct sk_buff *skb,
161 const struct net_device *in,
162 const struct net_device *out,
163 const struct nf_loginfo *li,
164 const char *prefix);
165
166struct nf_logger {
167 struct module *me;
168 nf_logfn *logfn;
169 char *name;
170};
171
172/* Function to register/unregister log function. */
173int nf_log_register(int pf, struct nf_logger *logger);
174void nf_log_unregister(struct nf_logger *logger);
175void nf_log_unregister_pf(int pf);
176
177/* Calls the registered backend logging function */
178void nf_log_packet(int pf,
179 unsigned int hooknum,
180 const struct sk_buff *skb,
181 const struct net_device *in,
182 const struct net_device *out,
183 struct nf_loginfo *li,
184 const char *fmt, ...);
185
186int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb, 133int nf_hook_slow(int pf, unsigned int hook, struct sk_buff *skb,
187 struct net_device *indev, struct net_device *outdev, 134 struct net_device *indev, struct net_device *outdev,
188 int (*okfn)(struct sk_buff *), int thresh); 135 int (*okfn)(struct sk_buff *), int thresh);
@@ -265,65 +212,28 @@ int compat_nf_setsockopt(struct sock *sk, int pf, int optval,
265int compat_nf_getsockopt(struct sock *sk, int pf, int optval, 212int compat_nf_getsockopt(struct sock *sk, int pf, int optval,
266 char __user *opt, int *len); 213 char __user *opt, int *len);
267 214
268/* Packet queuing */
269struct nf_queue_handler {
270 int (*outfn)(struct sk_buff *skb, struct nf_info *info,
271 unsigned int queuenum, void *data);
272 void *data;
273 char *name;
274};
275extern int nf_register_queue_handler(int pf,
276 struct nf_queue_handler *qh);
277extern int nf_unregister_queue_handler(int pf,
278 struct nf_queue_handler *qh);
279extern void nf_unregister_queue_handlers(struct nf_queue_handler *qh);
280extern void nf_reinject(struct sk_buff *skb,
281 struct nf_info *info,
282 unsigned int verdict);
283
284/* FIXME: Before cache is ever used, this must be implemented for real. */
285extern void nf_invalidate_cache(int pf);
286
287/* Call this before modifying an existing packet: ensures it is 215/* Call this before modifying an existing packet: ensures it is
288 modifiable and linear to the point you care about (writable_len). 216 modifiable and linear to the point you care about (writable_len).
289 Returns true or false. */ 217 Returns true or false. */
290extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len); 218extern int skb_make_writable(struct sk_buff *skb, unsigned int writable_len);
291 219
292static inline void nf_csum_replace4(__sum16 *sum, __be32 from, __be32 to) 220struct flowi;
293{ 221struct nf_queue_entry;
294 __be32 diff[] = { ~from, to };
295
296 *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum)));
297}
298
299static inline void nf_csum_replace2(__sum16 *sum, __be16 from, __be16 to)
300{
301 nf_csum_replace4(sum, (__force __be32)from, (__force __be32)to);
302}
303
304extern void nf_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
305 __be32 from, __be32 to, int pseudohdr);
306
307static inline void nf_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb,
308 __be16 from, __be16 to, int pseudohdr)
309{
310 nf_proto_csum_replace4(sum, skb, (__force __be32)from,
311 (__force __be32)to, pseudohdr);
312}
313 222
314struct nf_afinfo { 223struct nf_afinfo {
315 unsigned short family; 224 unsigned short family;
316 __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook, 225 __sum16 (*checksum)(struct sk_buff *skb, unsigned int hook,
317 unsigned int dataoff, u_int8_t protocol); 226 unsigned int dataoff, u_int8_t protocol);
227 int (*route)(struct dst_entry **dst, struct flowi *fl);
318 void (*saveroute)(const struct sk_buff *skb, 228 void (*saveroute)(const struct sk_buff *skb,
319 struct nf_info *info); 229 struct nf_queue_entry *entry);
320 int (*reroute)(struct sk_buff *skb, 230 int (*reroute)(struct sk_buff *skb,
321 const struct nf_info *info); 231 const struct nf_queue_entry *entry);
322 int route_key_size; 232 int route_key_size;
323}; 233};
324 234
325extern struct nf_afinfo *nf_afinfo[]; 235extern const struct nf_afinfo *nf_afinfo[NPROTO];
326static inline struct nf_afinfo *nf_get_afinfo(unsigned short family) 236static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
327{ 237{
328 return rcu_dereference(nf_afinfo[family]); 238 return rcu_dereference(nf_afinfo[family]);
329} 239}
@@ -332,7 +242,7 @@ static inline __sum16
332nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff, 242nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
333 u_int8_t protocol, unsigned short family) 243 u_int8_t protocol, unsigned short family)
334{ 244{
335 struct nf_afinfo *afinfo; 245 const struct nf_afinfo *afinfo;
336 __sum16 csum = 0; 246 __sum16 csum = 0;
337 247
338 rcu_read_lock(); 248 rcu_read_lock();
@@ -343,10 +253,8 @@ nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
343 return csum; 253 return csum;
344} 254}
345 255
346extern int nf_register_afinfo(struct nf_afinfo *afinfo); 256extern int nf_register_afinfo(const struct nf_afinfo *afinfo);
347extern void nf_unregister_afinfo(struct nf_afinfo *afinfo); 257extern void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
348
349#define nf_info_reroute(x) ((void *)x + sizeof(struct nf_info))
350 258
351#include <net/flow.h> 259#include <net/flow.h>
352extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *); 260extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *);
@@ -354,11 +262,16 @@ extern void (*ip_nat_decode_session)(struct sk_buff *, struct flowi *);
354static inline void 262static inline void
355nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family) 263nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, int family)
356{ 264{
357#if defined(CONFIG_IP_NF_NAT_NEEDED) || defined(CONFIG_NF_NAT_NEEDED) 265#ifdef CONFIG_NF_NAT_NEEDED
358 void (*decodefn)(struct sk_buff *, struct flowi *); 266 void (*decodefn)(struct sk_buff *, struct flowi *);
359 267
360 if (family == AF_INET && (decodefn = ip_nat_decode_session) != NULL) 268 if (family == AF_INET) {
361 decodefn(skb, fl); 269 rcu_read_lock();
270 decodefn = rcu_dereference(ip_nat_decode_session);
271 if (decodefn)
272 decodefn(skb, fl);
273 rcu_read_unlock();
274 }
362#endif 275#endif
363} 276}
364 277
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild
index f2eaea2234ec..91fef0cae42f 100644
--- a/include/linux/netfilter/Kbuild
+++ b/include/linux/netfilter/Kbuild
@@ -4,27 +4,34 @@ header-y += nfnetlink_conntrack.h
4header-y += nfnetlink_log.h 4header-y += nfnetlink_log.h
5header-y += nfnetlink_queue.h 5header-y += nfnetlink_queue.h
6header-y += xt_CLASSIFY.h 6header-y += xt_CLASSIFY.h
7header-y += xt_CONNMARK.h
8header-y += xt_CONNSECMARK.h
9header-y += xt_DSCP.h
10header-y += xt_MARK.h
11header-y += xt_NFLOG.h
12header-y += xt_NFQUEUE.h
13header-y += xt_RATEEST.h
14header-y += xt_SECMARK.h
15header-y += xt_TCPMSS.h
7header-y += xt_comment.h 16header-y += xt_comment.h
8header-y += xt_connbytes.h 17header-y += xt_connbytes.h
9header-y += xt_connmark.h 18header-y += xt_connmark.h
10header-y += xt_CONNMARK.h
11header-y += xt_conntrack.h 19header-y += xt_conntrack.h
12header-y += xt_dccp.h 20header-y += xt_dccp.h
13header-y += xt_dscp.h 21header-y += xt_dscp.h
14header-y += xt_DSCP.h
15header-y += xt_esp.h 22header-y += xt_esp.h
16header-y += xt_helper.h
17header-y += xt_hashlimit.h 23header-y += xt_hashlimit.h
24header-y += xt_iprange.h
25header-y += xt_helper.h
18header-y += xt_length.h 26header-y += xt_length.h
19header-y += xt_limit.h 27header-y += xt_limit.h
20header-y += xt_mac.h 28header-y += xt_mac.h
21header-y += xt_mark.h 29header-y += xt_mark.h
22header-y += xt_MARK.h
23header-y += xt_multiport.h 30header-y += xt_multiport.h
24header-y += xt_NFQUEUE.h 31header-y += xt_owner.h
25header-y += xt_NFLOG.h
26header-y += xt_pkttype.h 32header-y += xt_pkttype.h
27header-y += xt_policy.h 33header-y += xt_policy.h
34header-y += xt_rateest.h
28header-y += xt_realm.h 35header-y += xt_realm.h
29header-y += xt_sctp.h 36header-y += xt_sctp.h
30header-y += xt_state.h 37header-y += xt_state.h
@@ -32,9 +39,6 @@ header-y += xt_statistic.h
32header-y += xt_string.h 39header-y += xt_string.h
33header-y += xt_tcpmss.h 40header-y += xt_tcpmss.h
34header-y += xt_tcpudp.h 41header-y += xt_tcpudp.h
35header-y += xt_SECMARK.h
36header-y += xt_CONNSECMARK.h
37header-y += xt_TCPMSS.h
38 42
39unifdef-y += nf_conntrack_common.h 43unifdef-y += nf_conntrack_common.h
40unifdef-y += nf_conntrack_ftp.h 44unifdef-y += nf_conntrack_ftp.h
diff --git a/include/linux/netfilter/nf_conntrack_common.h b/include/linux/netfilter/nf_conntrack_common.h
index 9e0dae07861e..bad1eb760f61 100644
--- a/include/linux/netfilter/nf_conntrack_common.h
+++ b/include/linux/netfilter/nf_conntrack_common.h
@@ -129,6 +129,14 @@ enum ip_conntrack_events
129 /* Mark is set */ 129 /* Mark is set */
130 IPCT_MARK_BIT = 12, 130 IPCT_MARK_BIT = 12,
131 IPCT_MARK = (1 << IPCT_MARK_BIT), 131 IPCT_MARK = (1 << IPCT_MARK_BIT),
132
133 /* NAT sequence adjustment */
134 IPCT_NATSEQADJ_BIT = 13,
135 IPCT_NATSEQADJ = (1 << IPCT_NATSEQADJ_BIT),
136
137 /* Secmark is set */
138 IPCT_SECMARK_BIT = 14,
139 IPCT_SECMARK = (1 << IPCT_SECMARK_BIT),
132}; 140};
133 141
134enum ip_conntrack_expect_events { 142enum ip_conntrack_expect_events {
diff --git a/include/linux/netfilter/nf_conntrack_h323.h b/include/linux/netfilter/nf_conntrack_h323.h
index aabd24ac7631..26f9226ea72b 100644
--- a/include/linux/netfilter/nf_conntrack_h323.h
+++ b/include/linux/netfilter/nf_conntrack_h323.h
@@ -31,7 +31,7 @@ struct nf_conn;
31 31
32extern int get_h225_addr(struct nf_conn *ct, unsigned char *data, 32extern int get_h225_addr(struct nf_conn *ct, unsigned char *data,
33 TransportAddress *taddr, 33 TransportAddress *taddr,
34 union nf_conntrack_address *addr, __be16 *port); 34 union nf_inet_addr *addr, __be16 *port);
35extern void nf_conntrack_h245_expect(struct nf_conn *new, 35extern void nf_conntrack_h245_expect(struct nf_conn *new,
36 struct nf_conntrack_expect *this); 36 struct nf_conntrack_expect *this);
37extern void nf_conntrack_q931_expect(struct nf_conn *new, 37extern void nf_conntrack_q931_expect(struct nf_conn *new,
@@ -39,12 +39,12 @@ extern void nf_conntrack_q931_expect(struct nf_conn *new,
39extern int (*set_h245_addr_hook) (struct sk_buff *skb, 39extern int (*set_h245_addr_hook) (struct sk_buff *skb,
40 unsigned char **data, int dataoff, 40 unsigned char **data, int dataoff,
41 H245_TransportAddress *taddr, 41 H245_TransportAddress *taddr,
42 union nf_conntrack_address *addr, 42 union nf_inet_addr *addr,
43 __be16 port); 43 __be16 port);
44extern int (*set_h225_addr_hook) (struct sk_buff *skb, 44extern int (*set_h225_addr_hook) (struct sk_buff *skb,
45 unsigned char **data, int dataoff, 45 unsigned char **data, int dataoff,
46 TransportAddress *taddr, 46 TransportAddress *taddr,
47 union nf_conntrack_address *addr, 47 union nf_inet_addr *addr,
48 __be16 port); 48 __be16 port);
49extern int (*set_sig_addr_hook) (struct sk_buff *skb, 49extern int (*set_sig_addr_hook) (struct sk_buff *skb,
50 struct nf_conn *ct, 50 struct nf_conn *ct,
diff --git a/include/linux/netfilter/nf_conntrack_pptp.h b/include/linux/netfilter/nf_conntrack_pptp.h
index 23435496d24a..3bbde0c3a8a6 100644
--- a/include/linux/netfilter/nf_conntrack_pptp.h
+++ b/include/linux/netfilter/nf_conntrack_pptp.h
@@ -4,7 +4,7 @@
4 4
5#include <linux/netfilter/nf_conntrack_common.h> 5#include <linux/netfilter/nf_conntrack_common.h>
6 6
7extern const char *pptp_msg_name[]; 7extern const char *const pptp_msg_name[];
8 8
9/* state of the control session */ 9/* state of the control session */
10enum pptp_ctrlsess_state { 10enum pptp_ctrlsess_state {
diff --git a/include/linux/netfilter/nf_conntrack_sctp.h b/include/linux/netfilter/nf_conntrack_sctp.h
index 5cf2c115cce4..768f78c4ac53 100644
--- a/include/linux/netfilter/nf_conntrack_sctp.h
+++ b/include/linux/netfilter/nf_conntrack_sctp.h
@@ -21,7 +21,6 @@ struct ip_ct_sctp
21 enum sctp_conntrack state; 21 enum sctp_conntrack state;
22 22
23 __be32 vtag[IP_CT_DIR_MAX]; 23 __be32 vtag[IP_CT_DIR_MAX];
24 u_int32_t ttag[IP_CT_DIR_MAX];
25}; 24};
26 25
27#endif /* _NF_CONNTRACK_SCTP_H */ 26#endif /* _NF_CONNTRACK_SCTP_H */
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h
index 9fff19779bd5..8e5ce1ca7bfc 100644
--- a/include/linux/netfilter/nf_conntrack_sip.h
+++ b/include/linux/netfilter/nf_conntrack_sip.h
@@ -30,9 +30,9 @@ extern unsigned int (*nf_nat_sdp_hook)(struct sk_buff *skb,
30 struct nf_conntrack_expect *exp, 30 struct nf_conntrack_expect *exp,
31 const char *dptr); 31 const char *dptr);
32 32
33extern int ct_sip_get_info(struct nf_conn *ct, const char *dptr, size_t dlen, 33extern int ct_sip_get_info(const struct nf_conn *ct, const char *dptr,
34 unsigned int *matchoff, unsigned int *matchlen, 34 size_t dlen, unsigned int *matchoff,
35 enum sip_header_pos pos); 35 unsigned int *matchlen, enum sip_header_pos pos);
36extern int ct_sip_lnlen(const char *line, const char *limit); 36extern int ct_sip_lnlen(const char *line, const char *limit);
37extern const char *ct_sip_search(const char *needle, const char *haystack, 37extern const char *ct_sip_search(const char *needle, const char *haystack,
38 size_t needle_len, size_t haystack_len, 38 size_t needle_len, size_t haystack_len,
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h
index 4affa3fe78e0..e3e1533aba2d 100644
--- a/include/linux/netfilter/nfnetlink_conntrack.h
+++ b/include/linux/netfilter/nfnetlink_conntrack.h
@@ -37,6 +37,9 @@ enum ctattr_type {
37 CTA_ID, 37 CTA_ID,
38 CTA_NAT_DST, 38 CTA_NAT_DST,
39 CTA_TUPLE_MASTER, 39 CTA_TUPLE_MASTER,
40 CTA_NAT_SEQ_ADJ_ORIG,
41 CTA_NAT_SEQ_ADJ_REPLY,
42 CTA_SECMARK,
40 __CTA_MAX 43 __CTA_MAX
41}; 44};
42#define CTA_MAX (__CTA_MAX - 1) 45#define CTA_MAX (__CTA_MAX - 1)
@@ -119,6 +122,14 @@ enum ctattr_protonat {
119}; 122};
120#define CTA_PROTONAT_MAX (__CTA_PROTONAT_MAX - 1) 123#define CTA_PROTONAT_MAX (__CTA_PROTONAT_MAX - 1)
121 124
125enum ctattr_natseq {
126 CTA_NAT_SEQ_CORRECTION_POS,
127 CTA_NAT_SEQ_OFFSET_BEFORE,
128 CTA_NAT_SEQ_OFFSET_AFTER,
129 __CTA_NAT_SEQ_MAX
130};
131#define CTA_NAT_SEQ_MAX (__CTA_NAT_SEQ_MAX - 1)
132
122enum ctattr_expect { 133enum ctattr_expect {
123 CTA_EXPECT_UNSPEC, 134 CTA_EXPECT_UNSPEC,
124 CTA_EXPECT_MASTER, 135 CTA_EXPECT_MASTER,
diff --git a/include/linux/netfilter/nfnetlink_log.h b/include/linux/netfilter/nfnetlink_log.h
index 5966afa026e9..a85721332924 100644
--- a/include/linux/netfilter/nfnetlink_log.h
+++ b/include/linux/netfilter/nfnetlink_log.h
@@ -47,6 +47,7 @@ enum nfulnl_attr_type {
47 NFULA_UID, /* user id of socket */ 47 NFULA_UID, /* user id of socket */
48 NFULA_SEQ, /* instance-local sequence number */ 48 NFULA_SEQ, /* instance-local sequence number */
49 NFULA_SEQ_GLOBAL, /* global sequence number */ 49 NFULA_SEQ_GLOBAL, /* global sequence number */
50 NFULA_GID, /* group id of socket */
50 51
51 __NFULA_MAX 52 __NFULA_MAX
52}; 53};
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 03e6ce979eaa..b2c62cc618f5 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -126,6 +126,49 @@ struct xt_counters_info
126 126
127#define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */ 127#define XT_INV_PROTO 0x40 /* Invert the sense of PROTO. */
128 128
129/* fn returns 0 to continue iteration */
130#define XT_MATCH_ITERATE(type, e, fn, args...) \
131({ \
132 unsigned int __i; \
133 int __ret = 0; \
134 struct xt_entry_match *__m; \
135 \
136 for (__i = sizeof(type); \
137 __i < (e)->target_offset; \
138 __i += __m->u.match_size) { \
139 __m = (void *)e + __i; \
140 \
141 __ret = fn(__m , ## args); \
142 if (__ret != 0) \
143 break; \
144 } \
145 __ret; \
146})
147
148/* fn returns 0 to continue iteration */
149#define XT_ENTRY_ITERATE_CONTINUE(type, entries, size, n, fn, args...) \
150({ \
151 unsigned int __i, __n; \
152 int __ret = 0; \
153 type *__entry; \
154 \
155 for (__i = 0, __n = 0; __i < (size); \
156 __i += __entry->next_offset, __n++) { \
157 __entry = (void *)(entries) + __i; \
158 if (__n < n) \
159 continue; \
160 \
161 __ret = fn(__entry , ## args); \
162 if (__ret != 0) \
163 break; \
164 } \
165 __ret; \
166})
167
168/* fn returns 0 to continue iteration */
169#define XT_ENTRY_ITERATE(type, entries, size, fn, args...) \
170 XT_ENTRY_ITERATE_CONTINUE(type, entries, size, 0, fn, args)
171
129#ifdef __KERNEL__ 172#ifdef __KERNEL__
130 173
131#include <linux/netdevice.h> 174#include <linux/netdevice.h>
@@ -171,7 +214,7 @@ struct xt_match
171 /* Free to use by each match */ 214 /* Free to use by each match */
172 unsigned long data; 215 unsigned long data;
173 216
174 char *table; 217 const char *table;
175 unsigned int matchsize; 218 unsigned int matchsize;
176 unsigned int compatsize; 219 unsigned int compatsize;
177 unsigned int hooks; 220 unsigned int hooks;
@@ -218,7 +261,7 @@ struct xt_target
218 /* Set this to THIS_MODULE if you are a module, otherwise NULL */ 261 /* Set this to THIS_MODULE if you are a module, otherwise NULL */
219 struct module *me; 262 struct module *me;
220 263
221 char *table; 264 const char *table;
222 unsigned int targetsize; 265 unsigned int targetsize;
223 unsigned int compatsize; 266 unsigned int compatsize;
224 unsigned int hooks; 267 unsigned int hooks;
@@ -234,7 +277,7 @@ struct xt_table
234 struct list_head list; 277 struct list_head list;
235 278
236 /* A unique name... */ 279 /* A unique name... */
237 char name[XT_TABLE_MAXNAMELEN]; 280 const char name[XT_TABLE_MAXNAMELEN];
238 281
239 /* What hooks you will enter on */ 282 /* What hooks you will enter on */
240 unsigned int valid_hooks; 283 unsigned int valid_hooks;
@@ -265,13 +308,16 @@ struct xt_table_info
265 unsigned int initial_entries; 308 unsigned int initial_entries;
266 309
267 /* Entry points and underflows */ 310 /* Entry points and underflows */
268 unsigned int hook_entry[NF_IP_NUMHOOKS]; 311 unsigned int hook_entry[NF_INET_NUMHOOKS];
269 unsigned int underflow[NF_IP_NUMHOOKS]; 312 unsigned int underflow[NF_INET_NUMHOOKS];
270 313
271 /* ipt_entry tables: one per CPU */ 314 /* ipt_entry tables: one per CPU */
272 char *entries[NR_CPUS]; 315 /* Note : this field MUST be the last one, see XT_TABLE_INFO_SZ */
316 char *entries[1];
273}; 317};
274 318
319#define XT_TABLE_INFO_SZ (offsetof(struct xt_table_info, entries) \
320 + nr_cpu_ids * sizeof(char *))
275extern int xt_register_target(struct xt_target *target); 321extern int xt_register_target(struct xt_target *target);
276extern void xt_unregister_target(struct xt_target *target); 322extern void xt_unregister_target(struct xt_target *target);
277extern int xt_register_targets(struct xt_target *target, unsigned int n); 323extern int xt_register_targets(struct xt_target *target, unsigned int n);
@@ -289,9 +335,10 @@ extern int xt_check_target(const struct xt_target *target, unsigned short family
289 unsigned int size, const char *table, unsigned int hook, 335 unsigned int size, const char *table, unsigned int hook,
290 unsigned short proto, int inv_proto); 336 unsigned short proto, int inv_proto);
291 337
292extern int xt_register_table(struct xt_table *table, 338extern struct xt_table *xt_register_table(struct net *net,
293 struct xt_table_info *bootstrap, 339 struct xt_table *table,
294 struct xt_table_info *newinfo); 340 struct xt_table_info *bootstrap,
341 struct xt_table_info *newinfo);
295extern void *xt_unregister_table(struct xt_table *table); 342extern void *xt_unregister_table(struct xt_table *table);
296 343
297extern struct xt_table_info *xt_replace_table(struct xt_table *table, 344extern struct xt_table_info *xt_replace_table(struct xt_table *table,
@@ -306,11 +353,12 @@ extern struct xt_target *xt_request_find_target(int af, const char *name,
306extern int xt_find_revision(int af, const char *name, u8 revision, int target, 353extern int xt_find_revision(int af, const char *name, u8 revision, int target,
307 int *err); 354 int *err);
308 355
309extern struct xt_table *xt_find_table_lock(int af, const char *name); 356extern struct xt_table *xt_find_table_lock(struct net *net, int af,
357 const char *name);
310extern void xt_table_unlock(struct xt_table *t); 358extern void xt_table_unlock(struct xt_table *t);
311 359
312extern int xt_proto_init(int af); 360extern int xt_proto_init(struct net *net, int af);
313extern void xt_proto_fini(int af); 361extern void xt_proto_fini(struct net *net, int af);
314 362
315extern struct xt_table_info *xt_alloc_table_info(unsigned int size); 363extern struct xt_table_info *xt_alloc_table_info(unsigned int size);
316extern void xt_free_table_info(struct xt_table_info *info); 364extern void xt_free_table_info(struct xt_table_info *info);
@@ -378,17 +426,21 @@ struct compat_xt_counters_info
378extern void xt_compat_lock(int af); 426extern void xt_compat_lock(int af);
379extern void xt_compat_unlock(int af); 427extern void xt_compat_unlock(int af);
380 428
429extern int xt_compat_add_offset(int af, unsigned int offset, short delta);
430extern void xt_compat_flush_offsets(int af);
431extern short xt_compat_calc_jump(int af, unsigned int offset);
432
381extern int xt_compat_match_offset(struct xt_match *match); 433extern int xt_compat_match_offset(struct xt_match *match);
382extern void xt_compat_match_from_user(struct xt_entry_match *m, 434extern int xt_compat_match_from_user(struct xt_entry_match *m,
383 void **dstptr, int *size); 435 void **dstptr, unsigned int *size);
384extern int xt_compat_match_to_user(struct xt_entry_match *m, 436extern int xt_compat_match_to_user(struct xt_entry_match *m,
385 void __user **dstptr, int *size); 437 void __user **dstptr, unsigned int *size);
386 438
387extern int xt_compat_target_offset(struct xt_target *target); 439extern int xt_compat_target_offset(struct xt_target *target);
388extern void xt_compat_target_from_user(struct xt_entry_target *t, 440extern void xt_compat_target_from_user(struct xt_entry_target *t,
389 void **dstptr, int *size); 441 void **dstptr, unsigned int *size);
390extern int xt_compat_target_to_user(struct xt_entry_target *t, 442extern int xt_compat_target_to_user(struct xt_entry_target *t,
391 void __user **dstptr, int *size); 443 void __user **dstptr, unsigned int *size);
392 444
393#endif /* CONFIG_COMPAT */ 445#endif /* CONFIG_COMPAT */
394#endif /* __KERNEL__ */ 446#endif /* __KERNEL__ */
diff --git a/include/linux/netfilter/xt_CONNMARK.h b/include/linux/netfilter/xt_CONNMARK.h
index 9f744689fffc..4e58ba43c289 100644
--- a/include/linux/netfilter/xt_CONNMARK.h
+++ b/include/linux/netfilter/xt_CONNMARK.h
@@ -22,4 +22,9 @@ struct xt_connmark_target_info {
22 u_int8_t mode; 22 u_int8_t mode;
23}; 23};
24 24
25struct xt_connmark_tginfo1 {
26 u_int32_t ctmark, ctmask, nfmask;
27 u_int8_t mode;
28};
29
25#endif /*_XT_CONNMARK_H_target*/ 30#endif /*_XT_CONNMARK_H_target*/
diff --git a/include/linux/netfilter/xt_DSCP.h b/include/linux/netfilter/xt_DSCP.h
index 3c7c963997bd..14da1968e2c6 100644
--- a/include/linux/netfilter/xt_DSCP.h
+++ b/include/linux/netfilter/xt_DSCP.h
@@ -17,4 +17,9 @@ struct xt_DSCP_info {
17 u_int8_t dscp; 17 u_int8_t dscp;
18}; 18};
19 19
20struct xt_tos_target_info {
21 u_int8_t tos_value;
22 u_int8_t tos_mask;
23};
24
20#endif /* _XT_DSCP_TARGET_H */ 25#endif /* _XT_DSCP_TARGET_H */
diff --git a/include/linux/netfilter/xt_MARK.h b/include/linux/netfilter/xt_MARK.h
index b021e93ee5d6..778b278fd9f2 100644
--- a/include/linux/netfilter/xt_MARK.h
+++ b/include/linux/netfilter/xt_MARK.h
@@ -18,4 +18,8 @@ struct xt_mark_target_info_v1 {
18 u_int8_t mode; 18 u_int8_t mode;
19}; 19};
20 20
21struct xt_mark_tginfo2 {
22 u_int32_t mark, mask;
23};
24
21#endif /*_XT_MARK_H_target */ 25#endif /*_XT_MARK_H_target */
diff --git a/include/linux/netfilter/xt_RATEEST.h b/include/linux/netfilter/xt_RATEEST.h
new file mode 100644
index 000000000000..f79e3133cbea
--- /dev/null
+++ b/include/linux/netfilter/xt_RATEEST.h
@@ -0,0 +1,13 @@
1#ifndef _XT_RATEEST_TARGET_H
2#define _XT_RATEEST_TARGET_H
3
4struct xt_rateest_target_info {
5 char name[IFNAMSIZ];
6 int8_t interval;
7 u_int8_t ewma_log;
8
9 /* Used internally by the kernel */
10 struct xt_rateest *est __attribute__((aligned(8)));
11};
12
13#endif /* _XT_RATEEST_TARGET_H */
diff --git a/include/linux/netfilter/xt_TCPOPTSTRIP.h b/include/linux/netfilter/xt_TCPOPTSTRIP.h
new file mode 100644
index 000000000000..2db543214ff5
--- /dev/null
+++ b/include/linux/netfilter/xt_TCPOPTSTRIP.h
@@ -0,0 +1,13 @@
1#ifndef _XT_TCPOPTSTRIP_H
2#define _XT_TCPOPTSTRIP_H
3
4#define tcpoptstrip_set_bit(bmap, idx) \
5 (bmap[(idx) >> 5] |= 1U << (idx & 31))
6#define tcpoptstrip_test_bit(bmap, idx) \
7 (((1U << (idx & 31)) & bmap[(idx) >> 5]) != 0)
8
9struct xt_tcpoptstrip_target_info {
10 u_int32_t strip_bmap[8];
11};
12
13#endif /* _XT_TCPOPTSTRIP_H */
diff --git a/include/linux/netfilter/xt_connlimit.h b/include/linux/netfilter/xt_connlimit.h
index 37e933c9987d..7e3284bcbd2b 100644
--- a/include/linux/netfilter/xt_connlimit.h
+++ b/include/linux/netfilter/xt_connlimit.h
@@ -5,12 +5,17 @@ struct xt_connlimit_data;
5 5
6struct xt_connlimit_info { 6struct xt_connlimit_info {
7 union { 7 union {
8 __be32 v4_mask; 8 union nf_inet_addr mask;
9 __be32 v6_mask[4]; 9#ifndef __KERNEL__
10 union {
11 __be32 v4_mask;
12 __be32 v6_mask[4];
13 };
14#endif
10 }; 15 };
11 unsigned int limit, inverse; 16 unsigned int limit, inverse;
12 17
13 /* this needs to be at the end */ 18 /* Used internally by the kernel */
14 struct xt_connlimit_data *data __attribute__((aligned(8))); 19 struct xt_connlimit_data *data __attribute__((aligned(8)));
15}; 20};
16 21
diff --git a/include/linux/netfilter/xt_connmark.h b/include/linux/netfilter/xt_connmark.h
index c592f6ae0883..359ef86918dc 100644
--- a/include/linux/netfilter/xt_connmark.h
+++ b/include/linux/netfilter/xt_connmark.h
@@ -15,4 +15,9 @@ struct xt_connmark_info {
15 u_int8_t invert; 15 u_int8_t invert;
16}; 16};
17 17
18struct xt_connmark_mtinfo1 {
19 u_int32_t mark, mask;
20 u_int8_t invert;
21};
22
18#endif /*_XT_CONNMARK_H*/ 23#endif /*_XT_CONNMARK_H*/
diff --git a/include/linux/netfilter/xt_conntrack.h b/include/linux/netfilter/xt_conntrack.h
index 70b6f718cf4c..f3fd83e46bab 100644
--- a/include/linux/netfilter/xt_conntrack.h
+++ b/include/linux/netfilter/xt_conntrack.h
@@ -6,7 +6,6 @@
6#define _XT_CONNTRACK_H 6#define _XT_CONNTRACK_H
7 7
8#include <linux/netfilter/nf_conntrack_tuple_common.h> 8#include <linux/netfilter/nf_conntrack_tuple_common.h>
9#include <linux/in.h>
10 9
11#define XT_CONNTRACK_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1)) 10#define XT_CONNTRACK_STATE_BIT(ctinfo) (1 << ((ctinfo)%IP_CT_IS_REPLY+1))
12#define XT_CONNTRACK_STATE_INVALID (1 << 0) 11#define XT_CONNTRACK_STATE_INVALID (1 << 0)
@@ -16,14 +15,21 @@
16#define XT_CONNTRACK_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 3)) 15#define XT_CONNTRACK_STATE_UNTRACKED (1 << (IP_CT_NUMBER + 3))
17 16
18/* flags, invflags: */ 17/* flags, invflags: */
19#define XT_CONNTRACK_STATE 0x01 18enum {
20#define XT_CONNTRACK_PROTO 0x02 19 XT_CONNTRACK_STATE = 1 << 0,
21#define XT_CONNTRACK_ORIGSRC 0x04 20 XT_CONNTRACK_PROTO = 1 << 1,
22#define XT_CONNTRACK_ORIGDST 0x08 21 XT_CONNTRACK_ORIGSRC = 1 << 2,
23#define XT_CONNTRACK_REPLSRC 0x10 22 XT_CONNTRACK_ORIGDST = 1 << 3,
24#define XT_CONNTRACK_REPLDST 0x20 23 XT_CONNTRACK_REPLSRC = 1 << 4,
25#define XT_CONNTRACK_STATUS 0x40 24 XT_CONNTRACK_REPLDST = 1 << 5,
26#define XT_CONNTRACK_EXPIRES 0x80 25 XT_CONNTRACK_STATUS = 1 << 6,
26 XT_CONNTRACK_EXPIRES = 1 << 7,
27 XT_CONNTRACK_ORIGSRC_PORT = 1 << 8,
28 XT_CONNTRACK_ORIGDST_PORT = 1 << 9,
29 XT_CONNTRACK_REPLSRC_PORT = 1 << 10,
30 XT_CONNTRACK_REPLDST_PORT = 1 << 11,
31 XT_CONNTRACK_DIRECTION = 1 << 12,
32};
27 33
28/* This is exposed to userspace, so remains frozen in time. */ 34/* This is exposed to userspace, so remains frozen in time. */
29struct ip_conntrack_old_tuple 35struct ip_conntrack_old_tuple
@@ -60,4 +66,18 @@ struct xt_conntrack_info
60 /* Inverse flags */ 66 /* Inverse flags */
61 u_int8_t invflags; 67 u_int8_t invflags;
62}; 68};
69
70struct xt_conntrack_mtinfo1 {
71 union nf_inet_addr origsrc_addr, origsrc_mask;
72 union nf_inet_addr origdst_addr, origdst_mask;
73 union nf_inet_addr replsrc_addr, replsrc_mask;
74 union nf_inet_addr repldst_addr, repldst_mask;
75 u_int32_t expires_min, expires_max;
76 u_int16_t l4proto;
77 __be16 origsrc_port, origdst_port;
78 __be16 replsrc_port, repldst_port;
79 u_int16_t match_flags, invert_flags;
80 u_int8_t state_mask, status_mask;
81};
82
63#endif /*_XT_CONNTRACK_H*/ 83#endif /*_XT_CONNTRACK_H*/
diff --git a/include/linux/netfilter/xt_dscp.h b/include/linux/netfilter/xt_dscp.h
index 1da61e6acaf7..f49bc1a648dc 100644
--- a/include/linux/netfilter/xt_dscp.h
+++ b/include/linux/netfilter/xt_dscp.h
@@ -20,4 +20,10 @@ struct xt_dscp_info {
20 u_int8_t invert; 20 u_int8_t invert;
21}; 21};
22 22
23struct xt_tos_match_info {
24 u_int8_t tos_mask;
25 u_int8_t tos_value;
26 u_int8_t invert;
27};
28
23#endif /* _XT_DSCP_H */ 29#endif /* _XT_DSCP_H */
diff --git a/include/linux/netfilter/xt_hashlimit.h b/include/linux/netfilter/xt_hashlimit.h
index b4556b8edbfd..58b818ee41ca 100644
--- a/include/linux/netfilter/xt_hashlimit.h
+++ b/include/linux/netfilter/xt_hashlimit.h
@@ -9,13 +9,16 @@
9/* details of this structure hidden by the implementation */ 9/* details of this structure hidden by the implementation */
10struct xt_hashlimit_htable; 10struct xt_hashlimit_htable;
11 11
12#define XT_HASHLIMIT_HASH_DIP 0x0001 12enum {
13#define XT_HASHLIMIT_HASH_DPT 0x0002 13 XT_HASHLIMIT_HASH_DIP = 1 << 0,
14#define XT_HASHLIMIT_HASH_SIP 0x0004 14 XT_HASHLIMIT_HASH_DPT = 1 << 1,
15#define XT_HASHLIMIT_HASH_SPT 0x0008 15 XT_HASHLIMIT_HASH_SIP = 1 << 2,
16 XT_HASHLIMIT_HASH_SPT = 1 << 3,
17 XT_HASHLIMIT_INVERT = 1 << 4,
18};
16 19
17struct hashlimit_cfg { 20struct hashlimit_cfg {
18 u_int32_t mode; /* bitmask of IPT_HASHLIMIT_HASH_* */ 21 u_int32_t mode; /* bitmask of XT_HASHLIMIT_HASH_* */
19 u_int32_t avg; /* Average secs between packets * scale */ 22 u_int32_t avg; /* Average secs between packets * scale */
20 u_int32_t burst; /* Period multiplier for upper limit. */ 23 u_int32_t burst; /* Period multiplier for upper limit. */
21 24
@@ -29,12 +32,36 @@ struct hashlimit_cfg {
29struct xt_hashlimit_info { 32struct xt_hashlimit_info {
30 char name [IFNAMSIZ]; /* name */ 33 char name [IFNAMSIZ]; /* name */
31 struct hashlimit_cfg cfg; 34 struct hashlimit_cfg cfg;
32 struct xt_hashlimit_htable *hinfo;
33 35
34 /* Used internally by the kernel */ 36 /* Used internally by the kernel */
37 struct xt_hashlimit_htable *hinfo;
35 union { 38 union {
36 void *ptr; 39 void *ptr;
37 struct xt_hashlimit_info *master; 40 struct xt_hashlimit_info *master;
38 } u; 41 } u;
39}; 42};
43
44struct hashlimit_cfg1 {
45 u_int32_t mode; /* bitmask of XT_HASHLIMIT_HASH_* */
46 u_int32_t avg; /* Average secs between packets * scale */
47 u_int32_t burst; /* Period multiplier for upper limit. */
48
49 /* user specified */
50 u_int32_t size; /* how many buckets */
51 u_int32_t max; /* max number of entries */
52 u_int32_t gc_interval; /* gc interval */
53 u_int32_t expire; /* when do entries expire? */
54
55 u_int8_t srcmask, dstmask;
56};
57
58struct xt_hashlimit_mtinfo1 {
59 char name[IFNAMSIZ];
60 struct hashlimit_cfg1 cfg;
61
62 /* Used internally by the kernel */
63 struct xt_hashlimit_htable *hinfo __attribute__((aligned(8)));
64 struct xt_hashlimit_mtinfo1 *master __attribute__((aligned(8)));
65};
66
40#endif /*_XT_HASHLIMIT_H*/ 67#endif /*_XT_HASHLIMIT_H*/
diff --git a/include/linux/netfilter/xt_iprange.h b/include/linux/netfilter/xt_iprange.h
new file mode 100644
index 000000000000..a4299c7d3680
--- /dev/null
+++ b/include/linux/netfilter/xt_iprange.h
@@ -0,0 +1,17 @@
1#ifndef _LINUX_NETFILTER_XT_IPRANGE_H
2#define _LINUX_NETFILTER_XT_IPRANGE_H 1
3
4enum {
5 IPRANGE_SRC = 1 << 0, /* match source IP address */
6 IPRANGE_DST = 1 << 1, /* match destination IP address */
7 IPRANGE_SRC_INV = 1 << 4, /* negate the condition */
8 IPRANGE_DST_INV = 1 << 5, /* -"- */
9};
10
11struct xt_iprange_mtinfo {
12 union nf_inet_addr src_min, src_max;
13 union nf_inet_addr dst_min, dst_max;
14 u_int8_t flags;
15};
16
17#endif /* _LINUX_NETFILTER_XT_IPRANGE_H */
diff --git a/include/linux/netfilter/xt_mark.h b/include/linux/netfilter/xt_mark.h
index 802dd4842caf..fae74bc3f34e 100644
--- a/include/linux/netfilter/xt_mark.h
+++ b/include/linux/netfilter/xt_mark.h
@@ -6,4 +6,9 @@ struct xt_mark_info {
6 u_int8_t invert; 6 u_int8_t invert;
7}; 7};
8 8
9struct xt_mark_mtinfo1 {
10 u_int32_t mark, mask;
11 u_int8_t invert;
12};
13
9#endif /*_XT_MARK_H*/ 14#endif /*_XT_MARK_H*/
diff --git a/include/linux/netfilter/xt_owner.h b/include/linux/netfilter/xt_owner.h
new file mode 100644
index 000000000000..c84e52cfe415
--- /dev/null
+++ b/include/linux/netfilter/xt_owner.h
@@ -0,0 +1,16 @@
1#ifndef _XT_OWNER_MATCH_H
2#define _XT_OWNER_MATCH_H
3
4enum {
5 XT_OWNER_UID = 1 << 0,
6 XT_OWNER_GID = 1 << 1,
7 XT_OWNER_SOCKET = 1 << 2,
8};
9
10struct xt_owner_match_info {
11 u_int32_t uid_min, uid_max;
12 u_int32_t gid_min, gid_max;
13 u_int8_t match, invert;
14};
15
16#endif /* _XT_OWNER_MATCH_H */
diff --git a/include/linux/netfilter/xt_policy.h b/include/linux/netfilter/xt_policy.h
index 45654d359a68..053d8cc65464 100644
--- a/include/linux/netfilter/xt_policy.h
+++ b/include/linux/netfilter/xt_policy.h
@@ -27,18 +27,33 @@ struct xt_policy_spec
27 reqid:1; 27 reqid:1;
28}; 28};
29 29
30#ifndef __KERNEL__
30union xt_policy_addr 31union xt_policy_addr
31{ 32{
32 struct in_addr a4; 33 struct in_addr a4;
33 struct in6_addr a6; 34 struct in6_addr a6;
34}; 35};
36#endif
35 37
36struct xt_policy_elem 38struct xt_policy_elem
37{ 39{
38 union xt_policy_addr saddr; 40 union {
39 union xt_policy_addr smask; 41#ifdef __KERNEL__
40 union xt_policy_addr daddr; 42 struct {
41 union xt_policy_addr dmask; 43 union nf_inet_addr saddr;
44 union nf_inet_addr smask;
45 union nf_inet_addr daddr;
46 union nf_inet_addr dmask;
47 };
48#else
49 struct {
50 union xt_policy_addr saddr;
51 union xt_policy_addr smask;
52 union xt_policy_addr daddr;
53 union xt_policy_addr dmask;
54 };
55#endif
56 };
42 __be32 spi; 57 __be32 spi;
43 u_int32_t reqid; 58 u_int32_t reqid;
44 u_int8_t proto; 59 u_int8_t proto;
diff --git a/include/linux/netfilter/xt_quota.h b/include/linux/netfilter/xt_quota.h
index acd7fd77bbee..4c8368d781e5 100644
--- a/include/linux/netfilter/xt_quota.h
+++ b/include/linux/netfilter/xt_quota.h
@@ -9,6 +9,8 @@ enum xt_quota_flags {
9struct xt_quota_info { 9struct xt_quota_info {
10 u_int32_t flags; 10 u_int32_t flags;
11 u_int32_t pad; 11 u_int32_t pad;
12
13 /* Used internally by the kernel */
12 aligned_u64 quota; 14 aligned_u64 quota;
13 struct xt_quota_info *master; 15 struct xt_quota_info *master;
14}; 16};
diff --git a/include/linux/netfilter/xt_rateest.h b/include/linux/netfilter/xt_rateest.h
new file mode 100644
index 000000000000..2010cb74250f
--- /dev/null
+++ b/include/linux/netfilter/xt_rateest.h
@@ -0,0 +1,35 @@
1#ifndef _XT_RATEEST_MATCH_H
2#define _XT_RATEEST_MATCH_H
3
4enum xt_rateest_match_flags {
5 XT_RATEEST_MATCH_INVERT = 1<<0,
6 XT_RATEEST_MATCH_ABS = 1<<1,
7 XT_RATEEST_MATCH_REL = 1<<2,
8 XT_RATEEST_MATCH_DELTA = 1<<3,
9 XT_RATEEST_MATCH_BPS = 1<<4,
10 XT_RATEEST_MATCH_PPS = 1<<5,
11};
12
13enum xt_rateest_match_mode {
14 XT_RATEEST_MATCH_NONE,
15 XT_RATEEST_MATCH_EQ,
16 XT_RATEEST_MATCH_LT,
17 XT_RATEEST_MATCH_GT,
18};
19
20struct xt_rateest_match_info {
21 char name1[IFNAMSIZ];
22 char name2[IFNAMSIZ];
23 u_int16_t flags;
24 u_int16_t mode;
25 u_int32_t bps1;
26 u_int32_t pps1;
27 u_int32_t bps2;
28 u_int32_t pps2;
29
30 /* Used internally by the kernel */
31 struct xt_rateest *est1 __attribute__((aligned(8)));
32 struct xt_rateest *est2 __attribute__((aligned(8)));
33};
34
35#endif /* _XT_RATEEST_MATCH_H */
diff --git a/include/linux/netfilter/xt_statistic.h b/include/linux/netfilter/xt_statistic.h
index c344e9916e23..3d38bc975048 100644
--- a/include/linux/netfilter/xt_statistic.h
+++ b/include/linux/netfilter/xt_statistic.h
@@ -23,6 +23,7 @@ struct xt_statistic_info {
23 struct { 23 struct {
24 u_int32_t every; 24 u_int32_t every;
25 u_int32_t packet; 25 u_int32_t packet;
26 /* Used internally by the kernel */
26 u_int32_t count; 27 u_int32_t count;
27 } nth; 28 } nth;
28 } u; 29 } u;
diff --git a/include/linux/netfilter/xt_string.h b/include/linux/netfilter/xt_string.h
index 3b3419f2637d..bb21dd1aee2d 100644
--- a/include/linux/netfilter/xt_string.h
+++ b/include/linux/netfilter/xt_string.h
@@ -12,6 +12,8 @@ struct xt_string_info
12 char pattern[XT_STRING_MAX_PATTERN_SIZE]; 12 char pattern[XT_STRING_MAX_PATTERN_SIZE];
13 u_int8_t patlen; 13 u_int8_t patlen;
14 u_int8_t invert; 14 u_int8_t invert;
15
16 /* Used internally by the kernel */
15 struct ts_config __attribute__((aligned(8))) *config; 17 struct ts_config __attribute__((aligned(8))) *config;
16}; 18};
17 19
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index 2fc73fa8e37f..db223ca92c8b 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -217,21 +217,8 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e
217} 217}
218 218
219/* fn returns 0 to continue iteration */ 219/* fn returns 0 to continue iteration */
220#define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ 220#define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
221({ \ 221 XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args)
222 unsigned int __i; \
223 int __ret = 0; \
224 struct arpt_entry *__entry; \
225 \
226 for (__i = 0; __i < (size); __i += __entry->next_offset) { \
227 __entry = (void *)(entries) + __i; \
228 \
229 __ret = fn(__entry , ## args); \
230 if (__ret != 0) \
231 break; \
232 } \
233 __ret; \
234})
235 222
236/* 223/*
237 * Main firewall chains definitions and global var's definitions. 224 * Main firewall chains definitions and global var's definitions.
@@ -284,8 +271,9 @@ struct arpt_error
284 xt_register_target(tgt); }) 271 xt_register_target(tgt); })
285#define arpt_unregister_target(tgt) xt_unregister_target(tgt) 272#define arpt_unregister_target(tgt) xt_unregister_target(tgt)
286 273
287extern int arpt_register_table(struct arpt_table *table, 274extern struct arpt_table *arpt_register_table(struct net *net,
288 const struct arpt_replace *repl); 275 struct arpt_table *table,
276 const struct arpt_replace *repl);
289extern void arpt_unregister_table(struct arpt_table *table); 277extern void arpt_unregister_table(struct arpt_table *table);
290extern unsigned int arpt_do_table(struct sk_buff *skb, 278extern unsigned int arpt_do_table(struct sk_buff *skb,
291 unsigned int hook, 279 unsigned int hook,
@@ -293,6 +281,37 @@ extern unsigned int arpt_do_table(struct sk_buff *skb,
293 const struct net_device *out, 281 const struct net_device *out,
294 struct arpt_table *table); 282 struct arpt_table *table);
295 283
296#define ARPT_ALIGN(s) (((s) + (__alignof__(struct arpt_entry)-1)) & ~(__alignof__(struct arpt_entry)-1)) 284#define ARPT_ALIGN(s) XT_ALIGN(s)
285
286#ifdef CONFIG_COMPAT
287#include <net/compat.h>
288
289struct compat_arpt_entry
290{
291 struct arpt_arp arp;
292 u_int16_t target_offset;
293 u_int16_t next_offset;
294 compat_uint_t comefrom;
295 struct compat_xt_counters counters;
296 unsigned char elems[0];
297};
298
299static inline struct arpt_entry_target *
300compat_arpt_get_target(struct compat_arpt_entry *e)
301{
302 return (void *)e + e->target_offset;
303}
304
305#define COMPAT_ARPT_ALIGN(s) COMPAT_XT_ALIGN(s)
306
307/* fn returns 0 to continue iteration */
308#define COMPAT_ARPT_ENTRY_ITERATE(entries, size, fn, args...) \
309 XT_ENTRY_ITERATE(struct compat_arpt_entry, entries, size, fn, ## args)
310
311#define COMPAT_ARPT_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \
312 XT_ENTRY_ITERATE_CONTINUE(struct compat_arpt_entry, entries, size, n, \
313 fn, ## args)
314
315#endif /* CONFIG_COMPAT */
297#endif /*__KERNEL__*/ 316#endif /*__KERNEL__*/
298#endif /* _ARPTABLES_H */ 317#endif /* _ARPTABLES_H */
diff --git a/include/linux/netfilter_bridge.h b/include/linux/netfilter_bridge.h
index 533ee351a273..499aa9375901 100644
--- a/include/linux/netfilter_bridge.h
+++ b/include/linux/netfilter_bridge.h
@@ -50,7 +50,8 @@ enum nf_br_hook_priorities {
50extern int nf_bridge_copy_header(struct sk_buff *skb); 50extern int nf_bridge_copy_header(struct sk_buff *skb);
51static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb) 51static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb)
52{ 52{
53 if (skb->nf_bridge) 53 if (skb->nf_bridge &&
54 skb->nf_bridge->mask & (BRNF_BRIDGED | BRNF_BRIDGED_DNAT))
54 return nf_bridge_copy_header(skb); 55 return nf_bridge_copy_header(skb);
55 return 0; 56 return 0;
56} 57}
diff --git a/include/linux/netfilter_ipv4.h b/include/linux/netfilter_ipv4.h
index 1a63adf5c4c1..9a10092e358c 100644
--- a/include/linux/netfilter_ipv4.h
+++ b/include/linux/netfilter_ipv4.h
@@ -36,7 +36,6 @@
36#define NFC_IP_DST_PT 0x0400 36#define NFC_IP_DST_PT 0x0400
37/* Something else about the proto */ 37/* Something else about the proto */
38#define NFC_IP_PROTO_UNKNOWN 0x2000 38#define NFC_IP_PROTO_UNKNOWN 0x2000
39#endif /* ! __KERNEL__ */
40 39
41/* IP Hooks */ 40/* IP Hooks */
42/* After promisc drops, checksum checks. */ 41/* After promisc drops, checksum checks. */
@@ -50,6 +49,7 @@
50/* Packets about to hit the wire. */ 49/* Packets about to hit the wire. */
51#define NF_IP_POST_ROUTING 4 50#define NF_IP_POST_ROUTING 4
52#define NF_IP_NUMHOOKS 5 51#define NF_IP_NUMHOOKS 5
52#endif /* ! __KERNEL__ */
53 53
54enum nf_ip_hook_priorities { 54enum nf_ip_hook_priorities {
55 NF_IP_PRI_FIRST = INT_MIN, 55 NF_IP_PRI_FIRST = INT_MIN,
diff --git a/include/linux/netfilter_ipv4/Kbuild b/include/linux/netfilter_ipv4/Kbuild
index 7185792b900f..3a7105bb8f33 100644
--- a/include/linux/netfilter_ipv4/Kbuild
+++ b/include/linux/netfilter_ipv4/Kbuild
@@ -1,47 +1,47 @@
1header-y += ipt_addrtype.h
2header-y += ipt_ah.h
3header-y += ipt_CLASSIFY.h 1header-y += ipt_CLASSIFY.h
4header-y += ipt_CLUSTERIP.h 2header-y += ipt_CLUSTERIP.h
3header-y += ipt_CONNMARK.h
4header-y += ipt_DSCP.h
5header-y += ipt_ECN.h
6header-y += ipt_LOG.h
7header-y += ipt_MARK.h
8header-y += ipt_NFQUEUE.h
9header-y += ipt_REJECT.h
10header-y += ipt_SAME.h
11header-y += ipt_TCPMSS.h
12header-y += ipt_TOS.h
13header-y += ipt_TTL.h
14header-y += ipt_ULOG.h
15header-y += ipt_addrtype.h
16header-y += ipt_ah.h
5header-y += ipt_comment.h 17header-y += ipt_comment.h
6header-y += ipt_connbytes.h 18header-y += ipt_connbytes.h
7header-y += ipt_connmark.h 19header-y += ipt_connmark.h
8header-y += ipt_CONNMARK.h
9header-y += ipt_conntrack.h 20header-y += ipt_conntrack.h
10header-y += ipt_dccp.h 21header-y += ipt_dccp.h
11header-y += ipt_dscp.h 22header-y += ipt_dscp.h
12header-y += ipt_DSCP.h
13header-y += ipt_ecn.h 23header-y += ipt_ecn.h
14header-y += ipt_ECN.h
15header-y += ipt_esp.h 24header-y += ipt_esp.h
16header-y += ipt_hashlimit.h 25header-y += ipt_hashlimit.h
17header-y += ipt_helper.h 26header-y += ipt_helper.h
18header-y += ipt_iprange.h 27header-y += ipt_iprange.h
19header-y += ipt_length.h 28header-y += ipt_length.h
20header-y += ipt_limit.h 29header-y += ipt_limit.h
21header-y += ipt_LOG.h
22header-y += ipt_mac.h 30header-y += ipt_mac.h
23header-y += ipt_mark.h 31header-y += ipt_mark.h
24header-y += ipt_MARK.h
25header-y += ipt_multiport.h 32header-y += ipt_multiport.h
26header-y += ipt_NFQUEUE.h
27header-y += ipt_owner.h 33header-y += ipt_owner.h
28header-y += ipt_physdev.h 34header-y += ipt_physdev.h
29header-y += ipt_pkttype.h 35header-y += ipt_pkttype.h
30header-y += ipt_policy.h 36header-y += ipt_policy.h
31header-y += ipt_realm.h 37header-y += ipt_realm.h
32header-y += ipt_recent.h 38header-y += ipt_recent.h
33header-y += ipt_REJECT.h
34header-y += ipt_SAME.h
35header-y += ipt_sctp.h 39header-y += ipt_sctp.h
36header-y += ipt_state.h 40header-y += ipt_state.h
37header-y += ipt_string.h 41header-y += ipt_string.h
38header-y += ipt_tcpmss.h 42header-y += ipt_tcpmss.h
39header-y += ipt_TCPMSS.h
40header-y += ipt_tos.h 43header-y += ipt_tos.h
41header-y += ipt_TOS.h
42header-y += ipt_ttl.h 44header-y += ipt_ttl.h
43header-y += ipt_TTL.h
44header-y += ipt_ULOG.h
45 45
46unifdef-y += ip_queue.h 46unifdef-y += ip_queue.h
47unifdef-y += ip_tables.h 47unifdef-y += ip_tables.h
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index d79ed69cbc1f..bfc889f90276 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -156,10 +156,10 @@ struct ipt_getinfo
156 unsigned int valid_hooks; 156 unsigned int valid_hooks;
157 157
158 /* Hook entry points: one per netfilter hook. */ 158 /* Hook entry points: one per netfilter hook. */
159 unsigned int hook_entry[NF_IP_NUMHOOKS]; 159 unsigned int hook_entry[NF_INET_NUMHOOKS];
160 160
161 /* Underflow points. */ 161 /* Underflow points. */
162 unsigned int underflow[NF_IP_NUMHOOKS]; 162 unsigned int underflow[NF_INET_NUMHOOKS];
163 163
164 /* Number of entries */ 164 /* Number of entries */
165 unsigned int num_entries; 165 unsigned int num_entries;
@@ -185,10 +185,10 @@ struct ipt_replace
185 unsigned int size; 185 unsigned int size;
186 186
187 /* Hook entry points. */ 187 /* Hook entry points. */
188 unsigned int hook_entry[NF_IP_NUMHOOKS]; 188 unsigned int hook_entry[NF_INET_NUMHOOKS];
189 189
190 /* Underflow points. */ 190 /* Underflow points. */
191 unsigned int underflow[NF_IP_NUMHOOKS]; 191 unsigned int underflow[NF_INET_NUMHOOKS];
192 192
193 /* Information about old entries: */ 193 /* Information about old entries: */
194 /* Number of counters (must be equal to current number of entries). */ 194 /* Number of counters (must be equal to current number of entries). */
@@ -229,60 +229,12 @@ ipt_get_target(struct ipt_entry *e)
229} 229}
230 230
231/* fn returns 0 to continue iteration */ 231/* fn returns 0 to continue iteration */
232#define IPT_MATCH_ITERATE(e, fn, args...) \ 232#define IPT_MATCH_ITERATE(e, fn, args...) \
233({ \ 233 XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args)
234 unsigned int __i; \
235 int __ret = 0; \
236 struct ipt_entry_match *__match; \
237 \
238 for (__i = sizeof(struct ipt_entry); \
239 __i < (e)->target_offset; \
240 __i += __match->u.match_size) { \
241 __match = (void *)(e) + __i; \
242 \
243 __ret = fn(__match , ## args); \
244 if (__ret != 0) \
245 break; \
246 } \
247 __ret; \
248})
249 234
250/* fn returns 0 to continue iteration */ 235/* fn returns 0 to continue iteration */
251#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \ 236#define IPT_ENTRY_ITERATE(entries, size, fn, args...) \
252({ \ 237 XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args)
253 unsigned int __i; \
254 int __ret = 0; \
255 struct ipt_entry *__entry; \
256 \
257 for (__i = 0; __i < (size); __i += __entry->next_offset) { \
258 __entry = (void *)(entries) + __i; \
259 \
260 __ret = fn(__entry , ## args); \
261 if (__ret != 0) \
262 break; \
263 } \
264 __ret; \
265})
266
267/* fn returns 0 to continue iteration */
268#define IPT_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \
269({ \
270 unsigned int __i, __n; \
271 int __ret = 0; \
272 struct ipt_entry *__entry; \
273 \
274 for (__i = 0, __n = 0; __i < (size); \
275 __i += __entry->next_offset, __n++) { \
276 __entry = (void *)(entries) + __i; \
277 if (__n < n) \
278 continue; \
279 \
280 __ret = fn(__entry , ## args); \
281 if (__ret != 0) \
282 break; \
283 } \
284 __ret; \
285})
286 238
287/* 239/*
288 * Main firewall chains definitions and global var's definitions. 240 * Main firewall chains definitions and global var's definitions.
@@ -292,8 +244,9 @@ ipt_get_target(struct ipt_entry *e)
292#include <linux/init.h> 244#include <linux/init.h>
293extern void ipt_init(void) __init; 245extern void ipt_init(void) __init;
294 246
295extern int ipt_register_table(struct xt_table *table, 247extern struct xt_table *ipt_register_table(struct net *net,
296 const struct ipt_replace *repl); 248 struct xt_table *table,
249 const struct ipt_replace *repl);
297extern void ipt_unregister_table(struct xt_table *table); 250extern void ipt_unregister_table(struct xt_table *table);
298 251
299/* Standard entry. */ 252/* Standard entry. */
@@ -359,8 +312,28 @@ struct compat_ipt_entry
359 unsigned char elems[0]; 312 unsigned char elems[0];
360}; 313};
361 314
315/* Helper functions */
316static inline struct ipt_entry_target *
317compat_ipt_get_target(struct compat_ipt_entry *e)
318{
319 return (void *)e + e->target_offset;
320}
321
362#define COMPAT_IPT_ALIGN(s) COMPAT_XT_ALIGN(s) 322#define COMPAT_IPT_ALIGN(s) COMPAT_XT_ALIGN(s)
363 323
324/* fn returns 0 to continue iteration */
325#define COMPAT_IPT_MATCH_ITERATE(e, fn, args...) \
326 XT_MATCH_ITERATE(struct compat_ipt_entry, e, fn, ## args)
327
328/* fn returns 0 to continue iteration */
329#define COMPAT_IPT_ENTRY_ITERATE(entries, size, fn, args...) \
330 XT_ENTRY_ITERATE(struct compat_ipt_entry, entries, size, fn, ## args)
331
332/* fn returns 0 to continue iteration */
333#define COMPAT_IPT_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \
334 XT_ENTRY_ITERATE_CONTINUE(struct compat_ipt_entry, entries, size, n, \
335 fn, ## args)
336
364#endif /* CONFIG_COMPAT */ 337#endif /* CONFIG_COMPAT */
365#endif /*__KERNEL__*/ 338#endif /*__KERNEL__*/
366#endif /* _IPTABLES_H */ 339#endif /* _IPTABLES_H */
diff --git a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
index daf50be22c9d..e5a3687c8a72 100644
--- a/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
+++ b/include/linux/netfilter_ipv4/ipt_CLUSTERIP.h
@@ -27,6 +27,7 @@ struct ipt_clusterip_tgt_info {
27 u_int32_t hash_mode; 27 u_int32_t hash_mode;
28 u_int32_t hash_initval; 28 u_int32_t hash_initval;
29 29
30 /* Used internally by the kernel */
30 struct clusterip_config *config; 31 struct clusterip_config *config;
31}; 32};
32 33
diff --git a/include/linux/netfilter_ipv4/ipt_addrtype.h b/include/linux/netfilter_ipv4/ipt_addrtype.h
index 166ed01a8122..446de6aef983 100644
--- a/include/linux/netfilter_ipv4/ipt_addrtype.h
+++ b/include/linux/netfilter_ipv4/ipt_addrtype.h
@@ -1,6 +1,20 @@
1#ifndef _IPT_ADDRTYPE_H 1#ifndef _IPT_ADDRTYPE_H
2#define _IPT_ADDRTYPE_H 2#define _IPT_ADDRTYPE_H
3 3
4enum {
5 IPT_ADDRTYPE_INVERT_SOURCE = 0x0001,
6 IPT_ADDRTYPE_INVERT_DEST = 0x0002,
7 IPT_ADDRTYPE_LIMIT_IFACE_IN = 0x0004,
8 IPT_ADDRTYPE_LIMIT_IFACE_OUT = 0x0008,
9};
10
11struct ipt_addrtype_info_v1 {
12 u_int16_t source; /* source-type mask */
13 u_int16_t dest; /* dest-type mask */
14 u_int32_t flags;
15};
16
17/* revision 0 */
4struct ipt_addrtype_info { 18struct ipt_addrtype_info {
5 u_int16_t source; /* source-type mask */ 19 u_int16_t source; /* source-type mask */
6 u_int16_t dest; /* dest-type mask */ 20 u_int16_t dest; /* dest-type mask */
diff --git a/include/linux/netfilter_ipv4/ipt_iprange.h b/include/linux/netfilter_ipv4/ipt_iprange.h
index a92fefc3c7ec..5f1aebde4d2f 100644
--- a/include/linux/netfilter_ipv4/ipt_iprange.h
+++ b/include/linux/netfilter_ipv4/ipt_iprange.h
@@ -2,11 +2,7 @@
2#define _IPT_IPRANGE_H 2#define _IPT_IPRANGE_H
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5#include <linux/netfilter/xt_iprange.h>
6#define IPRANGE_SRC 0x01 /* Match source IP address */
7#define IPRANGE_DST 0x02 /* Match destination IP address */
8#define IPRANGE_SRC_INV 0x10 /* Negate the condition */
9#define IPRANGE_DST_INV 0x20 /* Negate the condition */
10 6
11struct ipt_iprange { 7struct ipt_iprange {
12 /* Inclusive: network order. */ 8 /* Inclusive: network order. */
diff --git a/include/linux/netfilter_ipv6.h b/include/linux/netfilter_ipv6.h
index 66ca8e3100dc..3475a65dae9b 100644
--- a/include/linux/netfilter_ipv6.h
+++ b/include/linux/netfilter_ipv6.h
@@ -40,8 +40,6 @@
40#define NFC_IP6_DST_PT 0x0400 40#define NFC_IP6_DST_PT 0x0400
41/* Something else about the proto */ 41/* Something else about the proto */
42#define NFC_IP6_PROTO_UNKNOWN 0x2000 42#define NFC_IP6_PROTO_UNKNOWN 0x2000
43#endif /* ! __KERNEL__ */
44
45 43
46/* IP6 Hooks */ 44/* IP6 Hooks */
47/* After promisc drops, checksum checks. */ 45/* After promisc drops, checksum checks. */
@@ -55,6 +53,7 @@
55/* Packets about to hit the wire. */ 53/* Packets about to hit the wire. */
56#define NF_IP6_POST_ROUTING 4 54#define NF_IP6_POST_ROUTING 4
57#define NF_IP6_NUMHOOKS 5 55#define NF_IP6_NUMHOOKS 5
56#endif /* ! __KERNEL__ */
58 57
59 58
60enum nf_ip6_hook_priorities { 59enum nf_ip6_hook_priorities {
diff --git a/include/linux/netfilter_ipv6/Kbuild b/include/linux/netfilter_ipv6/Kbuild
index 9dd978d149ff..8887a5fcd1d0 100644
--- a/include/linux/netfilter_ipv6/Kbuild
+++ b/include/linux/netfilter_ipv6/Kbuild
@@ -14,8 +14,8 @@ header-y += ip6t_mark.h
14header-y += ip6t_multiport.h 14header-y += ip6t_multiport.h
15header-y += ip6t_opts.h 15header-y += ip6t_opts.h
16header-y += ip6t_owner.h 16header-y += ip6t_owner.h
17header-y += ip6t_policy.h
18header-y += ip6t_physdev.h 17header-y += ip6t_physdev.h
18header-y += ip6t_policy.h
19header-y += ip6t_rt.h 19header-y += ip6t_rt.h
20 20
21unifdef-y += ip6_tables.h 21unifdef-y += ip6_tables.h
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index 7dc481ce7cba..f2507dcc5750 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -216,10 +216,10 @@ struct ip6t_getinfo
216 unsigned int valid_hooks; 216 unsigned int valid_hooks;
217 217
218 /* Hook entry points: one per netfilter hook. */ 218 /* Hook entry points: one per netfilter hook. */
219 unsigned int hook_entry[NF_IP6_NUMHOOKS]; 219 unsigned int hook_entry[NF_INET_NUMHOOKS];
220 220
221 /* Underflow points. */ 221 /* Underflow points. */
222 unsigned int underflow[NF_IP6_NUMHOOKS]; 222 unsigned int underflow[NF_INET_NUMHOOKS];
223 223
224 /* Number of entries */ 224 /* Number of entries */
225 unsigned int num_entries; 225 unsigned int num_entries;
@@ -245,10 +245,10 @@ struct ip6t_replace
245 unsigned int size; 245 unsigned int size;
246 246
247 /* Hook entry points. */ 247 /* Hook entry points. */
248 unsigned int hook_entry[NF_IP6_NUMHOOKS]; 248 unsigned int hook_entry[NF_INET_NUMHOOKS];
249 249
250 /* Underflow points. */ 250 /* Underflow points. */
251 unsigned int underflow[NF_IP6_NUMHOOKS]; 251 unsigned int underflow[NF_INET_NUMHOOKS];
252 252
253 /* Information about old entries: */ 253 /* Information about old entries: */
254 /* Number of counters (must be equal to current number of entries). */ 254 /* Number of counters (must be equal to current number of entries). */
@@ -289,40 +289,12 @@ ip6t_get_target(struct ip6t_entry *e)
289} 289}
290 290
291/* fn returns 0 to continue iteration */ 291/* fn returns 0 to continue iteration */
292#define IP6T_MATCH_ITERATE(e, fn, args...) \ 292#define IP6T_MATCH_ITERATE(e, fn, args...) \
293({ \ 293 XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args)
294 unsigned int __i; \
295 int __ret = 0; \
296 struct ip6t_entry_match *__m; \
297 \
298 for (__i = sizeof(struct ip6t_entry); \
299 __i < (e)->target_offset; \
300 __i += __m->u.match_size) { \
301 __m = (void *)(e) + __i; \
302 \
303 __ret = fn(__m , ## args); \
304 if (__ret != 0) \
305 break; \
306 } \
307 __ret; \
308})
309 294
310/* fn returns 0 to continue iteration */ 295/* fn returns 0 to continue iteration */
311#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ 296#define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \
312({ \ 297 XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args)
313 unsigned int __i; \
314 int __ret = 0; \
315 struct ip6t_entry *__e; \
316 \
317 for (__i = 0; __i < (size); __i += __e->next_offset) { \
318 __e = (void *)(entries) + __i; \
319 \
320 __ret = fn(__e , ## args); \
321 if (__ret != 0) \
322 break; \
323 } \
324 __ret; \
325})
326 298
327/* 299/*
328 * Main firewall chains definitions and global var's definitions. 300 * Main firewall chains definitions and global var's definitions.
@@ -333,8 +305,9 @@ ip6t_get_target(struct ip6t_entry *e)
333#include <linux/init.h> 305#include <linux/init.h>
334extern void ip6t_init(void) __init; 306extern void ip6t_init(void) __init;
335 307
336extern int ip6t_register_table(struct xt_table *table, 308extern struct xt_table *ip6t_register_table(struct net *net,
337 const struct ip6t_replace *repl); 309 struct xt_table *table,
310 const struct ip6t_replace *repl);
338extern void ip6t_unregister_table(struct xt_table *table); 311extern void ip6t_unregister_table(struct xt_table *table);
339extern unsigned int ip6t_do_table(struct sk_buff *skb, 312extern unsigned int ip6t_do_table(struct sk_buff *skb,
340 unsigned int hook, 313 unsigned int hook,
@@ -352,7 +325,42 @@ extern int ip6_masked_addrcmp(const struct in6_addr *addr1,
352 const struct in6_addr *mask, 325 const struct in6_addr *mask,
353 const struct in6_addr *addr2); 326 const struct in6_addr *addr2);
354 327
355#define IP6T_ALIGN(s) (((s) + (__alignof__(struct ip6t_entry)-1)) & ~(__alignof__(struct ip6t_entry)-1)) 328#define IP6T_ALIGN(s) XT_ALIGN(s)
356 329
330#ifdef CONFIG_COMPAT
331#include <net/compat.h>
332
333struct compat_ip6t_entry
334{
335 struct ip6t_ip6 ipv6;
336 compat_uint_t nfcache;
337 u_int16_t target_offset;
338 u_int16_t next_offset;
339 compat_uint_t comefrom;
340 struct compat_xt_counters counters;
341 unsigned char elems[0];
342};
343
344static inline struct ip6t_entry_target *
345compat_ip6t_get_target(struct compat_ip6t_entry *e)
346{
347 return (void *)e + e->target_offset;
348}
349
350#define COMPAT_IP6T_ALIGN(s) COMPAT_XT_ALIGN(s)
351
352/* fn returns 0 to continue iteration */
353#define COMPAT_IP6T_MATCH_ITERATE(e, fn, args...) \
354 XT_MATCH_ITERATE(struct compat_ip6t_entry, e, fn, ## args)
355
356/* fn returns 0 to continue iteration */
357#define COMPAT_IP6T_ENTRY_ITERATE(entries, size, fn, args...) \
358 XT_ENTRY_ITERATE(struct compat_ip6t_entry, entries, size, fn, ## args)
359
360#define COMPAT_IP6T_ENTRY_ITERATE_CONTINUE(entries, size, n, fn, args...) \
361 XT_ENTRY_ITERATE_CONTINUE(struct compat_ip6t_entry, entries, size, n, \
362 fn, ## args)
363
364#endif /* CONFIG_COMPAT */
357#endif /*__KERNEL__*/ 365#endif /*__KERNEL__*/
358#endif /* _IP6_TABLES_H */ 366#endif /* _IP6_TABLES_H */
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 7c1f3b1d2ee5..fb0713b6ffaf 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -178,6 +178,7 @@ extern struct sock *netlink_kernel_create(struct net *net,
178 void (*input)(struct sk_buff *skb), 178 void (*input)(struct sk_buff *skb),
179 struct mutex *cb_mutex, 179 struct mutex *cb_mutex,
180 struct module *module); 180 struct module *module);
181extern void netlink_kernel_release(struct sock *sk);
181extern int netlink_change_ngroups(struct sock *sk, unsigned int groups); 182extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
182extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group); 183extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group);
183extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err); 184extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
@@ -192,7 +193,7 @@ extern int netlink_unregister_notifier(struct notifier_block *nb);
192/* finegrained unicast helpers: */ 193/* finegrained unicast helpers: */
193struct sock *netlink_getsockbyfilp(struct file *filp); 194struct sock *netlink_getsockbyfilp(struct file *filp);
194int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, 195int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
195 long timeo, struct sock *ssk); 196 long *timeo, struct sock *ssk);
196void netlink_detachskb(struct sock *sk, struct sk_buff *skb); 197void netlink_detachskb(struct sock *sk, struct sk_buff *skb);
197int netlink_sendskb(struct sock *sk, struct sk_buff *skb); 198int netlink_sendskb(struct sock *sk, struct sk_buff *skb);
198 199
@@ -218,7 +219,7 @@ struct netlink_callback
218 int (*dump)(struct sk_buff * skb, struct netlink_callback *cb); 219 int (*dump)(struct sk_buff * skb, struct netlink_callback *cb);
219 int (*done)(struct netlink_callback *cb); 220 int (*done)(struct netlink_callback *cb);
220 int family; 221 int family;
221 long args[5]; 222 long args[6];
222}; 223};
223 224
224struct netlink_notify 225struct netlink_notify
@@ -245,7 +246,7 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
245} 246}
246 247
247#define NLMSG_NEW(skb, pid, seq, type, len, flags) \ 248#define NLMSG_NEW(skb, pid, seq, type, len, flags) \
248({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) \ 249({ if (unlikely(skb_tailroom(skb) < (int)NLMSG_SPACE(len))) \
249 goto nlmsg_failure; \ 250 goto nlmsg_failure; \
250 __nlmsg_put(skb, pid, seq, type, len, flags); }) 251 __nlmsg_put(skb, pid, seq, type, len, flags); })
251 252
diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h
index 20250d963d72..a0525a1f4715 100644
--- a/include/linux/netpoll.h
+++ b/include/linux/netpoll.h
@@ -20,12 +20,11 @@ struct netpoll {
20 20
21 u32 local_ip, remote_ip; 21 u32 local_ip, remote_ip;
22 u16 local_port, remote_port; 22 u16 local_port, remote_port;
23 u8 local_mac[ETH_ALEN], remote_mac[ETH_ALEN]; 23 u8 remote_mac[ETH_ALEN];
24}; 24};
25 25
26struct netpoll_info { 26struct netpoll_info {
27 atomic_t refcnt; 27 atomic_t refcnt;
28 int rx_flags;
29 spinlock_t rx_lock; 28 spinlock_t rx_lock;
30 struct netpoll *rx_np; /* netpoll that registered an rx_hook */ 29 struct netpoll *rx_np; /* netpoll that registered an rx_hook */
31 struct sk_buff_head arp_tx; /* list of arp requests to reply to */ 30 struct sk_buff_head arp_tx; /* list of arp requests to reply to */
@@ -51,12 +50,12 @@ static inline int netpoll_rx(struct sk_buff *skb)
51 unsigned long flags; 50 unsigned long flags;
52 int ret = 0; 51 int ret = 0;
53 52
54 if (!npinfo || (!npinfo->rx_np && !npinfo->rx_flags)) 53 if (!npinfo || !npinfo->rx_np)
55 return 0; 54 return 0;
56 55
57 spin_lock_irqsave(&npinfo->rx_lock, flags); 56 spin_lock_irqsave(&npinfo->rx_lock, flags);
58 /* check rx_flags again with the lock held */ 57 /* check rx_np again with the lock held */
59 if (npinfo->rx_flags && __netpoll_rx(skb)) 58 if (npinfo->rx_np && __netpoll_rx(skb))
60 ret = 1; 59 ret = 1;
61 spin_unlock_irqrestore(&npinfo->rx_lock, flags); 60 spin_unlock_irqrestore(&npinfo->rx_lock, flags);
62 61
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index e82a6ebc725d..a69ba80f2dfe 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -196,28 +196,67 @@ struct nfs_inode {
196#define NFS_INO_STALE (2) /* possible stale inode */ 196#define NFS_INO_STALE (2) /* possible stale inode */
197#define NFS_INO_ACL_LRU_SET (3) /* Inode is on the LRU list */ 197#define NFS_INO_ACL_LRU_SET (3) /* Inode is on the LRU list */
198 198
199static inline struct nfs_inode *NFS_I(struct inode *inode) 199static inline struct nfs_inode *NFS_I(const struct inode *inode)
200{ 200{
201 return container_of(inode, struct nfs_inode, vfs_inode); 201 return container_of(inode, struct nfs_inode, vfs_inode);
202} 202}
203#define NFS_SB(s) ((struct nfs_server *)(s->s_fs_info))
204 203
205#define NFS_FH(inode) (&NFS_I(inode)->fh) 204static inline struct nfs_server *NFS_SB(const struct super_block *s)
206#define NFS_SERVER(inode) (NFS_SB(inode->i_sb)) 205{
207#define NFS_CLIENT(inode) (NFS_SERVER(inode)->client) 206 return (struct nfs_server *)(s->s_fs_info);
208#define NFS_PROTO(inode) (NFS_SERVER(inode)->nfs_client->rpc_ops) 207}
209#define NFS_COOKIEVERF(inode) (NFS_I(inode)->cookieverf) 208
210#define NFS_MINATTRTIMEO(inode) \ 209static inline struct nfs_fh *NFS_FH(const struct inode *inode)
211 (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmin \ 210{
212 : NFS_SERVER(inode)->acregmin) 211 return &NFS_I(inode)->fh;
213#define NFS_MAXATTRTIMEO(inode) \ 212}
214 (S_ISDIR(inode->i_mode)? NFS_SERVER(inode)->acdirmax \ 213
215 : NFS_SERVER(inode)->acregmax) 214static inline struct nfs_server *NFS_SERVER(const struct inode *inode)
215{
216 return NFS_SB(inode->i_sb);
217}
218
219static inline struct rpc_clnt *NFS_CLIENT(const struct inode *inode)
220{
221 return NFS_SERVER(inode)->client;
222}
223
224static inline const struct nfs_rpc_ops *NFS_PROTO(const struct inode *inode)
225{
226 return NFS_SERVER(inode)->nfs_client->rpc_ops;
227}
228
229static inline __be32 *NFS_COOKIEVERF(const struct inode *inode)
230{
231 return NFS_I(inode)->cookieverf;
232}
233
234static inline unsigned NFS_MINATTRTIMEO(const struct inode *inode)
235{
236 struct nfs_server *nfss = NFS_SERVER(inode);
237 return S_ISDIR(inode->i_mode) ? nfss->acdirmin : nfss->acregmin;
238}
216 239
217#define NFS_FLAGS(inode) (NFS_I(inode)->flags) 240static inline unsigned NFS_MAXATTRTIMEO(const struct inode *inode)
218#define NFS_STALE(inode) (test_bit(NFS_INO_STALE, &NFS_FLAGS(inode))) 241{
242 struct nfs_server *nfss = NFS_SERVER(inode);
243 return S_ISDIR(inode->i_mode) ? nfss->acdirmax : nfss->acregmax;
244}
219 245
220#define NFS_FILEID(inode) (NFS_I(inode)->fileid) 246static inline int NFS_STALE(const struct inode *inode)
247{
248 return test_bit(NFS_INO_STALE, &NFS_I(inode)->flags);
249}
250
251static inline __u64 NFS_FILEID(const struct inode *inode)
252{
253 return NFS_I(inode)->fileid;
254}
255
256static inline void set_nfs_fileid(struct inode *inode, __u64 fileid)
257{
258 NFS_I(inode)->fileid = fileid;
259}
221 260
222static inline void nfs_mark_for_revalidate(struct inode *inode) 261static inline void nfs_mark_for_revalidate(struct inode *inode)
223{ 262{
@@ -237,7 +276,7 @@ static inline int nfs_server_capable(struct inode *inode, int cap)
237 276
238static inline int NFS_USE_READDIRPLUS(struct inode *inode) 277static inline int NFS_USE_READDIRPLUS(struct inode *inode)
239{ 278{
240 return test_bit(NFS_INO_ADVISE_RDPLUS, &NFS_FLAGS(inode)); 279 return test_bit(NFS_INO_ADVISE_RDPLUS, &NFS_I(inode)->flags);
241} 280}
242 281
243static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf) 282static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)
@@ -366,6 +405,7 @@ extern const struct inode_operations nfs3_dir_inode_operations;
366extern const struct file_operations nfs_dir_operations; 405extern const struct file_operations nfs_dir_operations;
367extern struct dentry_operations nfs_dentry_operations; 406extern struct dentry_operations nfs_dentry_operations;
368 407
408extern void nfs_force_lookup_revalidate(struct inode *dir);
369extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, struct nfs_fattr *fattr); 409extern int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fh, struct nfs_fattr *fattr);
370extern int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags); 410extern int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags);
371extern void nfs_access_zap_cache(struct inode *inode); 411extern void nfs_access_zap_cache(struct inode *inode);
@@ -422,7 +462,6 @@ extern long nfs_sync_mapping_wait(struct address_space *, struct writeback_contr
422extern int nfs_wb_all(struct inode *inode); 462extern int nfs_wb_all(struct inode *inode);
423extern int nfs_wb_nocommit(struct inode *inode); 463extern int nfs_wb_nocommit(struct inode *inode);
424extern int nfs_wb_page(struct inode *inode, struct page* page); 464extern int nfs_wb_page(struct inode *inode, struct page* page);
425extern int nfs_wb_page_priority(struct inode *inode, struct page* page, int how);
426extern int nfs_wb_page_cancel(struct inode *inode, struct page* page); 465extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
427#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4) 466#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
428extern int nfs_commit_inode(struct inode *, int); 467extern int nfs_commit_inode(struct inode *, int);
@@ -517,14 +556,7 @@ extern void * nfs_root_data(void);
517 556
518#define nfs_wait_event(clnt, wq, condition) \ 557#define nfs_wait_event(clnt, wq, condition) \
519({ \ 558({ \
520 int __retval = 0; \ 559 int __retval = wait_event_killable(wq, condition); \
521 if (clnt->cl_intr) { \
522 sigset_t oldmask; \
523 rpc_clnt_sigmask(clnt, &oldmask); \
524 __retval = wait_event_interruptible(wq, condition); \
525 rpc_clnt_sigunmask(clnt, &oldmask); \
526 } else \
527 wait_event(wq, condition); \
528 __retval; \ 560 __retval; \
529}) 561})
530 562
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 0cac49bc0955..3423c6761bf7 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -3,8 +3,12 @@
3 3
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/backing-dev.h> 5#include <linux/backing-dev.h>
6#include <linux/wait.h>
7
8#include <asm/atomic.h>
6 9
7struct nfs_iostats; 10struct nfs_iostats;
11struct nlm_host;
8 12
9/* 13/*
10 * The nfs_client identifies our client state to the server. 14 * The nfs_client identifies our client state to the server.
@@ -14,20 +18,19 @@ struct nfs_client {
14 int cl_cons_state; /* current construction state (-ve: init error) */ 18 int cl_cons_state; /* current construction state (-ve: init error) */
15#define NFS_CS_READY 0 /* ready to be used */ 19#define NFS_CS_READY 0 /* ready to be used */
16#define NFS_CS_INITING 1 /* busy initialising */ 20#define NFS_CS_INITING 1 /* busy initialising */
17 int cl_nfsversion; /* NFS protocol version */
18 unsigned long cl_res_state; /* NFS resources state */ 21 unsigned long cl_res_state; /* NFS resources state */
19#define NFS_CS_CALLBACK 1 /* - callback started */ 22#define NFS_CS_CALLBACK 1 /* - callback started */
20#define NFS_CS_IDMAP 2 /* - idmap started */ 23#define NFS_CS_IDMAP 2 /* - idmap started */
21#define NFS_CS_RENEWD 3 /* - renewd started */ 24#define NFS_CS_RENEWD 3 /* - renewd started */
22 struct sockaddr_in cl_addr; /* server identifier */ 25 struct sockaddr_storage cl_addr; /* server identifier */
26 size_t cl_addrlen;
23 char * cl_hostname; /* hostname of server */ 27 char * cl_hostname; /* hostname of server */
24 struct list_head cl_share_link; /* link in global client list */ 28 struct list_head cl_share_link; /* link in global client list */
25 struct list_head cl_superblocks; /* List of nfs_server structs */ 29 struct list_head cl_superblocks; /* List of nfs_server structs */
26 30
27 struct rpc_clnt * cl_rpcclient; 31 struct rpc_clnt * cl_rpcclient;
28 const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */ 32 const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
29 unsigned long retrans_timeo; /* retransmit timeout */ 33 int cl_proto; /* Network transport protocol */
30 unsigned int retrans_count; /* number of retransmit tries */
31 34
32#ifdef CONFIG_NFS_V4 35#ifdef CONFIG_NFS_V4
33 u64 cl_clientid; /* constant */ 36 u64 cl_clientid; /* constant */
@@ -62,7 +65,7 @@ struct nfs_client {
62 /* Our own IP address, as a null-terminated string. 65 /* Our own IP address, as a null-terminated string.
63 * This is used to generate the clientid, and the callback address. 66 * This is used to generate the clientid, and the callback address.
64 */ 67 */
65 char cl_ipaddr[16]; 68 char cl_ipaddr[48];
66 unsigned char cl_id_uniquifier; 69 unsigned char cl_id_uniquifier;
67#endif 70#endif
68}; 71};
@@ -78,6 +81,7 @@ struct nfs_server {
78 struct list_head master_link; /* link in master servers list */ 81 struct list_head master_link; /* link in master servers list */
79 struct rpc_clnt * client; /* RPC client handle */ 82 struct rpc_clnt * client; /* RPC client handle */
80 struct rpc_clnt * client_acl; /* ACL RPC client handle */ 83 struct rpc_clnt * client_acl; /* ACL RPC client handle */
84 struct nlm_host *nlm_host; /* NLM client handle */
81 struct nfs_iostats * io_stats; /* I/O statistics */ 85 struct nfs_iostats * io_stats; /* I/O statistics */
82 struct backing_dev_info backing_dev_info; 86 struct backing_dev_info backing_dev_info;
83 atomic_long_t writeback; /* number of writeback pages */ 87 atomic_long_t writeback; /* number of writeback pages */
@@ -110,6 +114,9 @@ struct nfs_server {
110 filesystem */ 114 filesystem */
111#endif 115#endif
112 void (*destroy)(struct nfs_server *); 116 void (*destroy)(struct nfs_server *);
117
118 atomic_t active; /* Keep trace of any activity to this server */
119 wait_queue_head_t active_wq; /* Wait for any activity to stop */
113}; 120};
114 121
115/* Server capabilities */ 122/* Server capabilities */
diff --git a/include/linux/nfs_mount.h b/include/linux/nfs_mount.h
index a3ade89a64d2..df7c6b7a7ebb 100644
--- a/include/linux/nfs_mount.h
+++ b/include/linux/nfs_mount.h
@@ -48,7 +48,7 @@ struct nfs_mount_data {
48/* bits in the flags field */ 48/* bits in the flags field */
49 49
50#define NFS_MOUNT_SOFT 0x0001 /* 1 */ 50#define NFS_MOUNT_SOFT 0x0001 /* 1 */
51#define NFS_MOUNT_INTR 0x0002 /* 1 */ 51#define NFS_MOUNT_INTR 0x0002 /* 1 */ /* now unused, but ABI */
52#define NFS_MOUNT_SECURE 0x0004 /* 1 */ 52#define NFS_MOUNT_SECURE 0x0004 /* 1 */
53#define NFS_MOUNT_POSIX 0x0008 /* 1 */ 53#define NFS_MOUNT_POSIX 0x0008 /* 1 */
54#define NFS_MOUNT_NOCTO 0x0010 /* 1 */ 54#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
index 30dbcc185e69..a1676e19e491 100644
--- a/include/linux/nfs_page.h
+++ b/include/linux/nfs_page.h
@@ -83,6 +83,7 @@ extern void nfs_pageio_complete(struct nfs_pageio_descriptor *desc);
83extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t); 83extern void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *, pgoff_t);
84extern int nfs_wait_on_request(struct nfs_page *); 84extern int nfs_wait_on_request(struct nfs_page *);
85extern void nfs_unlock_request(struct nfs_page *req); 85extern void nfs_unlock_request(struct nfs_page *req);
86extern int nfs_set_page_tag_locked(struct nfs_page *req);
86extern void nfs_clear_page_tag_locked(struct nfs_page *req); 87extern void nfs_clear_page_tag_locked(struct nfs_page *req);
87 88
88 89
@@ -95,18 +96,6 @@ nfs_lock_request_dontget(struct nfs_page *req)
95 return !test_and_set_bit(PG_BUSY, &req->wb_flags); 96 return !test_and_set_bit(PG_BUSY, &req->wb_flags);
96} 97}
97 98
98/*
99 * Lock the page of an asynchronous request and take a reference
100 */
101static inline int
102nfs_lock_request(struct nfs_page *req)
103{
104 if (test_and_set_bit(PG_BUSY, &req->wb_flags))
105 return 0;
106 kref_get(&req->wb_kref);
107 return 1;
108}
109
110/** 99/**
111 * nfs_list_add_request - Insert a request into a list 100 * nfs_list_add_request - Insert a request into a list
112 * @req: request 101 * @req: request
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index daab252f2e5c..f301d0b8babc 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -666,16 +666,17 @@ struct nfs4_rename_res {
666 struct nfs_fattr * new_fattr; 666 struct nfs_fattr * new_fattr;
667}; 667};
668 668
669#define NFS4_SETCLIENTID_NAMELEN (56)
669struct nfs4_setclientid { 670struct nfs4_setclientid {
670 const nfs4_verifier * sc_verifier; /* request */ 671 const nfs4_verifier * sc_verifier;
671 unsigned int sc_name_len; 672 unsigned int sc_name_len;
672 char sc_name[48]; /* request */ 673 char sc_name[NFS4_SETCLIENTID_NAMELEN];
673 u32 sc_prog; /* request */ 674 u32 sc_prog;
674 unsigned int sc_netid_len; 675 unsigned int sc_netid_len;
675 char sc_netid[4]; /* request */ 676 char sc_netid[RPCBIND_MAXNETIDLEN];
676 unsigned int sc_uaddr_len; 677 unsigned int sc_uaddr_len;
677 char sc_uaddr[24]; /* request */ 678 char sc_uaddr[RPCBIND_MAXUADDRLEN];
678 u32 sc_cb_ident; /* request */ 679 u32 sc_cb_ident;
679}; 680};
680 681
681struct nfs4_statfs_arg { 682struct nfs4_statfs_arg {
@@ -773,7 +774,7 @@ struct nfs_access_entry;
773 * RPC procedure vector for NFSv2/NFSv3 demuxing 774 * RPC procedure vector for NFSv2/NFSv3 demuxing
774 */ 775 */
775struct nfs_rpc_ops { 776struct nfs_rpc_ops {
776 int version; /* Protocol version */ 777 u32 version; /* Protocol version */
777 struct dentry_operations *dentry_ops; 778 struct dentry_operations *dentry_ops;
778 const struct inode_operations *dir_inode_ops; 779 const struct inode_operations *dir_inode_ops;
779 const struct inode_operations *file_inode_ops; 780 const struct inode_operations *file_inode_ops;
@@ -816,11 +817,11 @@ struct nfs_rpc_ops {
816 struct nfs_pathconf *); 817 struct nfs_pathconf *);
817 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); 818 int (*set_capabilities)(struct nfs_server *, struct nfs_fh *);
818 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus); 819 __be32 *(*decode_dirent)(__be32 *, struct nfs_entry *, int plus);
819 void (*read_setup) (struct nfs_read_data *); 820 void (*read_setup) (struct nfs_read_data *, struct rpc_message *);
820 int (*read_done) (struct rpc_task *, struct nfs_read_data *); 821 int (*read_done) (struct rpc_task *, struct nfs_read_data *);
821 void (*write_setup) (struct nfs_write_data *, int how); 822 void (*write_setup) (struct nfs_write_data *, struct rpc_message *);
822 int (*write_done) (struct rpc_task *, struct nfs_write_data *); 823 int (*write_done) (struct rpc_task *, struct nfs_write_data *);
823 void (*commit_setup) (struct nfs_write_data *, int how); 824 void (*commit_setup) (struct nfs_write_data *, struct rpc_message *);
824 int (*commit_done) (struct rpc_task *, struct nfs_write_data *); 825 int (*commit_done) (struct rpc_task *, struct nfs_write_data *);
825 int (*file_open) (struct inode *, struct file *); 826 int (*file_open) (struct inode *, struct file *);
826 int (*file_release) (struct inode *, struct file *); 827 int (*file_release) (struct inode *, struct file *);
diff --git a/include/linux/nfsd/Kbuild b/include/linux/nfsd/Kbuild
index d9c5455808e5..e726fc3a4375 100644
--- a/include/linux/nfsd/Kbuild
+++ b/include/linux/nfsd/Kbuild
@@ -4,4 +4,3 @@ unifdef-y += stats.h
4unifdef-y += syscall.h 4unifdef-y += syscall.h
5unifdef-y += nfsfh.h 5unifdef-y += nfsfh.h
6unifdef-y += debug.h 6unifdef-y += debug.h
7unifdef-y += auth.h
diff --git a/include/linux/nfsd/auth.h b/include/linux/nfsd/auth.h
deleted file mode 100644
index 0fb9f7212195..000000000000
--- a/include/linux/nfsd/auth.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/*
2 * include/linux/nfsd/auth.h
3 *
4 * nfsd-specific authentication stuff.
5 * uid/gid mapping not yet implemented.
6 *
7 * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
8 */
9
10#ifndef LINUX_NFSD_AUTH_H
11#define LINUX_NFSD_AUTH_H
12
13#ifdef __KERNEL__
14
15#define nfsd_luid(rq, uid) ((u32)(uid))
16#define nfsd_lgid(rq, gid) ((u32)(gid))
17#define nfsd_ruid(rq, uid) ((u32)(uid))
18#define nfsd_rgid(rq, gid) ((u32)(gid))
19
20/*
21 * Set the current process's fsuid/fsgid etc to those of the NFS
22 * client user
23 */
24int nfsd_setuser(struct svc_rqst *, struct svc_export *);
25
26#endif /* __KERNEL__ */
27#endif /* LINUX_NFSD_AUTH_H */
diff --git a/include/linux/nfsd/cache.h b/include/linux/nfsd/cache.h
index 007480cd6a60..7b5d784cc858 100644
--- a/include/linux/nfsd/cache.h
+++ b/include/linux/nfsd/cache.h
@@ -72,8 +72,8 @@ enum {
72 */ 72 */
73#define RC_DELAY (HZ/5) 73#define RC_DELAY (HZ/5)
74 74
75void nfsd_cache_init(void); 75int nfsd_reply_cache_init(void);
76void nfsd_cache_shutdown(void); 76void nfsd_reply_cache_shutdown(void);
77int nfsd_cache_lookup(struct svc_rqst *, int); 77int nfsd_cache_lookup(struct svc_rqst *, int);
78void nfsd_cache_update(struct svc_rqst *, int, __be32 *); 78void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
79 79
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index bcb7abafbca9..3a1687251367 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -122,7 +122,7 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp);
122/* 122/*
123 * Function declarations 123 * Function declarations
124 */ 124 */
125void nfsd_export_init(void); 125int nfsd_export_init(void);
126void nfsd_export_shutdown(void); 126void nfsd_export_shutdown(void);
127void nfsd_export_flush(void); 127void nfsd_export_flush(void);
128void exp_readlock(void); 128void exp_readlock(void);
diff --git a/include/linux/nfsd/nfsd.h b/include/linux/nfsd/nfsd.h
index 604a0d786bc6..8caf4c4f64e6 100644
--- a/include/linux/nfsd/nfsd.h
+++ b/include/linux/nfsd/nfsd.h
@@ -20,7 +20,6 @@
20#include <linux/nfsd/debug.h> 20#include <linux/nfsd/debug.h>
21#include <linux/nfsd/nfsfh.h> 21#include <linux/nfsd/nfsfh.h>
22#include <linux/nfsd/export.h> 22#include <linux/nfsd/export.h>
23#include <linux/nfsd/auth.h>
24#include <linux/nfsd/stats.h> 23#include <linux/nfsd/stats.h>
25/* 24/*
26 * nfsd version 25 * nfsd version
@@ -70,9 +69,9 @@ void nfsd_racache_shutdown(void);
70int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp, 69int nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
71 struct svc_export **expp); 70 struct svc_export **expp);
72__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *, 71__be32 nfsd_lookup(struct svc_rqst *, struct svc_fh *,
73 const char *, int, struct svc_fh *); 72 const char *, unsigned int, struct svc_fh *);
74__be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *, 73__be32 nfsd_lookup_dentry(struct svc_rqst *, struct svc_fh *,
75 const char *, int, 74 const char *, unsigned int,
76 struct svc_export **, struct dentry **); 75 struct svc_export **, struct dentry **);
77__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *, 76__be32 nfsd_setattr(struct svc_rqst *, struct svc_fh *,
78 struct iattr *, int, time_t); 77 struct iattr *, int, time_t);
diff --git a/include/linux/nfsd/syscall.h b/include/linux/nfsd/syscall.h
index 8bcddccb6c42..4e439765b705 100644
--- a/include/linux/nfsd/syscall.h
+++ b/include/linux/nfsd/syscall.h
@@ -18,7 +18,6 @@
18#include <linux/nfsd/const.h> 18#include <linux/nfsd/const.h>
19#include <linux/nfsd/export.h> 19#include <linux/nfsd/export.h>
20#include <linux/nfsd/nfsfh.h> 20#include <linux/nfsd/nfsfh.h>
21#include <linux/nfsd/auth.h>
22 21
23/* 22/*
24 * Version of the syscall interface 23 * Version of the syscall interface
diff --git a/include/linux/nfsd/xdr.h b/include/linux/nfsd/xdr.h
index 67885d5e6e50..a0132ef58f21 100644
--- a/include/linux/nfsd/xdr.h
+++ b/include/linux/nfsd/xdr.h
@@ -23,7 +23,7 @@ struct nfsd_sattrargs {
23struct nfsd_diropargs { 23struct nfsd_diropargs {
24 struct svc_fh fh; 24 struct svc_fh fh;
25 char * name; 25 char * name;
26 int len; 26 unsigned int len;
27}; 27};
28 28
29struct nfsd_readargs { 29struct nfsd_readargs {
@@ -43,17 +43,17 @@ struct nfsd_writeargs {
43struct nfsd_createargs { 43struct nfsd_createargs {
44 struct svc_fh fh; 44 struct svc_fh fh;
45 char * name; 45 char * name;
46 int len; 46 unsigned int len;
47 struct iattr attrs; 47 struct iattr attrs;
48}; 48};
49 49
50struct nfsd_renameargs { 50struct nfsd_renameargs {
51 struct svc_fh ffh; 51 struct svc_fh ffh;
52 char * fname; 52 char * fname;
53 int flen; 53 unsigned int flen;
54 struct svc_fh tfh; 54 struct svc_fh tfh;
55 char * tname; 55 char * tname;
56 int tlen; 56 unsigned int tlen;
57}; 57};
58 58
59struct nfsd_readlinkargs { 59struct nfsd_readlinkargs {
@@ -65,15 +65,15 @@ struct nfsd_linkargs {
65 struct svc_fh ffh; 65 struct svc_fh ffh;
66 struct svc_fh tfh; 66 struct svc_fh tfh;
67 char * tname; 67 char * tname;
68 int tlen; 68 unsigned int tlen;
69}; 69};
70 70
71struct nfsd_symlinkargs { 71struct nfsd_symlinkargs {
72 struct svc_fh ffh; 72 struct svc_fh ffh;
73 char * fname; 73 char * fname;
74 int flen; 74 unsigned int flen;
75 char * tname; 75 char * tname;
76 int tlen; 76 unsigned int tlen;
77 struct iattr attrs; 77 struct iattr attrs;
78}; 78};
79 79
diff --git a/include/linux/nfsd/xdr3.h b/include/linux/nfsd/xdr3.h
index 89d9d6061a62..421eddd65a25 100644
--- a/include/linux/nfsd/xdr3.h
+++ b/include/linux/nfsd/xdr3.h
@@ -21,7 +21,7 @@ struct nfsd3_sattrargs {
21struct nfsd3_diropargs { 21struct nfsd3_diropargs {
22 struct svc_fh fh; 22 struct svc_fh fh;
23 char * name; 23 char * name;
24 int len; 24 unsigned int len;
25}; 25};
26 26
27struct nfsd3_accessargs { 27struct nfsd3_accessargs {
@@ -48,7 +48,7 @@ struct nfsd3_writeargs {
48struct nfsd3_createargs { 48struct nfsd3_createargs {
49 struct svc_fh fh; 49 struct svc_fh fh;
50 char * name; 50 char * name;
51 int len; 51 unsigned int len;
52 int createmode; 52 int createmode;
53 struct iattr attrs; 53 struct iattr attrs;
54 __be32 * verf; 54 __be32 * verf;
@@ -57,7 +57,7 @@ struct nfsd3_createargs {
57struct nfsd3_mknodargs { 57struct nfsd3_mknodargs {
58 struct svc_fh fh; 58 struct svc_fh fh;
59 char * name; 59 char * name;
60 int len; 60 unsigned int len;
61 __u32 ftype; 61 __u32 ftype;
62 __u32 major, minor; 62 __u32 major, minor;
63 struct iattr attrs; 63 struct iattr attrs;
@@ -66,10 +66,10 @@ struct nfsd3_mknodargs {
66struct nfsd3_renameargs { 66struct nfsd3_renameargs {
67 struct svc_fh ffh; 67 struct svc_fh ffh;
68 char * fname; 68 char * fname;
69 int flen; 69 unsigned int flen;
70 struct svc_fh tfh; 70 struct svc_fh tfh;
71 char * tname; 71 char * tname;
72 int tlen; 72 unsigned int tlen;
73}; 73};
74 74
75struct nfsd3_readlinkargs { 75struct nfsd3_readlinkargs {
@@ -81,15 +81,15 @@ struct nfsd3_linkargs {
81 struct svc_fh ffh; 81 struct svc_fh ffh;
82 struct svc_fh tfh; 82 struct svc_fh tfh;
83 char * tname; 83 char * tname;
84 int tlen; 84 unsigned int tlen;
85}; 85};
86 86
87struct nfsd3_symlinkargs { 87struct nfsd3_symlinkargs {
88 struct svc_fh ffh; 88 struct svc_fh ffh;
89 char * fname; 89 char * fname;
90 int flen; 90 unsigned int flen;
91 char * tname; 91 char * tname;
92 int tlen; 92 unsigned int tlen;
93 struct iattr attrs; 93 struct iattr attrs;
94}; 94};
95 95
diff --git a/include/linux/nfsd/xdr4.h b/include/linux/nfsd/xdr4.h
index b0ddfb41c790..27bd3e38ec5a 100644
--- a/include/linux/nfsd/xdr4.h
+++ b/include/linux/nfsd/xdr4.h
@@ -441,7 +441,7 @@ void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
441void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op); 441void nfsd4_encode_replay(struct nfsd4_compoundres *resp, struct nfsd4_op *op);
442__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp, 442__be32 nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
443 struct dentry *dentry, __be32 *buffer, int *countp, 443 struct dentry *dentry, __be32 *buffer, int *countp,
444 u32 *bmval, struct svc_rqst *); 444 u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
445extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, 445extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
446 struct nfsd4_compound_state *, 446 struct nfsd4_compound_state *,
447 struct nfsd4_setclientid *setclid); 447 struct nfsd4_setclientid *setclid);
diff --git a/include/linux/nfsd_idmap.h b/include/linux/nfsd_idmap.h
index e82746fcad14..d4a2ac18bd4c 100644
--- a/include/linux/nfsd_idmap.h
+++ b/include/linux/nfsd_idmap.h
@@ -44,11 +44,16 @@
44#define IDMAP_NAMESZ 128 44#define IDMAP_NAMESZ 128
45 45
46#ifdef CONFIG_NFSD_V4 46#ifdef CONFIG_NFSD_V4
47void nfsd_idmap_init(void); 47int nfsd_idmap_init(void);
48void nfsd_idmap_shutdown(void); 48void nfsd_idmap_shutdown(void);
49#else 49#else
50static inline void nfsd_idmap_init(void) {}; 50static inline int nfsd_idmap_init(void)
51static inline void nfsd_idmap_shutdown(void) {}; 51{
52 return 0;
53}
54static inline void nfsd_idmap_shutdown(void)
55{
56}
52#endif 57#endif
53 58
54int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *); 59int nfsd_map_name_to_uid(struct svc_rqst *, const char *, size_t, __u32 *);
diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 538ee1dd3d0a..9fecf902419c 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -7,6 +7,18 @@
7 */ 7 */
8 8
9/** 9/**
10 * DOC: Station handling
11 *
12 * Stations are added per interface, but a special case exists with VLAN
13 * interfaces. When a station is bound to an AP interface, it may be moved
14 * into a VLAN identified by a VLAN interface index (%NL80211_ATTR_STA_VLAN).
15 * The station is still assumed to belong to the AP interface it was added
16 * to.
17 *
18 * TODO: need more info?
19 */
20
21/**
10 * enum nl80211_commands - supported nl80211 commands 22 * enum nl80211_commands - supported nl80211 commands
11 * 23 *
12 * @NL80211_CMD_UNSPEC: unspecified command to catch errors 24 * @NL80211_CMD_UNSPEC: unspecified command to catch errors
@@ -37,6 +49,35 @@
37 * userspace to request deletion of a virtual interface, then requires 49 * userspace to request deletion of a virtual interface, then requires
38 * attribute %NL80211_ATTR_IFINDEX. 50 * attribute %NL80211_ATTR_IFINDEX.
39 * 51 *
52 * @NL80211_CMD_GET_KEY: Get sequence counter information for a key specified
53 * by %NL80211_ATTR_KEY_IDX and/or %NL80211_ATTR_MAC.
54 * @NL80211_CMD_SET_KEY: Set key attributes %NL80211_ATTR_KEY_DEFAULT or
55 * %NL80211_ATTR_KEY_THRESHOLD.
56 * @NL80211_CMD_NEW_KEY: add a key with given %NL80211_ATTR_KEY_DATA,
57 * %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC and %NL80211_ATTR_KEY_CIPHER
58 * attributes.
59 * @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
60 * or %NL80211_ATTR_MAC.
61 *
62 * @NL80211_CMD_GET_BEACON: retrieve beacon information (returned in a
63 * %NL80222_CMD_NEW_BEACON message)
64 * @NL80211_CMD_SET_BEACON: set the beacon on an access point interface
65 * using the %NL80211_ATTR_BEACON_INTERVAL, %NL80211_ATTR_DTIM_PERIOD,
66 * %NL80211_BEACON_HEAD and %NL80211_BEACON_TAIL attributes.
67 * @NL80211_CMD_NEW_BEACON: add a new beacon to an access point interface,
68 * parameters are like for %NL80211_CMD_SET_BEACON.
69 * @NL80211_CMD_DEL_BEACON: remove the beacon, stop sending it
70 *
71 * @NL80211_CMD_GET_STATION: Get station attributes for station identified by
72 * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
73 * @NL80211_CMD_SET_STATION: Set station attributes for station identified by
74 * %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
75 * @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
76 * the interface identified by %NL80211_ATTR_IFINDEX.
77 * @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
78 * or, if no MAC address given, all stations, on the interface identified
79 * by %NL80211_ATTR_IFINDEX.
80 *
40 * @NL80211_CMD_MAX: highest used command number 81 * @NL80211_CMD_MAX: highest used command number
41 * @__NL80211_CMD_AFTER_LAST: internal use 82 * @__NL80211_CMD_AFTER_LAST: internal use
42 */ 83 */
@@ -54,6 +95,21 @@ enum nl80211_commands {
54 NL80211_CMD_NEW_INTERFACE, 95 NL80211_CMD_NEW_INTERFACE,
55 NL80211_CMD_DEL_INTERFACE, 96 NL80211_CMD_DEL_INTERFACE,
56 97
98 NL80211_CMD_GET_KEY,
99 NL80211_CMD_SET_KEY,
100 NL80211_CMD_NEW_KEY,
101 NL80211_CMD_DEL_KEY,
102
103 NL80211_CMD_GET_BEACON,
104 NL80211_CMD_SET_BEACON,
105 NL80211_CMD_NEW_BEACON,
106 NL80211_CMD_DEL_BEACON,
107
108 NL80211_CMD_GET_STATION,
109 NL80211_CMD_SET_STATION,
110 NL80211_CMD_NEW_STATION,
111 NL80211_CMD_DEL_STATION,
112
57 /* add commands here */ 113 /* add commands here */
58 114
59 /* used to define NL80211_CMD_MAX below */ 115 /* used to define NL80211_CMD_MAX below */
@@ -75,6 +131,36 @@ enum nl80211_commands {
75 * @NL80211_ATTR_IFNAME: network interface name 131 * @NL80211_ATTR_IFNAME: network interface name
76 * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype 132 * @NL80211_ATTR_IFTYPE: type of virtual interface, see &enum nl80211_iftype
77 * 133 *
134 * @NL80211_ATTR_MAC: MAC address (various uses)
135 *
136 * @NL80211_ATTR_KEY_DATA: (temporal) key data; for TKIP this consists of
137 * 16 bytes encryption key followed by 8 bytes each for TX and RX MIC
138 * keys
139 * @NL80211_ATTR_KEY_IDX: key ID (u8, 0-3)
140 * @NL80211_ATTR_KEY_CIPHER: key cipher suite (u32, as defined by IEEE 802.11
141 * section 7.3.2.25.1, e.g. 0x000FAC04)
142 * @NL80211_ATTR_KEY_SEQ: transmit key sequence number (IV/PN) for TKIP and
143 * CCMP keys, each six bytes in little endian
144 *
145 * @NL80211_ATTR_BEACON_INTERVAL: beacon interval in TU
146 * @NL80211_ATTR_DTIM_PERIOD: DTIM period for beaconing
147 * @NL80211_ATTR_BEACON_HEAD: portion of the beacon before the TIM IE
148 * @NL80211_ATTR_BEACON_TAIL: portion of the beacon after the TIM IE
149 *
150 * @NL80211_ATTR_STA_AID: Association ID for the station (u16)
151 * @NL80211_ATTR_STA_FLAGS: flags, nested element with NLA_FLAG attributes of
152 * &enum nl80211_sta_flags.
153 * @NL80211_ATTR_STA_LISTEN_INTERVAL: listen interval as defined by
154 * IEEE 802.11 7.3.1.6 (u16).
155 * @NL80211_ATTR_STA_SUPPORTED_RATES: supported rates, array of supported
156 * rates as defined by IEEE 802.11 7.3.2.2 but without the length
157 * restriction (at most %NL80211_MAX_SUPP_RATES).
158 * @NL80211_ATTR_STA_VLAN: interface index of VLAN interface to move station
159 * to, or the AP interface the station was originally added to to.
160 * @NL80211_ATTR_STA_STATS: statistics for a station, part of station info
161 * given for %NL80211_CMD_GET_STATION, nested attribute containing
162 * info as possible, see &enum nl80211_sta_stats.
163 *
78 * @NL80211_ATTR_MAX: highest attribute number currently defined 164 * @NL80211_ATTR_MAX: highest attribute number currently defined
79 * @__NL80211_ATTR_AFTER_LAST: internal use 165 * @__NL80211_ATTR_AFTER_LAST: internal use
80 */ 166 */
@@ -89,12 +175,34 @@ enum nl80211_attrs {
89 NL80211_ATTR_IFNAME, 175 NL80211_ATTR_IFNAME,
90 NL80211_ATTR_IFTYPE, 176 NL80211_ATTR_IFTYPE,
91 177
178 NL80211_ATTR_MAC,
179
180 NL80211_ATTR_KEY_DATA,
181 NL80211_ATTR_KEY_IDX,
182 NL80211_ATTR_KEY_CIPHER,
183 NL80211_ATTR_KEY_SEQ,
184 NL80211_ATTR_KEY_DEFAULT,
185
186 NL80211_ATTR_BEACON_INTERVAL,
187 NL80211_ATTR_DTIM_PERIOD,
188 NL80211_ATTR_BEACON_HEAD,
189 NL80211_ATTR_BEACON_TAIL,
190
191 NL80211_ATTR_STA_AID,
192 NL80211_ATTR_STA_FLAGS,
193 NL80211_ATTR_STA_LISTEN_INTERVAL,
194 NL80211_ATTR_STA_SUPPORTED_RATES,
195 NL80211_ATTR_STA_VLAN,
196 NL80211_ATTR_STA_STATS,
197
92 /* add attributes here, update the policy in nl80211.c */ 198 /* add attributes here, update the policy in nl80211.c */
93 199
94 __NL80211_ATTR_AFTER_LAST, 200 __NL80211_ATTR_AFTER_LAST,
95 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1 201 NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
96}; 202};
97 203
204#define NL80211_MAX_SUPP_RATES 32
205
98/** 206/**
99 * enum nl80211_iftype - (virtual) interface types 207 * enum nl80211_iftype - (virtual) interface types
100 * 208 *
@@ -126,4 +234,50 @@ enum nl80211_iftype {
126 NL80211_IFTYPE_MAX = __NL80211_IFTYPE_AFTER_LAST - 1 234 NL80211_IFTYPE_MAX = __NL80211_IFTYPE_AFTER_LAST - 1
127}; 235};
128 236
237/**
238 * enum nl80211_sta_flags - station flags
239 *
240 * Station flags. When a station is added to an AP interface, it is
241 * assumed to be already associated (and hence authenticated.)
242 *
243 * @NL80211_STA_FLAG_AUTHORIZED: station is authorized (802.1X)
244 * @NL80211_STA_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
245 * with short barker preamble
246 * @NL80211_STA_FLAG_WME: station is WME/QoS capable
247 */
248enum nl80211_sta_flags {
249 __NL80211_STA_FLAG_INVALID,
250 NL80211_STA_FLAG_AUTHORIZED,
251 NL80211_STA_FLAG_SHORT_PREAMBLE,
252 NL80211_STA_FLAG_WME,
253
254 /* keep last */
255 __NL80211_STA_FLAG_AFTER_LAST,
256 NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
257};
258
259/**
260 * enum nl80211_sta_stats - station statistics
261 *
262 * These attribute types are used with %NL80211_ATTR_STA_STATS
263 * when getting information about a station.
264 *
265 * @__NL80211_STA_STAT_INVALID: attribute number 0 is reserved
266 * @NL80211_STA_STAT_INACTIVE_TIME: time since last activity (u32, msecs)
267 * @NL80211_STA_STAT_RX_BYTES: total received bytes (u32, from this station)
268 * @NL80211_STA_STAT_TX_BYTES: total transmitted bytes (u32, to this station)
269 * @__NL80211_STA_STAT_AFTER_LAST: internal
270 * @NL80211_STA_STAT_MAX: highest possible station stats attribute
271 */
272enum nl80211_sta_stats {
273 __NL80211_STA_STAT_INVALID,
274 NL80211_STA_STAT_INACTIVE_TIME,
275 NL80211_STA_STAT_RX_BYTES,
276 NL80211_STA_STAT_TX_BYTES,
277
278 /* keep last */
279 __NL80211_STA_STAT_AFTER_LAST,
280 NL80211_STA_STAT_MAX = __NL80211_STA_STAT_AFTER_LAST - 1
281};
282
129#endif /* __LINUX_NL80211_H */ 283#endif /* __LINUX_NL80211_H */
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 0c40cc0b4a36..f4df40038f0c 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -207,9 +207,7 @@ static inline int notifier_to_errno(int ret)
207#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */ 207#define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */
208#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */ 208#define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
209#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ 209#define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
210#define CPU_LOCK_ACQUIRE 0x0008 /* Acquire all hotcpu locks */ 210#define CPU_DYING 0x0008 /* CPU (unsigned)v not running any task,
211#define CPU_LOCK_RELEASE 0x0009 /* Release all hotcpu locks */
212#define CPU_DYING 0x000A /* CPU (unsigned)v not running any task,
213 * not handling interrupts, soon dead */ 211 * not handling interrupts, soon dead */
214 212
215/* Used for CPU hotplug events occuring while tasks are frozen due to a suspend 213/* Used for CPU hotplug events occuring while tasks are frozen due to a suspend
@@ -230,6 +228,8 @@ static inline int notifier_to_errno(int ret)
230#define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */ 228#define PM_POST_HIBERNATION 0x0002 /* Hibernation finished */
231#define PM_SUSPEND_PREPARE 0x0003 /* Going to suspend the system */ 229#define PM_SUSPEND_PREPARE 0x0003 /* Going to suspend the system */
232#define PM_POST_SUSPEND 0x0004 /* Suspend finished */ 230#define PM_POST_SUSPEND 0x0004 /* Suspend finished */
231#define PM_RESTORE_PREPARE 0x0005 /* Going to restore a saved image */
232#define PM_POST_RESTORE 0x0006 /* Restore failed */
233 233
234/* Console keyboard events. 234/* Console keyboard events.
235 * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and 235 * Note: KBD_KEYCODE is always sent before KBD_UNBOUND_KEYCODE, KBD_UNICODE and
diff --git a/include/linux/of.h b/include/linux/of.h
index 5c39b9270ff7..b5f33efcb8e2 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -17,6 +17,7 @@
17 */ 17 */
18#include <linux/types.h> 18#include <linux/types.h>
19#include <linux/bitops.h> 19#include <linux/bitops.h>
20#include <linux/mod_devicetable.h>
20 21
21#include <asm/prom.h> 22#include <asm/prom.h>
22 23
@@ -41,11 +42,20 @@ extern struct device_node *of_find_compatible_node(struct device_node *from,
41#define for_each_compatible_node(dn, type, compatible) \ 42#define for_each_compatible_node(dn, type, compatible) \
42 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \ 43 for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
43 dn = of_find_compatible_node(dn, type, compatible)) 44 dn = of_find_compatible_node(dn, type, compatible))
45extern struct device_node *of_find_matching_node(struct device_node *from,
46 const struct of_device_id *matches);
47#define for_each_matching_node(dn, matches) \
48 for (dn = of_find_matching_node(NULL, matches); dn; \
49 dn = of_find_matching_node(dn, matches))
44extern struct device_node *of_find_node_by_path(const char *path); 50extern struct device_node *of_find_node_by_path(const char *path);
45extern struct device_node *of_find_node_by_phandle(phandle handle); 51extern struct device_node *of_find_node_by_phandle(phandle handle);
46extern struct device_node *of_get_parent(const struct device_node *node); 52extern struct device_node *of_get_parent(const struct device_node *node);
47extern struct device_node *of_get_next_child(const struct device_node *node, 53extern struct device_node *of_get_next_child(const struct device_node *node,
48 struct device_node *prev); 54 struct device_node *prev);
55#define for_each_child_of_node(parent, child) \
56 for (child = of_get_next_child(parent, NULL); child != NULL; \
57 child = of_get_next_child(parent, child))
58
49extern struct property *of_find_property(const struct device_node *np, 59extern struct property *of_find_property(const struct device_node *np,
50 const char *name, 60 const char *name,
51 int *lenp); 61 int *lenp);
@@ -56,5 +66,7 @@ extern const void *of_get_property(const struct device_node *node,
56 int *lenp); 66 int *lenp);
57extern int of_n_addr_cells(struct device_node *np); 67extern int of_n_addr_cells(struct device_node *np);
58extern int of_n_size_cells(struct device_node *np); 68extern int of_n_size_cells(struct device_node *np);
69extern const struct of_device_id *of_match_node(
70 const struct of_device_id *matches, const struct device_node *node);
59 71
60#endif /* _LINUX_OF_H */ 72#endif /* _LINUX_OF_H */
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 212bffb2b174..6dc11959770c 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -10,8 +10,6 @@
10 10
11#define to_of_device(d) container_of(d, struct of_device, dev) 11#define to_of_device(d) container_of(d, struct of_device, dev)
12 12
13extern const struct of_device_id *of_match_node(
14 const struct of_device_id *matches, const struct device_node *node);
15extern const struct of_device_id *of_match_device( 13extern const struct of_device_id *of_match_device(
16 const struct of_device_id *matches, const struct of_device *dev); 14 const struct of_device_id *matches, const struct of_device *dev);
17 15
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index db8a410ae9e1..4b62a105622b 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -157,6 +157,7 @@ static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
157} 157}
158 158
159extern void FASTCALL(__lock_page(struct page *page)); 159extern void FASTCALL(__lock_page(struct page *page));
160extern int FASTCALL(__lock_page_killable(struct page *page));
160extern void FASTCALL(__lock_page_nosync(struct page *page)); 161extern void FASTCALL(__lock_page_nosync(struct page *page));
161extern void FASTCALL(unlock_page(struct page *page)); 162extern void FASTCALL(unlock_page(struct page *page));
162 163
@@ -171,6 +172,19 @@ static inline void lock_page(struct page *page)
171} 172}
172 173
173/* 174/*
175 * lock_page_killable is like lock_page but can be interrupted by fatal
176 * signals. It returns 0 if it locked the page and -EINTR if it was
177 * killed while waiting.
178 */
179static inline int lock_page_killable(struct page *page)
180{
181 might_sleep();
182 if (TestSetPageLocked(page))
183 return __lock_page_killable(page);
184 return 0;
185}
186
187/*
174 * lock_page_nosync should only be used if we can't pin the page's inode. 188 * lock_page_nosync should only be used if we can't pin the page's inode.
175 * Doesn't play quite so well with block device plugging. 189 * Doesn't play quite so well with block device plugging.
176 */ 190 */
diff --git a/include/linux/pata_platform.h b/include/linux/pata_platform.h
index 5799e8d50623..6a7a92db294c 100644
--- a/include/linux/pata_platform.h
+++ b/include/linux/pata_platform.h
@@ -15,4 +15,13 @@ struct pata_platform_info {
15 unsigned int irq_flags; 15 unsigned int irq_flags;
16}; 16};
17 17
18extern int __devinit __pata_platform_probe(struct device *dev,
19 struct resource *io_res,
20 struct resource *ctl_res,
21 struct resource *irq_res,
22 unsigned int ioport_shift,
23 int __pio_mask);
24
25extern int __devexit __pata_platform_remove(struct device *dev);
26
18#endif /* __LINUX_PATA_PLATFORM_H */ 27#endif /* __LINUX_PATA_PLATFORM_H */
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h
index 936ef82ed76a..3ba25065fa96 100644
--- a/include/linux/pci-acpi.h
+++ b/include/linux/pci-acpi.h
@@ -48,7 +48,15 @@
48 48
49#ifdef CONFIG_ACPI 49#ifdef CONFIG_ACPI
50extern acpi_status pci_osc_control_set(acpi_handle handle, u32 flags); 50extern acpi_status pci_osc_control_set(acpi_handle handle, u32 flags);
51extern acpi_status pci_osc_support_set(u32 flags); 51extern acpi_status __pci_osc_support_set(u32 flags, const char *hid);
52static inline acpi_status pci_osc_support_set(u32 flags)
53{
54 return __pci_osc_support_set(flags, PCI_ROOT_HID_STRING);
55}
56static inline acpi_status pcie_osc_support_set(u32 flags)
57{
58 return __pci_osc_support_set(flags, PCI_EXPRESS_ROOT_HID_STRING);
59}
52#else 60#else
53#if !defined(AE_ERROR) 61#if !defined(AE_ERROR)
54typedef u32 acpi_status; 62typedef u32 acpi_status;
@@ -57,6 +65,7 @@ typedef u32 acpi_status;
57static inline acpi_status pci_osc_control_set(acpi_handle handle, u32 flags) 65static inline acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
58{return AE_ERROR;} 66{return AE_ERROR;}
59static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;} 67static inline acpi_status pci_osc_support_set(u32 flags) {return AE_ERROR;}
68static inline acpi_status pcie_osc_support_set(u32 flags) {return AE_ERROR;}
60#endif 69#endif
61 70
62#endif /* _PCI_ACPI_H_ */ 71#endif /* _PCI_ACPI_H_ */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5d2281f661f7..4f96f1d94ac4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -28,7 +28,7 @@
28 * 7:3 = slot 28 * 7:3 = slot
29 * 2:0 = function 29 * 2:0 = function
30 */ 30 */
31#define PCI_DEVFN(slot,func) ((((slot) & 0x1f) << 3) | ((func) & 0x07)) 31#define PCI_DEVFN(slot, func) ((((slot) & 0x1f) << 3) | ((func) & 0x07))
32#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f) 32#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
33#define PCI_FUNC(devfn) ((devfn) & 0x07) 33#define PCI_FUNC(devfn) ((devfn) & 0x07)
34 34
@@ -66,7 +66,6 @@ enum pci_mmap_state {
66#define PCI_DMA_FROMDEVICE 2 66#define PCI_DMA_FROMDEVICE 2
67#define PCI_DMA_NONE 3 67#define PCI_DMA_NONE 3
68 68
69#define DEVICE_COUNT_COMPATIBLE 4
70#define DEVICE_COUNT_RESOURCE 12 69#define DEVICE_COUNT_RESOURCE 12
71 70
72typedef int __bitwise pci_power_t; 71typedef int __bitwise pci_power_t;
@@ -109,6 +108,14 @@ enum pcie_reset_state {
109 pcie_hot_reset = (__force pcie_reset_state_t) 3 108 pcie_hot_reset = (__force pcie_reset_state_t) 3
110}; 109};
111 110
111typedef unsigned short __bitwise pci_dev_flags_t;
112enum pci_dev_flags {
113 /* INTX_DISABLE in PCI_COMMAND register disables MSI
114 * generation too.
115 */
116 PCI_DEV_FLAGS_MSI_INTX_DISABLE_BUG = (__force pci_dev_flags_t) 1,
117};
118
112typedef unsigned short __bitwise pci_bus_flags_t; 119typedef unsigned short __bitwise pci_bus_flags_t;
113enum pci_bus_flags { 120enum pci_bus_flags {
114 PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1, 121 PCI_BUS_FLAGS_NO_MSI = (__force pci_bus_flags_t) 1,
@@ -121,6 +128,7 @@ struct pci_cap_saved_state {
121 u32 data[0]; 128 u32 data[0];
122}; 129};
123 130
131struct pcie_link_state;
124/* 132/*
125 * The pci_dev structure is used to describe PCI devices. 133 * The pci_dev structure is used to describe PCI devices.
126 */ 134 */
@@ -156,13 +164,13 @@ struct pci_dev {
156 this is D0-D3, D0 being fully functional, 164 this is D0-D3, D0 being fully functional,
157 and D3 being off. */ 165 and D3 being off. */
158 166
167#ifdef CONFIG_PCIEASPM
168 struct pcie_link_state *link_state; /* ASPM link state. */
169#endif
170
159 pci_channel_state_t error_state; /* current connectivity state */ 171 pci_channel_state_t error_state; /* current connectivity state */
160 struct device dev; /* Generic device interface */ 172 struct device dev; /* Generic device interface */
161 173
162 /* device is compatible with these IDs */
163 unsigned short vendor_compatible[DEVICE_COUNT_COMPATIBLE];
164 unsigned short device_compatible[DEVICE_COUNT_COMPATIBLE];
165
166 int cfg_size; /* Size of configuration space */ 174 int cfg_size; /* Size of configuration space */
167 175
168 /* 176 /*
@@ -185,6 +193,7 @@ struct pci_dev {
185 unsigned int msix_enabled:1; 193 unsigned int msix_enabled:1;
186 unsigned int is_managed:1; 194 unsigned int is_managed:1;
187 unsigned int is_pcie:1; 195 unsigned int is_pcie:1;
196 pci_dev_flags_t dev_flags;
188 atomic_t enable_cnt; /* pci_enable_device has been called */ 197 atomic_t enable_cnt; /* pci_enable_device has been called */
189 198
190 u32 saved_config_space[16]; /* config space saved at suspend time */ 199 u32 saved_config_space[16]; /* config space saved at suspend time */
@@ -210,7 +219,7 @@ static inline int pci_channel_offline(struct pci_dev *pdev)
210} 219}
211 220
212static inline struct pci_cap_saved_state *pci_find_saved_cap( 221static inline struct pci_cap_saved_state *pci_find_saved_cap(
213 struct pci_dev *pci_dev,char cap) 222 struct pci_dev *pci_dev, char cap)
214{ 223{
215 struct pci_cap_saved_state *tmp; 224 struct pci_cap_saved_state *tmp;
216 struct hlist_node *pos; 225 struct hlist_node *pos;
@@ -269,13 +278,13 @@ struct pci_bus {
269 unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */ 278 unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */
270 pci_bus_flags_t bus_flags; /* Inherited by child busses */ 279 pci_bus_flags_t bus_flags; /* Inherited by child busses */
271 struct device *bridge; 280 struct device *bridge;
272 struct class_device class_dev; 281 struct device dev;
273 struct bin_attribute *legacy_io; /* legacy I/O for this bus */ 282 struct bin_attribute *legacy_io; /* legacy I/O for this bus */
274 struct bin_attribute *legacy_mem; /* legacy mem */ 283 struct bin_attribute *legacy_mem; /* legacy mem */
275}; 284};
276 285
277#define pci_bus_b(n) list_entry(n, struct pci_bus, node) 286#define pci_bus_b(n) list_entry(n, struct pci_bus, node)
278#define to_pci_bus(n) container_of(n, struct pci_bus, class_dev) 287#define to_pci_bus(n) container_of(n, struct pci_bus, dev)
279 288
280/* 289/*
281 * Error values that may be returned by PCI functions. 290 * Error values that may be returned by PCI functions.
@@ -305,8 +314,8 @@ struct pci_raw_ops {
305extern struct pci_raw_ops *raw_pci_ops; 314extern struct pci_raw_ops *raw_pci_ops;
306 315
307struct pci_bus_region { 316struct pci_bus_region {
308 unsigned long start; 317 resource_size_t start;
309 unsigned long end; 318 resource_size_t end;
310}; 319};
311 320
312struct pci_dynids { 321struct pci_dynids {
@@ -342,11 +351,10 @@ enum pci_ers_result {
342}; 351};
343 352
344/* PCI bus error event callbacks */ 353/* PCI bus error event callbacks */
345struct pci_error_handlers 354struct pci_error_handlers {
346{
347 /* PCI bus error detected on this device */ 355 /* PCI bus error detected on this device */
348 pci_ers_result_t (*error_detected)(struct pci_dev *dev, 356 pci_ers_result_t (*error_detected)(struct pci_dev *dev,
349 enum pci_channel_state error); 357 enum pci_channel_state error);
350 358
351 /* MMIO has been re-enabled, but not DMA */ 359 /* MMIO has been re-enabled, but not DMA */
352 pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev); 360 pci_ers_result_t (*mmio_enabled)(struct pci_dev *dev);
@@ -381,7 +389,7 @@ struct pci_driver {
381 struct pci_dynids dynids; 389 struct pci_dynids dynids;
382}; 390};
383 391
384#define to_pci_driver(drv) container_of(drv,struct pci_driver, driver) 392#define to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
385 393
386/** 394/**
387 * PCI_DEVICE - macro used to describe a specific pci device 395 * PCI_DEVICE - macro used to describe a specific pci device
@@ -439,7 +447,7 @@ extern int no_pci_devices(void);
439 447
440void pcibios_fixup_bus(struct pci_bus *); 448void pcibios_fixup_bus(struct pci_bus *);
441int __must_check pcibios_enable_device(struct pci_dev *, int mask); 449int __must_check pcibios_enable_device(struct pci_dev *, int mask);
442char *pcibios_setup (char *str); 450char *pcibios_setup(char *str);
443 451
444/* Used only when drivers/pci/setup.c is used */ 452/* Used only when drivers/pci/setup.c is used */
445void pcibios_align_resource(void *, struct resource *, resource_size_t, 453void pcibios_align_resource(void *, struct resource *, resource_size_t,
@@ -450,8 +458,10 @@ void pcibios_update_irq(struct pci_dev *, int irq);
450 458
451extern struct pci_bus *pci_find_bus(int domain, int busnr); 459extern struct pci_bus *pci_find_bus(int domain, int busnr);
452void pci_bus_add_devices(struct pci_bus *bus); 460void pci_bus_add_devices(struct pci_bus *bus);
453struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); 461struct pci_bus *pci_scan_bus_parented(struct device *parent, int bus,
454static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata) 462 struct pci_ops *ops, void *sysdata);
463static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
464 void *sysdata)
455{ 465{
456 struct pci_bus *root_bus; 466 struct pci_bus *root_bus;
457 root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata); 467 root_bus = pci_scan_bus_parented(NULL, bus, ops, sysdata);
@@ -459,15 +469,18 @@ static inline struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *s
459 pci_bus_add_devices(root_bus); 469 pci_bus_add_devices(root_bus);
460 return root_bus; 470 return root_bus;
461} 471}
462struct pci_bus *pci_create_bus(struct device *parent, int bus, struct pci_ops *ops, void *sysdata); 472struct pci_bus *pci_create_bus(struct device *parent, int bus,
463struct pci_bus * pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr); 473 struct pci_ops *ops, void *sysdata);
474struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
475 int busnr);
464int pci_scan_slot(struct pci_bus *bus, int devfn); 476int pci_scan_slot(struct pci_bus *bus, int devfn);
465struct pci_dev * pci_scan_single_device(struct pci_bus *bus, int devfn); 477struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
466void pci_device_add(struct pci_dev *dev, struct pci_bus *bus); 478void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
467unsigned int pci_scan_child_bus(struct pci_bus *bus); 479unsigned int pci_scan_child_bus(struct pci_bus *bus);
468int __must_check pci_bus_add_device(struct pci_dev *dev); 480int __must_check pci_bus_add_device(struct pci_dev *dev);
469void pci_read_bridge_bases(struct pci_bus *child); 481void pci_read_bridge_bases(struct pci_bus *child);
470struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res); 482struct resource *pci_find_parent_resource(const struct pci_dev *dev,
483 struct resource *res);
471int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge); 484int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
472extern struct pci_dev *pci_dev_get(struct pci_dev *dev); 485extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
473extern void pci_dev_put(struct pci_dev *dev); 486extern void pci_dev_put(struct pci_dev *dev);
@@ -479,13 +492,20 @@ extern void pci_sort_breadthfirst(void);
479 492
480/* Generic PCI functions exported to card drivers */ 493/* Generic PCI functions exported to card drivers */
481 494
482struct pci_dev __deprecated *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from); 495#ifdef CONFIG_PCI_LEGACY
483struct pci_dev __deprecated *pci_find_slot (unsigned int bus, unsigned int devfn); 496struct pci_dev __deprecated *pci_find_device(unsigned int vendor,
484int pci_find_capability (struct pci_dev *dev, int cap); 497 unsigned int device,
485int pci_find_next_capability (struct pci_dev *dev, u8 pos, int cap); 498 const struct pci_dev *from);
486int pci_find_ext_capability (struct pci_dev *dev, int cap); 499struct pci_dev __deprecated *pci_find_slot(unsigned int bus,
487int pci_find_ht_capability (struct pci_dev *dev, int ht_cap); 500 unsigned int devfn);
488int pci_find_next_ht_capability (struct pci_dev *dev, int pos, int ht_cap); 501#endif /* CONFIG_PCI_LEGACY */
502
503int pci_find_capability(struct pci_dev *dev, int cap);
504int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap);
505int pci_find_ext_capability(struct pci_dev *dev, int cap);
506int pci_find_ht_capability(struct pci_dev *dev, int ht_cap);
507int pci_find_next_ht_capability(struct pci_dev *dev, int pos, int ht_cap);
508void pcie_wait_pending_transaction(struct pci_dev *dev);
489struct pci_bus *pci_find_next_bus(const struct pci_bus *from); 509struct pci_bus *pci_find_next_bus(const struct pci_bus *from);
490 510
491struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device, 511struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
@@ -493,49 +513,58 @@ struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
493struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device, 513struct pci_dev *pci_get_device_reverse(unsigned int vendor, unsigned int device,
494 struct pci_dev *from); 514 struct pci_dev *from);
495 515
496struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, 516struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
497 unsigned int ss_vendor, unsigned int ss_device, 517 unsigned int ss_vendor, unsigned int ss_device,
498 struct pci_dev *from); 518 struct pci_dev *from);
499struct pci_dev *pci_get_slot (struct pci_bus *bus, unsigned int devfn); 519struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn);
500struct pci_dev *pci_get_bus_and_slot (unsigned int bus, unsigned int devfn); 520struct pci_dev *pci_get_bus_and_slot(unsigned int bus, unsigned int devfn);
501struct pci_dev *pci_get_class (unsigned int class, struct pci_dev *from); 521struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from);
502int pci_dev_present(const struct pci_device_id *ids); 522int pci_dev_present(const struct pci_device_id *ids);
503const struct pci_device_id *pci_find_present(const struct pci_device_id *ids); 523const struct pci_device_id *pci_find_present(const struct pci_device_id *ids);
504 524
505int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); 525int pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn,
506int pci_bus_read_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 *val); 526 int where, u8 *val);
507int pci_bus_read_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 *val); 527int pci_bus_read_config_word(struct pci_bus *bus, unsigned int devfn,
508int pci_bus_write_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 val); 528 int where, u16 *val);
509int pci_bus_write_config_word (struct pci_bus *bus, unsigned int devfn, int where, u16 val); 529int pci_bus_read_config_dword(struct pci_bus *bus, unsigned int devfn,
510int pci_bus_write_config_dword (struct pci_bus *bus, unsigned int devfn, int where, u32 val); 530 int where, u32 *val);
531int pci_bus_write_config_byte(struct pci_bus *bus, unsigned int devfn,
532 int where, u8 val);
533int pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn,
534 int where, u16 val);
535int pci_bus_write_config_dword(struct pci_bus *bus, unsigned int devfn,
536 int where, u32 val);
511 537
512static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val) 538static inline int pci_read_config_byte(struct pci_dev *dev, int where, u8 *val)
513{ 539{
514 return pci_bus_read_config_byte (dev->bus, dev->devfn, where, val); 540 return pci_bus_read_config_byte(dev->bus, dev->devfn, where, val);
515} 541}
516static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val) 542static inline int pci_read_config_word(struct pci_dev *dev, int where, u16 *val)
517{ 543{
518 return pci_bus_read_config_word (dev->bus, dev->devfn, where, val); 544 return pci_bus_read_config_word(dev->bus, dev->devfn, where, val);
519} 545}
520static inline int pci_read_config_dword(struct pci_dev *dev, int where, u32 *val) 546static inline int pci_read_config_dword(struct pci_dev *dev, int where,
547 u32 *val)
521{ 548{
522 return pci_bus_read_config_dword (dev->bus, dev->devfn, where, val); 549 return pci_bus_read_config_dword(dev->bus, dev->devfn, where, val);
523} 550}
524static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val) 551static inline int pci_write_config_byte(struct pci_dev *dev, int where, u8 val)
525{ 552{
526 return pci_bus_write_config_byte (dev->bus, dev->devfn, where, val); 553 return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
527} 554}
528static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val) 555static inline int pci_write_config_word(struct pci_dev *dev, int where, u16 val)
529{ 556{
530 return pci_bus_write_config_word (dev->bus, dev->devfn, where, val); 557 return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
531} 558}
532static inline int pci_write_config_dword(struct pci_dev *dev, int where, u32 val) 559static inline int pci_write_config_dword(struct pci_dev *dev, int where,
560 u32 val)
533{ 561{
534 return pci_bus_write_config_dword (dev->bus, dev->devfn, where, val); 562 return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
535} 563}
536 564
537int __must_check pci_enable_device(struct pci_dev *dev); 565int __must_check pci_enable_device(struct pci_dev *dev);
538int __must_check pci_enable_device_bars(struct pci_dev *dev, int mask); 566int __must_check pci_enable_device_io(struct pci_dev *dev);
567int __must_check pci_enable_device_mem(struct pci_dev *dev);
539int __must_check pci_reenable_device(struct pci_dev *); 568int __must_check pci_reenable_device(struct pci_dev *);
540int __must_check pcim_enable_device(struct pci_dev *pdev); 569int __must_check pcim_enable_device(struct pci_dev *pdev);
541void pcim_pin_device(struct pci_dev *pdev); 570void pcim_pin_device(struct pci_dev *pdev);
@@ -564,14 +593,11 @@ int pcie_set_readrq(struct pci_dev *dev, int rq);
564void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno); 593void pci_update_resource(struct pci_dev *dev, struct resource *res, int resno);
565int __must_check pci_assign_resource(struct pci_dev *dev, int i); 594int __must_check pci_assign_resource(struct pci_dev *dev, int i);
566int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i); 595int __must_check pci_assign_resource_fixed(struct pci_dev *dev, int i);
567void pci_restore_bars(struct pci_dev *dev);
568int pci_select_bars(struct pci_dev *dev, unsigned long flags); 596int pci_select_bars(struct pci_dev *dev, unsigned long flags);
569 597
570/* ROM control related routines */ 598/* ROM control related routines */
571void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size); 599void __iomem __must_check *pci_map_rom(struct pci_dev *pdev, size_t *size);
572void __iomem __must_check *pci_map_rom_copy(struct pci_dev *pdev, size_t *size);
573void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom); 600void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom);
574void pci_remove_rom(struct pci_dev *pdev);
575size_t pci_get_rom_size(void __iomem *rom, size_t size); 601size_t pci_get_rom_size(void __iomem *rom, size_t size);
576 602
577/* Power management related routines */ 603/* Power management related routines */
@@ -582,7 +608,7 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
582int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); 608int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
583 609
584/* Functions for PCI Hotplug drivers to use */ 610/* Functions for PCI Hotplug drivers to use */
585int pci_bus_find_capability (struct pci_bus *bus, unsigned int devfn, int cap); 611int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap);
586 612
587/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */ 613/* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
588void pci_bus_assign_resources(struct pci_bus *bus); 614void pci_bus_assign_resources(struct pci_bus *bus);
@@ -619,17 +645,18 @@ static inline int __must_check pci_register_driver(struct pci_driver *driver)
619 return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME); 645 return __pci_register_driver(driver, THIS_MODULE, KBUILD_MODNAME);
620} 646}
621 647
622void pci_unregister_driver(struct pci_driver *); 648void pci_unregister_driver(struct pci_driver *dev);
623void pci_remove_behind_bridge(struct pci_dev *); 649void pci_remove_behind_bridge(struct pci_dev *dev);
624struct pci_driver *pci_dev_driver(const struct pci_dev *); 650struct pci_driver *pci_dev_driver(const struct pci_dev *dev);
625const struct pci_device_id *pci_match_device(struct pci_driver *drv, struct pci_dev *dev); 651const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
626const struct pci_device_id *pci_match_id(const struct pci_device_id *ids, struct pci_dev *dev); 652 struct pci_dev *dev);
627int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass); 653int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max,
654 int pass);
628 655
629void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *), 656void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
630 void *userdata); 657 void *userdata);
631int pci_cfg_space_size(struct pci_dev *dev); 658int pci_cfg_space_size(struct pci_dev *dev);
632unsigned char pci_bus_max_busnr(struct pci_bus* bus); 659unsigned char pci_bus_max_busnr(struct pci_bus *bus);
633 660
634/* kmem_cache style wrapper around pci_alloc_consistent() */ 661/* kmem_cache style wrapper around pci_alloc_consistent() */
635 662
@@ -658,19 +685,36 @@ struct msix_entry {
658 685
659 686
660#ifndef CONFIG_PCI_MSI 687#ifndef CONFIG_PCI_MSI
661static inline int pci_enable_msi(struct pci_dev *dev) {return -1;} 688static inline int pci_enable_msi(struct pci_dev *dev)
662static inline void pci_disable_msi(struct pci_dev *dev) {} 689{
663static inline int pci_enable_msix(struct pci_dev* dev, 690 return -1;
664 struct msix_entry *entries, int nvec) {return -1;} 691}
665static inline void pci_disable_msix(struct pci_dev *dev) {} 692
666static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev) {} 693static inline void pci_disable_msi(struct pci_dev *dev)
694{ }
695
696static inline int pci_enable_msix(struct pci_dev *dev,
697 struct msix_entry *entries, int nvec)
698{
699 return -1;
700}
701
702static inline void pci_disable_msix(struct pci_dev *dev)
703{ }
704
705static inline void msi_remove_pci_irq_vectors(struct pci_dev *dev)
706{ }
707
708static inline void pci_restore_msi_state(struct pci_dev *dev)
709{ }
667#else 710#else
668extern int pci_enable_msi(struct pci_dev *dev); 711extern int pci_enable_msi(struct pci_dev *dev);
669extern void pci_disable_msi(struct pci_dev *dev); 712extern void pci_disable_msi(struct pci_dev *dev);
670extern int pci_enable_msix(struct pci_dev* dev, 713extern int pci_enable_msix(struct pci_dev *dev,
671 struct msix_entry *entries, int nvec); 714 struct msix_entry *entries, int nvec);
672extern void pci_disable_msix(struct pci_dev *dev); 715extern void pci_disable_msix(struct pci_dev *dev);
673extern void msi_remove_pci_irq_vectors(struct pci_dev *dev); 716extern void msi_remove_pci_irq_vectors(struct pci_dev *dev);
717extern void pci_restore_msi_state(struct pci_dev *dev);
674#endif 718#endif
675 719
676#ifdef CONFIG_HT_IRQ 720#ifdef CONFIG_HT_IRQ
@@ -691,7 +735,11 @@ extern void pci_unblock_user_cfg_access(struct pci_dev *dev);
691extern int pci_domains_supported; 735extern int pci_domains_supported;
692#else 736#else
693enum { pci_domains_supported = 0 }; 737enum { pci_domains_supported = 0 };
694static inline int pci_domain_nr(struct pci_bus *bus) { return 0; } 738static inline int pci_domain_nr(struct pci_bus *bus)
739{
740 return 0;
741}
742
695static inline int pci_proc_domain(struct pci_bus *bus) 743static inline int pci_proc_domain(struct pci_bus *bus)
696{ 744{
697 return 0; 745 return 0;
@@ -705,68 +753,161 @@ static inline int pci_proc_domain(struct pci_bus *bus)
705 * these as simple inline functions to avoid hair in drivers. 753 * these as simple inline functions to avoid hair in drivers.
706 */ 754 */
707 755
708#define _PCI_NOP(o,s,t) \ 756#define _PCI_NOP(o, s, t) \
709 static inline int pci_##o##_config_##s (struct pci_dev *dev, int where, t val) \ 757 static inline int pci_##o##_config_##s(struct pci_dev *dev, \
758 int where, t val) \
710 { return PCIBIOS_FUNC_NOT_SUPPORTED; } 759 { return PCIBIOS_FUNC_NOT_SUPPORTED; }
711#define _PCI_NOP_ALL(o,x) _PCI_NOP(o,byte,u8 x) \ 760
712 _PCI_NOP(o,word,u16 x) \ 761#define _PCI_NOP_ALL(o, x) _PCI_NOP(o, byte, u8 x) \
713 _PCI_NOP(o,dword,u32 x) 762 _PCI_NOP(o, word, u16 x) \
763 _PCI_NOP(o, dword, u32 x)
714_PCI_NOP_ALL(read, *) 764_PCI_NOP_ALL(read, *)
715_PCI_NOP_ALL(write,) 765_PCI_NOP_ALL(write,)
716 766
717static inline struct pci_dev *pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *from) 767static inline struct pci_dev *pci_find_device(unsigned int vendor,
718{ return NULL; } 768 unsigned int device,
769 const struct pci_dev *from)
770{
771 return NULL;
772}
719 773
720static inline struct pci_dev *pci_find_slot(unsigned int bus, unsigned int devfn) 774static inline struct pci_dev *pci_find_slot(unsigned int bus,
721{ return NULL; } 775 unsigned int devfn)
776{
777 return NULL;
778}
722 779
723static inline struct pci_dev *pci_get_device(unsigned int vendor, 780static inline struct pci_dev *pci_get_device(unsigned int vendor,
724 unsigned int device, struct pci_dev *from) 781 unsigned int device,
725{ return NULL; } 782 struct pci_dev *from)
783{
784 return NULL;
785}
726 786
727static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor, 787static inline struct pci_dev *pci_get_device_reverse(unsigned int vendor,
728 unsigned int device, struct pci_dev *from) 788 unsigned int device,
729{ return NULL; } 789 struct pci_dev *from)
790{
791 return NULL;
792}
730 793
731static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int device, 794static inline struct pci_dev *pci_get_subsys(unsigned int vendor,
732unsigned int ss_vendor, unsigned int ss_device, struct pci_dev *from) 795 unsigned int device,
733{ return NULL; } 796 unsigned int ss_vendor,
797 unsigned int ss_device,
798 struct pci_dev *from)
799{
800 return NULL;
801}
734 802
735static inline struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from) 803static inline struct pci_dev *pci_get_class(unsigned int class,
736{ return NULL; } 804 struct pci_dev *from)
805{
806 return NULL;
807}
737 808
738#define pci_dev_present(ids) (0) 809#define pci_dev_present(ids) (0)
739#define no_pci_devices() (1) 810#define no_pci_devices() (1)
740#define pci_find_present(ids) (NULL) 811#define pci_find_present(ids) (NULL)
741#define pci_dev_put(dev) do { } while (0) 812#define pci_dev_put(dev) do { } while (0)
742 813
743static inline void pci_set_master(struct pci_dev *dev) { } 814static inline void pci_set_master(struct pci_dev *dev)
744static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; } 815{ }
745static inline void pci_disable_device(struct pci_dev *dev) { } 816
746static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask) { return -EIO; } 817static inline int pci_enable_device(struct pci_dev *dev)
747static inline int pci_assign_resource(struct pci_dev *dev, int i) { return -EBUSY;} 818{
748static inline int __pci_register_driver(struct pci_driver *drv, struct module *owner) { return 0;} 819 return -EIO;
749static inline int pci_register_driver(struct pci_driver *drv) { return 0;} 820}
750static inline void pci_unregister_driver(struct pci_driver *drv) { } 821
751static inline int pci_find_capability (struct pci_dev *dev, int cap) {return 0; } 822static inline void pci_disable_device(struct pci_dev *dev)
752static inline int pci_find_next_capability (struct pci_dev *dev, u8 post, int cap) { return 0; } 823{ }
753static inline int pci_find_ext_capability (struct pci_dev *dev, int cap) {return 0; } 824
754static inline const struct pci_device_id *pci_match_device(const struct pci_device_id *ids, const struct pci_dev *dev) { return NULL; } 825static inline int pci_set_dma_mask(struct pci_dev *dev, u64 mask)
826{
827 return -EIO;
828}
829
830static inline int pci_assign_resource(struct pci_dev *dev, int i)
831{
832 return -EBUSY;
833}
834
835static inline int __pci_register_driver(struct pci_driver *drv,
836 struct module *owner)
837{
838 return 0;
839}
840
841static inline int pci_register_driver(struct pci_driver *drv)
842{
843 return 0;
844}
845
846static inline void pci_unregister_driver(struct pci_driver *drv)
847{ }
848
849static inline int pci_find_capability(struct pci_dev *dev, int cap)
850{
851 return 0;
852}
853
854static inline int pci_find_next_capability(struct pci_dev *dev, u8 post,
855 int cap)
856{
857 return 0;
858}
859
860static inline int pci_find_ext_capability(struct pci_dev *dev, int cap)
861{
862 return 0;
863}
864
865static inline void pcie_wait_pending_transaction(struct pci_dev *dev)
866{ }
755 867
756/* Power management related routines */ 868/* Power management related routines */
757static inline int pci_save_state(struct pci_dev *dev) { return 0; } 869static inline int pci_save_state(struct pci_dev *dev)
758static inline int pci_restore_state(struct pci_dev *dev) { return 0; } 870{
759static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state) { return 0; } 871 return 0;
760static inline pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) { return PCI_D0; } 872}
761static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) { return 0; } 873
874static inline int pci_restore_state(struct pci_dev *dev)
875{
876 return 0;
877}
878
879static inline int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
880{
881 return 0;
882}
883
884static inline pci_power_t pci_choose_state(struct pci_dev *dev,
885 pm_message_t state)
886{
887 return PCI_D0;
888}
889
890static inline int pci_enable_wake(struct pci_dev *dev, pci_power_t state,
891 int enable)
892{
893 return 0;
894}
895
896static inline int pci_request_regions(struct pci_dev *dev, const char *res_name)
897{
898 return -EIO;
899}
762 900
763static inline int pci_request_regions(struct pci_dev *dev, const char *res_name) { return -EIO; } 901static inline void pci_release_regions(struct pci_dev *dev)
764static inline void pci_release_regions(struct pci_dev *dev) { } 902{ }
765 903
766#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0) 904#define pci_dma_burst_advice(pdev, strat, strategy_parameter) do { } while (0)
767 905
768static inline void pci_block_user_cfg_access(struct pci_dev *dev) { } 906static inline void pci_block_user_cfg_access(struct pci_dev *dev)
769static inline void pci_unblock_user_cfg_access(struct pci_dev *dev) { } 907{ }
908
909static inline void pci_unblock_user_cfg_access(struct pci_dev *dev)
910{ }
770 911
771static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from) 912static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
772{ return NULL; } 913{ return NULL; }
@@ -787,27 +928,27 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
787 928
788/* these helpers provide future and backwards compatibility 929/* these helpers provide future and backwards compatibility
789 * for accessing popular PCI BAR info */ 930 * for accessing popular PCI BAR info */
790#define pci_resource_start(dev,bar) ((dev)->resource[(bar)].start) 931#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
791#define pci_resource_end(dev,bar) ((dev)->resource[(bar)].end) 932#define pci_resource_end(dev, bar) ((dev)->resource[(bar)].end)
792#define pci_resource_flags(dev,bar) ((dev)->resource[(bar)].flags) 933#define pci_resource_flags(dev, bar) ((dev)->resource[(bar)].flags)
793#define pci_resource_len(dev,bar) \ 934#define pci_resource_len(dev,bar) \
794 ((pci_resource_start((dev),(bar)) == 0 && \ 935 ((pci_resource_start((dev), (bar)) == 0 && \
795 pci_resource_end((dev),(bar)) == \ 936 pci_resource_end((dev), (bar)) == \
796 pci_resource_start((dev),(bar))) ? 0 : \ 937 pci_resource_start((dev), (bar))) ? 0 : \
797 \ 938 \
798 (pci_resource_end((dev),(bar)) - \ 939 (pci_resource_end((dev), (bar)) - \
799 pci_resource_start((dev),(bar)) + 1)) 940 pci_resource_start((dev), (bar)) + 1))
800 941
801/* Similar to the helpers above, these manipulate per-pci_dev 942/* Similar to the helpers above, these manipulate per-pci_dev
802 * driver-specific data. They are really just a wrapper around 943 * driver-specific data. They are really just a wrapper around
803 * the generic device structure functions of these calls. 944 * the generic device structure functions of these calls.
804 */ 945 */
805static inline void *pci_get_drvdata (struct pci_dev *pdev) 946static inline void *pci_get_drvdata(struct pci_dev *pdev)
806{ 947{
807 return dev_get_drvdata(&pdev->dev); 948 return dev_get_drvdata(&pdev->dev);
808} 949}
809 950
810static inline void pci_set_drvdata (struct pci_dev *pdev, void *data) 951static inline void pci_set_drvdata(struct pci_dev *pdev, void *data)
811{ 952{
812 dev_set_drvdata(&pdev->dev, data); 953 dev_set_drvdata(&pdev->dev, data);
813} 954}
@@ -826,7 +967,7 @@ static inline char *pci_name(struct pci_dev *pdev)
826 */ 967 */
827#ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER 968#ifndef HAVE_ARCH_PCI_RESOURCE_TO_USER
828static inline void pci_resource_to_user(const struct pci_dev *dev, int bar, 969static inline void pci_resource_to_user(const struct pci_dev *dev, int bar,
829 const struct resource *rsrc, resource_size_t *start, 970 const struct resource *rsrc, resource_size_t *start,
830 resource_size_t *end) 971 resource_size_t *end)
831{ 972{
832 *start = rsrc->start; 973 *start = rsrc->start;
@@ -857,7 +998,7 @@ enum pci_fixup_pass {
857 998
858/* Anonymous variables would be nice... */ 999/* Anonymous variables would be nice... */
859#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \ 1000#define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \
860 static const struct pci_fixup __pci_fixup_##name __attribute_used__ \ 1001 static const struct pci_fixup __pci_fixup_##name __used \
861 __attribute__((__section__(#section))) = { vendor, device, hook }; 1002 __attribute__((__section__(#section))) = { vendor, device, hook };
862#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ 1003#define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \
863 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ 1004 DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \
@@ -878,9 +1019,9 @@ enum pci_fixup_pass {
878 1019
879void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev); 1020void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev);
880 1021
881void __iomem * pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen); 1022void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen);
882void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr); 1023void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr);
883void __iomem * const * pcim_iomap_table(struct pci_dev *pdev); 1024void __iomem * const *pcim_iomap_table(struct pci_dev *pdev);
884int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name); 1025int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name);
885void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask); 1026void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask);
886 1027
diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
index ab4cb6ecd47c..8f67e8f2a3cc 100644
--- a/include/linux/pci_hotplug.h
+++ b/include/linux/pci_hotplug.h
@@ -174,7 +174,7 @@ extern int pci_hp_register (struct hotplug_slot *slot);
174extern int pci_hp_deregister (struct hotplug_slot *slot); 174extern int pci_hp_deregister (struct hotplug_slot *slot);
175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot, 175extern int __must_check pci_hp_change_slot_info (struct hotplug_slot *slot,
176 struct hotplug_slot_info *info); 176 struct hotplug_slot_info *info);
177extern struct kset pci_hotplug_slots_subsys; 177extern struct kset *pci_hotplug_slots_kset;
178 178
179/* PCI Setting Record (Type 0) */ 179/* PCI Setting Record (Type 0) */
180struct hpp_type0 { 180struct hpp_type0 {
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index e44aac8cf5ff..41f6f28690f6 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -360,9 +360,6 @@
360#define PCI_DEVICE_ID_ATI_RS400_166 0x5a32 360#define PCI_DEVICE_ID_ATI_RS400_166 0x5a32
361#define PCI_DEVICE_ID_ATI_RS400_200 0x5a33 361#define PCI_DEVICE_ID_ATI_RS400_200 0x5a33
362#define PCI_DEVICE_ID_ATI_RS480 0x5950 362#define PCI_DEVICE_ID_ATI_RS480 0x5950
363#define PCI_DEVICE_ID_ATI_RD580 0x5952
364#define PCI_DEVICE_ID_ATI_RX790 0x5957
365#define PCI_DEVICE_ID_ATI_RS690 0x7910
366/* ATI IXP Chipset */ 363/* ATI IXP Chipset */
367#define PCI_DEVICE_ID_ATI_IXP200_IDE 0x4349 364#define PCI_DEVICE_ID_ATI_IXP200_IDE 0x4349
368#define PCI_DEVICE_ID_ATI_IXP200_SMBUS 0x4353 365#define PCI_DEVICE_ID_ATI_IXP200_SMBUS 0x4353
@@ -1240,6 +1237,10 @@
1240#define PCI_DEVICE_ID_NVIDIA_NVENET_33 0x0761 1237#define PCI_DEVICE_ID_NVIDIA_NVENET_33 0x0761
1241#define PCI_DEVICE_ID_NVIDIA_NVENET_34 0x0762 1238#define PCI_DEVICE_ID_NVIDIA_NVENET_34 0x0762
1242#define PCI_DEVICE_ID_NVIDIA_NVENET_35 0x0763 1239#define PCI_DEVICE_ID_NVIDIA_NVENET_35 0x0763
1240#define PCI_DEVICE_ID_NVIDIA_NVENET_36 0x0AB0
1241#define PCI_DEVICE_ID_NVIDIA_NVENET_37 0x0AB1
1242#define PCI_DEVICE_ID_NVIDIA_NVENET_38 0x0AB2
1243#define PCI_DEVICE_ID_NVIDIA_NVENET_39 0x0AB3
1243 1244
1244#define PCI_VENDOR_ID_IMS 0x10e0 1245#define PCI_VENDOR_ID_IMS 0x10e0
1245#define PCI_DEVICE_ID_IMS_TT128 0x9128 1246#define PCI_DEVICE_ID_IMS_TT128 0x9128
@@ -1436,8 +1437,8 @@
1436#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008 1437#define PCI_DEVICE_ID_SERVERWORKS_HE 0x0008
1437#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009 1438#define PCI_DEVICE_ID_SERVERWORKS_LE 0x0009
1438#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017 1439#define PCI_DEVICE_ID_SERVERWORKS_GCNB_LE 0x0017
1440#define PCI_DEVICE_ID_SERVERWORKS_HT1000_PXB 0x0036
1439#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103 1441#define PCI_DEVICE_ID_SERVERWORKS_EPB 0x0103
1440#define PCI_DEVICE_ID_SERVERWORKS_HT1000_PCIX 0x0104
1441#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE 0x0132 1442#define PCI_DEVICE_ID_SERVERWORKS_HT2000_PCIE 0x0132
1442#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200 1443#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200
1443#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201 1444#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201
@@ -1942,6 +1943,7 @@
1942#define PCI_DEVICE_ID_NX2_5706 0x164a 1943#define PCI_DEVICE_ID_NX2_5706 0x164a
1943#define PCI_DEVICE_ID_NX2_5708 0x164c 1944#define PCI_DEVICE_ID_NX2_5708 0x164c
1944#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d 1945#define PCI_DEVICE_ID_TIGON3_5702FE 0x164d
1946#define PCI_DEVICE_ID_NX2_57710 0x164e
1945#define PCI_DEVICE_ID_TIGON3_5705 0x1653 1947#define PCI_DEVICE_ID_TIGON3_5705 0x1653
1946#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654 1948#define PCI_DEVICE_ID_TIGON3_5705_2 0x1654
1947#define PCI_DEVICE_ID_TIGON3_5720 0x1658 1949#define PCI_DEVICE_ID_TIGON3_5720 0x1658
@@ -2065,6 +2067,9 @@
2065#define PCI_VENDOR_ID_NETCELL 0x169c 2067#define PCI_VENDOR_ID_NETCELL 0x169c
2066#define PCI_DEVICE_ID_REVOLUTION 0x0044 2068#define PCI_DEVICE_ID_REVOLUTION 0x0044
2067 2069
2070#define PCI_VENDOR_ID_CENATEK 0x16CA
2071#define PCI_DEVICE_ID_CENATEK_IDE 0x0001
2072
2068#define PCI_VENDOR_ID_VITESSE 0x1725 2073#define PCI_VENDOR_ID_VITESSE 0x1725
2069#define PCI_DEVICE_ID_VITESSE_VSC7174 0x7174 2074#define PCI_DEVICE_ID_VITESSE_VSC7174 0x7174
2070 2075
@@ -2077,6 +2082,16 @@
2077#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea 2082#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea
2078#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb 2083#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb
2079 2084
2085#define PCI_VENDOR_ID_BELKIN 0x1799
2086#define PCI_DEVICE_ID_BELKIN_F5D7010V7 0x701f
2087
2088#define PCI_VENDOR_ID_RDC 0x17f3
2089#define PCI_DEVICE_ID_RDC_R6020 0x6020
2090#define PCI_DEVICE_ID_RDC_R6030 0x6030
2091#define PCI_DEVICE_ID_RDC_R6040 0x6040
2092#define PCI_DEVICE_ID_RDC_R6060 0x6060
2093#define PCI_DEVICE_ID_RDC_R6061 0x6061
2094
2080#define PCI_VENDOR_ID_LENOVO 0x17aa 2095#define PCI_VENDOR_ID_LENOVO 0x17aa
2081 2096
2082#define PCI_VENDOR_ID_ARECA 0x17d3 2097#define PCI_VENDOR_ID_ARECA 0x17d3
@@ -2105,6 +2120,8 @@
2105#define PCI_DEVICE_ID_HERC_WIN 0x5732 2120#define PCI_DEVICE_ID_HERC_WIN 0x5732
2106#define PCI_DEVICE_ID_HERC_UNI 0x5832 2121#define PCI_DEVICE_ID_HERC_UNI 0x5832
2107 2122
2123#define PCI_VENDOR_ID_RDC 0x17f3
2124
2108#define PCI_VENDOR_ID_SITECOM 0x182d 2125#define PCI_VENDOR_ID_SITECOM 0x182d
2109#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069 2126#define PCI_DEVICE_ID_SITECOM_DC105V2 0x3069
2110 2127
@@ -2147,6 +2164,7 @@
2147#define PCI_DEVICE_ID_JMICRON_JMB365 0x2365 2164#define PCI_DEVICE_ID_JMICRON_JMB365 0x2365
2148#define PCI_DEVICE_ID_JMICRON_JMB366 0x2366 2165#define PCI_DEVICE_ID_JMICRON_JMB366 0x2366
2149#define PCI_DEVICE_ID_JMICRON_JMB368 0x2368 2166#define PCI_DEVICE_ID_JMICRON_JMB368 0x2368
2167#define PCI_DEVICE_ID_JMICRON_JMB38X_SD 0x2381
2150 2168
2151#define PCI_VENDOR_ID_KORENIX 0x1982 2169#define PCI_VENDOR_ID_KORENIX 0x1982
2152#define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600 2170#define PCI_DEVICE_ID_KORENIX_JETCARDF0 0x1600
@@ -2279,6 +2297,9 @@
2279#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582 2297#define PCI_DEVICE_ID_INTEL_82915G_IG 0x2582
2280#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590 2298#define PCI_DEVICE_ID_INTEL_82915GM_HB 0x2590
2281#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592 2299#define PCI_DEVICE_ID_INTEL_82915GM_IG 0x2592
2300#define PCI_DEVICE_ID_INTEL_5000_ERR 0x25F0
2301#define PCI_DEVICE_ID_INTEL_5000_FBD0 0x25F5
2302#define PCI_DEVICE_ID_INTEL_5000_FBD1 0x25F6
2282#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770 2303#define PCI_DEVICE_ID_INTEL_82945G_HB 0x2770
2283#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772 2304#define PCI_DEVICE_ID_INTEL_82945G_IG 0x2772
2284#define PCI_DEVICE_ID_INTEL_3000_HB 0x2778 2305#define PCI_DEVICE_ID_INTEL_3000_HB 0x2778
@@ -2317,6 +2338,8 @@
2317#define PCI_DEVICE_ID_INTEL_ICH9_4 0x2914 2338#define PCI_DEVICE_ID_INTEL_ICH9_4 0x2914
2318#define PCI_DEVICE_ID_INTEL_ICH9_5 0x2919 2339#define PCI_DEVICE_ID_INTEL_ICH9_5 0x2919
2319#define PCI_DEVICE_ID_INTEL_ICH9_6 0x2930 2340#define PCI_DEVICE_ID_INTEL_ICH9_6 0x2930
2341#define PCI_DEVICE_ID_INTEL_ICH9_7 0x2916
2342#define PCI_DEVICE_ID_INTEL_ICH9_8 0x2918
2320#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340 2343#define PCI_DEVICE_ID_INTEL_82855PM_HB 0x3340
2321#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575 2344#define PCI_DEVICE_ID_INTEL_82830_HB 0x3575
2322#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577 2345#define PCI_DEVICE_ID_INTEL_82830_CGC 0x3577
@@ -2332,6 +2355,7 @@
2332#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a 2355#define PCI_DEVICE_ID_INTEL_MCH_PC1 0x359a
2333#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e 2356#define PCI_DEVICE_ID_INTEL_E7525_MCH 0x359e
2334#define PCI_DEVICE_ID_INTEL_IOAT_CNB 0x360b 2357#define PCI_DEVICE_ID_INTEL_IOAT_CNB 0x360b
2358#define PCI_DEVICE_ID_INTEL_IOAT_SNB 0x402f
2335#define PCI_DEVICE_ID_INTEL_IOAT_SCNB 0x65ff 2359#define PCI_DEVICE_ID_INTEL_IOAT_SCNB 0x65ff
2336#define PCI_DEVICE_ID_INTEL_TOLAPAI_0 0x5031 2360#define PCI_DEVICE_ID_INTEL_TOLAPAI_0 0x5031
2337#define PCI_DEVICE_ID_INTEL_TOLAPAI_1 0x5032 2361#define PCI_DEVICE_ID_INTEL_TOLAPAI_1 0x5032
diff --git a/include/linux/pci_regs.h b/include/linux/pci_regs.h
index c1914a8b94a9..c0c1223c9194 100644
--- a/include/linux/pci_regs.h
+++ b/include/linux/pci_regs.h
@@ -395,9 +395,17 @@
395#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */ 395#define PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
396#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */ 396#define PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
397#define PCI_EXP_LNKCAP 12 /* Link Capabilities */ 397#define PCI_EXP_LNKCAP 12 /* Link Capabilities */
398#define PCI_EXP_LNKCAP_ASPMS 0xc00 /* ASPM Support */
399#define PCI_EXP_LNKCAP_L0SEL 0x7000 /* L0s Exit Latency */
400#define PCI_EXP_LNKCAP_L1EL 0x38000 /* L1 Exit Latency */
401#define PCI_EXP_LNKCAP_CLKPM 0x40000 /* L1 Clock Power Management */
398#define PCI_EXP_LNKCTL 16 /* Link Control */ 402#define PCI_EXP_LNKCTL 16 /* Link Control */
403#define PCI_EXP_LNKCTL_RL 0x20 /* Retrain Link */
404#define PCI_EXP_LNKCTL_CCC 0x40 /* Common Clock COnfiguration */
399#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */ 405#define PCI_EXP_LNKCTL_CLKREQ_EN 0x100 /* Enable clkreq */
400#define PCI_EXP_LNKSTA 18 /* Link Status */ 406#define PCI_EXP_LNKSTA 18 /* Link Status */
407#define PCI_EXP_LNKSTA_LT 0x800 /* Link Training */
408#define PCI_EXP_LNKSTA_SLC 0x1000 /* Slot Clock Configuration */
401#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */ 409#define PCI_EXP_SLTCAP 20 /* Slot Capabilities */
402#define PCI_EXP_SLTCTL 24 /* Slot Control */ 410#define PCI_EXP_SLTCTL 24 /* Slot Control */
403#define PCI_EXP_SLTSTA 26 /* Slot Status */ 411#define PCI_EXP_SLTSTA 26 /* Slot Status */
diff --git a/include/linux/pcounter.h b/include/linux/pcounter.h
new file mode 100644
index 000000000000..a82d9f2628ca
--- /dev/null
+++ b/include/linux/pcounter.h
@@ -0,0 +1,74 @@
1#ifndef __LINUX_PCOUNTER_H
2#define __LINUX_PCOUNTER_H
3/*
4 * Using a dynamic percpu 'int' variable has a cost :
5 * 1) Extra dereference
6 * Current per_cpu_ptr() implementation uses an array per 'percpu variable'.
7 * 2) memory cost of NR_CPUS*(32+sizeof(void *)) instead of num_possible_cpus()*4
8 *
9 * This pcounter implementation is an abstraction to be able to use
10 * either a static or a dynamic per cpu variable.
11 * One dynamic per cpu variable gets a fast & cheap implementation, we can
12 * change pcounter implementation too.
13 */
14struct pcounter {
15#ifdef CONFIG_SMP
16 void (*add)(struct pcounter *self, int inc);
17 int (*getval)(const struct pcounter *self, int cpu);
18 int *per_cpu_values;
19#else
20 int val;
21#endif
22};
23
24#ifdef CONFIG_SMP
25#include <linux/percpu.h>
26
27#define DEFINE_PCOUNTER(NAME) \
28static DEFINE_PER_CPU(int, NAME##_pcounter_values); \
29static void NAME##_pcounter_add(struct pcounter *self, int val) \
30{ \
31 __get_cpu_var(NAME##_pcounter_values) += val; \
32} \
33static int NAME##_pcounter_getval(const struct pcounter *self, int cpu) \
34{ \
35 return per_cpu(NAME##_pcounter_values, cpu); \
36} \
37
38#define PCOUNTER_MEMBER_INITIALIZER(NAME, MEMBER) \
39 MEMBER = { \
40 .add = NAME##_pcounter_add, \
41 .getval = NAME##_pcounter_getval, \
42 }
43
44
45static inline void pcounter_add(struct pcounter *self, int inc)
46{
47 self->add(self, inc);
48}
49
50extern int pcounter_getval(const struct pcounter *self);
51extern int pcounter_alloc(struct pcounter *self);
52extern void pcounter_free(struct pcounter *self);
53
54
55#else /* CONFIG_SMP */
56
57static inline void pcounter_add(struct pcounter *self, int inc)
58{
59 self->val += inc;
60}
61
62static inline int pcounter_getval(const struct pcounter *self)
63{
64 return self->val;
65}
66
67#define DEFINE_PCOUNTER(NAME)
68#define PCOUNTER_MEMBER_INITIALIZER(NAME, MEMBER)
69#define pcounter_alloc(self) 0
70#define pcounter_free(self)
71
72#endif /* CONFIG_SMP */
73
74#endif /* __LINUX_PCOUNTER_H */
diff --git a/include/linux/pda_power.h b/include/linux/pda_power.h
index 1375f15797e7..225beb136807 100644
--- a/include/linux/pda_power.h
+++ b/include/linux/pda_power.h
@@ -26,6 +26,7 @@ struct pda_power_pdata {
26 26
27 unsigned int wait_for_status; /* msecs, default is 500 */ 27 unsigned int wait_for_status; /* msecs, default is 500 */
28 unsigned int wait_for_charger; /* msecs, default is 500 */ 28 unsigned int wait_for_charger; /* msecs, default is 500 */
29 unsigned int polling_interval; /* msecs, default is 2000 */
29}; 30};
30 31
31#endif /* __PDA_POWER_H__ */ 32#endif /* __PDA_POWER_H__ */
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 926adaae0f96..50faa0ea28e4 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -9,6 +9,26 @@
9 9
10#include <asm/percpu.h> 10#include <asm/percpu.h>
11 11
12#ifdef CONFIG_SMP
13#define DEFINE_PER_CPU(type, name) \
14 __attribute__((__section__(".data.percpu"))) \
15 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
16
17#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
18 __attribute__((__section__(".data.percpu.shared_aligned"))) \
19 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name \
20 ____cacheline_aligned_in_smp
21#else
22#define DEFINE_PER_CPU(type, name) \
23 PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
24
25#define DEFINE_PER_CPU_SHARED_ALIGNED(type, name) \
26 DEFINE_PER_CPU(type, name)
27#endif
28
29#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
30#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
31
12/* Enough to cover all DEFINE_PER_CPUs in kernel, including modules. */ 32/* Enough to cover all DEFINE_PER_CPUs in kernel, including modules. */
13#ifndef PERCPU_ENOUGH_ROOM 33#ifndef PERCPU_ENOUGH_ROOM
14#ifdef CONFIG_MODULES 34#ifdef CONFIG_MODULES
diff --git a/include/linux/pfkeyv2.h b/include/linux/pfkeyv2.h
index d9db5f62ee48..6db69ff5d83e 100644
--- a/include/linux/pfkeyv2.h
+++ b/include/linux/pfkeyv2.h
@@ -298,6 +298,12 @@ struct sadb_x_sec_ctx {
298#define SADB_X_EALG_BLOWFISHCBC 7 298#define SADB_X_EALG_BLOWFISHCBC 7
299#define SADB_EALG_NULL 11 299#define SADB_EALG_NULL 11
300#define SADB_X_EALG_AESCBC 12 300#define SADB_X_EALG_AESCBC 12
301#define SADB_X_EALG_AES_CCM_ICV8 14
302#define SADB_X_EALG_AES_CCM_ICV12 15
303#define SADB_X_EALG_AES_CCM_ICV16 16
304#define SADB_X_EALG_AES_GCM_ICV8 18
305#define SADB_X_EALG_AES_GCM_ICV12 19
306#define SADB_X_EALG_AES_GCM_ICV16 20
301#define SADB_X_EALG_CAMELLIACBC 22 307#define SADB_X_EALG_CAMELLIACBC 22
302#define SADB_EALG_MAX 253 /* last EALG */ 308#define SADB_EALG_MAX 253 /* last EALG */
303/* private allocations should use 249-255 (RFC2407) */ 309/* private allocations should use 249-255 (RFC2407) */
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f0742b6aaa64..554836edd915 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -58,6 +58,8 @@ typedef enum {
58 PHY_INTERFACE_MODE_RMII, 58 PHY_INTERFACE_MODE_RMII,
59 PHY_INTERFACE_MODE_RGMII, 59 PHY_INTERFACE_MODE_RGMII,
60 PHY_INTERFACE_MODE_RGMII_ID, 60 PHY_INTERFACE_MODE_RGMII_ID,
61 PHY_INTERFACE_MODE_RGMII_RXID,
62 PHY_INTERFACE_MODE_RGMII_TXID,
61 PHY_INTERFACE_MODE_RTBI 63 PHY_INTERFACE_MODE_RTBI
62} phy_interface_t; 64} phy_interface_t;
63 65
@@ -401,6 +403,7 @@ int phy_mii_ioctl(struct phy_device *phydev,
401int phy_start_interrupts(struct phy_device *phydev); 403int phy_start_interrupts(struct phy_device *phydev);
402void phy_print_status(struct phy_device *phydev); 404void phy_print_status(struct phy_device *phydev);
403struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id); 405struct phy_device* phy_device_create(struct mii_bus *bus, int addr, int phy_id);
406void phy_device_free(struct phy_device *phydev);
404 407
405extern struct bus_type mdio_bus_type; 408extern struct bus_type mdio_bus_type;
406#endif /* __PHY_H */ 409#endif /* __PHY_H */
diff --git a/include/linux/phy_fixed.h b/include/linux/phy_fixed.h
index 04ba70d49fb8..509d8f5f984e 100644
--- a/include/linux/phy_fixed.h
+++ b/include/linux/phy_fixed.h
@@ -1,38 +1,31 @@
1#ifndef __PHY_FIXED_H 1#ifndef __PHY_FIXED_H
2#define __PHY_FIXED_H 2#define __PHY_FIXED_H
3 3
4#define MII_REGS_NUM 29
5
6/* max number of virtual phy stuff */
7#define MAX_PHY_AMNT 10
8/*
9 The idea is to emulate normal phy behavior by responding with
10 pre-defined values to mii BMCR read, so that read_status hook could
11 take all the needed info.
12*/
13
14struct fixed_phy_status { 4struct fixed_phy_status {
15 u8 link; 5 int link;
16 u16 speed; 6 int speed;
17 u8 duplex; 7 int duplex;
8 int pause;
9 int asym_pause;
18}; 10};
19 11
20/*----------------------------------------------------------------------------- 12#ifdef CONFIG_FIXED_PHY
21 * Private information hoder for mii_bus 13extern int fixed_phy_add(unsigned int irq, int phy_id,
22 *-----------------------------------------------------------------------------*/ 14 struct fixed_phy_status *status);
23struct fixed_info { 15#else
24 u16 *regs; 16static inline int fixed_phy_add(unsigned int irq, int phy_id,
25 u8 regs_num; 17 struct fixed_phy_status *status)
26 struct fixed_phy_status phy_status; 18{
27 struct phy_device *phydev; /* pointer to the container */ 19 return -ENODEV;
28 /* link & speed cb */ 20}
29 int (*link_update) (struct net_device *, struct fixed_phy_status *); 21#endif /* CONFIG_FIXED_PHY */
30 22
31}; 23/*
32 24 * This function issued only by fixed_phy-aware drivers, no need
33 25 * protect it with #ifdef
34int fixed_mdio_set_link_update(struct phy_device *, 26 */
35 int (*link_update) (struct net_device *, struct fixed_phy_status *)); 27extern int fixed_phy_set_link_update(struct phy_device *phydev,
36struct fixed_info *fixed_mdio_get_phydev (int phydev_ind); 28 int (*link_update)(struct net_device *,
29 struct fixed_phy_status *));
37 30
38#endif /* __PHY_FIXED_H */ 31#endif /* __PHY_FIXED_H */
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index 0135c76c76c6..1689e28483e4 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -29,6 +29,7 @@ struct pid_namespace {
29 29
30extern struct pid_namespace init_pid_ns; 30extern struct pid_namespace init_pid_ns;
31 31
32#ifdef CONFIG_PID_NS
32static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns) 33static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
33{ 34{
34 if (ns != &init_pid_ns) 35 if (ns != &init_pid_ns)
@@ -45,6 +46,28 @@ static inline void put_pid_ns(struct pid_namespace *ns)
45 kref_put(&ns->kref, free_pid_ns); 46 kref_put(&ns->kref, free_pid_ns);
46} 47}
47 48
49#else /* !CONFIG_PID_NS */
50#include <linux/err.h>
51
52static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
53{
54 return ns;
55}
56
57static inline struct pid_namespace *
58copy_pid_ns(unsigned long flags, struct pid_namespace *ns)
59{
60 if (flags & CLONE_NEWPID)
61 ns = ERR_PTR(-EINVAL);
62 return ns;
63}
64
65static inline void put_pid_ns(struct pid_namespace *ns)
66{
67}
68
69#endif /* CONFIG_PID_NS */
70
48static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk) 71static inline struct pid_namespace *task_active_pid_ns(struct task_struct *tsk)
49{ 72{
50 return tsk->nsproxy->pid_ns; 73 return tsk->nsproxy->pid_ns;
diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index 30b8571e6b34..1c1dba9ea5fb 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -328,6 +328,56 @@ enum
328 328
329#define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1) 329#define TCA_TCINDEX_MAX (__TCA_TCINDEX_MAX - 1)
330 330
331/* Flow filter */
332
333enum
334{
335 FLOW_KEY_SRC,
336 FLOW_KEY_DST,
337 FLOW_KEY_PROTO,
338 FLOW_KEY_PROTO_SRC,
339 FLOW_KEY_PROTO_DST,
340 FLOW_KEY_IIF,
341 FLOW_KEY_PRIORITY,
342 FLOW_KEY_MARK,
343 FLOW_KEY_NFCT,
344 FLOW_KEY_NFCT_SRC,
345 FLOW_KEY_NFCT_DST,
346 FLOW_KEY_NFCT_PROTO_SRC,
347 FLOW_KEY_NFCT_PROTO_DST,
348 FLOW_KEY_RTCLASSID,
349 FLOW_KEY_SKUID,
350 FLOW_KEY_SKGID,
351 __FLOW_KEY_MAX,
352};
353
354#define FLOW_KEY_MAX (__FLOW_KEY_MAX - 1)
355
356enum
357{
358 FLOW_MODE_MAP,
359 FLOW_MODE_HASH,
360};
361
362enum
363{
364 TCA_FLOW_UNSPEC,
365 TCA_FLOW_KEYS,
366 TCA_FLOW_MODE,
367 TCA_FLOW_BASECLASS,
368 TCA_FLOW_RSHIFT,
369 TCA_FLOW_ADDEND,
370 TCA_FLOW_MASK,
371 TCA_FLOW_XOR,
372 TCA_FLOW_DIVISOR,
373 TCA_FLOW_ACT,
374 TCA_FLOW_POLICE,
375 TCA_FLOW_EMATCHES,
376 __TCA_FLOW_MAX
377};
378
379#define TCA_FLOW_MAX (__TCA_FLOW_MAX - 1)
380
331/* Basic filter */ 381/* Basic filter */
332 382
333enum 383enum
diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index 919af93b7059..dbb7ac37960d 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -83,6 +83,8 @@ struct tc_ratespec
83 __u32 rate; 83 __u32 rate;
84}; 84};
85 85
86#define TC_RTAB_SIZE 1024
87
86/* FIFO section */ 88/* FIFO section */
87 89
88struct tc_fifo_qopt 90struct tc_fifo_qopt
@@ -148,6 +150,11 @@ struct tc_sfq_qopt
148 unsigned flows; /* Maximal number of flows */ 150 unsigned flows; /* Maximal number of flows */
149}; 151};
150 152
153struct tc_sfq_xstats
154{
155 __s32 allot;
156};
157
151/* 158/*
152 * NOTE: limit, divisor and flows are hardwired to code at the moment. 159 * NOTE: limit, divisor and flows are hardwired to code at the moment.
153 * 160 *
diff --git a/include/linux/pktcdvd.h b/include/linux/pktcdvd.h
index 5ea4f05683f6..04b4d7330e6d 100644
--- a/include/linux/pktcdvd.h
+++ b/include/linux/pktcdvd.h
@@ -290,7 +290,7 @@ struct pktcdvd_device
290 int write_congestion_off; 290 int write_congestion_off;
291 int write_congestion_on; 291 int write_congestion_on;
292 292
293 struct class_device *clsdev; /* sysfs pktcdvd[0-7] class dev */ 293 struct device *dev; /* sysfs pktcdvd[0-7] dev */
294 struct pktcdvd_kobj *kobj_stat; /* sysfs pktcdvd[0-7]/stat/ */ 294 struct pktcdvd_kobj *kobj_stat; /* sysfs pktcdvd[0-7]/stat/ */
295 struct pktcdvd_kobj *kobj_wqueue; /* sysfs pktcdvd[0-7]/write_queue/ */ 295 struct pktcdvd_kobj *kobj_wqueue; /* sysfs pktcdvd[0-7]/write_queue/ */
296 296
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index e80804316cdb..3261681c82a4 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -35,7 +35,7 @@ extern struct resource *platform_get_resource_byname(struct platform_device *, u
35extern int platform_get_irq_byname(struct platform_device *, char *); 35extern int platform_get_irq_byname(struct platform_device *, char *);
36extern int platform_add_devices(struct platform_device **, int); 36extern int platform_add_devices(struct platform_device **, int);
37 37
38extern struct platform_device *platform_device_register_simple(char *, int id, 38extern struct platform_device *platform_device_register_simple(const char *, int id,
39 struct resource *, unsigned int); 39 struct resource *, unsigned int);
40 40
41extern struct platform_device *platform_device_alloc(const char *name, int id); 41extern struct platform_device *platform_device_alloc(const char *name, int id);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 09a309b7b5d2..b78e0295adf4 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -246,6 +246,15 @@ static inline int call_platform_enable_wakeup(struct device *dev, int is_on)
246 device_set_wakeup_enable(dev,val); \ 246 device_set_wakeup_enable(dev,val); \
247 } while(0) 247 } while(0)
248 248
249/*
250 * Global Power Management flags
251 * Used to keep APM and ACPI from both being active
252 */
253extern unsigned int pm_flags;
254
255#define PM_APM 1
256#define PM_ACPI 2
257
249#endif /* __KERNEL__ */ 258#endif /* __KERNEL__ */
250 259
251#endif /* _LINUX_PM_H */ 260#endif /* _LINUX_PM_H */
diff --git a/include/linux/pm_legacy.h b/include/linux/pm_legacy.h
index 514729a44688..446f4f42b952 100644
--- a/include/linux/pm_legacy.h
+++ b/include/linux/pm_legacy.h
@@ -4,10 +4,6 @@
4 4
5#ifdef CONFIG_PM_LEGACY 5#ifdef CONFIG_PM_LEGACY
6 6
7extern int pm_active;
8
9#define PM_IS_ACTIVE() (pm_active != 0)
10
11/* 7/*
12 * Register a device with power management 8 * Register a device with power management
13 */ 9 */
@@ -21,8 +17,6 @@ int __deprecated pm_send_all(pm_request_t rqst, void *data);
21 17
22#else /* CONFIG_PM_LEGACY */ 18#else /* CONFIG_PM_LEGACY */
23 19
24#define PM_IS_ACTIVE() 0
25
26static inline struct pm_dev *pm_register(pm_dev_t type, 20static inline struct pm_dev *pm_register(pm_dev_t type,
27 unsigned long id, 21 unsigned long id,
28 pm_callback callback) 22 pm_callback callback)
diff --git a/include/linux/pmu.h b/include/linux/pmu.h
index b7824c215354..4c5f65392d36 100644
--- a/include/linux/pmu.h
+++ b/include/linux/pmu.h
@@ -159,41 +159,7 @@ extern void pmu_unlock(void);
159extern int pmu_present(void); 159extern int pmu_present(void);
160extern int pmu_get_model(void); 160extern int pmu_get_model(void);
161 161
162#ifdef CONFIG_PM 162extern void pmu_backlight_set_sleep(int sleep);
163/*
164 * Stuff for putting the powerbook to sleep and waking it again.
165 *
166 */
167#include <linux/list.h>
168
169struct pmu_sleep_notifier
170{
171 void (*notifier_call)(struct pmu_sleep_notifier *self, int when);
172 int priority;
173 struct list_head list;
174};
175
176/* Code values for calling sleep/wakeup handlers
177 */
178#define PBOOK_SLEEP_REQUEST 1
179#define PBOOK_SLEEP_NOW 2
180#define PBOOK_WAKE 3
181
182/* priority levels in notifiers */
183#define SLEEP_LEVEL_VIDEO 100 /* Video driver (first wake) */
184#define SLEEP_LEVEL_MEDIABAY 90 /* Media bay driver */
185#define SLEEP_LEVEL_BLOCK 80 /* IDE, SCSI */
186#define SLEEP_LEVEL_NET 70 /* bmac, gmac */
187#define SLEEP_LEVEL_MISC 60 /* Anything else */
188#define SLEEP_LEVEL_USERLAND 55 /* Reserved for apm_emu */
189#define SLEEP_LEVEL_ADB 50 /* ADB (async) */
190#define SLEEP_LEVEL_SOUND 40 /* Sound driver (blocking) */
191
192/* special register notifier functions */
193int pmu_register_sleep_notifier(struct pmu_sleep_notifier* notifier);
194int pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* notifier);
195
196#endif /* CONFIG_PM */
197 163
198#define PMU_MAX_BATTERIES 2 164#define PMU_MAX_BATTERIES 2
199 165
diff --git a/include/linux/pnp.h b/include/linux/pnp.h
index 664d68cb1fbd..2a6d62c7d2d1 100644
--- a/include/linux/pnp.h
+++ b/include/linux/pnp.h
@@ -13,8 +13,8 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/mod_devicetable.h> 14#include <linux/mod_devicetable.h>
15 15
16#define PNP_MAX_PORT 8 16#define PNP_MAX_PORT 40
17#define PNP_MAX_MEM 4 17#define PNP_MAX_MEM 12
18#define PNP_MAX_IRQ 2 18#define PNP_MAX_IRQ 2
19#define PNP_MAX_DMA 2 19#define PNP_MAX_DMA 2
20#define PNP_NAME_LEN 50 20#define PNP_NAME_LEN 50
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 606c0957997f..5cbf3e371012 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -54,15 +54,7 @@ enum {
54 POWER_SUPPLY_TECHNOLOGY_LIPO, 54 POWER_SUPPLY_TECHNOLOGY_LIPO,
55 POWER_SUPPLY_TECHNOLOGY_LiFe, 55 POWER_SUPPLY_TECHNOLOGY_LiFe,
56 POWER_SUPPLY_TECHNOLOGY_NiCd, 56 POWER_SUPPLY_TECHNOLOGY_NiCd,
57}; 57 POWER_SUPPLY_TECHNOLOGY_LiMn,
58
59enum {
60 POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN = 0,
61 POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL,
62 POWER_SUPPLY_CAPACITY_LEVEL_LOW,
63 POWER_SUPPLY_CAPACITY_LEVEL_NORMAL,
64 POWER_SUPPLY_CAPACITY_LEVEL_HIGH,
65 POWER_SUPPLY_CAPACITY_LEVEL_FULL,
66}; 58};
67 59
68enum power_supply_property { 60enum power_supply_property {
@@ -72,6 +64,8 @@ enum power_supply_property {
72 POWER_SUPPLY_PROP_PRESENT, 64 POWER_SUPPLY_PROP_PRESENT,
73 POWER_SUPPLY_PROP_ONLINE, 65 POWER_SUPPLY_PROP_ONLINE,
74 POWER_SUPPLY_PROP_TECHNOLOGY, 66 POWER_SUPPLY_PROP_TECHNOLOGY,
67 POWER_SUPPLY_PROP_VOLTAGE_MAX,
68 POWER_SUPPLY_PROP_VOLTAGE_MIN,
75 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, 69 POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
76 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 70 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
77 POWER_SUPPLY_PROP_VOLTAGE_NOW, 71 POWER_SUPPLY_PROP_VOLTAGE_NOW,
@@ -91,7 +85,6 @@ enum power_supply_property {
91 POWER_SUPPLY_PROP_ENERGY_NOW, 85 POWER_SUPPLY_PROP_ENERGY_NOW,
92 POWER_SUPPLY_PROP_ENERGY_AVG, 86 POWER_SUPPLY_PROP_ENERGY_AVG,
93 POWER_SUPPLY_PROP_CAPACITY, /* in percents! */ 87 POWER_SUPPLY_PROP_CAPACITY, /* in percents! */
94 POWER_SUPPLY_PROP_CAPACITY_LEVEL,
95 POWER_SUPPLY_PROP_TEMP, 88 POWER_SUPPLY_PROP_TEMP,
96 POWER_SUPPLY_PROP_TEMP_AMBIENT, 89 POWER_SUPPLY_PROP_TEMP_AMBIENT,
97 POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW, 90 POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 1ff461672060..8f92546b403d 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -48,6 +48,8 @@ typedef int (read_proc_t)(char *page, char **start, off_t off,
48typedef int (write_proc_t)(struct file *file, const char __user *buffer, 48typedef int (write_proc_t)(struct file *file, const char __user *buffer,
49 unsigned long count, void *data); 49 unsigned long count, void *data);
50typedef int (get_info_t)(char *, char **, off_t, int); 50typedef int (get_info_t)(char *, char **, off_t, int);
51typedef struct proc_dir_entry *(shadow_proc_t)(struct task_struct *task,
52 struct proc_dir_entry *pde);
51 53
52struct proc_dir_entry { 54struct proc_dir_entry {
53 unsigned int low_ino; 55 unsigned int low_ino;
@@ -75,10 +77,10 @@ struct proc_dir_entry {
75 read_proc_t *read_proc; 77 read_proc_t *read_proc;
76 write_proc_t *write_proc; 78 write_proc_t *write_proc;
77 atomic_t count; /* use count */ 79 atomic_t count; /* use count */
78 int deleted; /* delete flag */
79 int pde_users; /* number of callers into module in progress */ 80 int pde_users; /* number of callers into module in progress */
80 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */ 81 spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */
81 struct completion *pde_unload_completion; 82 struct completion *pde_unload_completion;
83 shadow_proc_t *shadow_proc;
82}; 84};
83 85
84struct kcore_list { 86struct kcore_list {
@@ -196,11 +198,11 @@ static inline struct proc_dir_entry *create_proc_info_entry(const char *name,
196 return res; 198 return res;
197} 199}
198 200
199extern struct proc_dir_entry *proc_net_create(struct net *net,
200 const char *name, mode_t mode, get_info_t *get_info);
201extern struct proc_dir_entry *proc_net_fops_create(struct net *net, 201extern struct proc_dir_entry *proc_net_fops_create(struct net *net,
202 const char *name, mode_t mode, const struct file_operations *fops); 202 const char *name, mode_t mode, const struct file_operations *fops);
203extern void proc_net_remove(struct net *net, const char *name); 203extern void proc_net_remove(struct net *net, const char *name);
204extern struct proc_dir_entry *proc_net_mkdir(struct net *net, const char *name,
205 struct proc_dir_entry *parent);
204 206
205#else 207#else
206 208
@@ -208,7 +210,6 @@ extern void proc_net_remove(struct net *net, const char *name);
208#define proc_bus NULL 210#define proc_bus NULL
209 211
210#define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; }) 212#define proc_net_fops_create(net, name, mode, fops) ({ (void)(mode), NULL; })
211#define proc_net_create(net, name, mode, info) ({ (void)(mode), NULL; })
212static inline void proc_net_remove(struct net *net, const char *name) {} 213static inline void proc_net_remove(struct net *net, const char *name) {}
213 214
214static inline void proc_flush_task(struct task_struct *task) 215static inline void proc_flush_task(struct task_struct *task)
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index ae8146abd746..515bff053de8 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -97,6 +97,7 @@ extern void __ptrace_link(struct task_struct *child,
97extern void __ptrace_unlink(struct task_struct *child); 97extern void __ptrace_unlink(struct task_struct *child);
98extern void ptrace_untrace(struct task_struct *child); 98extern void ptrace_untrace(struct task_struct *child);
99extern int ptrace_may_attach(struct task_struct *task); 99extern int ptrace_may_attach(struct task_struct *task);
100extern int __ptrace_may_attach(struct task_struct *task);
100 101
101static inline void ptrace_link(struct task_struct *child, 102static inline void ptrace_link(struct task_struct *child,
102 struct task_struct *new_parent) 103 struct task_struct *new_parent)
@@ -128,6 +129,81 @@ int generic_ptrace_pokedata(struct task_struct *tsk, long addr, long data);
128#define force_successful_syscall_return() do { } while (0) 129#define force_successful_syscall_return() do { } while (0)
129#endif 130#endif
130 131
132/*
133 * <asm/ptrace.h> should define the following things inside #ifdef __KERNEL__.
134 *
135 * These do-nothing inlines are used when the arch does not
136 * implement single-step. The kerneldoc comments are here
137 * to document the interface for all arch definitions.
138 */
139
140#ifndef arch_has_single_step
141/**
142 * arch_has_single_step - does this CPU support user-mode single-step?
143 *
144 * If this is defined, then there must be function declarations or
145 * inlines for user_enable_single_step() and user_disable_single_step().
146 * arch_has_single_step() should evaluate to nonzero iff the machine
147 * supports instruction single-step for user mode.
148 * It can be a constant or it can test a CPU feature bit.
149 */
150#define arch_has_single_step() (0)
151
152/**
153 * user_enable_single_step - single-step in user-mode task
154 * @task: either current or a task stopped in %TASK_TRACED
155 *
156 * This can only be called when arch_has_single_step() has returned nonzero.
157 * Set @task so that when it returns to user mode, it will trap after the
158 * next single instruction executes. If arch_has_block_step() is defined,
159 * this must clear the effects of user_enable_block_step() too.
160 */
161static inline void user_enable_single_step(struct task_struct *task)
162{
163 BUG(); /* This can never be called. */
164}
165
166/**
167 * user_disable_single_step - cancel user-mode single-step
168 * @task: either current or a task stopped in %TASK_TRACED
169 *
170 * Clear @task of the effects of user_enable_single_step() and
171 * user_enable_block_step(). This can be called whether or not either
172 * of those was ever called on @task, and even if arch_has_single_step()
173 * returned zero.
174 */
175static inline void user_disable_single_step(struct task_struct *task)
176{
177}
178#endif /* arch_has_single_step */
179
180#ifndef arch_has_block_step
181/**
182 * arch_has_block_step - does this CPU support user-mode block-step?
183 *
184 * If this is defined, then there must be a function declaration or inline
185 * for user_enable_block_step(), and arch_has_single_step() must be defined
186 * too. arch_has_block_step() should evaluate to nonzero iff the machine
187 * supports step-until-branch for user mode. It can be a constant or it
188 * can test a CPU feature bit.
189 */
190#define arch_has_block_step() (0)
191
192/**
193 * user_enable_block_step - step until branch in user-mode task
194 * @task: either current or a task stopped in %TASK_TRACED
195 *
196 * This can only be called when arch_has_block_step() has returned nonzero,
197 * and will never be called when single-instruction stepping is being used.
198 * Set @task so that when it returns to user mode, it will trap after the
199 * next branch or trap taken.
200 */
201static inline void user_enable_block_step(struct task_struct *task)
202{
203 BUG(); /* This can never be called. */
204}
205#endif /* arch_has_block_step */
206
131#endif 207#endif
132 208
133#endif 209#endif
diff --git a/include/linux/quicklist.h b/include/linux/quicklist.h
index 9371c6116df3..39b66713a0bb 100644
--- a/include/linux/quicklist.h
+++ b/include/linux/quicklist.h
@@ -56,14 +56,6 @@ static inline void __quicklist_free(int nr, void (*dtor)(void *), void *p,
56 struct page *page) 56 struct page *page)
57{ 57{
58 struct quicklist *q; 58 struct quicklist *q;
59 int nid = page_to_nid(page);
60
61 if (unlikely(nid != numa_node_id())) {
62 if (dtor)
63 dtor(p);
64 __free_page(page);
65 return;
66 }
67 59
68 q = &get_cpu_var(quicklist)[nr]; 60 q = &get_cpu_var(quicklist)[nr];
69 *(void **)p = q->page; 61 *(void **)p = q->page;
diff --git a/include/linux/rcuclassic.h b/include/linux/rcuclassic.h
new file mode 100644
index 000000000000..4d6624260b4c
--- /dev/null
+++ b/include/linux/rcuclassic.h
@@ -0,0 +1,164 @@
1/*
2 * Read-Copy Update mechanism for mutual exclusion (classic version)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright IBM Corporation, 2001
19 *
20 * Author: Dipankar Sarma <dipankar@in.ibm.com>
21 *
22 * Based on the original work by Paul McKenney <paulmck@us.ibm.com>
23 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
24 * Papers:
25 * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
26 * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
27 *
28 * For detailed explanation of Read-Copy Update mechanism see -
29 * Documentation/RCU
30 *
31 */
32
33#ifndef __LINUX_RCUCLASSIC_H
34#define __LINUX_RCUCLASSIC_H
35
36#ifdef __KERNEL__
37
38#include <linux/cache.h>
39#include <linux/spinlock.h>
40#include <linux/threads.h>
41#include <linux/percpu.h>
42#include <linux/cpumask.h>
43#include <linux/seqlock.h>
44
45
46/* Global control variables for rcupdate callback mechanism. */
47struct rcu_ctrlblk {
48 long cur; /* Current batch number. */
49 long completed; /* Number of the last completed batch */
50 int next_pending; /* Is the next batch already waiting? */
51
52 int signaled;
53
54 spinlock_t lock ____cacheline_internodealigned_in_smp;
55 cpumask_t cpumask; /* CPUs that need to switch in order */
56 /* for current batch to proceed. */
57} ____cacheline_internodealigned_in_smp;
58
59/* Is batch a before batch b ? */
60static inline int rcu_batch_before(long a, long b)
61{
62 return (a - b) < 0;
63}
64
65/* Is batch a after batch b ? */
66static inline int rcu_batch_after(long a, long b)
67{
68 return (a - b) > 0;
69}
70
71/*
72 * Per-CPU data for Read-Copy UPdate.
73 * nxtlist - new callbacks are added here
74 * curlist - current batch for which quiescent cycle started if any
75 */
76struct rcu_data {
77 /* 1) quiescent state handling : */
78 long quiescbatch; /* Batch # for grace period */
79 int passed_quiesc; /* User-mode/idle loop etc. */
80 int qs_pending; /* core waits for quiesc state */
81
82 /* 2) batch handling */
83 long batch; /* Batch # for current RCU batch */
84 struct rcu_head *nxtlist;
85 struct rcu_head **nxttail;
86 long qlen; /* # of queued callbacks */
87 struct rcu_head *curlist;
88 struct rcu_head **curtail;
89 struct rcu_head *donelist;
90 struct rcu_head **donetail;
91 long blimit; /* Upper limit on a processed batch */
92 int cpu;
93 struct rcu_head barrier;
94};
95
96DECLARE_PER_CPU(struct rcu_data, rcu_data);
97DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
98
99/*
100 * Increment the quiescent state counter.
101 * The counter is a bit degenerated: We do not need to know
102 * how many quiescent states passed, just if there was at least
103 * one since the start of the grace period. Thus just a flag.
104 */
105static inline void rcu_qsctr_inc(int cpu)
106{
107 struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
108 rdp->passed_quiesc = 1;
109}
110static inline void rcu_bh_qsctr_inc(int cpu)
111{
112 struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
113 rdp->passed_quiesc = 1;
114}
115
116extern int rcu_pending(int cpu);
117extern int rcu_needs_cpu(int cpu);
118
119#ifdef CONFIG_DEBUG_LOCK_ALLOC
120extern struct lockdep_map rcu_lock_map;
121# define rcu_read_acquire() \
122 lock_acquire(&rcu_lock_map, 0, 0, 2, 1, _THIS_IP_)
123# define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_)
124#else
125# define rcu_read_acquire() do { } while (0)
126# define rcu_read_release() do { } while (0)
127#endif
128
129#define __rcu_read_lock() \
130 do { \
131 preempt_disable(); \
132 __acquire(RCU); \
133 rcu_read_acquire(); \
134 } while (0)
135#define __rcu_read_unlock() \
136 do { \
137 rcu_read_release(); \
138 __release(RCU); \
139 preempt_enable(); \
140 } while (0)
141#define __rcu_read_lock_bh() \
142 do { \
143 local_bh_disable(); \
144 __acquire(RCU_BH); \
145 rcu_read_acquire(); \
146 } while (0)
147#define __rcu_read_unlock_bh() \
148 do { \
149 rcu_read_release(); \
150 __release(RCU_BH); \
151 local_bh_enable(); \
152 } while (0)
153
154#define __synchronize_sched() synchronize_rcu()
155
156extern void __rcu_init(void);
157extern void rcu_check_callbacks(int cpu, int user);
158extern void rcu_restart_cpu(int cpu);
159
160extern long rcu_batches_completed(void);
161extern long rcu_batches_completed_bh(void);
162
163#endif /* __KERNEL__ */
164#endif /* __LINUX_RCUCLASSIC_H */
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index cc24a01df940..d32c14de270e 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -15,7 +15,7 @@
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * 17 *
18 * Copyright (C) IBM Corporation, 2001 18 * Copyright IBM Corporation, 2001
19 * 19 *
20 * Author: Dipankar Sarma <dipankar@in.ibm.com> 20 * Author: Dipankar Sarma <dipankar@in.ibm.com>
21 * 21 *
@@ -53,96 +53,18 @@ struct rcu_head {
53 void (*func)(struct rcu_head *head); 53 void (*func)(struct rcu_head *head);
54}; 54};
55 55
56#ifdef CONFIG_CLASSIC_RCU
57#include <linux/rcuclassic.h>
58#else /* #ifdef CONFIG_CLASSIC_RCU */
59#include <linux/rcupreempt.h>
60#endif /* #else #ifdef CONFIG_CLASSIC_RCU */
61
56#define RCU_HEAD_INIT { .next = NULL, .func = NULL } 62#define RCU_HEAD_INIT { .next = NULL, .func = NULL }
57#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT 63#define RCU_HEAD(head) struct rcu_head head = RCU_HEAD_INIT
58#define INIT_RCU_HEAD(ptr) do { \ 64#define INIT_RCU_HEAD(ptr) do { \
59 (ptr)->next = NULL; (ptr)->func = NULL; \ 65 (ptr)->next = NULL; (ptr)->func = NULL; \
60} while (0) 66} while (0)
61 67
62
63
64/* Global control variables for rcupdate callback mechanism. */
65struct rcu_ctrlblk {
66 long cur; /* Current batch number. */
67 long completed; /* Number of the last completed batch */
68 int next_pending; /* Is the next batch already waiting? */
69
70 int signaled;
71
72 spinlock_t lock ____cacheline_internodealigned_in_smp;
73 cpumask_t cpumask; /* CPUs that need to switch in order */
74 /* for current batch to proceed. */
75} ____cacheline_internodealigned_in_smp;
76
77/* Is batch a before batch b ? */
78static inline int rcu_batch_before(long a, long b)
79{
80 return (a - b) < 0;
81}
82
83/* Is batch a after batch b ? */
84static inline int rcu_batch_after(long a, long b)
85{
86 return (a - b) > 0;
87}
88
89/*
90 * Per-CPU data for Read-Copy UPdate.
91 * nxtlist - new callbacks are added here
92 * curlist - current batch for which quiescent cycle started if any
93 */
94struct rcu_data {
95 /* 1) quiescent state handling : */
96 long quiescbatch; /* Batch # for grace period */
97 int passed_quiesc; /* User-mode/idle loop etc. */
98 int qs_pending; /* core waits for quiesc state */
99
100 /* 2) batch handling */
101 long batch; /* Batch # for current RCU batch */
102 struct rcu_head *nxtlist;
103 struct rcu_head **nxttail;
104 long qlen; /* # of queued callbacks */
105 struct rcu_head *curlist;
106 struct rcu_head **curtail;
107 struct rcu_head *donelist;
108 struct rcu_head **donetail;
109 long blimit; /* Upper limit on a processed batch */
110 int cpu;
111 struct rcu_head barrier;
112};
113
114DECLARE_PER_CPU(struct rcu_data, rcu_data);
115DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
116
117/*
118 * Increment the quiescent state counter.
119 * The counter is a bit degenerated: We do not need to know
120 * how many quiescent states passed, just if there was at least
121 * one since the start of the grace period. Thus just a flag.
122 */
123static inline void rcu_qsctr_inc(int cpu)
124{
125 struct rcu_data *rdp = &per_cpu(rcu_data, cpu);
126 rdp->passed_quiesc = 1;
127}
128static inline void rcu_bh_qsctr_inc(int cpu)
129{
130 struct rcu_data *rdp = &per_cpu(rcu_bh_data, cpu);
131 rdp->passed_quiesc = 1;
132}
133
134extern int rcu_pending(int cpu);
135extern int rcu_needs_cpu(int cpu);
136
137#ifdef CONFIG_DEBUG_LOCK_ALLOC
138extern struct lockdep_map rcu_lock_map;
139# define rcu_read_acquire() lock_acquire(&rcu_lock_map, 0, 0, 2, 1, _THIS_IP_)
140# define rcu_read_release() lock_release(&rcu_lock_map, 1, _THIS_IP_)
141#else
142# define rcu_read_acquire() do { } while (0)
143# define rcu_read_release() do { } while (0)
144#endif
145
146/** 68/**
147 * rcu_read_lock - mark the beginning of an RCU read-side critical section. 69 * rcu_read_lock - mark the beginning of an RCU read-side critical section.
148 * 70 *
@@ -172,24 +94,13 @@ extern struct lockdep_map rcu_lock_map;
172 * 94 *
173 * It is illegal to block while in an RCU read-side critical section. 95 * It is illegal to block while in an RCU read-side critical section.
174 */ 96 */
175#define rcu_read_lock() \ 97#define rcu_read_lock() __rcu_read_lock()
176 do { \
177 preempt_disable(); \
178 __acquire(RCU); \
179 rcu_read_acquire(); \
180 } while(0)
181 98
182/** 99/**
183 * rcu_read_unlock - marks the end of an RCU read-side critical section. 100 * rcu_read_unlock - marks the end of an RCU read-side critical section.
184 * 101 *
185 * See rcu_read_lock() for more information. 102 * See rcu_read_lock() for more information.
186 */ 103 */
187#define rcu_read_unlock() \
188 do { \
189 rcu_read_release(); \
190 __release(RCU); \
191 preempt_enable(); \
192 } while(0)
193 104
194/* 105/*
195 * So where is rcu_write_lock()? It does not exist, as there is no 106 * So where is rcu_write_lock()? It does not exist, as there is no
@@ -200,6 +111,7 @@ extern struct lockdep_map rcu_lock_map;
200 * used as well. RCU does not care how the writers keep out of each 111 * used as well. RCU does not care how the writers keep out of each
201 * others' way, as long as they do so. 112 * others' way, as long as they do so.
202 */ 113 */
114#define rcu_read_unlock() __rcu_read_unlock()
203 115
204/** 116/**
205 * rcu_read_lock_bh - mark the beginning of a softirq-only RCU critical section 117 * rcu_read_lock_bh - mark the beginning of a softirq-only RCU critical section
@@ -212,24 +124,14 @@ extern struct lockdep_map rcu_lock_map;
212 * can use just rcu_read_lock(). 124 * can use just rcu_read_lock().
213 * 125 *
214 */ 126 */
215#define rcu_read_lock_bh() \ 127#define rcu_read_lock_bh() __rcu_read_lock_bh()
216 do { \
217 local_bh_disable(); \
218 __acquire(RCU_BH); \
219 rcu_read_acquire(); \
220 } while(0)
221 128
222/* 129/*
223 * rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section 130 * rcu_read_unlock_bh - marks the end of a softirq-only RCU critical section
224 * 131 *
225 * See rcu_read_lock_bh() for more information. 132 * See rcu_read_lock_bh() for more information.
226 */ 133 */
227#define rcu_read_unlock_bh() \ 134#define rcu_read_unlock_bh() __rcu_read_unlock_bh()
228 do { \
229 rcu_read_release(); \
230 __release(RCU_BH); \
231 local_bh_enable(); \
232 } while(0)
233 135
234/* 136/*
235 * Prevent the compiler from merging or refetching accesses. The compiler 137 * Prevent the compiler from merging or refetching accesses. The compiler
@@ -293,21 +195,52 @@ extern struct lockdep_map rcu_lock_map;
293 * In "classic RCU", these two guarantees happen to be one and 195 * In "classic RCU", these two guarantees happen to be one and
294 * the same, but can differ in realtime RCU implementations. 196 * the same, but can differ in realtime RCU implementations.
295 */ 197 */
296#define synchronize_sched() synchronize_rcu() 198#define synchronize_sched() __synchronize_sched()
297 199
298extern void rcu_init(void); 200/**
299extern void rcu_check_callbacks(int cpu, int user); 201 * call_rcu - Queue an RCU callback for invocation after a grace period.
300extern void rcu_restart_cpu(int cpu); 202 * @head: structure to be used for queueing the RCU updates.
301extern long rcu_batches_completed(void); 203 * @func: actual update function to be invoked after the grace period
302extern long rcu_batches_completed_bh(void); 204 *
205 * The update function will be invoked some time after a full grace
206 * period elapses, in other words after all currently executing RCU
207 * read-side critical sections have completed. RCU read-side critical
208 * sections are delimited by rcu_read_lock() and rcu_read_unlock(),
209 * and may be nested.
210 */
211extern void call_rcu(struct rcu_head *head,
212 void (*func)(struct rcu_head *head));
303 213
304/* Exported interfaces */ 214/**
305extern void FASTCALL(call_rcu(struct rcu_head *head, 215 * call_rcu_bh - Queue an RCU for invocation after a quicker grace period.
306 void (*func)(struct rcu_head *head))); 216 * @head: structure to be used for queueing the RCU updates.
307extern void FASTCALL(call_rcu_bh(struct rcu_head *head, 217 * @func: actual update function to be invoked after the grace period
308 void (*func)(struct rcu_head *head))); 218 *
219 * The update function will be invoked some time after a full grace
220 * period elapses, in other words after all currently executing RCU
221 * read-side critical sections have completed. call_rcu_bh() assumes
222 * that the read-side critical sections end on completion of a softirq
223 * handler. This means that read-side critical sections in process
224 * context must not be interrupted by softirqs. This interface is to be
225 * used when most of the read-side critical sections are in softirq context.
226 * RCU read-side critical sections are delimited by :
227 * - rcu_read_lock() and rcu_read_unlock(), if in interrupt context.
228 * OR
229 * - rcu_read_lock_bh() and rcu_read_unlock_bh(), if in process context.
230 * These may be nested.
231 */
232extern void call_rcu_bh(struct rcu_head *head,
233 void (*func)(struct rcu_head *head));
234
235/* Exported common interfaces */
309extern void synchronize_rcu(void); 236extern void synchronize_rcu(void);
310extern void rcu_barrier(void); 237extern void rcu_barrier(void);
238extern long rcu_batches_completed(void);
239extern long rcu_batches_completed_bh(void);
240
241/* Internal to kernel */
242extern void rcu_init(void);
243extern int rcu_needs_cpu(int cpu);
311 244
312#endif /* __KERNEL__ */ 245#endif /* __KERNEL__ */
313#endif /* __LINUX_RCUPDATE_H */ 246#endif /* __LINUX_RCUPDATE_H */
diff --git a/include/linux/rcupreempt.h b/include/linux/rcupreempt.h
new file mode 100644
index 000000000000..ece8eb3e4151
--- /dev/null
+++ b/include/linux/rcupreempt.h
@@ -0,0 +1,86 @@
1/*
2 * Read-Copy Update mechanism for mutual exclusion (RT implementation)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) IBM Corporation, 2006
19 *
20 * Author: Paul McKenney <paulmck@us.ibm.com>
21 *
22 * Based on the original work by Paul McKenney <paul.mckenney@us.ibm.com>
23 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
24 * Papers:
25 * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
26 * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
27 *
28 * For detailed explanation of Read-Copy Update mechanism see -
29 * Documentation/RCU
30 *
31 */
32
33#ifndef __LINUX_RCUPREEMPT_H
34#define __LINUX_RCUPREEMPT_H
35
36#ifdef __KERNEL__
37
38#include <linux/cache.h>
39#include <linux/spinlock.h>
40#include <linux/threads.h>
41#include <linux/percpu.h>
42#include <linux/cpumask.h>
43#include <linux/seqlock.h>
44
45#define rcu_qsctr_inc(cpu)
46#define rcu_bh_qsctr_inc(cpu)
47#define call_rcu_bh(head, rcu) call_rcu(head, rcu)
48
49extern void __rcu_read_lock(void);
50extern void __rcu_read_unlock(void);
51extern int rcu_pending(int cpu);
52extern int rcu_needs_cpu(int cpu);
53
54#define __rcu_read_lock_bh() { rcu_read_lock(); local_bh_disable(); }
55#define __rcu_read_unlock_bh() { local_bh_enable(); rcu_read_unlock(); }
56
57extern void __synchronize_sched(void);
58
59extern void __rcu_init(void);
60extern void rcu_check_callbacks(int cpu, int user);
61extern void rcu_restart_cpu(int cpu);
62extern long rcu_batches_completed(void);
63
64/*
65 * Return the number of RCU batches processed thus far. Useful for debug
66 * and statistic. The _bh variant is identifcal to straight RCU
67 */
68static inline long rcu_batches_completed_bh(void)
69{
70 return rcu_batches_completed();
71}
72
73#ifdef CONFIG_RCU_TRACE
74struct rcupreempt_trace;
75extern long *rcupreempt_flipctr(int cpu);
76extern long rcupreempt_data_completed(void);
77extern int rcupreempt_flip_flag(int cpu);
78extern int rcupreempt_mb_flag(int cpu);
79extern char *rcupreempt_try_flip_state_name(void);
80extern struct rcupreempt_trace *rcupreempt_trace_cpu(int cpu);
81#endif
82
83struct softirq_action;
84
85#endif /* __KERNEL__ */
86#endif /* __LINUX_RCUPREEMPT_H */
diff --git a/include/linux/rcupreempt_trace.h b/include/linux/rcupreempt_trace.h
new file mode 100644
index 000000000000..21cd6b2a5c42
--- /dev/null
+++ b/include/linux/rcupreempt_trace.h
@@ -0,0 +1,99 @@
1/*
2 * Read-Copy Update mechanism for mutual exclusion (RT implementation)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 * Copyright (C) IBM Corporation, 2006
19 *
20 * Author: Paul McKenney <paulmck@us.ibm.com>
21 *
22 * Based on the original work by Paul McKenney <paul.mckenney@us.ibm.com>
23 * and inputs from Rusty Russell, Andrea Arcangeli and Andi Kleen.
24 * Papers:
25 * http://www.rdrop.com/users/paulmck/paper/rclockpdcsproof.pdf
26 * http://lse.sourceforge.net/locking/rclock_OLS.2001.05.01c.sc.pdf (OLS2001)
27 *
28 * For detailed explanation of the Preemptible Read-Copy Update mechanism see -
29 * http://lwn.net/Articles/253651/
30 */
31
32#ifndef __LINUX_RCUPREEMPT_TRACE_H
33#define __LINUX_RCUPREEMPT_TRACE_H
34
35#ifdef __KERNEL__
36#include <linux/types.h>
37#include <linux/kernel.h>
38
39#include <asm/atomic.h>
40
41/*
42 * PREEMPT_RCU data structures.
43 */
44
45struct rcupreempt_trace {
46 long next_length;
47 long next_add;
48 long wait_length;
49 long wait_add;
50 long done_length;
51 long done_add;
52 long done_remove;
53 atomic_t done_invoked;
54 long rcu_check_callbacks;
55 atomic_t rcu_try_flip_1;
56 atomic_t rcu_try_flip_e1;
57 long rcu_try_flip_i1;
58 long rcu_try_flip_ie1;
59 long rcu_try_flip_g1;
60 long rcu_try_flip_a1;
61 long rcu_try_flip_ae1;
62 long rcu_try_flip_a2;
63 long rcu_try_flip_z1;
64 long rcu_try_flip_ze1;
65 long rcu_try_flip_z2;
66 long rcu_try_flip_m1;
67 long rcu_try_flip_me1;
68 long rcu_try_flip_m2;
69};
70
71#ifdef CONFIG_RCU_TRACE
72#define RCU_TRACE(fn, arg) fn(arg);
73#else
74#define RCU_TRACE(fn, arg)
75#endif
76
77extern void rcupreempt_trace_move2done(struct rcupreempt_trace *trace);
78extern void rcupreempt_trace_move2wait(struct rcupreempt_trace *trace);
79extern void rcupreempt_trace_try_flip_1(struct rcupreempt_trace *trace);
80extern void rcupreempt_trace_try_flip_e1(struct rcupreempt_trace *trace);
81extern void rcupreempt_trace_try_flip_i1(struct rcupreempt_trace *trace);
82extern void rcupreempt_trace_try_flip_ie1(struct rcupreempt_trace *trace);
83extern void rcupreempt_trace_try_flip_g1(struct rcupreempt_trace *trace);
84extern void rcupreempt_trace_try_flip_a1(struct rcupreempt_trace *trace);
85extern void rcupreempt_trace_try_flip_ae1(struct rcupreempt_trace *trace);
86extern void rcupreempt_trace_try_flip_a2(struct rcupreempt_trace *trace);
87extern void rcupreempt_trace_try_flip_z1(struct rcupreempt_trace *trace);
88extern void rcupreempt_trace_try_flip_ze1(struct rcupreempt_trace *trace);
89extern void rcupreempt_trace_try_flip_z2(struct rcupreempt_trace *trace);
90extern void rcupreempt_trace_try_flip_m1(struct rcupreempt_trace *trace);
91extern void rcupreempt_trace_try_flip_me1(struct rcupreempt_trace *trace);
92extern void rcupreempt_trace_try_flip_m2(struct rcupreempt_trace *trace);
93extern void rcupreempt_trace_check_callbacks(struct rcupreempt_trace *trace);
94extern void rcupreempt_trace_done_remove(struct rcupreempt_trace *trace);
95extern void rcupreempt_trace_invoke(struct rcupreempt_trace *trace);
96extern void rcupreempt_trace_next_add(struct rcupreempt_trace *trace);
97
98#endif /* __KERNEL__ */
99#endif /* __LINUX_RCUPREEMPT_TRACE_H */
diff --git a/include/linux/regset.h b/include/linux/regset.h
new file mode 100644
index 000000000000..8abee6556223
--- /dev/null
+++ b/include/linux/regset.h
@@ -0,0 +1,368 @@
1/*
2 * User-mode machine state access
3 *
4 * Copyright (C) 2007 Red Hat, Inc. All rights reserved.
5 *
6 * This copyrighted material is made available to anyone wishing to use,
7 * modify, copy, or redistribute it subject to the terms and conditions
8 * of the GNU General Public License v.2.
9 *
10 * Red Hat Author: Roland McGrath.
11 */
12
13#ifndef _LINUX_REGSET_H
14#define _LINUX_REGSET_H 1
15
16#include <linux/compiler.h>
17#include <linux/types.h>
18#include <linux/uaccess.h>
19struct task_struct;
20struct user_regset;
21
22
23/**
24 * user_regset_active_fn - type of @active function in &struct user_regset
25 * @target: thread being examined
26 * @regset: regset being examined
27 *
28 * Return -%ENODEV if not available on the hardware found.
29 * Return %0 if no interesting state in this thread.
30 * Return >%0 number of @size units of interesting state.
31 * Any get call fetching state beyond that number will
32 * see the default initialization state for this data,
33 * so a caller that knows what the default state is need
34 * not copy it all out.
35 * This call is optional; the pointer is %NULL if there
36 * is no inexpensive check to yield a value < @n.
37 */
38typedef int user_regset_active_fn(struct task_struct *target,
39 const struct user_regset *regset);
40
41/**
42 * user_regset_get_fn - type of @get function in &struct user_regset
43 * @target: thread being examined
44 * @regset: regset being examined
45 * @pos: offset into the regset data to access, in bytes
46 * @count: amount of data to copy, in bytes
47 * @kbuf: if not %NULL, a kernel-space pointer to copy into
48 * @ubuf: if @kbuf is %NULL, a user-space pointer to copy into
49 *
50 * Fetch register values. Return %0 on success; -%EIO or -%ENODEV
51 * are usual failure returns. The @pos and @count values are in
52 * bytes, but must be properly aligned. If @kbuf is non-null, that
53 * buffer is used and @ubuf is ignored. If @kbuf is %NULL, then
54 * ubuf gives a userland pointer to access directly, and an -%EFAULT
55 * return value is possible.
56 */
57typedef int user_regset_get_fn(struct task_struct *target,
58 const struct user_regset *regset,
59 unsigned int pos, unsigned int count,
60 void *kbuf, void __user *ubuf);
61
62/**
63 * user_regset_set_fn - type of @set function in &struct user_regset
64 * @target: thread being examined
65 * @regset: regset being examined
66 * @pos: offset into the regset data to access, in bytes
67 * @count: amount of data to copy, in bytes
68 * @kbuf: if not %NULL, a kernel-space pointer to copy from
69 * @ubuf: if @kbuf is %NULL, a user-space pointer to copy from
70 *
71 * Store register values. Return %0 on success; -%EIO or -%ENODEV
72 * are usual failure returns. The @pos and @count values are in
73 * bytes, but must be properly aligned. If @kbuf is non-null, that
74 * buffer is used and @ubuf is ignored. If @kbuf is %NULL, then
75 * ubuf gives a userland pointer to access directly, and an -%EFAULT
76 * return value is possible.
77 */
78typedef int user_regset_set_fn(struct task_struct *target,
79 const struct user_regset *regset,
80 unsigned int pos, unsigned int count,
81 const void *kbuf, const void __user *ubuf);
82
83/**
84 * user_regset_writeback_fn - type of @writeback function in &struct user_regset
85 * @target: thread being examined
86 * @regset: regset being examined
87 * @immediate: zero if writeback at completion of next context switch is OK
88 *
89 * This call is optional; usually the pointer is %NULL. When
90 * provided, there is some user memory associated with this regset's
91 * hardware, such as memory backing cached register data on register
92 * window machines; the regset's data controls what user memory is
93 * used (e.g. via the stack pointer value).
94 *
95 * Write register data back to user memory. If the @immediate flag
96 * is nonzero, it must be written to the user memory so uaccess or
97 * access_process_vm() can see it when this call returns; if zero,
98 * then it must be written back by the time the task completes a
99 * context switch (as synchronized with wait_task_inactive()).
100 * Return %0 on success or if there was nothing to do, -%EFAULT for
101 * a memory problem (bad stack pointer or whatever), or -%EIO for a
102 * hardware problem.
103 */
104typedef int user_regset_writeback_fn(struct task_struct *target,
105 const struct user_regset *regset,
106 int immediate);
107
108/**
109 * struct user_regset - accessible thread CPU state
110 * @n: Number of slots (registers).
111 * @size: Size in bytes of a slot (register).
112 * @align: Required alignment, in bytes.
113 * @bias: Bias from natural indexing.
114 * @core_note_type: ELF note @n_type value used in core dumps.
115 * @get: Function to fetch values.
116 * @set: Function to store values.
117 * @active: Function to report if regset is active, or %NULL.
118 * @writeback: Function to write data back to user memory, or %NULL.
119 *
120 * This data structure describes a machine resource we call a register set.
121 * This is part of the state of an individual thread, not necessarily
122 * actual CPU registers per se. A register set consists of a number of
123 * similar slots, given by @n. Each slot is @size bytes, and aligned to
124 * @align bytes (which is at least @size).
125 *
126 * These functions must be called only on the current thread or on a
127 * thread that is in %TASK_STOPPED or %TASK_TRACED state, that we are
128 * guaranteed will not be woken up and return to user mode, and that we
129 * have called wait_task_inactive() on. (The target thread always might
130 * wake up for SIGKILL while these functions are working, in which case
131 * that thread's user_regset state might be scrambled.)
132 *
133 * The @pos argument must be aligned according to @align; the @count
134 * argument must be a multiple of @size. These functions are not
135 * responsible for checking for invalid arguments.
136 *
137 * When there is a natural value to use as an index, @bias gives the
138 * difference between the natural index and the slot index for the
139 * register set. For example, x86 GDT segment descriptors form a regset;
140 * the segment selector produces a natural index, but only a subset of
141 * that index space is available as a regset (the TLS slots); subtracting
142 * @bias from a segment selector index value computes the regset slot.
143 *
144 * If nonzero, @core_note_type gives the n_type field (NT_* value)
145 * of the core file note in which this regset's data appears.
146 * NT_PRSTATUS is a special case in that the regset data starts at
147 * offsetof(struct elf_prstatus, pr_reg) into the note data; that is
148 * part of the per-machine ELF formats userland knows about. In
149 * other cases, the core file note contains exactly the whole regset
150 * (@n * @size) and nothing else. The core file note is normally
151 * omitted when there is an @active function and it returns zero.
152 */
153struct user_regset {
154 user_regset_get_fn *get;
155 user_regset_set_fn *set;
156 user_regset_active_fn *active;
157 user_regset_writeback_fn *writeback;
158 unsigned int n;
159 unsigned int size;
160 unsigned int align;
161 unsigned int bias;
162 unsigned int core_note_type;
163};
164
165/**
166 * struct user_regset_view - available regsets
167 * @name: Identifier, e.g. UTS_MACHINE string.
168 * @regsets: Array of @n regsets available in this view.
169 * @n: Number of elements in @regsets.
170 * @e_machine: ELF header @e_machine %EM_* value written in core dumps.
171 * @e_flags: ELF header @e_flags value written in core dumps.
172 * @ei_osabi: ELF header @e_ident[%EI_OSABI] value written in core dumps.
173 *
174 * A regset view is a collection of regsets (&struct user_regset,
175 * above). This describes all the state of a thread that can be seen
176 * from a given architecture/ABI environment. More than one view might
177 * refer to the same &struct user_regset, or more than one regset
178 * might refer to the same machine-specific state in the thread. For
179 * example, a 32-bit thread's state could be examined from the 32-bit
180 * view or from the 64-bit view. Either method reaches the same thread
181 * register state, doing appropriate widening or truncation.
182 */
183struct user_regset_view {
184 const char *name;
185 const struct user_regset *regsets;
186 unsigned int n;
187 u32 e_flags;
188 u16 e_machine;
189 u8 ei_osabi;
190};
191
192/*
193 * This is documented here rather than at the definition sites because its
194 * implementation is machine-dependent but its interface is universal.
195 */
196/**
197 * task_user_regset_view - Return the process's native regset view.
198 * @tsk: a thread of the process in question
199 *
200 * Return the &struct user_regset_view that is native for the given process.
201 * For example, what it would access when it called ptrace().
202 * Throughout the life of the process, this only changes at exec.
203 */
204const struct user_regset_view *task_user_regset_view(struct task_struct *tsk);
205
206
207/*
208 * These are helpers for writing regset get/set functions in arch code.
209 * Because @start_pos and @end_pos are always compile-time constants,
210 * these are inlined into very little code though they look large.
211 *
212 * Use one or more calls sequentially for each chunk of regset data stored
213 * contiguously in memory. Call with constants for @start_pos and @end_pos,
214 * giving the range of byte positions in the regset that data corresponds
215 * to; @end_pos can be -1 if this chunk is at the end of the regset layout.
216 * Each call updates the arguments to point past its chunk.
217 */
218
219static inline int user_regset_copyout(unsigned int *pos, unsigned int *count,
220 void **kbuf,
221 void __user **ubuf, const void *data,
222 const int start_pos, const int end_pos)
223{
224 if (*count == 0)
225 return 0;
226 BUG_ON(*pos < start_pos);
227 if (end_pos < 0 || *pos < end_pos) {
228 unsigned int copy = (end_pos < 0 ? *count
229 : min(*count, end_pos - *pos));
230 data += *pos - start_pos;
231 if (*kbuf) {
232 memcpy(*kbuf, data, copy);
233 *kbuf += copy;
234 } else if (__copy_to_user(*ubuf, data, copy))
235 return -EFAULT;
236 else
237 *ubuf += copy;
238 *pos += copy;
239 *count -= copy;
240 }
241 return 0;
242}
243
244static inline int user_regset_copyin(unsigned int *pos, unsigned int *count,
245 const void **kbuf,
246 const void __user **ubuf, void *data,
247 const int start_pos, const int end_pos)
248{
249 if (*count == 0)
250 return 0;
251 BUG_ON(*pos < start_pos);
252 if (end_pos < 0 || *pos < end_pos) {
253 unsigned int copy = (end_pos < 0 ? *count
254 : min(*count, end_pos - *pos));
255 data += *pos - start_pos;
256 if (*kbuf) {
257 memcpy(data, *kbuf, copy);
258 *kbuf += copy;
259 } else if (__copy_from_user(data, *ubuf, copy))
260 return -EFAULT;
261 else
262 *ubuf += copy;
263 *pos += copy;
264 *count -= copy;
265 }
266 return 0;
267}
268
269/*
270 * These two parallel the two above, but for portions of a regset layout
271 * that always read as all-zero or for which writes are ignored.
272 */
273static inline int user_regset_copyout_zero(unsigned int *pos,
274 unsigned int *count,
275 void **kbuf, void __user **ubuf,
276 const int start_pos,
277 const int end_pos)
278{
279 if (*count == 0)
280 return 0;
281 BUG_ON(*pos < start_pos);
282 if (end_pos < 0 || *pos < end_pos) {
283 unsigned int copy = (end_pos < 0 ? *count
284 : min(*count, end_pos - *pos));
285 if (*kbuf) {
286 memset(*kbuf, 0, copy);
287 *kbuf += copy;
288 } else if (__clear_user(*ubuf, copy))
289 return -EFAULT;
290 else
291 *ubuf += copy;
292 *pos += copy;
293 *count -= copy;
294 }
295 return 0;
296}
297
298static inline int user_regset_copyin_ignore(unsigned int *pos,
299 unsigned int *count,
300 const void **kbuf,
301 const void __user **ubuf,
302 const int start_pos,
303 const int end_pos)
304{
305 if (*count == 0)
306 return 0;
307 BUG_ON(*pos < start_pos);
308 if (end_pos < 0 || *pos < end_pos) {
309 unsigned int copy = (end_pos < 0 ? *count
310 : min(*count, end_pos - *pos));
311 if (*kbuf)
312 *kbuf += copy;
313 else
314 *ubuf += copy;
315 *pos += copy;
316 *count -= copy;
317 }
318 return 0;
319}
320
321/**
322 * copy_regset_to_user - fetch a thread's user_regset data into user memory
323 * @target: thread to be examined
324 * @view: &struct user_regset_view describing user thread machine state
325 * @setno: index in @view->regsets
326 * @offset: offset into the regset data, in bytes
327 * @size: amount of data to copy, in bytes
328 * @data: user-mode pointer to copy into
329 */
330static inline int copy_regset_to_user(struct task_struct *target,
331 const struct user_regset_view *view,
332 unsigned int setno,
333 unsigned int offset, unsigned int size,
334 void __user *data)
335{
336 const struct user_regset *regset = &view->regsets[setno];
337
338 if (!access_ok(VERIFY_WRITE, data, size))
339 return -EIO;
340
341 return regset->get(target, regset, offset, size, NULL, data);
342}
343
344/**
345 * copy_regset_from_user - store into thread's user_regset data from user memory
346 * @target: thread to be examined
347 * @view: &struct user_regset_view describing user thread machine state
348 * @setno: index in @view->regsets
349 * @offset: offset into the regset data, in bytes
350 * @size: amount of data to copy, in bytes
351 * @data: user-mode pointer to copy from
352 */
353static inline int copy_regset_from_user(struct task_struct *target,
354 const struct user_regset_view *view,
355 unsigned int setno,
356 unsigned int offset, unsigned int size,
357 const void __user *data)
358{
359 const struct user_regset *regset = &view->regsets[setno];
360
361 if (!access_ok(VERIFY_READ, data, size))
362 return -EIO;
363
364 return regset->set(target, regset, offset, size, NULL, data);
365}
366
367
368#endif /* <linux/regset.h> */
diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h
index 0ce5e0b52dbd..e3ab21d7fc7f 100644
--- a/include/linux/rfkill.h
+++ b/include/linux/rfkill.h
@@ -33,11 +33,13 @@
33 * RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device. 33 * RFKILL_TYPE_WLAN: switch is on a 802.11 wireless network device.
34 * RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device. 34 * RFKILL_TYPE_BLUETOOTH: switch is on a bluetooth device.
35 * RFKILL_TYPE_UWB: switch is on a ultra wideband device. 35 * RFKILL_TYPE_UWB: switch is on a ultra wideband device.
36 * RFKILL_TYPE_WIMAX: switch is on a WiMAX device.
36 */ 37 */
37enum rfkill_type { 38enum rfkill_type {
38 RFKILL_TYPE_WLAN , 39 RFKILL_TYPE_WLAN ,
39 RFKILL_TYPE_BLUETOOTH, 40 RFKILL_TYPE_BLUETOOTH,
40 RFKILL_TYPE_UWB, 41 RFKILL_TYPE_UWB,
42 RFKILL_TYPE_WIMAX,
41 RFKILL_TYPE_MAX, 43 RFKILL_TYPE_MAX,
42}; 44};
43 45
diff --git a/include/linux/rtc.h b/include/linux/rtc.h
index 6d5e4a46781e..f2d0d1527721 100644
--- a/include/linux/rtc.h
+++ b/include/linux/rtc.h
@@ -133,6 +133,9 @@ struct rtc_class_ops {
133#define RTC_DEVICE_NAME_SIZE 20 133#define RTC_DEVICE_NAME_SIZE 20
134struct rtc_task; 134struct rtc_task;
135 135
136/* flags */
137#define RTC_DEV_BUSY 0
138
136struct rtc_device 139struct rtc_device
137{ 140{
138 struct device dev; 141 struct device dev;
@@ -145,7 +148,7 @@ struct rtc_device
145 struct mutex ops_lock; 148 struct mutex ops_lock;
146 149
147 struct cdev char_dev; 150 struct cdev char_dev;
148 struct mutex char_lock; 151 unsigned long flags;
149 152
150 unsigned long irq_data; 153 unsigned long irq_data;
151 spinlock_t irq_lock; 154 spinlock_t irq_lock;
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 5bf618241ab9..b014f6b7fe29 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -100,6 +100,13 @@ enum {
100 RTM_NEWNDUSEROPT = 68, 100 RTM_NEWNDUSEROPT = 68,
101#define RTM_NEWNDUSEROPT RTM_NEWNDUSEROPT 101#define RTM_NEWNDUSEROPT RTM_NEWNDUSEROPT
102 102
103 RTM_NEWADDRLABEL = 72,
104#define RTM_NEWADDRLABEL RTM_NEWADDRLABEL
105 RTM_DELADDRLABEL,
106#define RTM_NEWADDRLABEL RTM_NEWADDRLABEL
107 RTM_GETADDRLABEL,
108#define RTM_GETADDRLABEL RTM_GETADDRLABEL
109
103 __RTM_MAX, 110 __RTM_MAX,
104#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1) 111#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
105}; 112};
@@ -491,9 +498,11 @@ struct nduseroptmsg
491 unsigned char nduseropt_family; 498 unsigned char nduseropt_family;
492 unsigned char nduseropt_pad1; 499 unsigned char nduseropt_pad1;
493 unsigned short nduseropt_opts_len; /* Total length of options */ 500 unsigned short nduseropt_opts_len; /* Total length of options */
501 int nduseropt_ifindex;
494 __u8 nduseropt_icmp_type; 502 __u8 nduseropt_icmp_type;
495 __u8 nduseropt_icmp_code; 503 __u8 nduseropt_icmp_code;
496 unsigned short nduseropt_pad2; 504 unsigned short nduseropt_pad2;
505 unsigned int nduseropt_pad3;
497 /* Followed by one or more ND options */ 506 /* Followed by one or more ND options */
498}; 507};
499 508
@@ -611,11 +620,11 @@ extern int __rtattr_parse_nested_compat(struct rtattr *tb[], int maxattr,
611({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \ 620({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL; \
612 __rtattr_parse_nested_compat(tb, max, rta, len); }) 621 __rtattr_parse_nested_compat(tb, max, rta, len); })
613 622
614extern int rtnetlink_send(struct sk_buff *skb, u32 pid, u32 group, int echo); 623extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
615extern int rtnl_unicast(struct sk_buff *skb, u32 pid); 624extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
616extern int rtnl_notify(struct sk_buff *skb, u32 pid, u32 group, 625extern int rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid, u32 group,
617 struct nlmsghdr *nlh, gfp_t flags); 626 struct nlmsghdr *nlh, gfp_t flags);
618extern void rtnl_set_sk_err(u32 group, int error); 627extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
619extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics); 628extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
620extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, 629extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
621 u32 id, u32 ts, u32 tsage, long expires, 630 u32 id, u32 ts, u32 tsage, long expires,
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index 457123171389..a3d567a974e8 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -7,6 +7,12 @@
7#include <linux/string.h> 7#include <linux/string.h>
8#include <asm/io.h> 8#include <asm/io.h>
9 9
10struct sg_table {
11 struct scatterlist *sgl; /* the list */
12 unsigned int nents; /* number of mapped entries */
13 unsigned int orig_nents; /* original size of list */
14};
15
10/* 16/*
11 * Notes on SG table design. 17 * Notes on SG table design.
12 * 18 *
@@ -26,6 +32,16 @@
26 32
27#define SG_MAGIC 0x87654321 33#define SG_MAGIC 0x87654321
28 34
35/*
36 * We overload the LSB of the page pointer to indicate whether it's
37 * a valid sg entry, or whether it points to the start of a new scatterlist.
38 * Those low bits are there for everyone! (thanks mason :-)
39 */
40#define sg_is_chain(sg) ((sg)->page_link & 0x01)
41#define sg_is_last(sg) ((sg)->page_link & 0x02)
42#define sg_chain_ptr(sg) \
43 ((struct scatterlist *) ((sg)->page_link & ~0x03))
44
29/** 45/**
30 * sg_assign_page - Assign a given page to an SG entry 46 * sg_assign_page - Assign a given page to an SG entry
31 * @sg: SG entry 47 * @sg: SG entry
@@ -47,6 +63,7 @@ static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
47 BUG_ON((unsigned long) page & 0x03); 63 BUG_ON((unsigned long) page & 0x03);
48#ifdef CONFIG_DEBUG_SG 64#ifdef CONFIG_DEBUG_SG
49 BUG_ON(sg->sg_magic != SG_MAGIC); 65 BUG_ON(sg->sg_magic != SG_MAGIC);
66 BUG_ON(sg_is_chain(sg));
50#endif 67#endif
51 sg->page_link = page_link | (unsigned long) page; 68 sg->page_link = page_link | (unsigned long) page;
52} 69}
@@ -73,7 +90,14 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page,
73 sg->length = len; 90 sg->length = len;
74} 91}
75 92
76#define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3)) 93static inline struct page *sg_page(struct scatterlist *sg)
94{
95#ifdef CONFIG_DEBUG_SG
96 BUG_ON(sg->sg_magic != SG_MAGIC);
97 BUG_ON(sg_is_chain(sg));
98#endif
99 return (struct page *)((sg)->page_link & ~0x3);
100}
77 101
78/** 102/**
79 * sg_set_buf - Set sg entry to point at given data 103 * sg_set_buf - Set sg entry to point at given data
@@ -89,81 +113,12 @@ static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
89} 113}
90 114
91/* 115/*
92 * We overload the LSB of the page pointer to indicate whether it's
93 * a valid sg entry, or whether it points to the start of a new scatterlist.
94 * Those low bits are there for everyone! (thanks mason :-)
95 */
96#define sg_is_chain(sg) ((sg)->page_link & 0x01)
97#define sg_is_last(sg) ((sg)->page_link & 0x02)
98#define sg_chain_ptr(sg) \
99 ((struct scatterlist *) ((sg)->page_link & ~0x03))
100
101/**
102 * sg_next - return the next scatterlist entry in a list
103 * @sg: The current sg entry
104 *
105 * Description:
106 * Usually the next entry will be @sg@ + 1, but if this sg element is part
107 * of a chained scatterlist, it could jump to the start of a new
108 * scatterlist array.
109 *
110 **/
111static inline struct scatterlist *sg_next(struct scatterlist *sg)
112{
113#ifdef CONFIG_DEBUG_SG
114 BUG_ON(sg->sg_magic != SG_MAGIC);
115#endif
116 if (sg_is_last(sg))
117 return NULL;
118
119 sg++;
120 if (unlikely(sg_is_chain(sg)))
121 sg = sg_chain_ptr(sg);
122
123 return sg;
124}
125
126/*
127 * Loop over each sg element, following the pointer to a new list if necessary 116 * Loop over each sg element, following the pointer to a new list if necessary
128 */ 117 */
129#define for_each_sg(sglist, sg, nr, __i) \ 118#define for_each_sg(sglist, sg, nr, __i) \
130 for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg)) 119 for (__i = 0, sg = (sglist); __i < (nr); __i++, sg = sg_next(sg))
131 120
132/** 121/**
133 * sg_last - return the last scatterlist entry in a list
134 * @sgl: First entry in the scatterlist
135 * @nents: Number of entries in the scatterlist
136 *
137 * Description:
138 * Should only be used casually, it (currently) scan the entire list
139 * to get the last entry.
140 *
141 * Note that the @sgl@ pointer passed in need not be the first one,
142 * the important bit is that @nents@ denotes the number of entries that
143 * exist from @sgl@.
144 *
145 **/
146static inline struct scatterlist *sg_last(struct scatterlist *sgl,
147 unsigned int nents)
148{
149#ifndef ARCH_HAS_SG_CHAIN
150 struct scatterlist *ret = &sgl[nents - 1];
151#else
152 struct scatterlist *sg, *ret = NULL;
153 int i;
154
155 for_each_sg(sgl, sg, nents, i)
156 ret = sg;
157
158#endif
159#ifdef CONFIG_DEBUG_SG
160 BUG_ON(sgl[0].sg_magic != SG_MAGIC);
161 BUG_ON(!sg_is_last(ret));
162#endif
163 return ret;
164}
165
166/**
167 * sg_chain - Chain two sglists together 122 * sg_chain - Chain two sglists together
168 * @prv: First scatterlist 123 * @prv: First scatterlist
169 * @prv_nents: Number of entries in prv 124 * @prv_nents: Number of entries in prv
@@ -179,71 +134,39 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents,
179#ifndef ARCH_HAS_SG_CHAIN 134#ifndef ARCH_HAS_SG_CHAIN
180 BUG(); 135 BUG();
181#endif 136#endif
182 prv[prv_nents - 1].page_link = (unsigned long) sgl | 0x01;
183}
184 137
185/** 138 /*
186 * sg_mark_end - Mark the end of the scatterlist 139 * offset and length are unused for chain entry. Clear them.
187 * @sgl: Scatterlist 140 */
188 * @nents: Number of entries in sgl 141 prv[prv_nents - 1].offset = 0;
189 * 142 prv[prv_nents - 1].length = 0;
190 * Description:
191 * Marks the last entry as the termination point for sg_next()
192 *
193 **/
194static inline void sg_mark_end(struct scatterlist *sgl, unsigned int nents)
195{
196 sgl[nents - 1].page_link = 0x02;
197}
198
199static inline void __sg_mark_end(struct scatterlist *sg)
200{
201 sg->page_link |= 0x02;
202}
203 143
204/** 144 /*
205 * sg_init_one - Initialize a single entry sg list 145 * Set lowest bit to indicate a link pointer, and make sure to clear
206 * @sg: SG entry 146 * the termination bit if it happens to be set.
207 * @buf: Virtual address for IO 147 */
208 * @buflen: IO length 148 prv[prv_nents - 1].page_link = ((unsigned long) sgl | 0x01) & ~0x02;
209 *
210 * Notes:
211 * This should not be used on a single entry that is part of a larger
212 * table. Use sg_init_table() for that.
213 *
214 **/
215static inline void sg_init_one(struct scatterlist *sg, const void *buf,
216 unsigned int buflen)
217{
218 memset(sg, 0, sizeof(*sg));
219#ifdef CONFIG_DEBUG_SG
220 sg->sg_magic = SG_MAGIC;
221#endif
222 sg_mark_end(sg, 1);
223 sg_set_buf(sg, buf, buflen);
224} 149}
225 150
226/** 151/**
227 * sg_init_table - Initialize SG table 152 * sg_mark_end - Mark the end of the scatterlist
228 * @sgl: The SG table 153 * @sg: SG entryScatterlist
229 * @nents: Number of entries in table
230 * 154 *
231 * Notes: 155 * Description:
232 * If this is part of a chained sg table, sg_mark_end() should be 156 * Marks the passed in sg entry as the termination point for the sg
233 * used only on the last table part. 157 * table. A call to sg_next() on this entry will return NULL.
234 * 158 *
235 **/ 159 **/
236static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) 160static inline void sg_mark_end(struct scatterlist *sg)
237{ 161{
238 memset(sgl, 0, sizeof(*sgl) * nents);
239 sg_mark_end(sgl, nents);
240#ifdef CONFIG_DEBUG_SG 162#ifdef CONFIG_DEBUG_SG
241 { 163 BUG_ON(sg->sg_magic != SG_MAGIC);
242 int i;
243 for (i = 0; i < nents; i++)
244 sgl[i].sg_magic = SG_MAGIC;
245 }
246#endif 164#endif
165 /*
166 * Set termination bit, clear potential chain bit
167 */
168 sg->page_link |= 0x02;
169 sg->page_link &= ~0x01;
247} 170}
248 171
249/** 172/**
@@ -276,4 +199,24 @@ static inline void *sg_virt(struct scatterlist *sg)
276 return page_address(sg_page(sg)) + sg->offset; 199 return page_address(sg_page(sg)) + sg->offset;
277} 200}
278 201
202struct scatterlist *sg_next(struct scatterlist *);
203struct scatterlist *sg_last(struct scatterlist *s, unsigned int);
204void sg_init_table(struct scatterlist *, unsigned int);
205void sg_init_one(struct scatterlist *, const void *, unsigned int);
206
207typedef struct scatterlist *(sg_alloc_fn)(unsigned int, gfp_t);
208typedef void (sg_free_fn)(struct scatterlist *, unsigned int);
209
210void __sg_free_table(struct sg_table *, unsigned int, sg_free_fn *);
211void sg_free_table(struct sg_table *);
212int __sg_alloc_table(struct sg_table *, unsigned int, unsigned int, gfp_t,
213 sg_alloc_fn *);
214int sg_alloc_table(struct sg_table *, unsigned int, gfp_t);
215
216/*
217 * Maximum number of entries that will be allocated in one piece, if
218 * a list larger than this is required then chaining will be utilized.
219 */
220#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist))
221
279#endif /* _LINUX_SCATTERLIST_H */ 222#endif /* _LINUX_SCATTERLIST_H */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3c07d595979f..af6947e69b40 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -27,6 +27,7 @@
27#define CLONE_NEWUSER 0x10000000 /* New user namespace */ 27#define CLONE_NEWUSER 0x10000000 /* New user namespace */
28#define CLONE_NEWPID 0x20000000 /* New pid namespace */ 28#define CLONE_NEWPID 0x20000000 /* New pid namespace */
29#define CLONE_NEWNET 0x40000000 /* New network namespace */ 29#define CLONE_NEWNET 0x40000000 /* New network namespace */
30#define CLONE_IO 0x80000000 /* Clone io context */
30 31
31/* 32/*
32 * Scheduling policies 33 * Scheduling policies
@@ -78,7 +79,6 @@ struct sched_param {
78#include <linux/proportions.h> 79#include <linux/proportions.h>
79#include <linux/seccomp.h> 80#include <linux/seccomp.h>
80#include <linux/rcupdate.h> 81#include <linux/rcupdate.h>
81#include <linux/futex.h>
82#include <linux/rtmutex.h> 82#include <linux/rtmutex.h>
83 83
84#include <linux/time.h> 84#include <linux/time.h>
@@ -88,11 +88,13 @@ struct sched_param {
88#include <linux/hrtimer.h> 88#include <linux/hrtimer.h>
89#include <linux/task_io_accounting.h> 89#include <linux/task_io_accounting.h>
90#include <linux/kobject.h> 90#include <linux/kobject.h>
91#include <linux/latencytop.h>
91 92
92#include <asm/processor.h> 93#include <asm/processor.h>
93 94
94struct exec_domain; 95struct exec_domain;
95struct futex_pi_state; 96struct futex_pi_state;
97struct robust_list_head;
96struct bio; 98struct bio;
97 99
98/* 100/*
@@ -170,13 +172,35 @@ print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq)
170#define TASK_RUNNING 0 172#define TASK_RUNNING 0
171#define TASK_INTERRUPTIBLE 1 173#define TASK_INTERRUPTIBLE 1
172#define TASK_UNINTERRUPTIBLE 2 174#define TASK_UNINTERRUPTIBLE 2
173#define TASK_STOPPED 4 175#define __TASK_STOPPED 4
174#define TASK_TRACED 8 176#define __TASK_TRACED 8
175/* in tsk->exit_state */ 177/* in tsk->exit_state */
176#define EXIT_ZOMBIE 16 178#define EXIT_ZOMBIE 16
177#define EXIT_DEAD 32 179#define EXIT_DEAD 32
178/* in tsk->state again */ 180/* in tsk->state again */
179#define TASK_DEAD 64 181#define TASK_DEAD 64
182#define TASK_WAKEKILL 128
183
184/* Convenience macros for the sake of set_task_state */
185#define TASK_KILLABLE (TASK_WAKEKILL | TASK_UNINTERRUPTIBLE)
186#define TASK_STOPPED (TASK_WAKEKILL | __TASK_STOPPED)
187#define TASK_TRACED (TASK_WAKEKILL | __TASK_TRACED)
188
189/* Convenience macros for the sake of wake_up */
190#define TASK_NORMAL (TASK_INTERRUPTIBLE | TASK_UNINTERRUPTIBLE)
191#define TASK_ALL (TASK_NORMAL | __TASK_STOPPED | __TASK_TRACED)
192
193/* get_task_state() */
194#define TASK_REPORT (TASK_RUNNING | TASK_INTERRUPTIBLE | \
195 TASK_UNINTERRUPTIBLE | __TASK_STOPPED | \
196 __TASK_TRACED)
197
198#define task_is_traced(task) ((task->state & __TASK_TRACED) != 0)
199#define task_is_stopped(task) ((task->state & __TASK_STOPPED) != 0)
200#define task_is_stopped_or_traced(task) \
201 ((task->state & (__TASK_STOPPED | __TASK_TRACED)) != 0)
202#define task_contributes_to_load(task) \
203 ((task->state & TASK_UNINTERRUPTIBLE) != 0)
180 204
181#define __set_task_state(tsk, state_value) \ 205#define __set_task_state(tsk, state_value) \
182 do { (tsk)->state = (state_value); } while (0) 206 do { (tsk)->state = (state_value); } while (0)
@@ -230,6 +254,8 @@ static inline int select_nohz_load_balancer(int cpu)
230} 254}
231#endif 255#endif
232 256
257extern unsigned long rt_needs_cpu(int cpu);
258
233/* 259/*
234 * Only dump TASK_* tasks. (0 for all tasks) 260 * Only dump TASK_* tasks. (0 for all tasks)
235 */ 261 */
@@ -254,15 +280,22 @@ long io_schedule_timeout(long timeout);
254 280
255extern void cpu_init (void); 281extern void cpu_init (void);
256extern void trap_init(void); 282extern void trap_init(void);
283extern void account_process_tick(struct task_struct *task, int user);
257extern void update_process_times(int user); 284extern void update_process_times(int user);
258extern void scheduler_tick(void); 285extern void scheduler_tick(void);
286extern void hrtick_resched(void);
287
288extern void sched_show_task(struct task_struct *p);
259 289
260#ifdef CONFIG_DETECT_SOFTLOCKUP 290#ifdef CONFIG_DETECT_SOFTLOCKUP
261extern void softlockup_tick(void); 291extern void softlockup_tick(void);
262extern void spawn_softlockup_task(void); 292extern void spawn_softlockup_task(void);
263extern void touch_softlockup_watchdog(void); 293extern void touch_softlockup_watchdog(void);
264extern void touch_all_softlockup_watchdogs(void); 294extern void touch_all_softlockup_watchdogs(void);
265extern int softlockup_thresh; 295extern unsigned long softlockup_thresh;
296extern unsigned long sysctl_hung_task_check_count;
297extern unsigned long sysctl_hung_task_timeout_secs;
298extern unsigned long sysctl_hung_task_warnings;
266#else 299#else
267static inline void softlockup_tick(void) 300static inline void softlockup_tick(void)
268{ 301{
@@ -281,12 +314,17 @@ static inline void touch_all_softlockup_watchdogs(void)
281 314
282/* Attach to any functions which should be ignored in wchan output. */ 315/* Attach to any functions which should be ignored in wchan output. */
283#define __sched __attribute__((__section__(".sched.text"))) 316#define __sched __attribute__((__section__(".sched.text")))
317
318/* Linker adds these: start and end of __sched functions */
319extern char __sched_text_start[], __sched_text_end[];
320
284/* Is this address in the __sched functions? */ 321/* Is this address in the __sched functions? */
285extern int in_sched_functions(unsigned long addr); 322extern int in_sched_functions(unsigned long addr);
286 323
287#define MAX_SCHEDULE_TIMEOUT LONG_MAX 324#define MAX_SCHEDULE_TIMEOUT LONG_MAX
288extern signed long FASTCALL(schedule_timeout(signed long timeout)); 325extern signed long FASTCALL(schedule_timeout(signed long timeout));
289extern signed long schedule_timeout_interruptible(signed long timeout); 326extern signed long schedule_timeout_interruptible(signed long timeout);
327extern signed long schedule_timeout_killable(signed long timeout);
290extern signed long schedule_timeout_uninterruptible(signed long timeout); 328extern signed long schedule_timeout_uninterruptible(signed long timeout);
291asmlinkage void schedule(void); 329asmlinkage void schedule(void);
292 330
@@ -547,18 +585,13 @@ struct user_struct {
547#ifdef CONFIG_FAIR_USER_SCHED 585#ifdef CONFIG_FAIR_USER_SCHED
548 struct task_group *tg; 586 struct task_group *tg;
549#ifdef CONFIG_SYSFS 587#ifdef CONFIG_SYSFS
550 struct kset kset; 588 struct kobject kobj;
551 struct subsys_attribute user_attr;
552 struct work_struct work; 589 struct work_struct work;
553#endif 590#endif
554#endif 591#endif
555}; 592};
556 593
557#ifdef CONFIG_FAIR_USER_SCHED 594extern int uids_sysfs_init(void);
558extern int uids_kobject_init(void);
559#else
560static inline int uids_kobject_init(void) { return 0; }
561#endif
562 595
563extern struct user_struct *find_user(uid_t); 596extern struct user_struct *find_user(uid_t);
564 597
@@ -822,6 +855,7 @@ struct sched_class {
822 void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup); 855 void (*enqueue_task) (struct rq *rq, struct task_struct *p, int wakeup);
823 void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep); 856 void (*dequeue_task) (struct rq *rq, struct task_struct *p, int sleep);
824 void (*yield_task) (struct rq *rq); 857 void (*yield_task) (struct rq *rq);
858 int (*select_task_rq)(struct task_struct *p, int sync);
825 859
826 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p); 860 void (*check_preempt_curr) (struct rq *rq, struct task_struct *p);
827 861
@@ -837,11 +871,25 @@ struct sched_class {
837 int (*move_one_task) (struct rq *this_rq, int this_cpu, 871 int (*move_one_task) (struct rq *this_rq, int this_cpu,
838 struct rq *busiest, struct sched_domain *sd, 872 struct rq *busiest, struct sched_domain *sd,
839 enum cpu_idle_type idle); 873 enum cpu_idle_type idle);
874 void (*pre_schedule) (struct rq *this_rq, struct task_struct *task);
875 void (*post_schedule) (struct rq *this_rq);
876 void (*task_wake_up) (struct rq *this_rq, struct task_struct *task);
840#endif 877#endif
841 878
842 void (*set_curr_task) (struct rq *rq); 879 void (*set_curr_task) (struct rq *rq);
843 void (*task_tick) (struct rq *rq, struct task_struct *p); 880 void (*task_tick) (struct rq *rq, struct task_struct *p, int queued);
844 void (*task_new) (struct rq *rq, struct task_struct *p); 881 void (*task_new) (struct rq *rq, struct task_struct *p);
882 void (*set_cpus_allowed)(struct task_struct *p, cpumask_t *newmask);
883
884 void (*join_domain)(struct rq *rq);
885 void (*leave_domain)(struct rq *rq);
886
887 void (*switched_from) (struct rq *this_rq, struct task_struct *task,
888 int running);
889 void (*switched_to) (struct rq *this_rq, struct task_struct *task,
890 int running);
891 void (*prio_changed) (struct rq *this_rq, struct task_struct *task,
892 int oldprio, int running);
845}; 893};
846 894
847struct load_weight { 895struct load_weight {
@@ -862,7 +910,6 @@ struct sched_entity {
862 struct load_weight load; /* for load-balancing */ 910 struct load_weight load; /* for load-balancing */
863 struct rb_node run_node; 911 struct rb_node run_node;
864 unsigned int on_rq; 912 unsigned int on_rq;
865 int peer_preempt;
866 913
867 u64 exec_start; 914 u64 exec_start;
868 u64 sum_exec_runtime; 915 u64 sum_exec_runtime;
@@ -872,6 +919,8 @@ struct sched_entity {
872#ifdef CONFIG_SCHEDSTATS 919#ifdef CONFIG_SCHEDSTATS
873 u64 wait_start; 920 u64 wait_start;
874 u64 wait_max; 921 u64 wait_max;
922 u64 wait_count;
923 u64 wait_sum;
875 924
876 u64 sleep_start; 925 u64 sleep_start;
877 u64 sleep_max; 926 u64 sleep_max;
@@ -910,6 +959,21 @@ struct sched_entity {
910#endif 959#endif
911}; 960};
912 961
962struct sched_rt_entity {
963 struct list_head run_list;
964 unsigned int time_slice;
965 unsigned long timeout;
966 int nr_cpus_allowed;
967
968#ifdef CONFIG_FAIR_GROUP_SCHED
969 struct sched_rt_entity *parent;
970 /* rq on which this entity is (to be) queued: */
971 struct rt_rq *rt_rq;
972 /* rq "owned" by this entity/group: */
973 struct rt_rq *my_q;
974#endif
975};
976
913struct task_struct { 977struct task_struct {
914 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */ 978 volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
915 void *stack; 979 void *stack;
@@ -926,16 +990,15 @@ struct task_struct {
926#endif 990#endif
927 991
928 int prio, static_prio, normal_prio; 992 int prio, static_prio, normal_prio;
929 struct list_head run_list;
930 const struct sched_class *sched_class; 993 const struct sched_class *sched_class;
931 struct sched_entity se; 994 struct sched_entity se;
995 struct sched_rt_entity rt;
932 996
933#ifdef CONFIG_PREEMPT_NOTIFIERS 997#ifdef CONFIG_PREEMPT_NOTIFIERS
934 /* list of struct preempt_notifier: */ 998 /* list of struct preempt_notifier: */
935 struct hlist_head preempt_notifiers; 999 struct hlist_head preempt_notifiers;
936#endif 1000#endif
937 1001
938 unsigned short ioprio;
939 /* 1002 /*
940 * fpu_counter contains the number of consecutive context switches 1003 * fpu_counter contains the number of consecutive context switches
941 * that the FPU is used. If this is over a threshold, the lazy fpu 1004 * that the FPU is used. If this is over a threshold, the lazy fpu
@@ -952,7 +1015,11 @@ struct task_struct {
952 1015
953 unsigned int policy; 1016 unsigned int policy;
954 cpumask_t cpus_allowed; 1017 cpumask_t cpus_allowed;
955 unsigned int time_slice; 1018
1019#ifdef CONFIG_PREEMPT_RCU
1020 int rcu_read_lock_nesting;
1021 int rcu_flipctr_idx;
1022#endif /* #ifdef CONFIG_PREEMPT_RCU */
956 1023
957#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT) 1024#if defined(CONFIG_SCHEDSTATS) || defined(CONFIG_TASK_DELAY_ACCT)
958 struct sched_info sched_info; 1025 struct sched_info sched_info;
@@ -1009,6 +1076,7 @@ struct task_struct {
1009 unsigned int rt_priority; 1076 unsigned int rt_priority;
1010 cputime_t utime, stime, utimescaled, stimescaled; 1077 cputime_t utime, stime, utimescaled, stimescaled;
1011 cputime_t gtime; 1078 cputime_t gtime;
1079 cputime_t prev_utime, prev_stime;
1012 unsigned long nvcsw, nivcsw; /* context switch counts */ 1080 unsigned long nvcsw, nivcsw; /* context switch counts */
1013 struct timespec start_time; /* monotonic time */ 1081 struct timespec start_time; /* monotonic time */
1014 struct timespec real_start_time; /* boot based time */ 1082 struct timespec real_start_time; /* boot based time */
@@ -1041,6 +1109,11 @@ struct task_struct {
1041/* ipc stuff */ 1109/* ipc stuff */
1042 struct sysv_sem sysvsem; 1110 struct sysv_sem sysvsem;
1043#endif 1111#endif
1112#ifdef CONFIG_DETECT_SOFTLOCKUP
1113/* hung task detection */
1114 unsigned long last_switch_timestamp;
1115 unsigned long last_switch_count;
1116#endif
1044/* CPU-specific state of this task */ 1117/* CPU-specific state of this task */
1045 struct thread_struct thread; 1118 struct thread_struct thread;
1046/* filesystem information */ 1119/* filesystem information */
@@ -1066,6 +1139,10 @@ struct task_struct {
1066 void *security; 1139 void *security;
1067#endif 1140#endif
1068 struct audit_context *audit_context; 1141 struct audit_context *audit_context;
1142#ifdef CONFIG_AUDITSYSCALL
1143 uid_t loginuid;
1144 unsigned int sessionid;
1145#endif
1069 seccomp_t seccomp; 1146 seccomp_t seccomp;
1070 1147
1071/* Thread group tracking */ 1148/* Thread group tracking */
@@ -1173,6 +1250,10 @@ struct task_struct {
1173 int make_it_fail; 1250 int make_it_fail;
1174#endif 1251#endif
1175 struct prop_local_single dirties; 1252 struct prop_local_single dirties;
1253#ifdef CONFIG_LATENCYTOP
1254 int latency_record_count;
1255 struct latency_record latency_record[LT_SAVECOUNT];
1256#endif
1176}; 1257};
1177 1258
1178/* 1259/*
@@ -1250,13 +1331,6 @@ struct pid_namespace;
1250 * 1331 *
1251 * set_task_vxid() : assigns a virtual id to a task; 1332 * set_task_vxid() : assigns a virtual id to a task;
1252 * 1333 *
1253 * task_ppid_nr_ns() : the parent's id as seen from the namespace specified.
1254 * the result depends on the namespace and whether the
1255 * task in question is the namespace's init. e.g. for the
1256 * namespace's init this will return 0 when called from
1257 * the namespace of this init, or appropriate id otherwise.
1258 *
1259 *
1260 * see also pid_nr() etc in include/linux/pid.h 1334 * see also pid_nr() etc in include/linux/pid.h
1261 */ 1335 */
1262 1336
@@ -1312,12 +1386,6 @@ static inline pid_t task_session_vnr(struct task_struct *tsk)
1312} 1386}
1313 1387
1314 1388
1315static inline pid_t task_ppid_nr_ns(struct task_struct *tsk,
1316 struct pid_namespace *ns)
1317{
1318 return pid_nr_ns(task_pid(rcu_dereference(tsk->real_parent)), ns);
1319}
1320
1321/** 1389/**
1322 * pid_alive - check that a task structure is not stale 1390 * pid_alive - check that a task structure is not stale
1323 * @p: Task structure to be checked. 1391 * @p: Task structure to be checked.
@@ -1459,12 +1527,23 @@ extern void sched_idle_next(void);
1459 1527
1460#ifdef CONFIG_SCHED_DEBUG 1528#ifdef CONFIG_SCHED_DEBUG
1461extern unsigned int sysctl_sched_latency; 1529extern unsigned int sysctl_sched_latency;
1462extern unsigned int sysctl_sched_nr_latency; 1530extern unsigned int sysctl_sched_min_granularity;
1463extern unsigned int sysctl_sched_wakeup_granularity; 1531extern unsigned int sysctl_sched_wakeup_granularity;
1464extern unsigned int sysctl_sched_batch_wakeup_granularity; 1532extern unsigned int sysctl_sched_batch_wakeup_granularity;
1465extern unsigned int sysctl_sched_child_runs_first; 1533extern unsigned int sysctl_sched_child_runs_first;
1466extern unsigned int sysctl_sched_features; 1534extern unsigned int sysctl_sched_features;
1467extern unsigned int sysctl_sched_migration_cost; 1535extern unsigned int sysctl_sched_migration_cost;
1536extern unsigned int sysctl_sched_nr_migrate;
1537extern unsigned int sysctl_sched_rt_period;
1538extern unsigned int sysctl_sched_rt_ratio;
1539#if defined(CONFIG_FAIR_GROUP_SCHED) && defined(CONFIG_SMP)
1540extern unsigned int sysctl_sched_min_bal_int_shares;
1541extern unsigned int sysctl_sched_max_bal_int_shares;
1542#endif
1543
1544int sched_nr_latency_handler(struct ctl_table *table, int write,
1545 struct file *file, void __user *buffer, size_t *length,
1546 loff_t *ppos);
1468#endif 1547#endif
1469 1548
1470extern unsigned int sysctl_sched_compat_yield; 1549extern unsigned int sysctl_sched_compat_yield;
@@ -1840,7 +1919,14 @@ static inline int signal_pending(struct task_struct *p)
1840{ 1919{
1841 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); 1920 return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
1842} 1921}
1843 1922
1923extern int FASTCALL(__fatal_signal_pending(struct task_struct *p));
1924
1925static inline int fatal_signal_pending(struct task_struct *p)
1926{
1927 return signal_pending(p) && __fatal_signal_pending(p);
1928}
1929
1844static inline int need_resched(void) 1930static inline int need_resched(void)
1845{ 1931{
1846 return unlikely(test_thread_flag(TIF_NEED_RESCHED)); 1932 return unlikely(test_thread_flag(TIF_NEED_RESCHED));
@@ -1853,29 +1939,33 @@ static inline int need_resched(void)
1853 * cond_resched_lock() will drop the spinlock before scheduling, 1939 * cond_resched_lock() will drop the spinlock before scheduling,
1854 * cond_resched_softirq() will enable bhs before scheduling. 1940 * cond_resched_softirq() will enable bhs before scheduling.
1855 */ 1941 */
1856extern int cond_resched(void); 1942#ifdef CONFIG_PREEMPT
1857extern int cond_resched_lock(spinlock_t * lock); 1943static inline int cond_resched(void)
1858extern int cond_resched_softirq(void); 1944{
1859 1945 return 0;
1860/* 1946}
1861 * Does a critical section need to be broken due to another
1862 * task waiting?:
1863 */
1864#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP)
1865# define need_lockbreak(lock) ((lock)->break_lock)
1866#else 1947#else
1867# define need_lockbreak(lock) 0 1948extern int _cond_resched(void);
1949static inline int cond_resched(void)
1950{
1951 return _cond_resched();
1952}
1868#endif 1953#endif
1954extern int cond_resched_lock(spinlock_t * lock);
1955extern int cond_resched_softirq(void);
1869 1956
1870/* 1957/*
1871 * Does a critical section need to be broken due to another 1958 * Does a critical section need to be broken due to another
1872 * task waiting or preemption being signalled: 1959 * task waiting?: (technically does not depend on CONFIG_PREEMPT,
1960 * but a general need for low latency)
1873 */ 1961 */
1874static inline int lock_need_resched(spinlock_t *lock) 1962static inline int spin_needbreak(spinlock_t *lock)
1875{ 1963{
1876 if (need_lockbreak(lock) || need_resched()) 1964#ifdef CONFIG_PREEMPT
1877 return 1; 1965 return spin_is_contended(lock);
1966#else
1878 return 0; 1967 return 0;
1968#endif
1879} 1969}
1880 1970
1881/* 1971/*
@@ -1982,6 +2072,14 @@ static inline void inc_syscw(struct task_struct *tsk)
1982} 2072}
1983#endif 2073#endif
1984 2074
2075#ifdef CONFIG_SMP
2076void migration_init(void);
2077#else
2078static inline void migration_init(void)
2079{
2080}
2081#endif
2082
1985#endif /* __KERNEL__ */ 2083#endif /* __KERNEL__ */
1986 2084
1987#endif 2085#endif
diff --git a/include/linux/screen_info.h b/include/linux/screen_info.h
index 827b85bbf388..1ee2c05142f6 100644
--- a/include/linux/screen_info.h
+++ b/include/linux/screen_info.h
@@ -63,6 +63,8 @@ struct screen_info {
63 63
64#define VIDEO_TYPE_PMAC 0x60 /* PowerMacintosh frame buffer. */ 64#define VIDEO_TYPE_PMAC 0x60 /* PowerMacintosh frame buffer. */
65 65
66#define VIDEO_TYPE_EFI 0x70 /* EFI graphic mode */
67
66#ifdef __KERNEL__ 68#ifdef __KERNEL__
67extern struct screen_info screen_info; 69extern struct screen_info screen_info;
68 70
diff --git a/include/linux/security.h b/include/linux/security.h
index ac050830a873..d24974262dc6 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -34,6 +34,12 @@
34#include <linux/xfrm.h> 34#include <linux/xfrm.h>
35#include <net/flow.h> 35#include <net/flow.h>
36 36
37/* only a char in selinux superblock security struct flags */
38#define FSCONTEXT_MNT 0x01
39#define CONTEXT_MNT 0x02
40#define ROOTCONTEXT_MNT 0x04
41#define DEFCONTEXT_MNT 0x08
42
37/* 43/*
38 * Bounding set 44 * Bounding set
39 */ 45 */
@@ -243,9 +249,6 @@ struct request_sock;
243 * @mnt contains the mounted file system. 249 * @mnt contains the mounted file system.
244 * @flags contains the new filesystem flags. 250 * @flags contains the new filesystem flags.
245 * @data contains the filesystem-specific data. 251 * @data contains the filesystem-specific data.
246 * @sb_post_mountroot:
247 * Update the security module's state when the root filesystem is mounted.
248 * This hook is only called if the mount was successful.
249 * @sb_post_addmount: 252 * @sb_post_addmount:
250 * Update the security module's state when a filesystem is mounted. 253 * Update the security module's state when a filesystem is mounted.
251 * This hook is called any time a mount is successfully grafetd to 254 * This hook is called any time a mount is successfully grafetd to
@@ -261,6 +264,22 @@ struct request_sock;
261 * Update module state after a successful pivot. 264 * Update module state after a successful pivot.
262 * @old_nd contains the nameidata structure for the old root. 265 * @old_nd contains the nameidata structure for the old root.
263 * @new_nd contains the nameidata structure for the new root. 266 * @new_nd contains the nameidata structure for the new root.
267 * @sb_get_mnt_opts:
268 * Get the security relevant mount options used for a superblock
269 * @sb the superblock to get security mount options from
270 * @mount_options array for pointers to mount options
271 * @mount_flags array of ints specifying what each mount options is
272 * @num_opts number of options in the arrays
273 * @sb_set_mnt_opts:
274 * Set the security relevant mount options used for a superblock
275 * @sb the superblock to set security mount options for
276 * @mount_options array for pointers to mount options
277 * @mount_flags array of ints specifying what each mount options is
278 * @num_opts number of options in the arrays
279 * @sb_clone_mnt_opts:
280 * Copy all security options from a given superblock to another
281 * @oldsb old superblock which contain information to clone
282 * @newsb new superblock which needs filled in
264 * 283 *
265 * Security hooks for inode operations. 284 * Security hooks for inode operations.
266 * 285 *
@@ -1183,6 +1202,10 @@ struct request_sock;
1183 * Convert secid to security context. 1202 * Convert secid to security context.
1184 * @secid contains the security ID. 1203 * @secid contains the security ID.
1185 * @secdata contains the pointer that stores the converted security context. 1204 * @secdata contains the pointer that stores the converted security context.
1205 * @secctx_to_secid:
1206 * Convert security context to secid.
1207 * @secid contains the pointer to the generated security ID.
1208 * @secdata contains the security context.
1186 * 1209 *
1187 * @release_secctx: 1210 * @release_secctx:
1188 * Release the security context. 1211 * Release the security context.
@@ -1235,13 +1258,19 @@ struct security_operations {
1235 void (*sb_umount_busy) (struct vfsmount * mnt); 1258 void (*sb_umount_busy) (struct vfsmount * mnt);
1236 void (*sb_post_remount) (struct vfsmount * mnt, 1259 void (*sb_post_remount) (struct vfsmount * mnt,
1237 unsigned long flags, void *data); 1260 unsigned long flags, void *data);
1238 void (*sb_post_mountroot) (void);
1239 void (*sb_post_addmount) (struct vfsmount * mnt, 1261 void (*sb_post_addmount) (struct vfsmount * mnt,
1240 struct nameidata * mountpoint_nd); 1262 struct nameidata * mountpoint_nd);
1241 int (*sb_pivotroot) (struct nameidata * old_nd, 1263 int (*sb_pivotroot) (struct nameidata * old_nd,
1242 struct nameidata * new_nd); 1264 struct nameidata * new_nd);
1243 void (*sb_post_pivotroot) (struct nameidata * old_nd, 1265 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1244 struct nameidata * new_nd); 1266 struct nameidata * new_nd);
1267 int (*sb_get_mnt_opts) (const struct super_block *sb,
1268 char ***mount_options, int **flags,
1269 int *num_opts);
1270 int (*sb_set_mnt_opts) (struct super_block *sb, char **mount_options,
1271 int *flags, int num_opts);
1272 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1273 struct super_block *newsb);
1245 1274
1246 int (*inode_alloc_security) (struct inode *inode); 1275 int (*inode_alloc_security) (struct inode *inode);
1247 void (*inode_free_security) (struct inode *inode); 1276 void (*inode_free_security) (struct inode *inode);
@@ -1371,6 +1400,7 @@ struct security_operations {
1371 int (*getprocattr)(struct task_struct *p, char *name, char **value); 1400 int (*getprocattr)(struct task_struct *p, char *name, char **value);
1372 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size); 1401 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1373 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen); 1402 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1403 int (*secctx_to_secid)(char *secdata, u32 seclen, u32 *secid);
1374 void (*release_secctx)(char *secdata, u32 seclen); 1404 void (*release_secctx)(char *secdata, u32 seclen);
1375 1405
1376#ifdef CONFIG_SECURITY_NETWORK 1406#ifdef CONFIG_SECURITY_NETWORK
@@ -1495,10 +1525,16 @@ int security_sb_umount(struct vfsmount *mnt, int flags);
1495void security_sb_umount_close(struct vfsmount *mnt); 1525void security_sb_umount_close(struct vfsmount *mnt);
1496void security_sb_umount_busy(struct vfsmount *mnt); 1526void security_sb_umount_busy(struct vfsmount *mnt);
1497void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data); 1527void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
1498void security_sb_post_mountroot(void);
1499void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd); 1528void security_sb_post_addmount(struct vfsmount *mnt, struct nameidata *mountpoint_nd);
1500int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd); 1529int security_sb_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
1501void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd); 1530void security_sb_post_pivotroot(struct nameidata *old_nd, struct nameidata *new_nd);
1531int security_sb_get_mnt_opts(const struct super_block *sb, char ***mount_options,
1532 int **flags, int *num_opts);
1533int security_sb_set_mnt_opts(struct super_block *sb, char **mount_options,
1534 int *flags, int num_opts);
1535void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1536 struct super_block *newsb);
1537
1502int security_inode_alloc(struct inode *inode); 1538int security_inode_alloc(struct inode *inode);
1503void security_inode_free(struct inode *inode); 1539void security_inode_free(struct inode *inode);
1504int security_inode_init_security(struct inode *inode, struct inode *dir, 1540int security_inode_init_security(struct inode *inode, struct inode *dir,
@@ -1603,6 +1639,7 @@ int security_setprocattr(struct task_struct *p, char *name, void *value, size_t
1603int security_netlink_send(struct sock *sk, struct sk_buff *skb); 1639int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1604int security_netlink_recv(struct sk_buff *skb, int cap); 1640int security_netlink_recv(struct sk_buff *skb, int cap);
1605int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen); 1641int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1642int security_secctx_to_secid(char *secdata, u32 seclen, u32 *secid);
1606void security_release_secctx(char *secdata, u32 seclen); 1643void security_release_secctx(char *secdata, u32 seclen);
1607 1644
1608#else /* CONFIG_SECURITY */ 1645#else /* CONFIG_SECURITY */
@@ -1777,9 +1814,6 @@ static inline void security_sb_post_remount (struct vfsmount *mnt,
1777 unsigned long flags, void *data) 1814 unsigned long flags, void *data)
1778{ } 1815{ }
1779 1816
1780static inline void security_sb_post_mountroot (void)
1781{ }
1782
1783static inline void security_sb_post_addmount (struct vfsmount *mnt, 1817static inline void security_sb_post_addmount (struct vfsmount *mnt,
1784 struct nameidata *mountpoint_nd) 1818 struct nameidata *mountpoint_nd)
1785{ } 1819{ }
@@ -2266,7 +2300,7 @@ static inline struct dentry *securityfs_create_file(const char *name,
2266 mode_t mode, 2300 mode_t mode,
2267 struct dentry *parent, 2301 struct dentry *parent,
2268 void *data, 2302 void *data,
2269 struct file_operations *fops) 2303 const struct file_operations *fops)
2270{ 2304{
2271 return ERR_PTR(-ENODEV); 2305 return ERR_PTR(-ENODEV);
2272} 2306}
@@ -2280,6 +2314,13 @@ static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *secle
2280 return -EOPNOTSUPP; 2314 return -EOPNOTSUPP;
2281} 2315}
2282 2316
2317static inline int security_secctx_to_secid(char *secdata,
2318 u32 seclen,
2319 u32 *secid)
2320{
2321 return -EOPNOTSUPP;
2322}
2323
2283static inline void security_release_secctx(char *secdata, u32 seclen) 2324static inline void security_release_secctx(char *secdata, u32 seclen)
2284{ 2325{
2285} 2326}
diff --git a/include/linux/selinux.h b/include/linux/selinux.h
index d1b7ca6c1c57..8c2cc4c02526 100644
--- a/include/linux/selinux.h
+++ b/include/linux/selinux.h
@@ -120,23 +120,42 @@ void selinux_get_task_sid(struct task_struct *tsk, u32 *sid);
120int selinux_string_to_sid(char *str, u32 *sid); 120int selinux_string_to_sid(char *str, u32 *sid);
121 121
122/** 122/**
123 * selinux_relabel_packet_permission - check permission to relabel a packet 123 * selinux_secmark_relabel_packet_permission - secmark permission check
124 * @sid: ID value to be applied to network packet (via SECMARK, most likely) 124 * @sid: SECMARK ID value to be applied to network packet
125 * 125 *
126 * Returns 0 if the current task is allowed to label packets with the 126 * Returns 0 if the current task is allowed to set the SECMARK label of
127 * supplied security ID. Note that it is implicit that the packet is always 127 * packets with the supplied security ID. Note that it is implicit that
128 * being relabeled from the default unlabled value, and that the access 128 * the packet is always being relabeled from the default unlabeled value,
129 * control decision is made in the AVC. 129 * and that the access control decision is made in the AVC.
130 */ 130 */
131int selinux_relabel_packet_permission(u32 sid); 131int selinux_secmark_relabel_packet_permission(u32 sid);
132 132
133/**
134 * selinux_secmark_refcount_inc - increments the secmark use counter
135 *
136 * SELinux keeps track of the current SECMARK targets in use so it knows
137 * when to apply SECMARK label access checks to network packets. This
138 * function incements this reference count to indicate that a new SECMARK
139 * target has been configured.
140 */
141void selinux_secmark_refcount_inc(void);
142
143/**
144 * selinux_secmark_refcount_dec - decrements the secmark use counter
145 *
146 * SELinux keeps track of the current SECMARK targets in use so it knows
147 * when to apply SECMARK label access checks to network packets. This
148 * function decements this reference count to indicate that one of the
149 * existing SECMARK targets has been removed/flushed.
150 */
151void selinux_secmark_refcount_dec(void);
133#else 152#else
134 153
135static inline int selinux_audit_rule_init(u32 field, u32 op, 154static inline int selinux_audit_rule_init(u32 field, u32 op,
136 char *rulestr, 155 char *rulestr,
137 struct selinux_audit_rule **rule) 156 struct selinux_audit_rule **rule)
138{ 157{
139 return -ENOTSUPP; 158 return -EOPNOTSUPP;
140} 159}
141 160
142static inline void selinux_audit_rule_free(struct selinux_audit_rule *rule) 161static inline void selinux_audit_rule_free(struct selinux_audit_rule *rule)
@@ -184,11 +203,21 @@ static inline int selinux_string_to_sid(const char *str, u32 *sid)
184 return 0; 203 return 0;
185} 204}
186 205
187static inline int selinux_relabel_packet_permission(u32 sid) 206static inline int selinux_secmark_relabel_packet_permission(u32 sid)
188{ 207{
189 return 0; 208 return 0;
190} 209}
191 210
211static inline void selinux_secmark_refcount_inc(void)
212{
213 return;
214}
215
216static inline void selinux_secmark_refcount_dec(void)
217{
218 return;
219}
220
192#endif /* CONFIG_SECURITY_SELINUX */ 221#endif /* CONFIG_SECURITY_SELINUX */
193 222
194#endif /* _LINUX_SELINUX_H */ 223#endif /* _LINUX_SELINUX_H */
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index ebbc02b325fc..648dfeb444db 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -63,5 +63,18 @@ extern struct list_head *seq_list_start_head(struct list_head *head,
63extern struct list_head *seq_list_next(void *v, struct list_head *head, 63extern struct list_head *seq_list_next(void *v, struct list_head *head,
64 loff_t *ppos); 64 loff_t *ppos);
65 65
66struct net;
67struct seq_net_private {
68 struct net *net;
69};
70
71int seq_open_net(struct inode *, struct file *,
72 const struct seq_operations *, int);
73int seq_release_net(struct inode *, struct file *);
74static inline struct net *seq_file_net(struct seq_file *seq)
75{
76 return ((struct seq_net_private *)seq->private)->net;
77}
78
66#endif 79#endif
67#endif 80#endif
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 6a5203fb9cf1..9963f81fea9a 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -437,7 +437,7 @@ uart_handle_sysrq_char(struct uart_port *port, unsigned int ch)
437#ifdef SUPPORT_SYSRQ 437#ifdef SUPPORT_SYSRQ
438 if (port->sysrq) { 438 if (port->sysrq) {
439 if (ch && time_before(jiffies, port->sysrq)) { 439 if (ch && time_before(jiffies, port->sysrq)) {
440 handle_sysrq(ch, port->info->tty); 440 handle_sysrq(ch, port->info ? port->info->tty : NULL);
441 port->sysrq = 0; 441 port->sysrq = 0;
442 return 1; 442 return 1;
443 } 443 }
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 94e49915a8c0..dfe975a9967e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -95,6 +95,7 @@
95 95
96struct net_device; 96struct net_device;
97struct scatterlist; 97struct scatterlist;
98struct pipe_inode_info;
98 99
99#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 100#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
100struct nf_conntrack { 101struct nf_conntrack {
@@ -107,9 +108,6 @@ struct nf_bridge_info {
107 atomic_t use; 108 atomic_t use;
108 struct net_device *physindev; 109 struct net_device *physindev;
109 struct net_device *physoutdev; 110 struct net_device *physoutdev;
110#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
111 struct net_device *netoutdev;
112#endif
113 unsigned int mask; 111 unsigned int mask;
114 unsigned long data[32 / sizeof(unsigned long)]; 112 unsigned long data[32 / sizeof(unsigned long)];
115}; 113};
@@ -287,6 +285,7 @@ struct sk_buff {
287 __u8 pkt_type:3, 285 __u8 pkt_type:3,
288 fclone:2, 286 fclone:2,
289 ipvs_property:1, 287 ipvs_property:1,
288 peeked:1,
290 nf_trace:1; 289 nf_trace:1;
291 __be16 protocol; 290 __be16 protocol;
292 291
@@ -356,7 +355,6 @@ static inline struct sk_buff *alloc_skb_fclone(unsigned int size,
356 return __alloc_skb(size, priority, 1, -1); 355 return __alloc_skb(size, priority, 1, -1);
357} 356}
358 357
359extern void kfree_skbmem(struct sk_buff *skb);
360extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src); 358extern struct sk_buff *skb_morph(struct sk_buff *dst, struct sk_buff *src);
361extern struct sk_buff *skb_clone(struct sk_buff *skb, 359extern struct sk_buff *skb_clone(struct sk_buff *skb,
362 gfp_t priority); 360 gfp_t priority);
@@ -387,7 +385,9 @@ extern void skb_truesize_bug(struct sk_buff *skb);
387 385
388static inline void skb_truesize_check(struct sk_buff *skb) 386static inline void skb_truesize_check(struct sk_buff *skb)
389{ 387{
390 if (unlikely((int)skb->truesize < sizeof(struct sk_buff) + skb->len)) 388 int len = sizeof(struct sk_buff) + skb->len;
389
390 if (unlikely((int)skb->truesize < len))
391 skb_truesize_bug(skb); 391 skb_truesize_bug(skb);
392} 392}
393 393
@@ -1536,6 +1536,8 @@ static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
1536 skb = skb->prev) 1536 skb = skb->prev)
1537 1537
1538 1538
1539extern struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags,
1540 int *peeked, int *err);
1539extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, 1541extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
1540 int noblock, int *err); 1542 int noblock, int *err);
1541extern unsigned int datagram_poll(struct file *file, struct socket *sock, 1543extern unsigned int datagram_poll(struct file *file, struct socket *sock,
@@ -1547,7 +1549,7 @@ extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
1547 int hlen, 1549 int hlen,
1548 struct iovec *iov); 1550 struct iovec *iov);
1549extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb); 1551extern void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
1550extern void skb_kill_datagram(struct sock *sk, struct sk_buff *skb, 1552extern int skb_kill_datagram(struct sock *sk, struct sk_buff *skb,
1551 unsigned int flags); 1553 unsigned int flags);
1552extern __wsum skb_checksum(const struct sk_buff *skb, int offset, 1554extern __wsum skb_checksum(const struct sk_buff *skb, int offset,
1553 int len, __wsum csum); 1555 int len, __wsum csum);
@@ -1558,6 +1560,11 @@ extern int skb_store_bits(struct sk_buff *skb, int offset,
1558extern __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, 1560extern __wsum skb_copy_and_csum_bits(const struct sk_buff *skb,
1559 int offset, u8 *to, int len, 1561 int offset, u8 *to, int len,
1560 __wsum csum); 1562 __wsum csum);
1563extern int skb_splice_bits(struct sk_buff *skb,
1564 unsigned int offset,
1565 struct pipe_inode_info *pipe,
1566 unsigned int len,
1567 unsigned int flags);
1561extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to); 1568extern void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);
1562extern void skb_split(struct sk_buff *skb, 1569extern void skb_split(struct sk_buff *skb,
1563 struct sk_buff *skb1, const u32 len); 1570 struct sk_buff *skb1, const u32 len);
diff --git a/include/linux/slab.h b/include/linux/slab.h
index f3a8eecd99f3..f62caaad94e0 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -271,5 +271,10 @@ static inline void *kzalloc(size_t size, gfp_t flags)
271 return kmalloc(size, flags | __GFP_ZERO); 271 return kmalloc(size, flags | __GFP_ZERO);
272} 272}
273 273
274#ifdef CONFIG_SLABINFO
275extern const struct seq_operations slabinfo_op;
276ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
277#endif
278
274#endif /* __KERNEL__ */ 279#endif /* __KERNEL__ */
275#endif /* _LINUX_SLAB_H */ 280#endif /* _LINUX_SLAB_H */
diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index 32bdc2ffd715..fcc48096ee64 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -95,7 +95,4 @@ found:
95 95
96#endif /* CONFIG_NUMA */ 96#endif /* CONFIG_NUMA */
97 97
98extern const struct seq_operations slabinfo_op;
99ssize_t slabinfo_write(struct file *, const char __user *, size_t, loff_t *);
100
101#endif /* _LINUX_SLAB_DEF_H */ 98#endif /* _LINUX_SLAB_DEF_H */
diff --git a/include/linux/smp.h b/include/linux/smp.h
index 259a13c3bd98..55232ccf9cfd 100644
--- a/include/linux/smp.h
+++ b/include/linux/smp.h
@@ -78,17 +78,20 @@ int on_each_cpu(void (*func) (void *info), void *info, int retry, int wait);
78 */ 78 */
79void smp_prepare_boot_cpu(void); 79void smp_prepare_boot_cpu(void);
80 80
81extern unsigned int setup_max_cpus;
82
81#else /* !SMP */ 83#else /* !SMP */
82 84
83/* 85/*
84 * These macros fold the SMP functionality into a single CPU system 86 * These macros fold the SMP functionality into a single CPU system
85 */ 87 */
86#define raw_smp_processor_id() 0 88#define raw_smp_processor_id() 0
87static inline int up_smp_call_function(void) 89static inline int up_smp_call_function(void (*func)(void *), void *info)
88{ 90{
89 return 0; 91 return 0;
90} 92}
91#define smp_call_function(func,info,retry,wait) (up_smp_call_function()) 93#define smp_call_function(func, info, retry, wait) \
94 (up_smp_call_function(func, info))
92#define on_each_cpu(func,info,retry,wait) \ 95#define on_each_cpu(func,info,retry,wait) \
93 ({ \ 96 ({ \
94 local_irq_disable(); \ 97 local_irq_disable(); \
@@ -107,6 +110,8 @@ static inline void smp_send_reschedule(int cpu) { }
107 local_irq_enable(); \ 110 local_irq_enable(); \
108 0; \ 111 0; \
109}) 112})
113#define smp_call_function_mask(mask, func, info, wait) \
114 (up_smp_call_function(func, info))
110 115
111#endif /* !SMP */ 116#endif /* !SMP */
112 117
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h
index 58962c51dee1..aab3a4cff4e1 100644
--- a/include/linux/smp_lock.h
+++ b/include/linux/smp_lock.h
@@ -17,22 +17,10 @@ extern void __lockfunc __release_kernel_lock(void);
17 __release_kernel_lock(); \ 17 __release_kernel_lock(); \
18} while (0) 18} while (0)
19 19
20/*
21 * Non-SMP kernels will never block on the kernel lock,
22 * so we are better off returning a constant zero from
23 * reacquire_kernel_lock() so that the compiler can see
24 * it at compile-time.
25 */
26#if defined(CONFIG_SMP) && !defined(CONFIG_PREEMPT_BKL)
27# define return_value_on_smp return
28#else
29# define return_value_on_smp
30#endif
31
32static inline int reacquire_kernel_lock(struct task_struct *task) 20static inline int reacquire_kernel_lock(struct task_struct *task)
33{ 21{
34 if (unlikely(task->lock_depth >= 0)) 22 if (unlikely(task->lock_depth >= 0))
35 return_value_on_smp __reacquire_kernel_lock(); 23 return __reacquire_kernel_lock();
36 return 0; 24 return 0;
37} 25}
38 26
diff --git a/include/linux/snmp.h b/include/linux/snmp.h
index 89f0c2b5f405..5df62ef1280c 100644
--- a/include/linux/snmp.h
+++ b/include/linux/snmp.h
@@ -217,4 +217,36 @@ enum
217 __LINUX_MIB_MAX 217 __LINUX_MIB_MAX
218}; 218};
219 219
220/* linux Xfrm mib definitions */
221enum
222{
223 LINUX_MIB_XFRMNUM = 0,
224 LINUX_MIB_XFRMINERROR, /* XfrmInError */
225 LINUX_MIB_XFRMINBUFFERERROR, /* XfrmInBufferError */
226 LINUX_MIB_XFRMINHDRERROR, /* XfrmInHdrError */
227 LINUX_MIB_XFRMINNOSTATES, /* XfrmInNoStates */
228 LINUX_MIB_XFRMINSTATEPROTOERROR, /* XfrmInStateProtoError */
229 LINUX_MIB_XFRMINSTATEMODEERROR, /* XfrmInStateModeError */
230 LINUX_MIB_XFRMINSTATESEQERROR, /* XfrmInStateSeqError */
231 LINUX_MIB_XFRMINSTATEEXPIRED, /* XfrmInStateExpired */
232 LINUX_MIB_XFRMINSTATEMISMATCH, /* XfrmInStateMismatch */
233 LINUX_MIB_XFRMINSTATEINVALID, /* XfrmInStateInvalid */
234 LINUX_MIB_XFRMINTMPLMISMATCH, /* XfrmInTmplMismatch */
235 LINUX_MIB_XFRMINNOPOLS, /* XfrmInNoPols */
236 LINUX_MIB_XFRMINPOLBLOCK, /* XfrmInPolBlock */
237 LINUX_MIB_XFRMINPOLERROR, /* XfrmInPolError */
238 LINUX_MIB_XFRMOUTERROR, /* XfrmOutError */
239 LINUX_MIB_XFRMOUTBUNDLEGENERROR, /* XfrmOutBundleGenError */
240 LINUX_MIB_XFRMOUTBUNDLECHECKERROR, /* XfrmOutBundleCheckError */
241 LINUX_MIB_XFRMOUTNOSTATES, /* XfrmOutNoStates */
242 LINUX_MIB_XFRMOUTSTATEPROTOERROR, /* XfrmOutStateProtoError */
243 LINUX_MIB_XFRMOUTSTATEMODEERROR, /* XfrmOutStateModeError */
244 LINUX_MIB_XFRMOUTSTATESEQERROR, /* XfrmOutStateSeqError */
245 LINUX_MIB_XFRMOUTSTATEEXPIRED, /* XfrmOutStateExpired */
246 LINUX_MIB_XFRMOUTPOLBLOCK, /* XfrmOutPolBlock */
247 LINUX_MIB_XFRMOUTPOLDEAD, /* XfrmOutPolDead */
248 LINUX_MIB_XFRMOUTPOLERROR, /* XfrmOutPolError */
249 __LINUX_MIB_XFRMMAX
250};
251
220#endif /* _LINUX_SNMP_H */ 252#endif /* _LINUX_SNMP_H */
diff --git a/include/linux/socket.h b/include/linux/socket.h
index c22ef1c1afb8..bd2b30a74e76 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -24,7 +24,6 @@ struct __kernel_sockaddr_storage {
24#include <linux/types.h> /* pid_t */ 24#include <linux/types.h> /* pid_t */
25#include <linux/compiler.h> /* __user */ 25#include <linux/compiler.h> /* __user */
26 26
27extern int sysctl_somaxconn;
28#ifdef CONFIG_PROC_FS 27#ifdef CONFIG_PROC_FS
29struct seq_file; 28struct seq_file;
30extern void socket_seq_show(struct seq_file *seq); 29extern void socket_seq_show(struct seq_file *seq);
@@ -185,6 +184,7 @@ struct ucred {
185#define AF_PPPOX 24 /* PPPoX sockets */ 184#define AF_PPPOX 24 /* PPPoX sockets */
186#define AF_WANPIPE 25 /* Wanpipe API Sockets */ 185#define AF_WANPIPE 25 /* Wanpipe API Sockets */
187#define AF_LLC 26 /* Linux LLC */ 186#define AF_LLC 26 /* Linux LLC */
187#define AF_CAN 29 /* Controller Area Network */
188#define AF_TIPC 30 /* TIPC sockets */ 188#define AF_TIPC 30 /* TIPC sockets */
189#define AF_BLUETOOTH 31 /* Bluetooth sockets */ 189#define AF_BLUETOOTH 31 /* Bluetooth sockets */
190#define AF_IUCV 32 /* IUCV sockets */ 190#define AF_IUCV 32 /* IUCV sockets */
@@ -220,6 +220,7 @@ struct ucred {
220#define PF_PPPOX AF_PPPOX 220#define PF_PPPOX AF_PPPOX
221#define PF_WANPIPE AF_WANPIPE 221#define PF_WANPIPE AF_WANPIPE
222#define PF_LLC AF_LLC 222#define PF_LLC AF_LLC
223#define PF_CAN AF_CAN
223#define PF_TIPC AF_TIPC 224#define PF_TIPC AF_TIPC
224#define PF_BLUETOOTH AF_BLUETOOTH 225#define PF_BLUETOOTH AF_BLUETOOTH
225#define PF_IUCV AF_IUCV 226#define PF_IUCV AF_IUCV
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index c376f3b36c89..124449733c55 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -120,6 +120,12 @@ do { \
120 120
121#define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock) 121#define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock)
122 122
123#ifdef CONFIG_GENERIC_LOCKBREAK
124#define spin_is_contended(lock) ((lock)->break_lock)
125#else
126#define spin_is_contended(lock) __raw_spin_is_contended(&(lock)->raw_lock)
127#endif
128
123/** 129/**
124 * spin_unlock_wait - wait until the spinlock gets unlocked 130 * spin_unlock_wait - wait until the spinlock gets unlocked
125 * @lock: the spinlock in question. 131 * @lock: the spinlock in question.
diff --git a/include/linux/spinlock_types.h b/include/linux/spinlock_types.h
index f6a3a951b79e..68d88f71f1a2 100644
--- a/include/linux/spinlock_types.h
+++ b/include/linux/spinlock_types.h
@@ -19,7 +19,7 @@
19 19
20typedef struct { 20typedef struct {
21 raw_spinlock_t raw_lock; 21 raw_spinlock_t raw_lock;
22#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) 22#ifdef CONFIG_GENERIC_LOCKBREAK
23 unsigned int break_lock; 23 unsigned int break_lock;
24#endif 24#endif
25#ifdef CONFIG_DEBUG_SPINLOCK 25#ifdef CONFIG_DEBUG_SPINLOCK
@@ -35,7 +35,7 @@ typedef struct {
35 35
36typedef struct { 36typedef struct {
37 raw_rwlock_t raw_lock; 37 raw_rwlock_t raw_lock;
38#if defined(CONFIG_PREEMPT) && defined(CONFIG_SMP) 38#ifdef CONFIG_GENERIC_LOCKBREAK
39 unsigned int break_lock; 39 unsigned int break_lock;
40#endif 40#endif
41#ifdef CONFIG_DEBUG_SPINLOCK 41#ifdef CONFIG_DEBUG_SPINLOCK
diff --git a/include/linux/spinlock_up.h b/include/linux/spinlock_up.h
index ea54c4c9a4ec..938234c4a996 100644
--- a/include/linux/spinlock_up.h
+++ b/include/linux/spinlock_up.h
@@ -64,6 +64,8 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)
64# define __raw_spin_trylock(lock) ({ (void)(lock); 1; }) 64# define __raw_spin_trylock(lock) ({ (void)(lock); 1; })
65#endif /* DEBUG_SPINLOCK */ 65#endif /* DEBUG_SPINLOCK */
66 66
67#define __raw_spin_is_contended(lock) (((void)(lock), 0))
68
67#define __raw_read_can_lock(lock) (((void)(lock), 1)) 69#define __raw_read_can_lock(lock) (((void)(lock), 1))
68#define __raw_write_can_lock(lock) (((void)(lock), 1)) 70#define __raw_write_can_lock(lock) (((void)(lock), 1))
69 71
diff --git a/include/linux/splice.h b/include/linux/splice.h
index 33e447f98a54..528dcb93c2f2 100644
--- a/include/linux/splice.h
+++ b/include/linux/splice.h
@@ -53,6 +53,7 @@ struct splice_pipe_desc {
53 int nr_pages; /* number of pages in map */ 53 int nr_pages; /* number of pages in map */
54 unsigned int flags; /* splice flags */ 54 unsigned int flags; /* splice flags */
55 const struct pipe_buf_operations *ops;/* ops associated with output pipe */ 55 const struct pipe_buf_operations *ops;/* ops associated with output pipe */
56 void (*spd_release)(struct splice_pipe_desc *, unsigned int);
56}; 57};
57 58
58typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *, 59typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,
diff --git a/include/linux/ssb/ssb.h b/include/linux/ssb/ssb.h
index 2b5c312c4960..e18f5c23b930 100644
--- a/include/linux/ssb/ssb.h
+++ b/include/linux/ssb/ssb.h
@@ -15,22 +15,19 @@ struct pcmcia_device;
15struct ssb_bus; 15struct ssb_bus;
16struct ssb_driver; 16struct ssb_driver;
17 17
18 18struct ssb_sprom {
19struct ssb_sprom_r1 { 19 u8 revision;
20 u16 pci_spid; /* Subsystem Product ID for PCI */
21 u16 pci_svid; /* Subsystem Vendor ID for PCI */
22 u16 pci_pid; /* Product ID for PCI */
23 u8 il0mac[6]; /* MAC address for 802.11b/g */ 20 u8 il0mac[6]; /* MAC address for 802.11b/g */
24 u8 et0mac[6]; /* MAC address for Ethernet */ 21 u8 et0mac[6]; /* MAC address for Ethernet */
25 u8 et1mac[6]; /* MAC address for 802.11a */ 22 u8 et1mac[6]; /* MAC address for 802.11a */
26 u8 et0phyaddr:5; /* MII address for enet0 */ 23 u8 et0phyaddr; /* MII address for enet0 */
27 u8 et1phyaddr:5; /* MII address for enet1 */ 24 u8 et1phyaddr; /* MII address for enet1 */
28 u8 et0mdcport:1; /* MDIO for enet0 */ 25 u8 et0mdcport; /* MDIO for enet0 */
29 u8 et1mdcport:1; /* MDIO for enet1 */ 26 u8 et1mdcport; /* MDIO for enet1 */
30 u8 board_rev; /* Board revision */ 27 u8 board_rev; /* Board revision number from SPROM. */
31 u8 country_code:4; /* Country Code */ 28 u8 country_code; /* Country Code */
32 u8 antenna_a:2; /* Antenna 0/1 available for A-PHY */ 29 u8 ant_available_a; /* A-PHY antenna available bits (up to 4) */
33 u8 antenna_bg:2; /* Antenna 0/1 available for B-PHY and G-PHY */ 30 u8 ant_available_bg; /* B/G-PHY antenna available bits (up to 4) */
34 u16 pa0b0; 31 u16 pa0b0;
35 u16 pa0b1; 32 u16 pa0b1;
36 u16 pa0b2; 33 u16 pa0b2;
@@ -41,61 +38,26 @@ struct ssb_sprom_r1 {
41 u8 gpio1; /* GPIO pin 1 */ 38 u8 gpio1; /* GPIO pin 1 */
42 u8 gpio2; /* GPIO pin 2 */ 39 u8 gpio2; /* GPIO pin 2 */
43 u8 gpio3; /* GPIO pin 3 */ 40 u8 gpio3; /* GPIO pin 3 */
44 u16 maxpwr_a; /* A-PHY Power Amplifier Max Power (in dBm Q5.2) */ 41 u16 maxpwr_a; /* A-PHY Amplifier Max Power (in dBm Q5.2) */
45 u16 maxpwr_bg; /* B/G-PHY Power Amplifier Max Power (in dBm Q5.2) */ 42 u16 maxpwr_bg; /* B/G-PHY Amplifier Max Power (in dBm Q5.2) */
46 u8 itssi_a; /* Idle TSSI Target for A-PHY */ 43 u8 itssi_a; /* Idle TSSI Target for A-PHY */
47 u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */ 44 u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
48 u16 boardflags_lo; /* Boardflags (low 16 bits) */ 45 u16 boardflags_lo; /* Boardflags (low 16 bits) */
49 u8 antenna_gain_a; /* A-PHY Antenna gain (in dBm Q5.2) */
50 u8 antenna_gain_bg; /* B/G-PHY Antenna gain (in dBm Q5.2) */
51 u8 oem[8]; /* OEM string (rev 1 only) */
52};
53
54struct ssb_sprom_r2 {
55 u16 boardflags_hi; /* Boardflags (high 16 bits) */ 46 u16 boardflags_hi; /* Boardflags (high 16 bits) */
56 u8 maxpwr_a_lo; /* A-PHY Max Power Low */
57 u8 maxpwr_a_hi; /* A-PHY Max Power High */
58 u16 pa1lob0; /* A-PHY PA Low Settings */
59 u16 pa1lob1; /* A-PHY PA Low Settings */
60 u16 pa1lob2; /* A-PHY PA Low Settings */
61 u16 pa1hib0; /* A-PHY PA High Settings */
62 u16 pa1hib1; /* A-PHY PA High Settings */
63 u16 pa1hib2; /* A-PHY PA High Settings */
64 u8 ofdm_pwr_off; /* OFDM Power Offset from CCK Level */
65 u8 country_str[2]; /* Two char Country Code */
66};
67
68struct ssb_sprom_r3 {
69 u32 ofdmapo; /* A-PHY OFDM Mid Power Offset */
70 u32 ofdmalpo; /* A-PHY OFDM Low Power Offset */
71 u32 ofdmahpo; /* A-PHY OFDM High Power Offset */
72 u8 gpioldc_on_cnt; /* GPIO LED Powersave Duty Cycle ON count */
73 u8 gpioldc_off_cnt; /* GPIO LED Powersave Duty Cycle OFF count */
74 u8 cckpo_1M:4; /* CCK Power Offset for Rate 1M */
75 u8 cckpo_2M:4; /* CCK Power Offset for Rate 2M */
76 u8 cckpo_55M:4; /* CCK Power Offset for Rate 5.5M */
77 u8 cckpo_11M:4; /* CCK Power Offset for Rate 11M */
78 u32 ofdmgpo; /* G-PHY OFDM Power Offset */
79};
80
81struct ssb_sprom_r4 {
82 /* TODO */
83};
84 47
85struct ssb_sprom { 48 /* Antenna gain values for up to 4 antennas
86 u8 revision; 49 * on each band. Values in dBm/4 (Q5.2). Negative gain means the
87 u8 crc; 50 * loss in the connectors is bigger than the gain. */
88 /* The valid r# fields are selected by the "revision". 51 struct {
89 * Revision 3 and lower inherit from lower revisions.
90 */
91 union {
92 struct { 52 struct {
93 struct ssb_sprom_r1 r1; 53 s8 a0, a1, a2, a3;
94 struct ssb_sprom_r2 r2; 54 } ghz24; /* 2.4GHz band */
95 struct ssb_sprom_r3 r3; 55 struct {
96 }; 56 s8 a0, a1, a2, a3;
97 struct ssb_sprom_r4 r4; 57 } ghz5; /* 5GHz band */
98 }; 58 } antenna_gain;
59
60 /* TODO - add any parameters needed from rev 2, 3, or 4 SPROMs */
99}; 61};
100 62
101/* Information about the PCB the circuitry is soldered on. */ 63/* Information about the PCB the circuitry is soldered on. */
@@ -270,7 +232,8 @@ struct ssb_bus {
270 struct ssb_device *mapped_device; 232 struct ssb_device *mapped_device;
271 /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */ 233 /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
272 u8 mapped_pcmcia_seg; 234 u8 mapped_pcmcia_seg;
273 /* Lock for core and segment switching. */ 235 /* Lock for core and segment switching.
236 * On PCMCIA-host busses this is used to protect the whole MMIO access. */
274 spinlock_t bar_lock; 237 spinlock_t bar_lock;
275 238
276 /* The bus this backplane is running on. */ 239 /* The bus this backplane is running on. */
@@ -288,6 +251,7 @@ struct ssb_bus {
288 /* ID information about the Chip. */ 251 /* ID information about the Chip. */
289 u16 chip_id; 252 u16 chip_id;
290 u16 chip_rev; 253 u16 chip_rev;
254 u16 sprom_size; /* number of words in sprom */
291 u8 chip_package; 255 u8 chip_package;
292 256
293 /* List of devices (cores) on the backplane. */ 257 /* List of devices (cores) on the backplane. */
@@ -402,6 +366,13 @@ static inline void ssb_pcihost_unregister(struct pci_driver *driver)
402{ 366{
403 pci_unregister_driver(driver); 367 pci_unregister_driver(driver);
404} 368}
369
370static inline
371void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
372{
373 if (sdev->bus->bustype == SSB_BUSTYPE_PCI)
374 pci_set_power_state(sdev->bus->host_pci, state);
375}
405#endif /* CONFIG_SSB_PCIHOST */ 376#endif /* CONFIG_SSB_PCIHOST */
406 377
407 378
diff --git a/include/linux/ssb/ssb_regs.h b/include/linux/ssb/ssb_regs.h
index 47c7c71a5acf..ebad0bac9801 100644
--- a/include/linux/ssb/ssb_regs.h
+++ b/include/linux/ssb/ssb_regs.h
@@ -147,6 +147,10 @@
147#define SSB_IDLOW_SSBREV 0xF0000000 /* Sonics Backplane Revision code */ 147#define SSB_IDLOW_SSBREV 0xF0000000 /* Sonics Backplane Revision code */
148#define SSB_IDLOW_SSBREV_22 0x00000000 /* <= 2.2 */ 148#define SSB_IDLOW_SSBREV_22 0x00000000 /* <= 2.2 */
149#define SSB_IDLOW_SSBREV_23 0x10000000 /* 2.3 */ 149#define SSB_IDLOW_SSBREV_23 0x10000000 /* 2.3 */
150#define SSB_IDLOW_SSBREV_24 0x40000000 /* ?? Found in BCM4328 */
151#define SSB_IDLOW_SSBREV_25 0x50000000 /* ?? Not Found yet */
152#define SSB_IDLOW_SSBREV_26 0x60000000 /* ?? Found in some BCM4311/2 */
153#define SSB_IDLOW_SSBREV_27 0x70000000 /* ?? Found in some BCM4311/2 */
150#define SSB_IDHIGH 0x0FFC /* SB Identification High */ 154#define SSB_IDHIGH 0x0FFC /* SB Identification High */
151#define SSB_IDHIGH_RCLO 0x0000000F /* Revision Code (low part) */ 155#define SSB_IDHIGH_RCLO 0x0000000F /* Revision Code (low part) */
152#define SSB_IDHIGH_CC 0x00008FF0 /* Core Code */ 156#define SSB_IDHIGH_CC 0x00008FF0 /* Core Code */
@@ -162,11 +166,16 @@
162 */ 166 */
163#define SSB_SPROMSIZE_WORDS 64 167#define SSB_SPROMSIZE_WORDS 64
164#define SSB_SPROMSIZE_BYTES (SSB_SPROMSIZE_WORDS * sizeof(u16)) 168#define SSB_SPROMSIZE_BYTES (SSB_SPROMSIZE_WORDS * sizeof(u16))
169#define SSB_SPROMSIZE_WORDS_R123 64
170#define SSB_SPROMSIZE_WORDS_R4 220
171#define SSB_SPROMSIZE_BYTES_R123 (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
172#define SSB_SPROMSIZE_BYTES_R4 (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
165#define SSB_SPROM_BASE 0x1000 173#define SSB_SPROM_BASE 0x1000
166#define SSB_SPROM_REVISION 0x107E 174#define SSB_SPROM_REVISION 0x107E
167#define SSB_SPROM_REVISION_REV 0x00FF /* SPROM Revision number */ 175#define SSB_SPROM_REVISION_REV 0x00FF /* SPROM Revision number */
168#define SSB_SPROM_REVISION_CRC 0xFF00 /* SPROM CRC8 value */ 176#define SSB_SPROM_REVISION_CRC 0xFF00 /* SPROM CRC8 value */
169#define SSB_SPROM_REVISION_CRC_SHIFT 8 177#define SSB_SPROM_REVISION_CRC_SHIFT 8
178
170/* SPROM Revision 1 */ 179/* SPROM Revision 1 */
171#define SSB_SPROM1_SPID 0x1004 /* Subsystem Product ID for PCI */ 180#define SSB_SPROM1_SPID 0x1004 /* Subsystem Product ID for PCI */
172#define SSB_SPROM1_SVID 0x1006 /* Subsystem Vendor ID for PCI */ 181#define SSB_SPROM1_SVID 0x1006 /* Subsystem Vendor ID for PCI */
@@ -184,10 +193,10 @@
184#define SSB_SPROM1_BINF_BREV 0x00FF /* Board Revision */ 193#define SSB_SPROM1_BINF_BREV 0x00FF /* Board Revision */
185#define SSB_SPROM1_BINF_CCODE 0x0F00 /* Country Code */ 194#define SSB_SPROM1_BINF_CCODE 0x0F00 /* Country Code */
186#define SSB_SPROM1_BINF_CCODE_SHIFT 8 195#define SSB_SPROM1_BINF_CCODE_SHIFT 8
187#define SSB_SPROM1_BINF_ANTA 0x3000 /* Available A-PHY antennas */ 196#define SSB_SPROM1_BINF_ANTBG 0x3000 /* Available B-PHY and G-PHY antennas */
188#define SSB_SPROM1_BINF_ANTA_SHIFT 12 197#define SSB_SPROM1_BINF_ANTBG_SHIFT 12
189#define SSB_SPROM1_BINF_ANTBG 0xC000 /* Available B-PHY antennas */ 198#define SSB_SPROM1_BINF_ANTA 0xC000 /* Available A-PHY antennas */
190#define SSB_SPROM1_BINF_ANTBG_SHIFT 14 199#define SSB_SPROM1_BINF_ANTA_SHIFT 14
191#define SSB_SPROM1_PA0B0 0x105E 200#define SSB_SPROM1_PA0B0 0x105E
192#define SSB_SPROM1_PA0B1 0x1060 201#define SSB_SPROM1_PA0B1 0x1060
193#define SSB_SPROM1_PA0B2 0x1062 202#define SSB_SPROM1_PA0B2 0x1062
@@ -212,10 +221,11 @@
212#define SSB_SPROM1_ITSSI_A_SHIFT 8 221#define SSB_SPROM1_ITSSI_A_SHIFT 8
213#define SSB_SPROM1_BFLLO 0x1072 /* Boardflags (low 16 bits) */ 222#define SSB_SPROM1_BFLLO 0x1072 /* Boardflags (low 16 bits) */
214#define SSB_SPROM1_AGAIN 0x1074 /* Antenna Gain (in dBm Q5.2) */ 223#define SSB_SPROM1_AGAIN 0x1074 /* Antenna Gain (in dBm Q5.2) */
215#define SSB_SPROM1_AGAIN_A 0x00FF /* A-PHY */ 224#define SSB_SPROM1_AGAIN_BG 0x00FF /* B-PHY and G-PHY */
216#define SSB_SPROM1_AGAIN_BG 0xFF00 /* B-PHY and G-PHY */ 225#define SSB_SPROM1_AGAIN_BG_SHIFT 0
217#define SSB_SPROM1_AGAIN_BG_SHIFT 8 226#define SSB_SPROM1_AGAIN_A 0xFF00 /* A-PHY */
218#define SSB_SPROM1_OEM 0x1076 /* 8 bytes OEM string (rev 1 only) */ 227#define SSB_SPROM1_AGAIN_A_SHIFT 8
228
219/* SPROM Revision 2 (inherits from rev 1) */ 229/* SPROM Revision 2 (inherits from rev 1) */
220#define SSB_SPROM2_BFLHI 0x1038 /* Boardflags (high 16 bits) */ 230#define SSB_SPROM2_BFLHI 0x1038 /* Boardflags (high 16 bits) */
221#define SSB_SPROM2_MAXP_A 0x103A /* A-PHY Max Power */ 231#define SSB_SPROM2_MAXP_A 0x103A /* A-PHY Max Power */
@@ -232,7 +242,11 @@
232#define SSB_SPROM2_OPO_VALUE 0x00FF 242#define SSB_SPROM2_OPO_VALUE 0x00FF
233#define SSB_SPROM2_OPO_UNUSED 0xFF00 243#define SSB_SPROM2_OPO_UNUSED 0xFF00
234#define SSB_SPROM2_CCODE 0x107C /* Two char Country Code */ 244#define SSB_SPROM2_CCODE 0x107C /* Two char Country Code */
235/* SPROM Revision 3 (inherits from rev 2) */ 245
246/* SPROM Revision 3 (inherits most data from rev 2) */
247#define SSB_SPROM3_IL0MAC 0x104A /* 6 bytes MAC address for 802.11b/g */
248#define SSB_SPROM3_ET0MAC 0x1050 /* 6 bytes MAC address for Ethernet ?? */
249#define SSB_SPROM3_ET1MAC 0x1050 /* 6 bytes MAC address for 802.11a ?? */
236#define SSB_SPROM3_OFDMAPO 0x102C /* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */ 250#define SSB_SPROM3_OFDMAPO 0x102C /* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */
237#define SSB_SPROM3_OFDMALPO 0x1030 /* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */ 251#define SSB_SPROM3_OFDMALPO 0x1030 /* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */
238#define SSB_SPROM3_OFDMAHPO 0x1034 /* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */ 252#define SSB_SPROM3_OFDMAHPO 0x1034 /* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */
@@ -251,6 +265,57 @@
251#define SSB_SPROM3_CCKPO_11M_SHIFT 12 265#define SSB_SPROM3_CCKPO_11M_SHIFT 12
252#define SSB_SPROM3_OFDMGPO 0x107A /* G-PHY OFDM Power Offset (4 bytes, BigEndian) */ 266#define SSB_SPROM3_OFDMGPO 0x107A /* G-PHY OFDM Power Offset (4 bytes, BigEndian) */
253 267
268/* SPROM Revision 4 */
269#define SSB_SPROM4_IL0MAC 0x104C /* 6 byte MAC address for a/b/g/n */
270#define SSB_SPROM4_ET0MAC 0x1018 /* 6 bytes MAC address for Ethernet ?? */
271#define SSB_SPROM4_ET1MAC 0x1018 /* 6 bytes MAC address for 802.11a ?? */
272#define SSB_SPROM4_ETHPHY 0x105A /* Ethernet PHY settings ?? */
273#define SSB_SPROM4_ETHPHY_ET0A 0x001F /* MII Address for enet0 */
274#define SSB_SPROM4_ETHPHY_ET1A 0x03E0 /* MII Address for enet1 */
275#define SSB_SPROM4_ETHPHY_ET1A_SHIFT 5
276#define SSB_SPROM4_ETHPHY_ET0M (1<<14) /* MDIO for enet0 */
277#define SSB_SPROM4_ETHPHY_ET1M (1<<15) /* MDIO for enet1 */
278#define SSB_SPROM4_CCODE 0x1052 /* Country Code (2 bytes) */
279#define SSB_SPROM4_ANTAVAIL 0x105D /* Antenna available bitfields */
280#define SSB_SPROM4_ANTAVAIL_A 0x00FF /* A-PHY bitfield */
281#define SSB_SPROM4_ANTAVAIL_A_SHIFT 0
282#define SSB_SPROM4_ANTAVAIL_BG 0xFF00 /* B-PHY and G-PHY bitfield */
283#define SSB_SPROM4_ANTAVAIL_BG_SHIFT 8
284#define SSB_SPROM4_BFLLO 0x1044 /* Boardflags (low 16 bits) */
285#define SSB_SPROM4_AGAIN01 0x105E /* Antenna Gain (in dBm Q5.2) */
286#define SSB_SPROM4_AGAIN0 0x00FF /* Antenna 0 */
287#define SSB_SPROM4_AGAIN0_SHIFT 0
288#define SSB_SPROM4_AGAIN1 0xFF00 /* Antenna 1 */
289#define SSB_SPROM4_AGAIN1_SHIFT 8
290#define SSB_SPROM4_AGAIN23 0x1060
291#define SSB_SPROM4_AGAIN2 0x00FF /* Antenna 2 */
292#define SSB_SPROM4_AGAIN2_SHIFT 0
293#define SSB_SPROM4_AGAIN3 0xFF00 /* Antenna 3 */
294#define SSB_SPROM4_AGAIN3_SHIFT 8
295#define SSB_SPROM4_BFLHI 0x1046 /* Board Flags Hi */
296#define SSB_SPROM4_MAXP_BG 0x1080 /* Max Power BG in path 1 */
297#define SSB_SPROM4_MAXP_BG_MASK 0x00FF /* Mask for Max Power BG */
298#define SSB_SPROM4_ITSSI_BG 0xFF00 /* Mask for path 1 itssi_bg */
299#define SSB_SPROM4_ITSSI_BG_SHIFT 8
300#define SSB_SPROM4_MAXP_A 0x108A /* Max Power A in path 1 */
301#define SSB_SPROM4_MAXP_A_MASK 0x00FF /* Mask for Max Power A */
302#define SSB_SPROM4_ITSSI_A 0xFF00 /* Mask for path 1 itssi_a */
303#define SSB_SPROM4_ITSSI_A_SHIFT 8
304#define SSB_SPROM4_GPIOA 0x1056 /* Gen. Purpose IO # 0 and 1 */
305#define SSB_SPROM4_GPIOA_P0 0x00FF /* Pin 0 */
306#define SSB_SPROM4_GPIOA_P1 0xFF00 /* Pin 1 */
307#define SSB_SPROM4_GPIOA_P1_SHIFT 8
308#define SSB_SPROM4_GPIOB 0x1058 /* Gen. Purpose IO # 2 and 3 */
309#define SSB_SPROM4_GPIOB_P2 0x00FF /* Pin 2 */
310#define SSB_SPROM4_GPIOB_P3 0xFF00 /* Pin 3 */
311#define SSB_SPROM4_GPIOB_P3_SHIFT 8
312#define SSB_SPROM4_PA0B0 0x1082 /* The paXbY locations are */
313#define SSB_SPROM4_PA0B1 0x1084 /* only guesses */
314#define SSB_SPROM4_PA0B2 0x1086
315#define SSB_SPROM4_PA1B0 0x108E
316#define SSB_SPROM4_PA1B1 0x1090
317#define SSB_SPROM4_PA1B2 0x1092
318
254/* Values for SSB_SPROM1_BINF_CCODE */ 319/* Values for SSB_SPROM1_BINF_CCODE */
255enum { 320enum {
256 SSB_SPROM1CCODE_WORLD = 0, 321 SSB_SPROM1CCODE_WORLD = 0,
diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h
index e7fa657d0c49..5da9794b2d78 100644
--- a/include/linux/stacktrace.h
+++ b/include/linux/stacktrace.h
@@ -9,10 +9,13 @@ struct stack_trace {
9}; 9};
10 10
11extern void save_stack_trace(struct stack_trace *trace); 11extern void save_stack_trace(struct stack_trace *trace);
12extern void save_stack_trace_tsk(struct task_struct *tsk,
13 struct stack_trace *trace);
12 14
13extern void print_stack_trace(struct stack_trace *trace, int spaces); 15extern void print_stack_trace(struct stack_trace *trace, int spaces);
14#else 16#else
15# define save_stack_trace(trace) do { } while (0) 17# define save_stack_trace(trace) do { } while (0)
18# define save_stack_trace_tsk(tsk, trace) do { } while (0)
16# define print_stack_trace(trace, spaces) do { } while (0) 19# define print_stack_trace(trace, spaces) do { } while (0)
17#endif 20#endif
18 21
diff --git a/include/linux/string.h b/include/linux/string.h
index 836062b7582a..c5d3fcad7b57 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -3,16 +3,14 @@
3 3
4/* We don't want strings.h stuff being user by user stuff by accident */ 4/* We don't want strings.h stuff being user by user stuff by accident */
5 5
6#ifdef __KERNEL__ 6#ifndef __KERNEL__
7#include <string.h>
8#else
7 9
8#include <linux/compiler.h> /* for inline */ 10#include <linux/compiler.h> /* for inline */
9#include <linux/types.h> /* for size_t */ 11#include <linux/types.h> /* for size_t */
10#include <linux/stddef.h> /* for NULL */ 12#include <linux/stddef.h> /* for NULL */
11 13
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16extern char *strndup_user(const char __user *, long); 14extern char *strndup_user(const char __user *, long);
17 15
18/* 16/*
@@ -111,9 +109,5 @@ extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
111extern char **argv_split(gfp_t gfp, const char *str, int *argcp); 109extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
112extern void argv_free(char **argv); 110extern void argv_free(char **argv);
113 111
114#ifdef __cplusplus
115}
116#endif
117
118#endif 112#endif
119#endif /* _LINUX_STRING_H_ */ 113#endif /* _LINUX_STRING_H_ */
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index bd7a6b0a87af..03547d6abee5 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -169,8 +169,8 @@ extern int cache_check(struct cache_detail *detail,
169extern void cache_flush(void); 169extern void cache_flush(void);
170extern void cache_purge(struct cache_detail *detail); 170extern void cache_purge(struct cache_detail *detail);
171#define NEVER (0x7FFFFFFF) 171#define NEVER (0x7FFFFFFF)
172extern void cache_register(struct cache_detail *cd); 172extern int cache_register(struct cache_detail *cd);
173extern int cache_unregister(struct cache_detail *cd); 173extern void cache_unregister(struct cache_detail *cd);
174 174
175extern void qword_add(char **bpp, int *lp, char *str); 175extern void qword_add(char **bpp, int *lp, char *str);
176extern void qword_addhex(char **bpp, int *lp, char *buf, int blen); 176extern void qword_addhex(char **bpp, int *lp, char *buf, int blen);
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index d9d5c5ad826c..129a86e25d29 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -41,11 +41,11 @@ struct rpc_clnt {
41 struct rpc_iostats * cl_metrics; /* per-client statistics */ 41 struct rpc_iostats * cl_metrics; /* per-client statistics */
42 42
43 unsigned int cl_softrtry : 1,/* soft timeouts */ 43 unsigned int cl_softrtry : 1,/* soft timeouts */
44 cl_intr : 1,/* interruptible */
45 cl_discrtry : 1,/* disconnect before retry */ 44 cl_discrtry : 1,/* disconnect before retry */
46 cl_autobind : 1;/* use getport() */ 45 cl_autobind : 1;/* use getport() */
47 46
48 struct rpc_rtt * cl_rtt; /* RTO estimator data */ 47 struct rpc_rtt * cl_rtt; /* RTO estimator data */
48 const struct rpc_timeout *cl_timeout; /* Timeout strategy */
49 49
50 int cl_nodelen; /* nodename length */ 50 int cl_nodelen; /* nodename length */
51 char cl_nodename[UNX_MAXNODENAME]; 51 char cl_nodename[UNX_MAXNODENAME];
@@ -54,6 +54,7 @@ struct rpc_clnt {
54 struct dentry * cl_dentry; /* inode */ 54 struct dentry * cl_dentry; /* inode */
55 struct rpc_clnt * cl_parent; /* Points to parent of clones */ 55 struct rpc_clnt * cl_parent; /* Points to parent of clones */
56 struct rpc_rtt cl_rtt_default; 56 struct rpc_rtt cl_rtt_default;
57 struct rpc_timeout cl_timeout_default;
57 struct rpc_program * cl_program; 58 struct rpc_program * cl_program;
58 char cl_inline_name[32]; 59 char cl_inline_name[32];
59}; 60};
@@ -99,7 +100,7 @@ struct rpc_create_args {
99 struct sockaddr *address; 100 struct sockaddr *address;
100 size_t addrsize; 101 size_t addrsize;
101 struct sockaddr *saddress; 102 struct sockaddr *saddress;
102 struct rpc_timeout *timeout; 103 const struct rpc_timeout *timeout;
103 char *servername; 104 char *servername;
104 struct rpc_program *program; 105 struct rpc_program *program;
105 u32 version; 106 u32 version;
@@ -109,7 +110,6 @@ struct rpc_create_args {
109 110
110/* Values for "flags" field */ 111/* Values for "flags" field */
111#define RPC_CLNT_CREATE_HARDRTRY (1UL << 0) 112#define RPC_CLNT_CREATE_HARDRTRY (1UL << 0)
112#define RPC_CLNT_CREATE_INTR (1UL << 1)
113#define RPC_CLNT_CREATE_AUTOBIND (1UL << 2) 113#define RPC_CLNT_CREATE_AUTOBIND (1UL << 2)
114#define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3) 114#define RPC_CLNT_CREATE_NONPRIVPORT (1UL << 3)
115#define RPC_CLNT_CREATE_NOPING (1UL << 4) 115#define RPC_CLNT_CREATE_NOPING (1UL << 4)
@@ -123,11 +123,10 @@ void rpc_shutdown_client(struct rpc_clnt *);
123void rpc_release_client(struct rpc_clnt *); 123void rpc_release_client(struct rpc_clnt *);
124 124
125int rpcb_register(u32, u32, int, unsigned short, int *); 125int rpcb_register(u32, u32, int, unsigned short, int *);
126int rpcb_getport_sync(struct sockaddr_in *, __u32, __u32, int); 126int rpcb_getport_sync(struct sockaddr_in *, u32, u32, int);
127void rpcb_getport_async(struct rpc_task *); 127void rpcb_getport_async(struct rpc_task *);
128 128
129void rpc_call_setup(struct rpc_task *, struct rpc_message *, int); 129void rpc_call_start(struct rpc_task *);
130
131int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, 130int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg,
132 int flags, const struct rpc_call_ops *tk_ops, 131 int flags, const struct rpc_call_ops *tk_ops,
133 void *calldata); 132 void *calldata);
@@ -136,13 +135,11 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg,
136struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, 135struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
137 int flags); 136 int flags);
138void rpc_restart_call(struct rpc_task *); 137void rpc_restart_call(struct rpc_task *);
139void rpc_clnt_sigmask(struct rpc_clnt *clnt, sigset_t *oldset);
140void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset);
141void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int); 138void rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
142size_t rpc_max_payload(struct rpc_clnt *); 139size_t rpc_max_payload(struct rpc_clnt *);
143void rpc_force_rebind(struct rpc_clnt *); 140void rpc_force_rebind(struct rpc_clnt *);
144size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t); 141size_t rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
145char * rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t); 142const char *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
146 143
147#endif /* __KERNEL__ */ 144#endif /* __KERNEL__ */
148#endif /* _LINUX_SUNRPC_CLNT_H */ 145#endif /* _LINUX_SUNRPC_CLNT_H */
diff --git a/include/linux/sunrpc/debug.h b/include/linux/sunrpc/debug.h
index 3347c72b848a..10709cbe96fd 100644
--- a/include/linux/sunrpc/debug.h
+++ b/include/linux/sunrpc/debug.h
@@ -20,7 +20,7 @@
20#define RPCDBG_BIND 0x0020 20#define RPCDBG_BIND 0x0020
21#define RPCDBG_SCHED 0x0040 21#define RPCDBG_SCHED 0x0040
22#define RPCDBG_TRANS 0x0080 22#define RPCDBG_TRANS 0x0080
23#define RPCDBG_SVCSOCK 0x0100 23#define RPCDBG_SVCXPRT 0x0100
24#define RPCDBG_SVCDSP 0x0200 24#define RPCDBG_SVCDSP 0x0200
25#define RPCDBG_MISC 0x0400 25#define RPCDBG_MISC 0x0400
26#define RPCDBG_CACHE 0x0800 26#define RPCDBG_CACHE 0x0800
@@ -88,11 +88,6 @@ enum {
88 CTL_SLOTTABLE_TCP, 88 CTL_SLOTTABLE_TCP,
89 CTL_MIN_RESVPORT, 89 CTL_MIN_RESVPORT,
90 CTL_MAX_RESVPORT, 90 CTL_MAX_RESVPORT,
91 CTL_SLOTTABLE_RDMA,
92 CTL_RDMA_MAXINLINEREAD,
93 CTL_RDMA_MAXINLINEWRITE,
94 CTL_RDMA_WRITEPADDING,
95 CTL_RDMA_MEMREG,
96}; 91};
97 92
98#endif /* _LINUX_SUNRPC_DEBUG_H_ */ 93#endif /* _LINUX_SUNRPC_DEBUG_H_ */
diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h
index c4beb5775111..70df4f1d8847 100644
--- a/include/linux/sunrpc/msg_prot.h
+++ b/include/linux/sunrpc/msg_prot.h
@@ -152,5 +152,44 @@ typedef __be32 rpc_fraghdr;
152 */ 152 */
153#define RPCBIND_MAXNETIDLEN (4u) 153#define RPCBIND_MAXNETIDLEN (4u)
154 154
155/*
156 * Universal addresses are introduced in RFC 1833 and further spelled
157 * out in RFC 3530. RPCBIND_MAXUADDRLEN defines a maximum byte length
158 * of a universal address for use in allocating buffers and character
159 * arrays.
160 *
161 * Quoting RFC 3530, section 2.2:
162 *
163 * For TCP over IPv4 and for UDP over IPv4, the format of r_addr is the
164 * US-ASCII string:
165 *
166 * h1.h2.h3.h4.p1.p2
167 *
168 * The prefix, "h1.h2.h3.h4", is the standard textual form for
169 * representing an IPv4 address, which is always four octets long.
170 * Assuming big-endian ordering, h1, h2, h3, and h4, are respectively,
171 * the first through fourth octets each converted to ASCII-decimal.
172 * Assuming big-endian ordering, p1 and p2 are, respectively, the first
173 * and second octets each converted to ASCII-decimal. For example, if a
174 * host, in big-endian order, has an address of 0x0A010307 and there is
175 * a service listening on, in big endian order, port 0x020F (decimal
176 * 527), then the complete universal address is "10.1.3.7.2.15".
177 *
178 * ...
179 *
180 * For TCP over IPv6 and for UDP over IPv6, the format of r_addr is the
181 * US-ASCII string:
182 *
183 * x1:x2:x3:x4:x5:x6:x7:x8.p1.p2
184 *
185 * The suffix "p1.p2" is the service port, and is computed the same way
186 * as with universal addresses for TCP and UDP over IPv4. The prefix,
187 * "x1:x2:x3:x4:x5:x6:x7:x8", is the standard textual form for
188 * representing an IPv6 address as defined in Section 2.2 of [RFC2373].
189 * Additionally, the two alternative forms specified in Section 2.2 of
190 * [RFC2373] are also acceptable.
191 */
192#define RPCBIND_MAXUADDRLEN (56u)
193
155#endif /* __KERNEL__ */ 194#endif /* __KERNEL__ */
156#endif /* _LINUX_SUNRPC_MSGPROT_H_ */ 195#endif /* _LINUX_SUNRPC_MSGPROT_H_ */
diff --git a/include/linux/sunrpc/rpc_rdma.h b/include/linux/sunrpc/rpc_rdma.h
index 0013a0d8dc6b..87b895d5c786 100644
--- a/include/linux/sunrpc/rpc_rdma.h
+++ b/include/linux/sunrpc/rpc_rdma.h
@@ -41,17 +41,17 @@
41#define _LINUX_SUNRPC_RPC_RDMA_H 41#define _LINUX_SUNRPC_RPC_RDMA_H
42 42
43struct rpcrdma_segment { 43struct rpcrdma_segment {
44 uint32_t rs_handle; /* Registered memory handle */ 44 __be32 rs_handle; /* Registered memory handle */
45 uint32_t rs_length; /* Length of the chunk in bytes */ 45 __be32 rs_length; /* Length of the chunk in bytes */
46 uint64_t rs_offset; /* Chunk virtual address or offset */ 46 __be64 rs_offset; /* Chunk virtual address or offset */
47}; 47};
48 48
49/* 49/*
50 * read chunk(s), encoded as a linked list. 50 * read chunk(s), encoded as a linked list.
51 */ 51 */
52struct rpcrdma_read_chunk { 52struct rpcrdma_read_chunk {
53 uint32_t rc_discrim; /* 1 indicates presence */ 53 __be32 rc_discrim; /* 1 indicates presence */
54 uint32_t rc_position; /* Position in XDR stream */ 54 __be32 rc_position; /* Position in XDR stream */
55 struct rpcrdma_segment rc_target; 55 struct rpcrdma_segment rc_target;
56}; 56};
57 57
@@ -66,29 +66,29 @@ struct rpcrdma_write_chunk {
66 * write chunk(s), encoded as a counted array. 66 * write chunk(s), encoded as a counted array.
67 */ 67 */
68struct rpcrdma_write_array { 68struct rpcrdma_write_array {
69 uint32_t wc_discrim; /* 1 indicates presence */ 69 __be32 wc_discrim; /* 1 indicates presence */
70 uint32_t wc_nchunks; /* Array count */ 70 __be32 wc_nchunks; /* Array count */
71 struct rpcrdma_write_chunk wc_array[0]; 71 struct rpcrdma_write_chunk wc_array[0];
72}; 72};
73 73
74struct rpcrdma_msg { 74struct rpcrdma_msg {
75 uint32_t rm_xid; /* Mirrors the RPC header xid */ 75 __be32 rm_xid; /* Mirrors the RPC header xid */
76 uint32_t rm_vers; /* Version of this protocol */ 76 __be32 rm_vers; /* Version of this protocol */
77 uint32_t rm_credit; /* Buffers requested/granted */ 77 __be32 rm_credit; /* Buffers requested/granted */
78 uint32_t rm_type; /* Type of message (enum rpcrdma_proc) */ 78 __be32 rm_type; /* Type of message (enum rpcrdma_proc) */
79 union { 79 union {
80 80
81 struct { /* no chunks */ 81 struct { /* no chunks */
82 uint32_t rm_empty[3]; /* 3 empty chunk lists */ 82 __be32 rm_empty[3]; /* 3 empty chunk lists */
83 } rm_nochunks; 83 } rm_nochunks;
84 84
85 struct { /* no chunks and padded */ 85 struct { /* no chunks and padded */
86 uint32_t rm_align; /* Padding alignment */ 86 __be32 rm_align; /* Padding alignment */
87 uint32_t rm_thresh; /* Padding threshold */ 87 __be32 rm_thresh; /* Padding threshold */
88 uint32_t rm_pempty[3]; /* 3 empty chunk lists */ 88 __be32 rm_pempty[3]; /* 3 empty chunk lists */
89 } rm_padded; 89 } rm_padded;
90 90
91 uint32_t rm_chunks[0]; /* read, write and reply chunks */ 91 __be32 rm_chunks[0]; /* read, write and reply chunks */
92 92
93 } rm_body; 93 } rm_body;
94}; 94};
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 8ea077db0099..f689f02e6793 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -56,8 +56,6 @@ struct rpc_task {
56 __u8 tk_garb_retry; 56 __u8 tk_garb_retry;
57 __u8 tk_cred_retry; 57 __u8 tk_cred_retry;
58 58
59 unsigned long tk_cookie; /* Cookie for batching tasks */
60
61 /* 59 /*
62 * timeout_fn to be executed by timer bottom half 60 * timeout_fn to be executed by timer bottom half
63 * callback to be executed after waking up 61 * callback to be executed after waking up
@@ -78,7 +76,6 @@ struct rpc_task {
78 struct timer_list tk_timer; /* kernel timer */ 76 struct timer_list tk_timer; /* kernel timer */
79 unsigned long tk_timeout; /* timeout for rpc_sleep() */ 77 unsigned long tk_timeout; /* timeout for rpc_sleep() */
80 unsigned short tk_flags; /* misc flags */ 78 unsigned short tk_flags; /* misc flags */
81 unsigned char tk_priority : 2;/* Task priority */
82 unsigned long tk_runstate; /* Task run status */ 79 unsigned long tk_runstate; /* Task run status */
83 struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could 80 struct workqueue_struct *tk_workqueue; /* Normally rpciod, but could
84 * be any workqueue 81 * be any workqueue
@@ -94,6 +91,9 @@ struct rpc_task {
94 unsigned long tk_start; /* RPC task init timestamp */ 91 unsigned long tk_start; /* RPC task init timestamp */
95 long tk_rtt; /* round-trip time (jiffies) */ 92 long tk_rtt; /* round-trip time (jiffies) */
96 93
94 pid_t tk_owner; /* Process id for batching tasks */
95 unsigned char tk_priority : 2;/* Task priority */
96
97#ifdef RPC_DEBUG 97#ifdef RPC_DEBUG
98 unsigned short tk_pid; /* debugging aid */ 98 unsigned short tk_pid; /* debugging aid */
99#endif 99#endif
@@ -117,6 +117,15 @@ struct rpc_call_ops {
117 void (*rpc_release)(void *); 117 void (*rpc_release)(void *);
118}; 118};
119 119
120struct rpc_task_setup {
121 struct rpc_task *task;
122 struct rpc_clnt *rpc_client;
123 const struct rpc_message *rpc_message;
124 const struct rpc_call_ops *callback_ops;
125 void *callback_data;
126 unsigned short flags;
127 signed char priority;
128};
120 129
121/* 130/*
122 * RPC task flags 131 * RPC task flags
@@ -128,7 +137,6 @@ struct rpc_call_ops {
128#define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */ 137#define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */
129#define RPC_TASK_KILLED 0x0100 /* task was killed */ 138#define RPC_TASK_KILLED 0x0100 /* task was killed */
130#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */ 139#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */
131#define RPC_TASK_NOINTR 0x0400 /* uninterruptible task */
132 140
133#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) 141#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC)
134#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) 142#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER)
@@ -136,7 +144,6 @@ struct rpc_call_ops {
136#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED) 144#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED)
137#define RPC_DO_CALLBACK(t) ((t)->tk_callback != NULL) 145#define RPC_DO_CALLBACK(t) ((t)->tk_callback != NULL)
138#define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT) 146#define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT)
139#define RPC_TASK_UNINTERRUPTIBLE(t) ((t)->tk_flags & RPC_TASK_NOINTR)
140 147
141#define RPC_TASK_RUNNING 0 148#define RPC_TASK_RUNNING 0
142#define RPC_TASK_QUEUED 1 149#define RPC_TASK_QUEUED 1
@@ -180,10 +187,10 @@ struct rpc_call_ops {
180 * Note: if you change these, you must also change 187 * Note: if you change these, you must also change
181 * the task initialization definitions below. 188 * the task initialization definitions below.
182 */ 189 */
183#define RPC_PRIORITY_LOW 0 190#define RPC_PRIORITY_LOW (-1)
184#define RPC_PRIORITY_NORMAL 1 191#define RPC_PRIORITY_NORMAL (0)
185#define RPC_PRIORITY_HIGH 2 192#define RPC_PRIORITY_HIGH (1)
186#define RPC_NR_PRIORITY (RPC_PRIORITY_HIGH+1) 193#define RPC_NR_PRIORITY (1 + RPC_PRIORITY_HIGH - RPC_PRIORITY_LOW)
187 194
188/* 195/*
189 * RPC synchronization objects 196 * RPC synchronization objects
@@ -191,7 +198,7 @@ struct rpc_call_ops {
191struct rpc_wait_queue { 198struct rpc_wait_queue {
192 spinlock_t lock; 199 spinlock_t lock;
193 struct list_head tasks[RPC_NR_PRIORITY]; /* task queue for each priority level */ 200 struct list_head tasks[RPC_NR_PRIORITY]; /* task queue for each priority level */
194 unsigned long cookie; /* cookie of last task serviced */ 201 pid_t owner; /* process id of last task serviced */
195 unsigned char maxpriority; /* maximum priority (0 if queue is not a priority queue) */ 202 unsigned char maxpriority; /* maximum priority (0 if queue is not a priority queue) */
196 unsigned char priority; /* current priority */ 203 unsigned char priority; /* current priority */
197 unsigned char count; /* # task groups remaining serviced so far */ 204 unsigned char count; /* # task groups remaining serviced so far */
@@ -208,41 +215,13 @@ struct rpc_wait_queue {
208 * performance of NFS operations such as read/write. 215 * performance of NFS operations such as read/write.
209 */ 216 */
210#define RPC_BATCH_COUNT 16 217#define RPC_BATCH_COUNT 16
211
212#ifndef RPC_DEBUG
213# define RPC_WAITQ_INIT(var,qname) { \
214 .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
215 .tasks = { \
216 [0] = LIST_HEAD_INIT(var.tasks[0]), \
217 [1] = LIST_HEAD_INIT(var.tasks[1]), \
218 [2] = LIST_HEAD_INIT(var.tasks[2]), \
219 }, \
220 }
221#else
222# define RPC_WAITQ_INIT(var,qname) { \
223 .lock = __SPIN_LOCK_UNLOCKED(var.lock), \
224 .tasks = { \
225 [0] = LIST_HEAD_INIT(var.tasks[0]), \
226 [1] = LIST_HEAD_INIT(var.tasks[1]), \
227 [2] = LIST_HEAD_INIT(var.tasks[2]), \
228 }, \
229 .name = qname, \
230 }
231#endif
232# define RPC_WAITQ(var,qname) struct rpc_wait_queue var = RPC_WAITQ_INIT(var,qname)
233
234#define RPC_IS_PRIORITY(q) ((q)->maxpriority > 0) 218#define RPC_IS_PRIORITY(q) ((q)->maxpriority > 0)
235 219
236/* 220/*
237 * Function prototypes 221 * Function prototypes
238 */ 222 */
239struct rpc_task *rpc_new_task(struct rpc_clnt *, int flags, 223struct rpc_task *rpc_new_task(const struct rpc_task_setup *);
240 const struct rpc_call_ops *ops, void *data); 224struct rpc_task *rpc_run_task(const struct rpc_task_setup *);
241struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
242 const struct rpc_call_ops *ops, void *data);
243void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt,
244 int flags, const struct rpc_call_ops *ops,
245 void *data);
246void rpc_put_task(struct rpc_task *); 225void rpc_put_task(struct rpc_task *);
247void rpc_exit_task(struct rpc_task *); 226void rpc_exit_task(struct rpc_task *);
248void rpc_release_calldata(const struct rpc_call_ops *, void *); 227void rpc_release_calldata(const struct rpc_call_ops *, void *);
diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
index 8531a70da73d..64c771056187 100644
--- a/include/linux/sunrpc/svc.h
+++ b/include/linux/sunrpc/svc.h
@@ -204,7 +204,7 @@ union svc_addr_u {
204struct svc_rqst { 204struct svc_rqst {
205 struct list_head rq_list; /* idle list */ 205 struct list_head rq_list; /* idle list */
206 struct list_head rq_all; /* all threads list */ 206 struct list_head rq_all; /* all threads list */
207 struct svc_sock * rq_sock; /* socket */ 207 struct svc_xprt * rq_xprt; /* transport ptr */
208 struct sockaddr_storage rq_addr; /* peer address */ 208 struct sockaddr_storage rq_addr; /* peer address */
209 size_t rq_addrlen; 209 size_t rq_addrlen;
210 210
@@ -214,9 +214,10 @@ struct svc_rqst {
214 struct auth_ops * rq_authop; /* authentication flavour */ 214 struct auth_ops * rq_authop; /* authentication flavour */
215 u32 rq_flavor; /* pseudoflavor */ 215 u32 rq_flavor; /* pseudoflavor */
216 struct svc_cred rq_cred; /* auth info */ 216 struct svc_cred rq_cred; /* auth info */
217 struct sk_buff * rq_skbuff; /* fast recv inet buffer */ 217 void * rq_xprt_ctxt; /* transport specific context ptr */
218 struct svc_deferred_req*rq_deferred; /* deferred request we are replaying */ 218 struct svc_deferred_req*rq_deferred; /* deferred request we are replaying */
219 219
220 size_t rq_xprt_hlen; /* xprt header len */
220 struct xdr_buf rq_arg; 221 struct xdr_buf rq_arg;
221 struct xdr_buf rq_res; 222 struct xdr_buf rq_res;
222 struct page * rq_pages[RPCSVC_MAXPAGES]; 223 struct page * rq_pages[RPCSVC_MAXPAGES];
@@ -317,11 +318,12 @@ static inline void svc_free_res_pages(struct svc_rqst *rqstp)
317 318
318struct svc_deferred_req { 319struct svc_deferred_req {
319 u32 prot; /* protocol (UDP or TCP) */ 320 u32 prot; /* protocol (UDP or TCP) */
320 struct svc_sock *svsk; 321 struct svc_xprt *xprt;
321 struct sockaddr_storage addr; /* where reply must go */ 322 struct sockaddr_storage addr; /* where reply must go */
322 size_t addrlen; 323 size_t addrlen;
323 union svc_addr_u daddr; /* where reply must come from */ 324 union svc_addr_u daddr; /* where reply must come from */
324 struct cache_deferred_req handle; 325 struct cache_deferred_req handle;
326 size_t xprt_hlen;
325 int argslen; 327 int argslen;
326 __be32 args[0]; 328 __be32 args[0];
327}; 329};
@@ -382,6 +384,8 @@ struct svc_procedure {
382 */ 384 */
383struct svc_serv * svc_create(struct svc_program *, unsigned int, 385struct svc_serv * svc_create(struct svc_program *, unsigned int,
384 void (*shutdown)(struct svc_serv*)); 386 void (*shutdown)(struct svc_serv*));
387struct svc_rqst *svc_prepare_thread(struct svc_serv *serv,
388 struct svc_pool *pool);
385int svc_create_thread(svc_thread_fn, struct svc_serv *); 389int svc_create_thread(svc_thread_fn, struct svc_serv *);
386void svc_exit_thread(struct svc_rqst *); 390void svc_exit_thread(struct svc_rqst *);
387struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int, 391struct svc_serv * svc_create_pooled(struct svc_program *, unsigned int,
diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
new file mode 100644
index 000000000000..c11bbcc081f9
--- /dev/null
+++ b/include/linux/sunrpc/svc_rdma.h
@@ -0,0 +1,262 @@
1/*
2 * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the BSD-type
8 * license below:
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 *
17 * Redistributions in binary form must reproduce the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided
20 * with the distribution.
21 *
22 * Neither the name of the Network Appliance, Inc. nor the names of
23 * its contributors may be used to endorse or promote products
24 * derived from this software without specific prior written
25 * permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 *
39 * Author: Tom Tucker <tom@opengridcomputing.com>
40 */
41
42#ifndef SVC_RDMA_H
43#define SVC_RDMA_H
44#include <linux/sunrpc/xdr.h>
45#include <linux/sunrpc/svcsock.h>
46#include <linux/sunrpc/rpc_rdma.h>
47#include <rdma/ib_verbs.h>
48#include <rdma/rdma_cm.h>
49#define SVCRDMA_DEBUG
50
51/* RPC/RDMA parameters and stats */
52extern unsigned int svcrdma_ord;
53extern unsigned int svcrdma_max_requests;
54extern unsigned int svcrdma_max_req_size;
55
56extern atomic_t rdma_stat_recv;
57extern atomic_t rdma_stat_read;
58extern atomic_t rdma_stat_write;
59extern atomic_t rdma_stat_sq_starve;
60extern atomic_t rdma_stat_rq_starve;
61extern atomic_t rdma_stat_rq_poll;
62extern atomic_t rdma_stat_rq_prod;
63extern atomic_t rdma_stat_sq_poll;
64extern atomic_t rdma_stat_sq_prod;
65
66#define RPCRDMA_VERSION 1
67
68/*
69 * Contexts are built when an RDMA request is created and are a
70 * record of the resources that can be recovered when the request
71 * completes.
72 */
73struct svc_rdma_op_ctxt {
74 struct svc_rdma_op_ctxt *next;
75 struct xdr_buf arg;
76 struct list_head dto_q;
77 enum ib_wr_opcode wr_op;
78 enum ib_wc_status wc_status;
79 u32 byte_len;
80 struct svcxprt_rdma *xprt;
81 unsigned long flags;
82 enum dma_data_direction direction;
83 int count;
84 struct ib_sge sge[RPCSVC_MAXPAGES];
85 struct page *pages[RPCSVC_MAXPAGES];
86};
87
88#define RDMACTXT_F_READ_DONE 1
89#define RDMACTXT_F_LAST_CTXT 2
90
91struct svcxprt_rdma {
92 struct svc_xprt sc_xprt; /* SVC transport structure */
93 struct rdma_cm_id *sc_cm_id; /* RDMA connection id */
94 struct list_head sc_accept_q; /* Conn. waiting accept */
95 int sc_ord; /* RDMA read limit */
96 wait_queue_head_t sc_read_wait;
97 int sc_max_sge;
98
99 int sc_sq_depth; /* Depth of SQ */
100 atomic_t sc_sq_count; /* Number of SQ WR on queue */
101
102 int sc_max_requests; /* Depth of RQ */
103 int sc_max_req_size; /* Size of each RQ WR buf */
104
105 struct ib_pd *sc_pd;
106
107 struct svc_rdma_op_ctxt *sc_ctxt_head;
108 int sc_ctxt_cnt;
109 int sc_ctxt_bump;
110 int sc_ctxt_max;
111 spinlock_t sc_ctxt_lock;
112 struct list_head sc_rq_dto_q;
113 spinlock_t sc_rq_dto_lock;
114 struct ib_qp *sc_qp;
115 struct ib_cq *sc_rq_cq;
116 struct ib_cq *sc_sq_cq;
117 struct ib_mr *sc_phys_mr; /* MR for server memory */
118
119 spinlock_t sc_lock; /* transport lock */
120
121 wait_queue_head_t sc_send_wait; /* SQ exhaustion waitlist */
122 unsigned long sc_flags;
123 struct list_head sc_dto_q; /* DTO tasklet I/O pending Q */
124 struct list_head sc_read_complete_q;
125 spinlock_t sc_read_complete_lock;
126};
127/* sc_flags */
128#define RDMAXPRT_RQ_PENDING 1
129#define RDMAXPRT_SQ_PENDING 2
130#define RDMAXPRT_CONN_PENDING 3
131
132#define RPCRDMA_LISTEN_BACKLOG 10
133/* The default ORD value is based on two outstanding full-size writes with a
134 * page size of 4k, or 32k * 2 ops / 4k = 16 outstanding RDMA_READ. */
135#define RPCRDMA_ORD (64/4)
136#define RPCRDMA_SQ_DEPTH_MULT 8
137#define RPCRDMA_MAX_THREADS 16
138#define RPCRDMA_MAX_REQUESTS 16
139#define RPCRDMA_MAX_REQ_SIZE 4096
140
141/* svc_rdma_marshal.c */
142extern void svc_rdma_rcl_chunk_counts(struct rpcrdma_read_chunk *,
143 int *, int *);
144extern int svc_rdma_xdr_decode_req(struct rpcrdma_msg **, struct svc_rqst *);
145extern int svc_rdma_xdr_decode_deferred_req(struct svc_rqst *);
146extern int svc_rdma_xdr_encode_error(struct svcxprt_rdma *,
147 struct rpcrdma_msg *,
148 enum rpcrdma_errcode, u32 *);
149extern void svc_rdma_xdr_encode_write_list(struct rpcrdma_msg *, int);
150extern void svc_rdma_xdr_encode_reply_array(struct rpcrdma_write_array *, int);
151extern void svc_rdma_xdr_encode_array_chunk(struct rpcrdma_write_array *, int,
152 u32, u64, u32);
153extern void svc_rdma_xdr_encode_reply_header(struct svcxprt_rdma *,
154 struct rpcrdma_msg *,
155 struct rpcrdma_msg *,
156 enum rpcrdma_proc);
157extern int svc_rdma_xdr_get_reply_hdr_len(struct rpcrdma_msg *);
158
159/* svc_rdma_recvfrom.c */
160extern int svc_rdma_recvfrom(struct svc_rqst *);
161
162/* svc_rdma_sendto.c */
163extern int svc_rdma_sendto(struct svc_rqst *);
164
165/* svc_rdma_transport.c */
166extern int svc_rdma_send(struct svcxprt_rdma *, struct ib_send_wr *);
167extern int svc_rdma_send_error(struct svcxprt_rdma *, struct rpcrdma_msg *,
168 enum rpcrdma_errcode);
169struct page *svc_rdma_get_page(void);
170extern int svc_rdma_post_recv(struct svcxprt_rdma *);
171extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
172extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
173extern void svc_rdma_put_context(struct svc_rdma_op_ctxt *, int);
174extern void svc_sq_reap(struct svcxprt_rdma *);
175extern void svc_rq_reap(struct svcxprt_rdma *);
176extern struct svc_xprt_class svc_rdma_class;
177extern void svc_rdma_prep_reply_hdr(struct svc_rqst *);
178
179/* svc_rdma.c */
180extern int svc_rdma_init(void);
181extern void svc_rdma_cleanup(void);
182
183/*
184 * Returns the address of the first read chunk or <nul> if no read chunk is
185 * present
186 */
187static inline struct rpcrdma_read_chunk *
188svc_rdma_get_read_chunk(struct rpcrdma_msg *rmsgp)
189{
190 struct rpcrdma_read_chunk *ch =
191 (struct rpcrdma_read_chunk *)&rmsgp->rm_body.rm_chunks[0];
192
193 if (ch->rc_discrim == 0)
194 return NULL;
195
196 return ch;
197}
198
199/*
200 * Returns the address of the first read write array element or <nul> if no
201 * write array list is present
202 */
203static inline struct rpcrdma_write_array *
204svc_rdma_get_write_array(struct rpcrdma_msg *rmsgp)
205{
206 if (rmsgp->rm_body.rm_chunks[0] != 0
207 || rmsgp->rm_body.rm_chunks[1] == 0)
208 return NULL;
209
210 return (struct rpcrdma_write_array *)&rmsgp->rm_body.rm_chunks[1];
211}
212
213/*
214 * Returns the address of the first reply array element or <nul> if no
215 * reply array is present
216 */
217static inline struct rpcrdma_write_array *
218svc_rdma_get_reply_array(struct rpcrdma_msg *rmsgp)
219{
220 struct rpcrdma_read_chunk *rch;
221 struct rpcrdma_write_array *wr_ary;
222 struct rpcrdma_write_array *rp_ary;
223
224 /* XXX: Need to fix when reply list may occur with read-list and/or
225 * write list */
226 if (rmsgp->rm_body.rm_chunks[0] != 0 ||
227 rmsgp->rm_body.rm_chunks[1] != 0)
228 return NULL;
229
230 rch = svc_rdma_get_read_chunk(rmsgp);
231 if (rch) {
232 while (rch->rc_discrim)
233 rch++;
234
235 /* The reply list follows an empty write array located
236 * at 'rc_position' here. The reply array is at rc_target.
237 */
238 rp_ary = (struct rpcrdma_write_array *)&rch->rc_target;
239
240 goto found_it;
241 }
242
243 wr_ary = svc_rdma_get_write_array(rmsgp);
244 if (wr_ary) {
245 rp_ary = (struct rpcrdma_write_array *)
246 &wr_ary->
247 wc_array[wr_ary->wc_nchunks].wc_target.rs_length;
248
249 goto found_it;
250 }
251
252 /* No read list, no write list */
253 rp_ary = (struct rpcrdma_write_array *)
254 &rmsgp->rm_body.rm_chunks[2];
255
256 found_it:
257 if (rp_ary->wc_discrim == 0)
258 return NULL;
259
260 return rp_ary;
261}
262#endif
diff --git a/include/linux/sunrpc/svc_xprt.h b/include/linux/sunrpc/svc_xprt.h
new file mode 100644
index 000000000000..6fd7b016517f
--- /dev/null
+++ b/include/linux/sunrpc/svc_xprt.h
@@ -0,0 +1,159 @@
1/*
2 * linux/include/linux/sunrpc/svc_xprt.h
3 *
4 * RPC server transport I/O
5 */
6
7#ifndef SUNRPC_SVC_XPRT_H
8#define SUNRPC_SVC_XPRT_H
9
10#include <linux/sunrpc/svc.h>
11#include <linux/module.h>
12
13struct svc_xprt_ops {
14 struct svc_xprt *(*xpo_create)(struct svc_serv *,
15 struct sockaddr *, int,
16 int);
17 struct svc_xprt *(*xpo_accept)(struct svc_xprt *);
18 int (*xpo_has_wspace)(struct svc_xprt *);
19 int (*xpo_recvfrom)(struct svc_rqst *);
20 void (*xpo_prep_reply_hdr)(struct svc_rqst *);
21 int (*xpo_sendto)(struct svc_rqst *);
22 void (*xpo_release_rqst)(struct svc_rqst *);
23 void (*xpo_detach)(struct svc_xprt *);
24 void (*xpo_free)(struct svc_xprt *);
25};
26
27struct svc_xprt_class {
28 const char *xcl_name;
29 struct module *xcl_owner;
30 struct svc_xprt_ops *xcl_ops;
31 struct list_head xcl_list;
32 u32 xcl_max_payload;
33};
34
35struct svc_xprt {
36 struct svc_xprt_class *xpt_class;
37 struct svc_xprt_ops *xpt_ops;
38 struct kref xpt_ref;
39 struct list_head xpt_list;
40 struct list_head xpt_ready;
41 unsigned long xpt_flags;
42#define XPT_BUSY 0 /* enqueued/receiving */
43#define XPT_CONN 1 /* conn pending */
44#define XPT_CLOSE 2 /* dead or dying */
45#define XPT_DATA 3 /* data pending */
46#define XPT_TEMP 4 /* connected transport */
47#define XPT_DEAD 6 /* transport closed */
48#define XPT_CHNGBUF 7 /* need to change snd/rcv buf sizes */
49#define XPT_DEFERRED 8 /* deferred request pending */
50#define XPT_OLD 9 /* used for xprt aging mark+sweep */
51#define XPT_DETACHED 10 /* detached from tempsocks list */
52#define XPT_LISTENER 11 /* listening endpoint */
53#define XPT_CACHE_AUTH 12 /* cache auth info */
54
55 struct svc_pool *xpt_pool; /* current pool iff queued */
56 struct svc_serv *xpt_server; /* service for transport */
57 atomic_t xpt_reserved; /* space on outq that is rsvd */
58 struct mutex xpt_mutex; /* to serialize sending data */
59 spinlock_t xpt_lock; /* protects sk_deferred
60 * and xpt_auth_cache */
61 void *xpt_auth_cache;/* auth cache */
62 struct list_head xpt_deferred; /* deferred requests that need
63 * to be revisted */
64 struct sockaddr_storage xpt_local; /* local address */
65 size_t xpt_locallen; /* length of address */
66 struct sockaddr_storage xpt_remote; /* remote peer's address */
67 size_t xpt_remotelen; /* length of address */
68};
69
70int svc_reg_xprt_class(struct svc_xprt_class *);
71void svc_unreg_xprt_class(struct svc_xprt_class *);
72void svc_xprt_init(struct svc_xprt_class *, struct svc_xprt *,
73 struct svc_serv *);
74int svc_create_xprt(struct svc_serv *, char *, unsigned short, int);
75void svc_xprt_enqueue(struct svc_xprt *xprt);
76void svc_xprt_received(struct svc_xprt *);
77void svc_xprt_put(struct svc_xprt *xprt);
78void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt);
79void svc_close_xprt(struct svc_xprt *xprt);
80void svc_delete_xprt(struct svc_xprt *xprt);
81int svc_port_is_privileged(struct sockaddr *sin);
82int svc_print_xprts(char *buf, int maxlen);
83struct svc_xprt *svc_find_xprt(struct svc_serv *, char *, int, int);
84int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen);
85
86static inline void svc_xprt_get(struct svc_xprt *xprt)
87{
88 kref_get(&xprt->xpt_ref);
89}
90static inline void svc_xprt_set_local(struct svc_xprt *xprt,
91 struct sockaddr *sa, int salen)
92{
93 memcpy(&xprt->xpt_local, sa, salen);
94 xprt->xpt_locallen = salen;
95}
96static inline void svc_xprt_set_remote(struct svc_xprt *xprt,
97 struct sockaddr *sa, int salen)
98{
99 memcpy(&xprt->xpt_remote, sa, salen);
100 xprt->xpt_remotelen = salen;
101}
102static inline unsigned short svc_addr_port(struct sockaddr *sa)
103{
104 unsigned short ret = 0;
105 switch (sa->sa_family) {
106 case AF_INET:
107 ret = ntohs(((struct sockaddr_in *)sa)->sin_port);
108 break;
109 case AF_INET6:
110 ret = ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
111 break;
112 }
113 return ret;
114}
115
116static inline size_t svc_addr_len(struct sockaddr *sa)
117{
118 switch (sa->sa_family) {
119 case AF_INET:
120 return sizeof(struct sockaddr_in);
121 case AF_INET6:
122 return sizeof(struct sockaddr_in6);
123 }
124 return -EAFNOSUPPORT;
125}
126
127static inline unsigned short svc_xprt_local_port(struct svc_xprt *xprt)
128{
129 return svc_addr_port((struct sockaddr *)&xprt->xpt_local);
130}
131
132static inline unsigned short svc_xprt_remote_port(struct svc_xprt *xprt)
133{
134 return svc_addr_port((struct sockaddr *)&xprt->xpt_remote);
135}
136
137static inline char *__svc_print_addr(struct sockaddr *addr,
138 char *buf, size_t len)
139{
140 switch (addr->sa_family) {
141 case AF_INET:
142 snprintf(buf, len, "%u.%u.%u.%u, port=%u",
143 NIPQUAD(((struct sockaddr_in *) addr)->sin_addr),
144 ntohs(((struct sockaddr_in *) addr)->sin_port));
145 break;
146
147 case AF_INET6:
148 snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x, port=%u",
149 NIP6(((struct sockaddr_in6 *) addr)->sin6_addr),
150 ntohs(((struct sockaddr_in6 *) addr)->sin6_port));
151 break;
152
153 default:
154 snprintf(buf, len, "unknown address type: %d", addr->sa_family);
155 break;
156 }
157 return buf;
158}
159#endif /* SUNRPC_SVC_XPRT_H */
diff --git a/include/linux/sunrpc/svcsock.h b/include/linux/sunrpc/svcsock.h
index a53e0fa855d2..206f092ad4c7 100644
--- a/include/linux/sunrpc/svcsock.h
+++ b/include/linux/sunrpc/svcsock.h
@@ -10,42 +10,16 @@
10#define SUNRPC_SVCSOCK_H 10#define SUNRPC_SVCSOCK_H
11 11
12#include <linux/sunrpc/svc.h> 12#include <linux/sunrpc/svc.h>
13#include <linux/sunrpc/svc_xprt.h>
13 14
14/* 15/*
15 * RPC server socket. 16 * RPC server socket.
16 */ 17 */
17struct svc_sock { 18struct svc_sock {
18 struct list_head sk_ready; /* list of ready sockets */ 19 struct svc_xprt sk_xprt;
19 struct list_head sk_list; /* list of all sockets */
20 struct socket * sk_sock; /* berkeley socket layer */ 20 struct socket * sk_sock; /* berkeley socket layer */
21 struct sock * sk_sk; /* INET layer */ 21 struct sock * sk_sk; /* INET layer */
22 22
23 struct svc_pool * sk_pool; /* current pool iff queued */
24 struct svc_serv * sk_server; /* service for this socket */
25 atomic_t sk_inuse; /* use count */
26 unsigned long sk_flags;
27#define SK_BUSY 0 /* enqueued/receiving */
28#define SK_CONN 1 /* conn pending */
29#define SK_CLOSE 2 /* dead or dying */
30#define SK_DATA 3 /* data pending */
31#define SK_TEMP 4 /* temp (TCP) socket */
32#define SK_DEAD 6 /* socket closed */
33#define SK_CHNGBUF 7 /* need to change snd/rcv buffer sizes */
34#define SK_DEFERRED 8 /* request on sk_deferred */
35#define SK_OLD 9 /* used for temp socket aging mark+sweep */
36#define SK_DETACHED 10 /* detached from tempsocks list */
37
38 atomic_t sk_reserved; /* space on outq that is reserved */
39
40 spinlock_t sk_lock; /* protects sk_deferred and
41 * sk_info_authunix */
42 struct list_head sk_deferred; /* deferred requests that need to
43 * be revisted */
44 struct mutex sk_mutex; /* to serialize sending data */
45
46 int (*sk_recvfrom)(struct svc_rqst *rqstp);
47 int (*sk_sendto)(struct svc_rqst *rqstp);
48
49 /* We keep the old state_change and data_ready CB's here */ 23 /* We keep the old state_change and data_ready CB's here */
50 void (*sk_ostate)(struct sock *); 24 void (*sk_ostate)(struct sock *);
51 void (*sk_odata)(struct sock *, int bytes); 25 void (*sk_odata)(struct sock *, int bytes);
@@ -54,21 +28,12 @@ struct svc_sock {
54 /* private TCP part */ 28 /* private TCP part */
55 int sk_reclen; /* length of record */ 29 int sk_reclen; /* length of record */
56 int sk_tcplen; /* current read length */ 30 int sk_tcplen; /* current read length */
57 time_t sk_lastrecv; /* time of last received request */
58
59 /* cache of various info for TCP sockets */
60 void *sk_info_authunix;
61
62 struct sockaddr_storage sk_local; /* local address */
63 struct sockaddr_storage sk_remote; /* remote peer's address */
64 int sk_remotelen; /* length of address */
65}; 31};
66 32
67/* 33/*
68 * Function prototypes. 34 * Function prototypes.
69 */ 35 */
70int svc_makesock(struct svc_serv *, int, unsigned short, int flags); 36void svc_close_all(struct list_head *);
71void svc_force_close_socket(struct svc_sock *);
72int svc_recv(struct svc_rqst *, long); 37int svc_recv(struct svc_rqst *, long);
73int svc_send(struct svc_rqst *); 38int svc_send(struct svc_rqst *);
74void svc_drop(struct svc_rqst *); 39void svc_drop(struct svc_rqst *);
@@ -78,6 +43,8 @@ int svc_addsock(struct svc_serv *serv,
78 int fd, 43 int fd,
79 char *name_return, 44 char *name_return,
80 int *proto); 45 int *proto);
46void svc_init_xprt_sock(void);
47void svc_cleanup_xprt_sock(void);
81 48
82/* 49/*
83 * svc_makesock socket characteristics 50 * svc_makesock socket characteristics
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h
index 0751c9464d0f..e4057d729f03 100644
--- a/include/linux/sunrpc/xdr.h
+++ b/include/linux/sunrpc/xdr.h
@@ -112,7 +112,8 @@ struct xdr_buf {
112__be32 *xdr_encode_opaque_fixed(__be32 *p, const void *ptr, unsigned int len); 112__be32 *xdr_encode_opaque_fixed(__be32 *p, const void *ptr, unsigned int len);
113__be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int len); 113__be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int len);
114__be32 *xdr_encode_string(__be32 *p, const char *s); 114__be32 *xdr_encode_string(__be32 *p, const char *s);
115__be32 *xdr_decode_string_inplace(__be32 *p, char **sp, int *lenp, int maxlen); 115__be32 *xdr_decode_string_inplace(__be32 *p, char **sp, unsigned int *lenp,
116 unsigned int maxlen);
116__be32 *xdr_encode_netobj(__be32 *p, const struct xdr_netobj *); 117__be32 *xdr_encode_netobj(__be32 *p, const struct xdr_netobj *);
117__be32 *xdr_decode_netobj(__be32 *p, struct xdr_netobj *); 118__be32 *xdr_decode_netobj(__be32 *p, struct xdr_netobj *);
118 119
diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h
index 30b17b3bc1a9..b3ff9a815e6f 100644
--- a/include/linux/sunrpc/xprt.h
+++ b/include/linux/sunrpc/xprt.h
@@ -120,7 +120,7 @@ struct rpc_xprt {
120 struct kref kref; /* Reference count */ 120 struct kref kref; /* Reference count */
121 struct rpc_xprt_ops * ops; /* transport methods */ 121 struct rpc_xprt_ops * ops; /* transport methods */
122 122
123 struct rpc_timeout timeout; /* timeout parms */ 123 const struct rpc_timeout *timeout; /* timeout parms */
124 struct sockaddr_storage addr; /* server address */ 124 struct sockaddr_storage addr; /* server address */
125 size_t addrlen; /* size of server address */ 125 size_t addrlen; /* size of server address */
126 int prot; /* IP protocol */ 126 int prot; /* IP protocol */
@@ -183,7 +183,7 @@ struct rpc_xprt {
183 bklog_u; /* backlog queue utilization */ 183 bklog_u; /* backlog queue utilization */
184 } stat; 184 } stat;
185 185
186 char * address_strings[RPC_DISPLAY_MAX]; 186 const char *address_strings[RPC_DISPLAY_MAX];
187}; 187};
188 188
189struct xprt_create { 189struct xprt_create {
@@ -191,7 +191,6 @@ struct xprt_create {
191 struct sockaddr * srcaddr; /* optional local address */ 191 struct sockaddr * srcaddr; /* optional local address */
192 struct sockaddr * dstaddr; /* remote peer address */ 192 struct sockaddr * dstaddr; /* remote peer address */
193 size_t addrlen; 193 size_t addrlen;
194 struct rpc_timeout * timeout; /* optional timeout parameters */
195}; 194};
196 195
197struct xprt_class { 196struct xprt_class {
@@ -203,11 +202,6 @@ struct xprt_class {
203}; 202};
204 203
205/* 204/*
206 * Transport operations used by ULPs
207 */
208void xprt_set_timeout(struct rpc_timeout *to, unsigned int retr, unsigned long incr);
209
210/*
211 * Generic internal transport functions 205 * Generic internal transport functions
212 */ 206 */
213struct rpc_xprt *xprt_create_transport(struct xprt_create *args); 207struct rpc_xprt *xprt_create_transport(struct xprt_create *args);
@@ -245,7 +239,8 @@ void xprt_adjust_cwnd(struct rpc_task *task, int result);
245struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *xprt, __be32 xid); 239struct rpc_rqst * xprt_lookup_rqst(struct rpc_xprt *xprt, __be32 xid);
246void xprt_complete_rqst(struct rpc_task *task, int copied); 240void xprt_complete_rqst(struct rpc_task *task, int copied);
247void xprt_release_rqst_cong(struct rpc_task *task); 241void xprt_release_rqst_cong(struct rpc_task *task);
248void xprt_disconnect(struct rpc_xprt *xprt); 242void xprt_disconnect_done(struct rpc_xprt *xprt);
243void xprt_force_disconnect(struct rpc_xprt *xprt);
249 244
250/* 245/*
251 * Reserved bit positions in xprt->state 246 * Reserved bit positions in xprt->state
@@ -256,6 +251,7 @@ void xprt_disconnect(struct rpc_xprt *xprt);
256#define XPRT_CLOSE_WAIT (3) 251#define XPRT_CLOSE_WAIT (3)
257#define XPRT_BOUND (4) 252#define XPRT_BOUND (4)
258#define XPRT_BINDING (5) 253#define XPRT_BINDING (5)
254#define XPRT_CLOSING (6)
259 255
260static inline void xprt_set_connected(struct rpc_xprt *xprt) 256static inline void xprt_set_connected(struct rpc_xprt *xprt)
261{ 257{
diff --git a/include/linux/sunrpc/xprtsock.h b/include/linux/sunrpc/xprtsock.h
index 2c6c2c2783d8..c2a46c45c8f7 100644
--- a/include/linux/sunrpc/xprtsock.h
+++ b/include/linux/sunrpc/xprtsock.h
@@ -9,12 +9,6 @@
9 9
10#ifdef __KERNEL__ 10#ifdef __KERNEL__
11 11
12/*
13 * Socket transport setup operations
14 */
15struct rpc_xprt *xs_setup_udp(struct xprt_create *args);
16struct rpc_xprt *xs_setup_tcp(struct xprt_create *args);
17
18int init_socket_xprt(void); 12int init_socket_xprt(void);
19void cleanup_socket_xprt(void); 13void cleanup_socket_xprt(void);
20 14
diff --git a/include/linux/suspend.h b/include/linux/suspend.h
index 4360e0816956..646ce2d068d4 100644
--- a/include/linux/suspend.h
+++ b/include/linux/suspend.h
@@ -38,18 +38,16 @@ typedef int __bitwise suspend_state_t;
38 * There is the %suspend_valid_only_mem function available that can be 38 * There is the %suspend_valid_only_mem function available that can be
39 * assigned to this if the platform only supports mem sleep. 39 * assigned to this if the platform only supports mem sleep.
40 * 40 *
41 * @set_target: Tell the platform which system sleep state is going to be 41 * @begin: Initialise a transition to given system sleep state.
42 * entered. 42 * @begin() is executed right prior to suspending devices. The information
43 * @set_target() is executed right prior to suspending devices. The 43 * conveyed to the platform code by @begin() should be disregarded by it as
44 * information conveyed to the platform code by @set_target() should be 44 * soon as @end() is executed. If @begin() fails (ie. returns nonzero),
45 * disregarded by the platform as soon as @finish() is executed and if
46 * @prepare() fails. If @set_target() fails (ie. returns nonzero),
47 * @prepare(), @enter() and @finish() will not be called by the PM core. 45 * @prepare(), @enter() and @finish() will not be called by the PM core.
48 * This callback is optional. However, if it is implemented, the argument 46 * This callback is optional. However, if it is implemented, the argument
49 * passed to @enter() is meaningless and should be ignored. 47 * passed to @enter() is redundant and should be ignored.
50 * 48 *
51 * @prepare: Prepare the platform for entering the system sleep state indicated 49 * @prepare: Prepare the platform for entering the system sleep state indicated
52 * by @set_target(). 50 * by @begin().
53 * @prepare() is called right after devices have been suspended (ie. the 51 * @prepare() is called right after devices have been suspended (ie. the
54 * appropriate .suspend() method has been executed for each device) and 52 * appropriate .suspend() method has been executed for each device) and
55 * before the nonboot CPUs are disabled (it is executed with IRQs enabled). 53 * before the nonboot CPUs are disabled (it is executed with IRQs enabled).
@@ -57,8 +55,8 @@ typedef int __bitwise suspend_state_t;
57 * error code otherwise, in which case the system cannot enter the desired 55 * error code otherwise, in which case the system cannot enter the desired
58 * sleep state (@enter() and @finish() will not be called in that case). 56 * sleep state (@enter() and @finish() will not be called in that case).
59 * 57 *
60 * @enter: Enter the system sleep state indicated by @set_target() or 58 * @enter: Enter the system sleep state indicated by @begin() or represented by
61 * represented by the argument if @set_target() is not implemented. 59 * the argument if @begin() is not implemented.
62 * This callback is mandatory. It returns 0 on success or a negative 60 * This callback is mandatory. It returns 0 on success or a negative
63 * error code otherwise, in which case the system cannot enter the desired 61 * error code otherwise, in which case the system cannot enter the desired
64 * sleep state. 62 * sleep state.
@@ -69,13 +67,22 @@ typedef int __bitwise suspend_state_t;
69 * This callback is optional, but should be implemented by the platforms 67 * This callback is optional, but should be implemented by the platforms
70 * that implement @prepare(). If implemented, it is always called after 68 * that implement @prepare(). If implemented, it is always called after
71 * @enter() (even if @enter() fails). 69 * @enter() (even if @enter() fails).
70 *
71 * @end: Called by the PM core right after resuming devices, to indicate to
72 * the platform that the system has returned to the working state or
73 * the transition to the sleep state has been aborted.
74 * This callback is optional, but should be implemented by the platforms
75 * that implement @begin(), but platforms implementing @begin() should
76 * also provide a @end() which cleans up transitions aborted before
77 * @enter().
72 */ 78 */
73struct platform_suspend_ops { 79struct platform_suspend_ops {
74 int (*valid)(suspend_state_t state); 80 int (*valid)(suspend_state_t state);
75 int (*set_target)(suspend_state_t state); 81 int (*begin)(suspend_state_t state);
76 int (*prepare)(void); 82 int (*prepare)(void);
77 int (*enter)(suspend_state_t state); 83 int (*enter)(suspend_state_t state);
78 void (*finish)(void); 84 void (*finish)(void);
85 void (*end)(void);
79}; 86};
80 87
81#ifdef CONFIG_SUSPEND 88#ifdef CONFIG_SUSPEND
@@ -129,14 +136,17 @@ extern void mark_free_pages(struct zone *zone);
129/** 136/**
130 * struct platform_hibernation_ops - hibernation platform support 137 * struct platform_hibernation_ops - hibernation platform support
131 * 138 *
132 * The methods in this structure allow a platform to override the default 139 * The methods in this structure allow a platform to carry out special
133 * mechanism of shutting down the machine during a hibernation transition. 140 * operations required by it during a hibernation transition.
134 * 141 *
135 * All three methods must be assigned. 142 * All the methods below must be implemented.
136 * 143 *
137 * @start: Tell the platform driver that we're starting hibernation. 144 * @begin: Tell the platform driver that we're starting hibernation.
138 * Called right after shrinking memory and before freezing devices. 145 * Called right after shrinking memory and before freezing devices.
139 * 146 *
147 * @end: Called by the PM core right after resuming devices, to indicate to
148 * the platform that the system has returned to the working state.
149 *
140 * @pre_snapshot: Prepare the platform for creating the hibernation image. 150 * @pre_snapshot: Prepare the platform for creating the hibernation image.
141 * Called right after devices have been frozen and before the nonboot 151 * Called right after devices have been frozen and before the nonboot
142 * CPUs are disabled (runs with IRQs on). 152 * CPUs are disabled (runs with IRQs on).
@@ -171,7 +181,8 @@ extern void mark_free_pages(struct zone *zone);
171 * thawing devices (runs with IRQs on). 181 * thawing devices (runs with IRQs on).
172 */ 182 */
173struct platform_hibernation_ops { 183struct platform_hibernation_ops {
174 int (*start)(void); 184 int (*begin)(void);
185 void (*end)(void);
175 int (*pre_snapshot)(void); 186 int (*pre_snapshot)(void);
176 void (*finish)(void); 187 void (*finish)(void);
177 int (*prepare)(void); 188 int (*prepare)(void);
@@ -211,22 +222,10 @@ static inline int hibernate(void) { return -ENOSYS; }
211#ifdef CONFIG_PM_SLEEP 222#ifdef CONFIG_PM_SLEEP
212void save_processor_state(void); 223void save_processor_state(void);
213void restore_processor_state(void); 224void restore_processor_state(void);
214struct saved_context;
215void __save_processor_state(struct saved_context *ctxt);
216void __restore_processor_state(struct saved_context *ctxt);
217 225
218/* kernel/power/main.c */ 226/* kernel/power/main.c */
219extern struct blocking_notifier_head pm_chain_head; 227extern int register_pm_notifier(struct notifier_block *nb);
220 228extern int unregister_pm_notifier(struct notifier_block *nb);
221static inline int register_pm_notifier(struct notifier_block *nb)
222{
223 return blocking_notifier_chain_register(&pm_chain_head, nb);
224}
225
226static inline int unregister_pm_notifier(struct notifier_block *nb)
227{
228 return blocking_notifier_chain_unregister(&pm_chain_head, nb);
229}
230 229
231#define pm_notifier(fn, pri) { \ 230#define pm_notifier(fn, pri) { \
232 static struct notifier_block fn##_nb = \ 231 static struct notifier_block fn##_nb = \
diff --git a/include/linux/suspend_ioctls.h b/include/linux/suspend_ioctls.h
new file mode 100644
index 000000000000..2c6faec96bde
--- /dev/null
+++ b/include/linux/suspend_ioctls.h
@@ -0,0 +1,32 @@
1#ifndef _LINUX_SUSPEND_IOCTLS_H
2#define _LINUX_SUSPEND_IOCTLS_H
3
4/*
5 * This structure is used to pass the values needed for the identification
6 * of the resume swap area from a user space to the kernel via the
7 * SNAPSHOT_SET_SWAP_AREA ioctl
8 */
9struct resume_swap_area {
10 loff_t offset;
11 u_int32_t dev;
12} __attribute__((packed));
13
14#define SNAPSHOT_IOC_MAGIC '3'
15#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1)
16#define SNAPSHOT_UNFREEZE _IO(SNAPSHOT_IOC_MAGIC, 2)
17#define SNAPSHOT_ATOMIC_RESTORE _IO(SNAPSHOT_IOC_MAGIC, 4)
18#define SNAPSHOT_FREE _IO(SNAPSHOT_IOC_MAGIC, 5)
19#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9)
20#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
21#define SNAPSHOT_SET_SWAP_AREA _IOW(SNAPSHOT_IOC_MAGIC, 13, \
22 struct resume_swap_area)
23#define SNAPSHOT_GET_IMAGE_SIZE _IOR(SNAPSHOT_IOC_MAGIC, 14, loff_t)
24#define SNAPSHOT_PLATFORM_SUPPORT _IO(SNAPSHOT_IOC_MAGIC, 15)
25#define SNAPSHOT_POWER_OFF _IO(SNAPSHOT_IOC_MAGIC, 16)
26#define SNAPSHOT_CREATE_IMAGE _IOW(SNAPSHOT_IOC_MAGIC, 17, int)
27#define SNAPSHOT_PREF_IMAGE_SIZE _IO(SNAPSHOT_IOC_MAGIC, 18)
28#define SNAPSHOT_AVAIL_SWAP_SIZE _IOR(SNAPSHOT_IOC_MAGIC, 19, loff_t)
29#define SNAPSHOT_ALLOC_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 20, loff_t)
30#define SNAPSHOT_IOC_MAXNR 20
31
32#endif /* _LINUX_SUSPEND_IOCTLS_H */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index e99171f01b4c..bf4ae4e138f7 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -70,7 +70,6 @@ enum
70 CTL_ABI=9, /* Binary emulation */ 70 CTL_ABI=9, /* Binary emulation */
71 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */ 71 CTL_CPU=10, /* CPU stuff (speed scaling, etc) */
72 CTL_ARLAN=254, /* arlan wireless driver */ 72 CTL_ARLAN=254, /* arlan wireless driver */
73 CTL_APPLDATA=2120, /* s390 appldata */
74 CTL_S390DBF=5677, /* s390 debug */ 73 CTL_S390DBF=5677, /* s390 debug */
75 CTL_SUNRPC=7249, /* sunrpc debug */ 74 CTL_SUNRPC=7249, /* sunrpc debug */
76 CTL_PM=9899, /* frv power management */ 75 CTL_PM=9899, /* frv power management */
@@ -207,11 +206,6 @@ enum
207 VM_PANIC_ON_OOM=33, /* panic at out-of-memory */ 206 VM_PANIC_ON_OOM=33, /* panic at out-of-memory */
208 VM_VDSO_ENABLED=34, /* map VDSO into new processes? */ 207 VM_VDSO_ENABLED=34, /* map VDSO into new processes? */
209 VM_MIN_SLAB=35, /* Percent pages ignored by zone reclaim */ 208 VM_MIN_SLAB=35, /* Percent pages ignored by zone reclaim */
210
211 /* s390 vm cmm sysctls */
212 VM_CMM_PAGES=1111,
213 VM_CMM_TIMED_PAGES=1112,
214 VM_CMM_TIMEOUT=1113,
215}; 209};
216 210
217 211
@@ -446,8 +440,8 @@ enum
446 440
447enum { 441enum {
448 NET_IPV4_ROUTE_FLUSH=1, 442 NET_IPV4_ROUTE_FLUSH=1,
449 NET_IPV4_ROUTE_MIN_DELAY=2, 443 NET_IPV4_ROUTE_MIN_DELAY=2, /* obsolete since 2.6.25 */
450 NET_IPV4_ROUTE_MAX_DELAY=3, 444 NET_IPV4_ROUTE_MAX_DELAY=3, /* obsolete since 2.6.25 */
451 NET_IPV4_ROUTE_GC_THRESH=4, 445 NET_IPV4_ROUTE_GC_THRESH=4,
452 NET_IPV4_ROUTE_MAX_SIZE=5, 446 NET_IPV4_ROUTE_MAX_SIZE=5,
453 NET_IPV4_ROUTE_GC_MIN_INTERVAL=6, 447 NET_IPV4_ROUTE_GC_MIN_INTERVAL=6,
@@ -951,7 +945,10 @@ enum
951 945
952/* For the /proc/sys support */ 946/* For the /proc/sys support */
953struct ctl_table; 947struct ctl_table;
948struct nsproxy;
954extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev); 949extern struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev);
950extern struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
951 struct ctl_table_header *prev);
955extern void sysctl_head_finish(struct ctl_table_header *prev); 952extern void sysctl_head_finish(struct ctl_table_header *prev);
956extern int sysctl_perm(struct ctl_table *table, int op); 953extern int sysctl_perm(struct ctl_table *table, int op);
957 954
@@ -1055,6 +1052,13 @@ struct ctl_table
1055 void *extra2; 1052 void *extra2;
1056}; 1053};
1057 1054
1055struct ctl_table_root {
1056 struct list_head root_list;
1057 struct list_head header_list;
1058 struct list_head *(*lookup)(struct ctl_table_root *root,
1059 struct nsproxy *namespaces);
1060};
1061
1058/* struct ctl_table_header is used to maintain dynamic lists of 1062/* struct ctl_table_header is used to maintain dynamic lists of
1059 struct ctl_table trees. */ 1063 struct ctl_table trees. */
1060struct ctl_table_header 1064struct ctl_table_header
@@ -1063,12 +1067,26 @@ struct ctl_table_header
1063 struct list_head ctl_entry; 1067 struct list_head ctl_entry;
1064 int used; 1068 int used;
1065 struct completion *unregistering; 1069 struct completion *unregistering;
1070 struct ctl_table *ctl_table_arg;
1071 struct ctl_table_root *root;
1072};
1073
1074/* struct ctl_path describes where in the hierarchy a table is added */
1075struct ctl_path {
1076 const char *procname;
1077 int ctl_name;
1066}; 1078};
1067 1079
1080void register_sysctl_root(struct ctl_table_root *root);
1081struct ctl_table_header *__register_sysctl_paths(
1082 struct ctl_table_root *root, struct nsproxy *namespaces,
1083 const struct ctl_path *path, struct ctl_table *table);
1068struct ctl_table_header *register_sysctl_table(struct ctl_table * table); 1084struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
1085struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1086 struct ctl_table *table);
1069 1087
1070void unregister_sysctl_table(struct ctl_table_header * table); 1088void unregister_sysctl_table(struct ctl_table_header * table);
1071int sysctl_check_table(struct ctl_table *table); 1089int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table);
1072 1090
1073#else /* __KERNEL__ */ 1091#else /* __KERNEL__ */
1074 1092
diff --git a/include/linux/sysdev.h b/include/linux/sysdev.h
index e285746588d6..f752e73bf977 100644
--- a/include/linux/sysdev.h
+++ b/include/linux/sysdev.h
@@ -29,6 +29,7 @@
29struct sys_device; 29struct sys_device;
30 30
31struct sysdev_class { 31struct sysdev_class {
32 const char *name;
32 struct list_head drivers; 33 struct list_head drivers;
33 34
34 /* Default operations for these types of devices */ 35 /* Default operations for these types of devices */
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 149ab62329e2..802710438a9e 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -32,6 +32,8 @@ struct attribute {
32 32
33struct attribute_group { 33struct attribute_group {
34 const char *name; 34 const char *name;
35 int (*is_visible)(struct kobject *,
36 struct attribute *, int);
35 struct attribute **attrs; 37 struct attribute **attrs;
36}; 38};
37 39
diff --git a/include/linux/tc_act/Kbuild b/include/linux/tc_act/Kbuild
index 78dfbac36375..6dac0d7365cc 100644
--- a/include/linux/tc_act/Kbuild
+++ b/include/linux/tc_act/Kbuild
@@ -2,3 +2,4 @@ header-y += tc_gact.h
2header-y += tc_ipt.h 2header-y += tc_ipt.h
3header-y += tc_mirred.h 3header-y += tc_mirred.h
4header-y += tc_pedit.h 4header-y += tc_pedit.h
5header-y += tc_nat.h
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index bac17c59b24e..08027f1d7f31 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -330,10 +330,12 @@ struct tcp_sock {
330 struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */ 330 struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
331 struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/ 331 struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/
332 332
333 struct tcp_sack_block_wire recv_sack_cache[4]; 333 struct tcp_sack_block recv_sack_cache[4];
334 334
335 u32 highest_sack; /* Start seq of globally highest revd SACK 335 struct sk_buff *highest_sack; /* highest skb with SACK received
336 * (validity guaranteed only if sacked_out > 0) */ 336 * (validity guaranteed only if
337 * sacked_out > 0)
338 */
337 339
338 /* from STCP, retrans queue hinting */ 340 /* from STCP, retrans queue hinting */
339 struct sk_buff* lost_skb_hint; 341 struct sk_buff* lost_skb_hint;
@@ -341,10 +343,7 @@ struct tcp_sock {
341 struct sk_buff *scoreboard_skb_hint; 343 struct sk_buff *scoreboard_skb_hint;
342 struct sk_buff *retransmit_skb_hint; 344 struct sk_buff *retransmit_skb_hint;
343 struct sk_buff *forward_skb_hint; 345 struct sk_buff *forward_skb_hint;
344 struct sk_buff *fastpath_skb_hint;
345 346
346 int fastpath_cnt_hint; /* Lags behind by current skb's pcount
347 * compared to respective fackets_out */
348 int lost_cnt_hint; 347 int lost_cnt_hint;
349 int retransmit_cnt_hint; 348 int retransmit_cnt_hint;
350 349
diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
index 1c4eb41dbd89..421323e5a2d6 100644
--- a/include/linux/thread_info.h
+++ b/include/linux/thread_info.h
@@ -7,12 +7,26 @@
7#ifndef _LINUX_THREAD_INFO_H 7#ifndef _LINUX_THREAD_INFO_H
8#define _LINUX_THREAD_INFO_H 8#define _LINUX_THREAD_INFO_H
9 9
10#include <linux/types.h>
11
10/* 12/*
11 * System call restart block. 13 * System call restart block.
12 */ 14 */
13struct restart_block { 15struct restart_block {
14 long (*fn)(struct restart_block *); 16 long (*fn)(struct restart_block *);
15 unsigned long arg0, arg1, arg2, arg3; 17 union {
18 struct {
19 unsigned long arg0, arg1, arg2, arg3;
20 };
21 /* For futex_wait */
22 struct {
23 u32 *uaddr;
24 u32 val;
25 u32 flags;
26 u32 bitset;
27 u64 time;
28 } futex;
29 };
16}; 30};
17 31
18extern long do_no_restart_syscall(struct restart_block *parm); 32extern long do_no_restart_syscall(struct restart_block *parm);
@@ -29,27 +43,27 @@ extern long do_no_restart_syscall(struct restart_block *parm);
29 43
30static inline void set_ti_thread_flag(struct thread_info *ti, int flag) 44static inline void set_ti_thread_flag(struct thread_info *ti, int flag)
31{ 45{
32 set_bit(flag,&ti->flags); 46 set_bit(flag, (unsigned long *)&ti->flags);
33} 47}
34 48
35static inline void clear_ti_thread_flag(struct thread_info *ti, int flag) 49static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
36{ 50{
37 clear_bit(flag,&ti->flags); 51 clear_bit(flag, (unsigned long *)&ti->flags);
38} 52}
39 53
40static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) 54static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
41{ 55{
42 return test_and_set_bit(flag,&ti->flags); 56 return test_and_set_bit(flag, (unsigned long *)&ti->flags);
43} 57}
44 58
45static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag) 59static inline int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag)
46{ 60{
47 return test_and_clear_bit(flag,&ti->flags); 61 return test_and_clear_bit(flag, (unsigned long *)&ti->flags);
48} 62}
49 63
50static inline int test_ti_thread_flag(struct thread_info *ti, int flag) 64static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
51{ 65{
52 return test_bit(flag,&ti->flags); 66 return test_bit(flag, (unsigned long *)&ti->flags);
53} 67}
54 68
55#define set_thread_flag(flag) \ 69#define set_thread_flag(flag) \
diff --git a/include/linux/ticable.h b/include/linux/ticable.h
deleted file mode 100644
index 8c2212086dcd..000000000000
--- a/include/linux/ticable.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/* Hey EMACS -*- linux-c -*-
2 *
3 * tipar/tiser/tiusb - low level driver for handling link cables
4 * designed for Texas Instruments graphing calculators.
5 *
6 * Copyright (C) 2000-2002, Romain Lievin <roms@lpg.ticalc.org>
7 *
8 * Redistribution of this file is permitted under the terms of the GNU
9 * Public License (GPL)
10 */
11
12#ifndef _TICABLE_H
13#define _TICABLE_H 1
14
15/* Internal default constants for the kernel module */
16#define TIMAXTIME 15 /* 1.5 seconds */
17#define IO_DELAY 10 /* 10 micro-seconds */
18
19/* Major & minor number for character devices */
20#define TIPAR_MAJOR 115 /* 0 to 7 */
21#define TIPAR_MINOR 0
22
23#define TISER_MAJOR 115 /* 8 to 15 */
24#define TISER_MINOR 8
25
26#define TIUSB_MAJOR 115 /* 16 to 31 */
27#define TIUSB_MINOR 16
28
29/*
30 * Request values for the 'ioctl' function.
31 */
32#define IOCTL_TIPAR_DELAY _IOW('p', 0xa8, int) /* set delay */
33#define IOCTL_TIPAR_TIMEOUT _IOW('p', 0xa9, int) /* set timeout */
34
35#define IOCTL_TISER_DELAY _IOW('p', 0xa0, int) /* set delay */
36#define IOCTL_TISER_TIMEOUT _IOW('p', 0xa1, int) /* set timeout */
37
38#define IOCTL_TIUSB_TIMEOUT _IOW('N', 0x20, int) /* set timeout */
39#define IOCTL_TIUSB_RESET_DEVICE _IOW('N', 0x21, int) /* reset device */
40#define IOCTL_TIUSB_RESET_PIPES _IOW('N', 0x22, int) /* reset both pipes*/
41#define IOCTL_TIUSB_GET_MAXPS _IOR('N', 0x23, int) /* max packet size */
42#define IOCTL_TIUSB_GET_DEVID _IOR('N', 0x24, int) /* get device type */
43
44#endif /* TICABLE_H */
diff --git a/include/linux/tick.h b/include/linux/tick.h
index f4a1395e05ff..a881c652f7e9 100644
--- a/include/linux/tick.h
+++ b/include/linux/tick.h
@@ -39,6 +39,8 @@ enum tick_nohz_mode {
39 * @idle_calls: Total number of idle calls 39 * @idle_calls: Total number of idle calls
40 * @idle_sleeps: Number of idle calls, where the sched tick was stopped 40 * @idle_sleeps: Number of idle calls, where the sched tick was stopped
41 * @idle_entrytime: Time when the idle call was entered 41 * @idle_entrytime: Time when the idle call was entered
42 * @idle_waketime: Time when the idle was interrupted
43 * @idle_exittime: Time when the idle state was left
42 * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped 44 * @idle_sleeptime: Sum of the time slept in idle with sched tick stopped
43 * @sleep_length: Duration of the current idle sleep 45 * @sleep_length: Duration of the current idle sleep
44 */ 46 */
@@ -51,8 +53,12 @@ struct tick_sched {
51 unsigned long idle_jiffies; 53 unsigned long idle_jiffies;
52 unsigned long idle_calls; 54 unsigned long idle_calls;
53 unsigned long idle_sleeps; 55 unsigned long idle_sleeps;
56 int idle_active;
54 ktime_t idle_entrytime; 57 ktime_t idle_entrytime;
58 ktime_t idle_waketime;
59 ktime_t idle_exittime;
55 ktime_t idle_sleeptime; 60 ktime_t idle_sleeptime;
61 ktime_t idle_lastupdate;
56 ktime_t sleep_length; 62 ktime_t sleep_length;
57 unsigned long last_jiffies; 63 unsigned long last_jiffies;
58 unsigned long next_jiffies; 64 unsigned long next_jiffies;
@@ -103,6 +109,8 @@ extern void tick_nohz_stop_sched_tick(void);
103extern void tick_nohz_restart_sched_tick(void); 109extern void tick_nohz_restart_sched_tick(void);
104extern void tick_nohz_update_jiffies(void); 110extern void tick_nohz_update_jiffies(void);
105extern ktime_t tick_nohz_get_sleep_length(void); 111extern ktime_t tick_nohz_get_sleep_length(void);
112extern void tick_nohz_stop_idle(int cpu);
113extern u64 get_cpu_idle_time_us(int cpu, u64 *last_update_time);
106# else 114# else
107static inline void tick_nohz_stop_sched_tick(void) { } 115static inline void tick_nohz_stop_sched_tick(void) { }
108static inline void tick_nohz_restart_sched_tick(void) { } 116static inline void tick_nohz_restart_sched_tick(void) { }
@@ -113,6 +121,8 @@ static inline ktime_t tick_nohz_get_sleep_length(void)
113 121
114 return len; 122 return len;
115} 123}
124static inline void tick_nohz_stop_idle(int cpu) { }
125static inline u64 get_cpu_idle_time_us(int cpu, u64 *unused) { return 0; }
116# endif /* !NO_HZ */ 126# endif /* !NO_HZ */
117 127
118#endif 128#endif
diff --git a/include/linux/tifm.h b/include/linux/tifm.h
index 6b3a31805c72..2096b76d0cee 100644
--- a/include/linux/tifm.h
+++ b/include/linux/tifm.h
@@ -120,7 +120,7 @@ struct tifm_adapter {
120 struct completion *finish_me; 120 struct completion *finish_me;
121 121
122 struct work_struct media_switcher; 122 struct work_struct media_switcher;
123 struct class_device cdev; 123 struct device dev;
124 124
125 void (*eject)(struct tifm_adapter *fm, 125 void (*eject)(struct tifm_adapter *fm,
126 struct tifm_dev *sock); 126 struct tifm_dev *sock);
diff --git a/include/linux/time.h b/include/linux/time.h
index b04136d60a2f..ceaab9fff155 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -122,6 +122,7 @@ extern void monotonic_to_bootbased(struct timespec *ts);
122extern struct timespec timespec_trunc(struct timespec t, unsigned gran); 122extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
123extern int timekeeping_is_continuous(void); 123extern int timekeeping_is_continuous(void);
124extern void update_wall_time(void); 124extern void update_wall_time(void);
125extern void update_xtime_cache(u64 nsec);
125 126
126/** 127/**
127 * timespec_to_ns - Convert timespec to nanoseconds 128 * timespec_to_ns - Convert timespec to nanoseconds
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 78cf899b4409..de0e71359ede 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -5,7 +5,7 @@
5#include <linux/ktime.h> 5#include <linux/ktime.h>
6#include <linux/stddef.h> 6#include <linux/stddef.h>
7 7
8struct tvec_t_base_s; 8struct tvec_base;
9 9
10struct timer_list { 10struct timer_list {
11 struct list_head entry; 11 struct list_head entry;
@@ -14,7 +14,7 @@ struct timer_list {
14 void (*function)(unsigned long); 14 void (*function)(unsigned long);
15 unsigned long data; 15 unsigned long data;
16 16
17 struct tvec_t_base_s *base; 17 struct tvec_base *base;
18#ifdef CONFIG_TIMER_STATS 18#ifdef CONFIG_TIMER_STATS
19 void *start_site; 19 void *start_site;
20 char start_comm[16]; 20 char start_comm[16];
@@ -22,7 +22,7 @@ struct timer_list {
22#endif 22#endif
23}; 23};
24 24
25extern struct tvec_t_base_s boot_tvec_bases; 25extern struct tvec_base boot_tvec_bases;
26 26
27#define TIMER_INITIALIZER(_function, _expires, _data) { \ 27#define TIMER_INITIALIZER(_function, _expires, _data) { \
28 .function = (_function), \ 28 .function = (_function), \
diff --git a/include/linux/timex.h b/include/linux/timex.h
index 37ac3ff90faf..24c6a2b59511 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -137,6 +137,7 @@ struct timex {
137#define ADJ_TIMECONST 0x0020 /* pll time constant */ 137#define ADJ_TIMECONST 0x0020 /* pll time constant */
138#define ADJ_TICK 0x4000 /* tick value */ 138#define ADJ_TICK 0x4000 /* tick value */
139#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ 139#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
140#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
140 141
141/* xntp 3.4 compatibility names */ 142/* xntp 3.4 compatibility names */
142#define MOD_OFFSET ADJ_OFFSET 143#define MOD_OFFSET ADJ_OFFSET
diff --git a/include/linux/topology.h b/include/linux/topology.h
index 47729f18bfdf..2352f46160d3 100644
--- a/include/linux/topology.h
+++ b/include/linux/topology.h
@@ -5,7 +5,7 @@
5 * 5 *
6 * Copyright (C) 2002, IBM Corp. 6 * Copyright (C) 2002, IBM Corp.
7 * 7 *
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -103,6 +103,7 @@
103 .forkexec_idx = 0, \ 103 .forkexec_idx = 0, \
104 .flags = SD_LOAD_BALANCE \ 104 .flags = SD_LOAD_BALANCE \
105 | SD_BALANCE_NEWIDLE \ 105 | SD_BALANCE_NEWIDLE \
106 | SD_BALANCE_FORK \
106 | SD_BALANCE_EXEC \ 107 | SD_BALANCE_EXEC \
107 | SD_WAKE_AFFINE \ 108 | SD_WAKE_AFFINE \
108 | SD_WAKE_IDLE \ 109 | SD_WAKE_IDLE \
@@ -134,6 +135,7 @@
134 .forkexec_idx = 1, \ 135 .forkexec_idx = 1, \
135 .flags = SD_LOAD_BALANCE \ 136 .flags = SD_LOAD_BALANCE \
136 | SD_BALANCE_NEWIDLE \ 137 | SD_BALANCE_NEWIDLE \
138 | SD_BALANCE_FORK \
137 | SD_BALANCE_EXEC \ 139 | SD_BALANCE_EXEC \
138 | SD_WAKE_AFFINE \ 140 | SD_WAKE_AFFINE \
139 | SD_WAKE_IDLE \ 141 | SD_WAKE_IDLE \
@@ -165,6 +167,7 @@
165 .forkexec_idx = 1, \ 167 .forkexec_idx = 1, \
166 .flags = SD_LOAD_BALANCE \ 168 .flags = SD_LOAD_BALANCE \
167 | SD_BALANCE_NEWIDLE \ 169 | SD_BALANCE_NEWIDLE \
170 | SD_BALANCE_FORK \
168 | SD_BALANCE_EXEC \ 171 | SD_BALANCE_EXEC \
169 | SD_WAKE_AFFINE \ 172 | SD_WAKE_AFFINE \
170 | BALANCE_FOR_PKG_POWER,\ 173 | BALANCE_FOR_PKG_POWER,\
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 56164d7ba0ad..402de892b3ed 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -23,7 +23,7 @@
23 */ 23 */
24#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */ 24#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
25#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */ 25#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
26#define NR_LDISCS 17 26#define NR_LDISCS 18
27 27
28/* line disciplines */ 28/* line disciplines */
29#define N_TTY 0 29#define N_TTY 0
@@ -44,6 +44,7 @@
44#define N_SYNC_PPP 14 /* synchronous PPP */ 44#define N_SYNC_PPP 14 /* synchronous PPP */
45#define N_HCI 15 /* Bluetooth HCI UART */ 45#define N_HCI 15 /* Bluetooth HCI UART */
46#define N_GIGASET_M101 16 /* Siemens Gigaset M101 serial DECT adapter */ 46#define N_GIGASET_M101 16 /* Siemens Gigaset M101 serial DECT adapter */
47#define N_SLCAN 17 /* Serial / USB serial CAN Adaptors */
47 48
48/* 49/*
49 * This character is the same as _POSIX_VDISABLE: it cannot be used as 50 * This character is the same as _POSIX_VDISABLE: it cannot be used as
@@ -319,6 +320,7 @@ extern speed_t tty_termios_input_baud_rate(struct ktermios *termios);
319extern void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud); 320extern void tty_termios_encode_baud_rate(struct ktermios *termios, speed_t ibaud, speed_t obaud);
320extern void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud); 321extern void tty_encode_baud_rate(struct tty_struct *tty, speed_t ibaud, speed_t obaud);
321extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old); 322extern void tty_termios_copy_hw(struct ktermios *new, struct ktermios *old);
323extern int tty_termios_hw_change(struct ktermios *a, struct ktermios *b);
322 324
323extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *); 325extern struct tty_ldisc *tty_ldisc_ref(struct tty_struct *);
324extern void tty_ldisc_deref(struct tty_ldisc *); 326extern void tty_ldisc_deref(struct tty_ldisc *);
@@ -332,7 +334,9 @@ extern void tty_ldisc_flush(struct tty_struct *tty);
332 334
333extern int tty_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 335extern int tty_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
334 unsigned long arg); 336 unsigned long arg);
335 337extern int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
338 unsigned int cmd, unsigned long arg);
339extern int tty_perform_flush(struct tty_struct *tty, unsigned long arg);
336extern dev_t tty_devnum(struct tty_struct *tty); 340extern dev_t tty_devnum(struct tty_struct *tty);
337extern void proc_clear_tty(struct task_struct *p); 341extern void proc_clear_tty(struct task_struct *p);
338extern struct tty_struct *get_current_tty(void); 342extern struct tty_struct *get_current_tty(void);
diff --git a/include/linux/types.h b/include/linux/types.h
index 4f0dad21c917..b94c0e4efe24 100644
--- a/include/linux/types.h
+++ b/include/linux/types.h
@@ -37,6 +37,8 @@ typedef __kernel_gid32_t gid_t;
37typedef __kernel_uid16_t uid16_t; 37typedef __kernel_uid16_t uid16_t;
38typedef __kernel_gid16_t gid16_t; 38typedef __kernel_gid16_t gid16_t;
39 39
40typedef unsigned long uintptr_t;
41
40#ifdef CONFIG_UID16 42#ifdef CONFIG_UID16
41/* This is defined by include/asm-{arch}/posix_types.h */ 43/* This is defined by include/asm-{arch}/posix_types.h */
42typedef __kernel_old_uid_t old_uid_t; 44typedef __kernel_old_uid_t old_uid_t;
@@ -124,7 +126,7 @@ typedef __s64 int64_t;
124#endif 126#endif
125 127
126/* this is a special 64bit data type that is 8-byte aligned */ 128/* this is a special 64bit data type that is 8-byte aligned */
127#define aligned_u64 unsigned long long __attribute__((aligned(8))) 129#define aligned_u64 __u64 __attribute__((aligned(8)))
128#define aligned_be64 __be64 __attribute__((aligned(8))) 130#define aligned_be64 __be64 __attribute__((aligned(8)))
129#define aligned_le64 __le64 __attribute__((aligned(8))) 131#define aligned_le64 __le64 __attribute__((aligned(8)))
130 132
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 44c28e94df50..973386d439da 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -18,20 +18,22 @@
18#include <linux/fs.h> 18#include <linux/fs.h>
19#include <linux/interrupt.h> 19#include <linux/interrupt.h>
20 20
21struct uio_map;
22
21/** 23/**
22 * struct uio_mem - description of a UIO memory region 24 * struct uio_mem - description of a UIO memory region
23 * @kobj: kobject for this mapping
24 * @addr: address of the device's memory 25 * @addr: address of the device's memory
25 * @size: size of IO 26 * @size: size of IO
26 * @memtype: type of memory addr points to 27 * @memtype: type of memory addr points to
27 * @internal_addr: ioremap-ped version of addr, for driver internal use 28 * @internal_addr: ioremap-ped version of addr, for driver internal use
29 * @map: for use by the UIO core only.
28 */ 30 */
29struct uio_mem { 31struct uio_mem {
30 struct kobject kobj;
31 unsigned long addr; 32 unsigned long addr;
32 unsigned long size; 33 unsigned long size;
33 int memtype; 34 int memtype;
34 void __iomem *internal_addr; 35 void __iomem *internal_addr;
36 struct uio_map *map;
35}; 37};
36 38
37#define MAX_UIO_MAPS 5 39#define MAX_UIO_MAPS 5
diff --git a/include/linux/usb.h b/include/linux/usb.h
index c5c8f169d3cf..2372e2e6b527 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -107,6 +107,7 @@ enum usb_interface_condition {
107 * @condition: binding state of the interface: not bound, binding 107 * @condition: binding state of the interface: not bound, binding
108 * (in probe()), bound to a driver, or unbinding (in disconnect()) 108 * (in probe()), bound to a driver, or unbinding (in disconnect())
109 * @is_active: flag set when the interface is bound and not suspended. 109 * @is_active: flag set when the interface is bound and not suspended.
110 * @sysfs_files_created: sysfs attributes exist
110 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup 111 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup
111 * capability during autosuspend. 112 * capability during autosuspend.
112 * @dev: driver model's view of this device 113 * @dev: driver model's view of this device
@@ -157,22 +158,23 @@ struct usb_interface {
157 * bound to */ 158 * bound to */
158 enum usb_interface_condition condition; /* state of binding */ 159 enum usb_interface_condition condition; /* state of binding */
159 unsigned is_active:1; /* the interface is not suspended */ 160 unsigned is_active:1; /* the interface is not suspended */
161 unsigned sysfs_files_created:1; /* the sysfs attributes exist */
160 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ 162 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
161 163
162 struct device dev; /* interface specific device info */ 164 struct device dev; /* interface specific device info */
163 struct device *usb_dev; /* pointer to the usb class's device, if any */ 165 struct device *usb_dev;
164 int pm_usage_cnt; /* usage counter for autosuspend */ 166 int pm_usage_cnt; /* usage counter for autosuspend */
165}; 167};
166#define to_usb_interface(d) container_of(d, struct usb_interface, dev) 168#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
167#define interface_to_usbdev(intf) \ 169#define interface_to_usbdev(intf) \
168 container_of(intf->dev.parent, struct usb_device, dev) 170 container_of(intf->dev.parent, struct usb_device, dev)
169 171
170static inline void *usb_get_intfdata (struct usb_interface *intf) 172static inline void *usb_get_intfdata(struct usb_interface *intf)
171{ 173{
172 return dev_get_drvdata (&intf->dev); 174 return dev_get_drvdata(&intf->dev);
173} 175}
174 176
175static inline void usb_set_intfdata (struct usb_interface *intf, void *data) 177static inline void usb_set_intfdata(struct usb_interface *intf, void *data)
176{ 178{
177 dev_set_drvdata(&intf->dev, data); 179 dev_set_drvdata(&intf->dev, data);
178} 180}
@@ -273,9 +275,10 @@ struct usb_host_config {
273 275
274int __usb_get_extra_descriptor(char *buffer, unsigned size, 276int __usb_get_extra_descriptor(char *buffer, unsigned size,
275 unsigned char type, void **ptr); 277 unsigned char type, void **ptr);
276#define usb_get_extra_descriptor(ifpoint,type,ptr)\ 278#define usb_get_extra_descriptor(ifpoint, type, ptr) \
277 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\ 279 __usb_get_extra_descriptor((ifpoint)->extra, \
278 type,(void**)ptr) 280 (ifpoint)->extralen, \
281 type, (void **)ptr)
279 282
280/* ----------------------------------------------------------------------- */ 283/* ----------------------------------------------------------------------- */
281 284
@@ -316,7 +319,7 @@ struct usb_bus {
316#ifdef CONFIG_USB_DEVICEFS 319#ifdef CONFIG_USB_DEVICEFS
317 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 320 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
318#endif 321#endif
319 struct class_device *class_dev; /* class device for this bus */ 322 struct device *dev; /* device for this bus */
320 323
321#if defined(CONFIG_USB_MON) 324#if defined(CONFIG_USB_MON)
322 struct mon_bus *mon_bus; /* non-null when associated */ 325 struct mon_bus *mon_bus; /* non-null when associated */
@@ -386,7 +389,7 @@ struct usb_device {
386 unsigned can_submit:1; /* URBs may be submitted */ 389 unsigned can_submit:1; /* URBs may be submitted */
387 unsigned discon_suspended:1; /* Disconnected while suspended */ 390 unsigned discon_suspended:1; /* Disconnected while suspended */
388 unsigned have_langid:1; /* whether string_langid is valid */ 391 unsigned have_langid:1; /* whether string_langid is valid */
389 unsigned authorized:1; /* Policy has determined we can use it */ 392 unsigned authorized:1; /* Policy has said we can use it */
390 unsigned wusb:1; /* Device is Wireless USB */ 393 unsigned wusb:1; /* Device is Wireless USB */
391 int string_langid; /* language ID for strings */ 394 int string_langid; /* language ID for strings */
392 395
@@ -415,7 +418,10 @@ struct usb_device {
415 418
416 int pm_usage_cnt; /* usage counter for autosuspend */ 419 int pm_usage_cnt; /* usage counter for autosuspend */
417 u32 quirks; /* quirks of the whole device */ 420 u32 quirks; /* quirks of the whole device */
418 atomic_t urbnum; /* number of URBs submitted for the whole device */ 421 atomic_t urbnum; /* number of URBs submitted for
422 the whole device */
423
424 unsigned long active_duration; /* total time device is not suspended */
419 425
420#ifdef CONFIG_PM 426#ifdef CONFIG_PM
421 struct delayed_work autosuspend; /* for delayed autosuspends */ 427 struct delayed_work autosuspend; /* for delayed autosuspends */
@@ -423,6 +429,7 @@ struct usb_device {
423 429
424 unsigned long last_busy; /* time of last use */ 430 unsigned long last_busy; /* time of last use */
425 int autosuspend_delay; /* in jiffies */ 431 int autosuspend_delay; /* in jiffies */
432 unsigned long connect_time; /* time device was first connected */
426 433
427 unsigned auto_pm:1; /* autosuspend/resume in progress */ 434 unsigned auto_pm:1; /* autosuspend/resume in progress */
428 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ 435 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */
@@ -496,11 +503,11 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
496/*-------------------------------------------------------------------------*/ 503/*-------------------------------------------------------------------------*/
497 504
498/* for drivers using iso endpoints */ 505/* for drivers using iso endpoints */
499extern int usb_get_current_frame_number (struct usb_device *usb_dev); 506extern int usb_get_current_frame_number(struct usb_device *usb_dev);
500 507
501/* used these for multi-interface device registration */ 508/* used these for multi-interface device registration */
502extern int usb_driver_claim_interface(struct usb_driver *driver, 509extern int usb_driver_claim_interface(struct usb_driver *driver,
503 struct usb_interface *iface, void* priv); 510 struct usb_interface *iface, void *priv);
504 511
505/** 512/**
506 * usb_interface_claimed - returns true iff an interface is claimed 513 * usb_interface_claimed - returns true iff an interface is claimed
@@ -512,7 +519,8 @@ extern int usb_driver_claim_interface(struct usb_driver *driver,
512 * may need to explicitly claim that lock. 519 * may need to explicitly claim that lock.
513 * 520 *
514 */ 521 */
515static inline int usb_interface_claimed(struct usb_interface *iface) { 522static inline int usb_interface_claimed(struct usb_interface *iface)
523{
516 return (iface->dev.driver != NULL); 524 return (iface->dev.driver != NULL);
517} 525}
518 526
@@ -555,12 +563,11 @@ extern struct usb_host_interface *usb_altnum_to_altsetting(
555 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are 563 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
556 * high speed, and a different one if they are full or low speed. 564 * high speed, and a different one if they are full or low speed.
557 */ 565 */
558static inline int usb_make_path (struct usb_device *dev, char *buf, 566static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size)
559 size_t size)
560{ 567{
561 int actual; 568 int actual;
562 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, 569 actual = snprintf(buf, size, "usb-%s-%s", dev->bus->bus_name,
563 dev->devpath); 570 dev->devpath);
564 return (actual >= (int)size) ? -1 : actual; 571 return (actual >= (int)size) ? -1 : actual;
565} 572}
566 573
@@ -606,7 +613,8 @@ static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
606 * 613 *
607 * Returns true if the endpoint is of type OUT, otherwise it returns false. 614 * Returns true if the endpoint is of type OUT, otherwise it returns false.
608 */ 615 */
609static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) 616static inline int usb_endpoint_dir_out(
617 const struct usb_endpoint_descriptor *epd)
610{ 618{
611 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); 619 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
612} 620}
@@ -617,7 +625,8 @@ static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd
617 * 625 *
618 * Returns true if the endpoint is of type bulk, otherwise it returns false. 626 * Returns true if the endpoint is of type bulk, otherwise it returns false.
619 */ 627 */
620static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) 628static inline int usb_endpoint_xfer_bulk(
629 const struct usb_endpoint_descriptor *epd)
621{ 630{
622 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 631 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
623 USB_ENDPOINT_XFER_BULK); 632 USB_ENDPOINT_XFER_BULK);
@@ -629,7 +638,8 @@ static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *e
629 * 638 *
630 * Returns true if the endpoint is of type control, otherwise it returns false. 639 * Returns true if the endpoint is of type control, otherwise it returns false.
631 */ 640 */
632static inline int usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) 641static inline int usb_endpoint_xfer_control(
642 const struct usb_endpoint_descriptor *epd)
633{ 643{
634 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 644 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
635 USB_ENDPOINT_XFER_CONTROL); 645 USB_ENDPOINT_XFER_CONTROL);
@@ -642,7 +652,8 @@ static inline int usb_endpoint_xfer_control(const struct usb_endpoint_descriptor
642 * Returns true if the endpoint is of type interrupt, otherwise it returns 652 * Returns true if the endpoint is of type interrupt, otherwise it returns
643 * false. 653 * false.
644 */ 654 */
645static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) 655static inline int usb_endpoint_xfer_int(
656 const struct usb_endpoint_descriptor *epd)
646{ 657{
647 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 658 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
648 USB_ENDPOINT_XFER_INT); 659 USB_ENDPOINT_XFER_INT);
@@ -655,7 +666,8 @@ static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *ep
655 * Returns true if the endpoint is of type isochronous, otherwise it returns 666 * Returns true if the endpoint is of type isochronous, otherwise it returns
656 * false. 667 * false.
657 */ 668 */
658static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) 669static inline int usb_endpoint_xfer_isoc(
670 const struct usb_endpoint_descriptor *epd)
659{ 671{
660 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 672 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
661 USB_ENDPOINT_XFER_ISOC); 673 USB_ENDPOINT_XFER_ISOC);
@@ -668,7 +680,8 @@ static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *e
668 * Returns true if the endpoint has bulk transfer type and IN direction, 680 * Returns true if the endpoint has bulk transfer type and IN direction,
669 * otherwise it returns false. 681 * otherwise it returns false.
670 */ 682 */
671static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) 683static inline int usb_endpoint_is_bulk_in(
684 const struct usb_endpoint_descriptor *epd)
672{ 685{
673 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); 686 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
674} 687}
@@ -680,7 +693,8 @@ static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *
680 * Returns true if the endpoint has bulk transfer type and OUT direction, 693 * Returns true if the endpoint has bulk transfer type and OUT direction,
681 * otherwise it returns false. 694 * otherwise it returns false.
682 */ 695 */
683static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) 696static inline int usb_endpoint_is_bulk_out(
697 const struct usb_endpoint_descriptor *epd)
684{ 698{
685 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); 699 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
686} 700}
@@ -692,7 +706,8 @@ static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor
692 * Returns true if the endpoint has interrupt transfer type and IN direction, 706 * Returns true if the endpoint has interrupt transfer type and IN direction,
693 * otherwise it returns false. 707 * otherwise it returns false.
694 */ 708 */
695static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) 709static inline int usb_endpoint_is_int_in(
710 const struct usb_endpoint_descriptor *epd)
696{ 711{
697 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); 712 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
698} 713}
@@ -704,7 +719,8 @@ static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *e
704 * Returns true if the endpoint has interrupt transfer type and OUT direction, 719 * Returns true if the endpoint has interrupt transfer type and OUT direction,
705 * otherwise it returns false. 720 * otherwise it returns false.
706 */ 721 */
707static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) 722static inline int usb_endpoint_is_int_out(
723 const struct usb_endpoint_descriptor *epd)
708{ 724{
709 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); 725 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
710} 726}
@@ -716,7 +732,8 @@ static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *
716 * Returns true if the endpoint has isochronous transfer type and IN direction, 732 * Returns true if the endpoint has isochronous transfer type and IN direction,
717 * otherwise it returns false. 733 * otherwise it returns false.
718 */ 734 */
719static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) 735static inline int usb_endpoint_is_isoc_in(
736 const struct usb_endpoint_descriptor *epd)
720{ 737{
721 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); 738 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
722} 739}
@@ -728,7 +745,8 @@ static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *
728 * Returns true if the endpoint has isochronous transfer type and OUT direction, 745 * Returns true if the endpoint has isochronous transfer type and OUT direction,
729 * otherwise it returns false. 746 * otherwise it returns false.
730 */ 747 */
731static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) 748static inline int usb_endpoint_is_isoc_out(
749 const struct usb_endpoint_descriptor *epd)
732{ 750{
733 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); 751 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
734} 752}
@@ -759,8 +777,9 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
759 * specific device. 777 * specific device.
760 */ 778 */
761#define USB_DEVICE(vend,prod) \ 779#define USB_DEVICE(vend,prod) \
762 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \ 780 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
763 .idProduct = (prod) 781 .idVendor = (vend), \
782 .idProduct = (prod)
764/** 783/**
765 * USB_DEVICE_VER - macro used to describe a specific usb device with a 784 * USB_DEVICE_VER - macro used to describe a specific usb device with a
766 * version range 785 * version range
@@ -772,10 +791,12 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
772 * This macro is used to create a struct usb_device_id that matches a 791 * This macro is used to create a struct usb_device_id that matches a
773 * specific device, with a version range. 792 * specific device, with a version range.
774 */ 793 */
775#define USB_DEVICE_VER(vend,prod,lo,hi) \ 794#define USB_DEVICE_VER(vend, prod, lo, hi) \
776 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \ 795 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \
777 .idVendor = (vend), .idProduct = (prod), \ 796 .idVendor = (vend), \
778 .bcdDevice_lo = (lo), .bcdDevice_hi = (hi) 797 .idProduct = (prod), \
798 .bcdDevice_lo = (lo), \
799 .bcdDevice_hi = (hi)
779 800
780/** 801/**
781 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb 802 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb
@@ -787,8 +808,9 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
787 * This macro is used to create a struct usb_device_id that matches a 808 * This macro is used to create a struct usb_device_id that matches a
788 * specific interface protocol of devices. 809 * specific interface protocol of devices.
789 */ 810 */
790#define USB_DEVICE_INTERFACE_PROTOCOL(vend,prod,pr) \ 811#define USB_DEVICE_INTERFACE_PROTOCOL(vend, prod, pr) \
791 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ 812 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
813 USB_DEVICE_ID_MATCH_INT_PROTOCOL, \
792 .idVendor = (vend), \ 814 .idVendor = (vend), \
793 .idProduct = (prod), \ 815 .idProduct = (prod), \
794 .bInterfaceProtocol = (pr) 816 .bInterfaceProtocol = (pr)
@@ -802,12 +824,14 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
802 * This macro is used to create a struct usb_device_id that matches a 824 * This macro is used to create a struct usb_device_id that matches a
803 * specific class of devices. 825 * specific class of devices.
804 */ 826 */
805#define USB_DEVICE_INFO(cl,sc,pr) \ 827#define USB_DEVICE_INFO(cl, sc, pr) \
806 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), \ 828 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, \
807 .bDeviceSubClass = (sc), .bDeviceProtocol = (pr) 829 .bDeviceClass = (cl), \
830 .bDeviceSubClass = (sc), \
831 .bDeviceProtocol = (pr)
808 832
809/** 833/**
810 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 834 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
811 * @cl: bInterfaceClass value 835 * @cl: bInterfaceClass value
812 * @sc: bInterfaceSubClass value 836 * @sc: bInterfaceSubClass value
813 * @pr: bInterfaceProtocol value 837 * @pr: bInterfaceProtocol value
@@ -815,9 +839,11 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
815 * This macro is used to create a struct usb_device_id that matches a 839 * This macro is used to create a struct usb_device_id that matches a
816 * specific class of interfaces. 840 * specific class of interfaces.
817 */ 841 */
818#define USB_INTERFACE_INFO(cl,sc,pr) \ 842#define USB_INTERFACE_INFO(cl, sc, pr) \
819 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), \ 843 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, \
820 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 844 .bInterfaceClass = (cl), \
845 .bInterfaceSubClass = (sc), \
846 .bInterfaceProtocol = (pr)
821 847
822/** 848/**
823 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device 849 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device
@@ -834,12 +860,14 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
834 * This is especially useful when explicitly matching devices that have 860 * This is especially useful when explicitly matching devices that have
835 * vendor specific bDeviceClass values, but standards-compliant interfaces. 861 * vendor specific bDeviceClass values, but standards-compliant interfaces.
836 */ 862 */
837#define USB_DEVICE_AND_INTERFACE_INFO(vend,prod,cl,sc,pr) \ 863#define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, cl, sc, pr) \
838 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ 864 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
839 | USB_DEVICE_ID_MATCH_DEVICE, \ 865 | USB_DEVICE_ID_MATCH_DEVICE, \
840 .idVendor = (vend), .idProduct = (prod), \ 866 .idVendor = (vend), \
867 .idProduct = (prod), \
841 .bInterfaceClass = (cl), \ 868 .bInterfaceClass = (cl), \
842 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 869 .bInterfaceSubClass = (sc), \
870 .bInterfaceProtocol = (pr)
843 871
844/* ----------------------------------------------------------------------- */ 872/* ----------------------------------------------------------------------- */
845 873
@@ -1117,7 +1145,7 @@ typedef void (*usb_complete_t)(struct urb *);
1117 * transferred. It will normally be the same as requested, unless 1145 * transferred. It will normally be the same as requested, unless
1118 * either an error was reported or a short read was performed. 1146 * either an error was reported or a short read was performed.
1119 * The URB_SHORT_NOT_OK transfer flag may be used to make such 1147 * The URB_SHORT_NOT_OK transfer flag may be used to make such
1120 * short reads be reported as errors. 1148 * short reads be reported as errors.
1121 * @setup_packet: Only used for control transfers, this points to eight bytes 1149 * @setup_packet: Only used for control transfers, this points to eight bytes
1122 * of setup data. Control transfers always start by sending this data 1150 * of setup data. Control transfers always start by sending this data
1123 * to the device. Then transfer_buffer is read or written, if needed. 1151 * to the device. Then transfer_buffer is read or written, if needed.
@@ -1136,7 +1164,7 @@ typedef void (*usb_complete_t)(struct urb *);
1136 * @complete: Completion handler. This URB is passed as the parameter to the 1164 * @complete: Completion handler. This URB is passed as the parameter to the
1137 * completion function. The completion function may then do what 1165 * completion function. The completion function may then do what
1138 * it likes with the URB, including resubmitting or freeing it. 1166 * it likes with the URB, including resubmitting or freeing it.
1139 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to 1167 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to
1140 * collect the transfer status for each buffer. 1168 * collect the transfer status for each buffer.
1141 * 1169 *
1142 * This structure identifies USB transfer requests. URBs must be allocated by 1170 * This structure identifies USB transfer requests. URBs must be allocated by
@@ -1240,8 +1268,7 @@ typedef void (*usb_complete_t)(struct urb *);
1240 * when the urb is owned by the hcd, that is, since the call to 1268 * when the urb is owned by the hcd, that is, since the call to
1241 * usb_submit_urb() till the entry into the completion routine. 1269 * usb_submit_urb() till the entry into the completion routine.
1242 */ 1270 */
1243struct urb 1271struct urb {
1244{
1245 /* private: usb core and host controller only fields in the urb */ 1272 /* private: usb core and host controller only fields in the urb */
1246 struct kref kref; /* reference count of the URB */ 1273 struct kref kref; /* reference count of the URB */
1247 void *hcpriv; /* private data for host controller */ 1274 void *hcpriv; /* private data for host controller */
@@ -1252,10 +1279,10 @@ struct urb
1252 /* public: documented fields in the urb that can be used by drivers */ 1279 /* public: documented fields in the urb that can be used by drivers */
1253 struct list_head urb_list; /* list head for use by the urb's 1280 struct list_head urb_list; /* list head for use by the urb's
1254 * current owner */ 1281 * current owner */
1255 struct list_head anchor_list; /* the URB may be anchored by the driver */ 1282 struct list_head anchor_list; /* the URB may be anchored */
1256 struct usb_anchor *anchor; 1283 struct usb_anchor *anchor;
1257 struct usb_device *dev; /* (in) pointer to associated device */ 1284 struct usb_device *dev; /* (in) pointer to associated device */
1258 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint struct */ 1285 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
1259 unsigned int pipe; /* (in) pipe information */ 1286 unsigned int pipe; /* (in) pipe information */
1260 int status; /* (return) non-ISO status */ 1287 int status; /* (return) non-ISO status */
1261 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ 1288 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
@@ -1292,14 +1319,14 @@ struct urb
1292 * Initializes a control urb with the proper information needed to submit 1319 * Initializes a control urb with the proper information needed to submit
1293 * it to a device. 1320 * it to a device.
1294 */ 1321 */
1295static inline void usb_fill_control_urb (struct urb *urb, 1322static inline void usb_fill_control_urb(struct urb *urb,
1296 struct usb_device *dev, 1323 struct usb_device *dev,
1297 unsigned int pipe, 1324 unsigned int pipe,
1298 unsigned char *setup_packet, 1325 unsigned char *setup_packet,
1299 void *transfer_buffer, 1326 void *transfer_buffer,
1300 int buffer_length, 1327 int buffer_length,
1301 usb_complete_t complete_fn, 1328 usb_complete_t complete_fn,
1302 void *context) 1329 void *context)
1303{ 1330{
1304 urb->dev = dev; 1331 urb->dev = dev;
1305 urb->pipe = pipe; 1332 urb->pipe = pipe;
@@ -1323,13 +1350,13 @@ static inline void usb_fill_control_urb (struct urb *urb,
1323 * Initializes a bulk urb with the proper information needed to submit it 1350 * Initializes a bulk urb with the proper information needed to submit it
1324 * to a device. 1351 * to a device.
1325 */ 1352 */
1326static inline void usb_fill_bulk_urb (struct urb *urb, 1353static inline void usb_fill_bulk_urb(struct urb *urb,
1327 struct usb_device *dev, 1354 struct usb_device *dev,
1328 unsigned int pipe, 1355 unsigned int pipe,
1329 void *transfer_buffer, 1356 void *transfer_buffer,
1330 int buffer_length, 1357 int buffer_length,
1331 usb_complete_t complete_fn, 1358 usb_complete_t complete_fn,
1332 void *context) 1359 void *context)
1333{ 1360{
1334 urb->dev = dev; 1361 urb->dev = dev;
1335 urb->pipe = pipe; 1362 urb->pipe = pipe;
@@ -1357,14 +1384,14 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
1357 * the endpoint interval, and express polling intervals in microframes 1384 * the endpoint interval, and express polling intervals in microframes
1358 * (eight per millisecond) rather than in frames (one per millisecond). 1385 * (eight per millisecond) rather than in frames (one per millisecond).
1359 */ 1386 */
1360static inline void usb_fill_int_urb (struct urb *urb, 1387static inline void usb_fill_int_urb(struct urb *urb,
1361 struct usb_device *dev, 1388 struct usb_device *dev,
1362 unsigned int pipe, 1389 unsigned int pipe,
1363 void *transfer_buffer, 1390 void *transfer_buffer,
1364 int buffer_length, 1391 int buffer_length,
1365 usb_complete_t complete_fn, 1392 usb_complete_t complete_fn,
1366 void *context, 1393 void *context,
1367 int interval) 1394 int interval)
1368{ 1395{
1369 urb->dev = dev; 1396 urb->dev = dev;
1370 urb->pipe = pipe; 1397 urb->pipe = pipe;
@@ -1417,15 +1444,15 @@ static inline int usb_urb_dir_out(struct urb *urb)
1417 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; 1444 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
1418} 1445}
1419 1446
1420void *usb_buffer_alloc (struct usb_device *dev, size_t size, 1447void *usb_buffer_alloc(struct usb_device *dev, size_t size,
1421 gfp_t mem_flags, dma_addr_t *dma); 1448 gfp_t mem_flags, dma_addr_t *dma);
1422void usb_buffer_free (struct usb_device *dev, size_t size, 1449void usb_buffer_free(struct usb_device *dev, size_t size,
1423 void *addr, dma_addr_t dma); 1450 void *addr, dma_addr_t dma);
1424 1451
1425#if 0 1452#if 0
1426struct urb *usb_buffer_map (struct urb *urb); 1453struct urb *usb_buffer_map(struct urb *urb);
1427void usb_buffer_dmasync (struct urb *urb); 1454void usb_buffer_dmasync(struct urb *urb);
1428void usb_buffer_unmap (struct urb *urb); 1455void usb_buffer_unmap(struct urb *urb);
1429#endif 1456#endif
1430 1457
1431struct scatterlist; 1458struct scatterlist;
@@ -1497,7 +1524,7 @@ struct usb_sg_request {
1497 int status; 1524 int status;
1498 size_t bytes; 1525 size_t bytes;
1499 1526
1500 /* 1527 /*
1501 * members below are private: to usbcore, 1528 * members below are private: to usbcore,
1502 * and are not provided for driver access! 1529 * and are not provided for driver access!
1503 */ 1530 */
@@ -1515,18 +1542,18 @@ struct usb_sg_request {
1515 struct completion complete; 1542 struct completion complete;
1516}; 1543};
1517 1544
1518int usb_sg_init ( 1545int usb_sg_init(
1519 struct usb_sg_request *io, 1546 struct usb_sg_request *io,
1520 struct usb_device *dev, 1547 struct usb_device *dev,
1521 unsigned pipe, 1548 unsigned pipe,
1522 unsigned period, 1549 unsigned period,
1523 struct scatterlist *sg, 1550 struct scatterlist *sg,
1524 int nents, 1551 int nents,
1525 size_t length, 1552 size_t length,
1526 gfp_t mem_flags 1553 gfp_t mem_flags
1527); 1554);
1528void usb_sg_cancel (struct usb_sg_request *io); 1555void usb_sg_cancel(struct usb_sg_request *io);
1529void usb_sg_wait (struct usb_sg_request *io); 1556void usb_sg_wait(struct usb_sg_request *io);
1530 1557
1531 1558
1532/* ----------------------------------------------------------------------- */ 1559/* ----------------------------------------------------------------------- */
@@ -1583,21 +1610,21 @@ static inline unsigned int __create_pipe(struct usb_device *dev,
1583 1610
1584/* Create various pipes... */ 1611/* Create various pipes... */
1585#define usb_sndctrlpipe(dev,endpoint) \ 1612#define usb_sndctrlpipe(dev,endpoint) \
1586 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint)) 1613 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint))
1587#define usb_rcvctrlpipe(dev,endpoint) \ 1614#define usb_rcvctrlpipe(dev,endpoint) \
1588 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1615 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1589#define usb_sndisocpipe(dev,endpoint) \ 1616#define usb_sndisocpipe(dev,endpoint) \
1590 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint)) 1617 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint))
1591#define usb_rcvisocpipe(dev,endpoint) \ 1618#define usb_rcvisocpipe(dev,endpoint) \
1592 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1619 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1593#define usb_sndbulkpipe(dev,endpoint) \ 1620#define usb_sndbulkpipe(dev,endpoint) \
1594 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint)) 1621 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint))
1595#define usb_rcvbulkpipe(dev,endpoint) \ 1622#define usb_rcvbulkpipe(dev,endpoint) \
1596 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1623 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1597#define usb_sndintpipe(dev,endpoint) \ 1624#define usb_sndintpipe(dev,endpoint) \
1598 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) 1625 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint))
1599#define usb_rcvintpipe(dev,endpoint) \ 1626#define usb_rcvintpipe(dev,endpoint) \
1600 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1627 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1601 1628
1602/*-------------------------------------------------------------------------*/ 1629/*-------------------------------------------------------------------------*/
1603 1630
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
index 6ce42bf9f743..b8cba1dcb2c6 100644
--- a/include/linux/usb/Kbuild
+++ b/include/linux/usb/Kbuild
@@ -1,6 +1,7 @@
1unifdef-y += audio.h 1header-y += audio.h
2unifdef-y += cdc.h 2header-y += cdc.h
3unifdef-y += ch9.h 3header-y += ch9.h
4unifdef-y += gadgetfs.h 4header-y += gadgetfs.h
5unifdef-y += midi.h 5header-y += midi.h
6unifdef-y += g_printer.h
6 7
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index 6bd235994dc2..2dfeef16b221 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -27,13 +27,13 @@
27 27
28/* 4.3.2 Class-Specific AC Interface Descriptor */ 28/* 4.3.2 Class-Specific AC Interface Descriptor */
29struct usb_ac_header_descriptor { 29struct usb_ac_header_descriptor {
30 __u8 bLength; // 8+n 30 __u8 bLength; /* 8+n */
31 __u8 bDescriptorType; // USB_DT_CS_INTERFACE 31 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
32 __u8 bDescriptorSubtype; // USB_MS_HEADER 32 __u8 bDescriptorSubtype; /* USB_MS_HEADER */
33 __le16 bcdADC; // 0x0100 33 __le16 bcdADC; /* 0x0100 */
34 __le16 wTotalLength; // includes Unit and Terminal desc. 34 __le16 wTotalLength; /* includes Unit and Terminal desc. */
35 __u8 bInCollection; // n 35 __u8 bInCollection; /* n */
36 __u8 baInterfaceNr[]; // [n] 36 __u8 baInterfaceNr[]; /* [n] */
37} __attribute__ ((packed)); 37} __attribute__ ((packed));
38 38
39#define USB_DT_AC_HEADER_SIZE(n) (8+(n)) 39#define USB_DT_AC_HEADER_SIZE(n) (8+(n))
diff --git a/include/linux/usb/cdc.h b/include/linux/usb/cdc.h
index 2204ae22c381..94ee4ecf0564 100644
--- a/include/linux/usb/cdc.h
+++ b/include/linux/usb/cdc.h
@@ -29,16 +29,16 @@
29 * Class-Specific descriptors ... there are a couple dozen of them 29 * Class-Specific descriptors ... there are a couple dozen of them
30 */ 30 */
31 31
32#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */ 32#define USB_CDC_HEADER_TYPE 0x00 /* header_desc */
33#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */ 33#define USB_CDC_CALL_MANAGEMENT_TYPE 0x01 /* call_mgmt_descriptor */
34#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */ 34#define USB_CDC_ACM_TYPE 0x02 /* acm_descriptor */
35#define USB_CDC_UNION_TYPE 0x06 /* union_desc */ 35#define USB_CDC_UNION_TYPE 0x06 /* union_desc */
36#define USB_CDC_COUNTRY_TYPE 0x07 36#define USB_CDC_COUNTRY_TYPE 0x07
37#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */ 37#define USB_CDC_NETWORK_TERMINAL_TYPE 0x0a /* network_terminal_desc */
38#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */ 38#define USB_CDC_ETHERNET_TYPE 0x0f /* ether_desc */
39#define USB_CDC_WHCM_TYPE 0x11 39#define USB_CDC_WHCM_TYPE 0x11
40#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */ 40#define USB_CDC_MDLM_TYPE 0x12 /* mdlm_desc */
41#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */ 41#define USB_CDC_MDLM_DETAIL_TYPE 0x13 /* mdlm_detail_desc */
42#define USB_CDC_DMM_TYPE 0x14 42#define USB_CDC_DMM_TYPE 0x14
43#define USB_CDC_OBEX_TYPE 0x15 43#define USB_CDC_OBEX_TYPE 0x15
44 44
diff --git a/include/linux/usb/g_printer.h b/include/linux/usb/g_printer.h
new file mode 100644
index 000000000000..0c5ea1e3eb98
--- /dev/null
+++ b/include/linux/usb/g_printer.h
@@ -0,0 +1,31 @@
1/*
2 * g_printer.h -- Header file for USB Printer gadget driver
3 *
4 * Copyright (C) 2007 Craig W. Nadler
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21
22#define PRINTER_NOT_ERROR 0x08
23#define PRINTER_SELECTED 0x10
24#define PRINTER_PAPER_EMPTY 0x20
25
26/* The 'g' code is also used by gadgetfs ioctl requests.
27 * Don't add any colliding codes to either driver, and keep
28 * them in unique ranges (size 0x20 for now).
29 */
30#define GADGET_GET_PRINTER_STATUS _IOR('g', 0x21, unsigned char)
31#define GADGET_SET_PRINTER_STATUS _IOWR('g', 0x22, unsigned char)
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index c1527c2ef3cb..aa3047ff00d1 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -70,9 +70,10 @@ struct usb_ep;
70 * 70 *
71 * Bulk endpoints can use any size buffers, and can also be used for interrupt 71 * Bulk endpoints can use any size buffers, and can also be used for interrupt
72 * transfers. interrupt-only endpoints can be much less functional. 72 * transfers. interrupt-only endpoints can be much less functional.
73 *
74 * NOTE: this is analagous to 'struct urb' on the host side, except that
75 * it's thinner and promotes more pre-allocation.
73 */ 76 */
74 // NOTE this is analagous to 'struct urb' on the host side,
75 // except that it's thinner and promotes more pre-allocation.
76 77
77struct usb_request { 78struct usb_request {
78 void *buf; 79 void *buf;
@@ -168,10 +169,10 @@ struct usb_ep {
168 * 169 *
169 * returns zero, or a negative error code. 170 * returns zero, or a negative error code.
170 */ 171 */
171static inline int 172static inline int usb_ep_enable(struct usb_ep *ep,
172usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc) 173 const struct usb_endpoint_descriptor *desc)
173{ 174{
174 return ep->ops->enable (ep, desc); 175 return ep->ops->enable(ep, desc);
175} 176}
176 177
177/** 178/**
@@ -186,10 +187,9 @@ usb_ep_enable (struct usb_ep *ep, const struct usb_endpoint_descriptor *desc)
186 * 187 *
187 * returns zero, or a negative error code. 188 * returns zero, or a negative error code.
188 */ 189 */
189static inline int 190static inline int usb_ep_disable(struct usb_ep *ep)
190usb_ep_disable (struct usb_ep *ep)
191{ 191{
192 return ep->ops->disable (ep); 192 return ep->ops->disable(ep);
193} 193}
194 194
195/** 195/**
@@ -206,10 +206,10 @@ usb_ep_disable (struct usb_ep *ep)
206 * 206 *
207 * Returns the request, or null if one could not be allocated. 207 * Returns the request, or null if one could not be allocated.
208 */ 208 */
209static inline struct usb_request * 209static inline struct usb_request *usb_ep_alloc_request(struct usb_ep *ep,
210usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags) 210 gfp_t gfp_flags)
211{ 211{
212 return ep->ops->alloc_request (ep, gfp_flags); 212 return ep->ops->alloc_request(ep, gfp_flags);
213} 213}
214 214
215/** 215/**
@@ -221,10 +221,10 @@ usb_ep_alloc_request (struct usb_ep *ep, gfp_t gfp_flags)
221 * Caller guarantees the request is not queued, and that it will 221 * Caller guarantees the request is not queued, and that it will
222 * no longer be requeued (or otherwise used). 222 * no longer be requeued (or otherwise used).
223 */ 223 */
224static inline void 224static inline void usb_ep_free_request(struct usb_ep *ep,
225usb_ep_free_request (struct usb_ep *ep, struct usb_request *req) 225 struct usb_request *req)
226{ 226{
227 ep->ops->free_request (ep, req); 227 ep->ops->free_request(ep, req);
228} 228}
229 229
230/** 230/**
@@ -281,10 +281,10 @@ usb_ep_free_request (struct usb_ep *ep, struct usb_request *req)
281 * report errors; errors will also be 281 * report errors; errors will also be
282 * reported when the usb peripheral is disconnected. 282 * reported when the usb peripheral is disconnected.
283 */ 283 */
284static inline int 284static inline int usb_ep_queue(struct usb_ep *ep,
285usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags) 285 struct usb_request *req, gfp_t gfp_flags)
286{ 286{
287 return ep->ops->queue (ep, req, gfp_flags); 287 return ep->ops->queue(ep, req, gfp_flags);
288} 288}
289 289
290/** 290/**
@@ -301,9 +301,9 @@ usb_ep_queue (struct usb_ep *ep, struct usb_request *req, gfp_t gfp_flags)
301 * restrictions prevent drivers from supporting configuration changes, 301 * restrictions prevent drivers from supporting configuration changes,
302 * even to configuration zero (a "chapter 9" requirement). 302 * even to configuration zero (a "chapter 9" requirement).
303 */ 303 */
304static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req) 304static inline int usb_ep_dequeue(struct usb_ep *ep, struct usb_request *req)
305{ 305{
306 return ep->ops->dequeue (ep, req); 306 return ep->ops->dequeue(ep, req);
307} 307}
308 308
309/** 309/**
@@ -327,10 +327,9 @@ static inline int usb_ep_dequeue (struct usb_ep *ep, struct usb_request *req)
327 * transfer requests are still queued, or if the controller hardware 327 * transfer requests are still queued, or if the controller hardware
328 * (usually a FIFO) still holds bytes that the host hasn't collected. 328 * (usually a FIFO) still holds bytes that the host hasn't collected.
329 */ 329 */
330static inline int 330static inline int usb_ep_set_halt(struct usb_ep *ep)
331usb_ep_set_halt (struct usb_ep *ep)
332{ 331{
333 return ep->ops->set_halt (ep, 1); 332 return ep->ops->set_halt(ep, 1);
334} 333}
335 334
336/** 335/**
@@ -346,10 +345,9 @@ usb_ep_set_halt (struct usb_ep *ep)
346 * Note that some hardware can't support this request (like pxa2xx_udc), 345 * Note that some hardware can't support this request (like pxa2xx_udc),
347 * and accordingly can't correctly implement interface altsettings. 346 * and accordingly can't correctly implement interface altsettings.
348 */ 347 */
349static inline int 348static inline int usb_ep_clear_halt(struct usb_ep *ep)
350usb_ep_clear_halt (struct usb_ep *ep)
351{ 349{
352 return ep->ops->set_halt (ep, 0); 350 return ep->ops->set_halt(ep, 0);
353} 351}
354 352
355/** 353/**
@@ -367,11 +365,10 @@ usb_ep_clear_halt (struct usb_ep *ep)
367 * errno if the endpoint doesn't use a FIFO or doesn't support such 365 * errno if the endpoint doesn't use a FIFO or doesn't support such
368 * precise handling. 366 * precise handling.
369 */ 367 */
370static inline int 368static inline int usb_ep_fifo_status(struct usb_ep *ep)
371usb_ep_fifo_status (struct usb_ep *ep)
372{ 369{
373 if (ep->ops->fifo_status) 370 if (ep->ops->fifo_status)
374 return ep->ops->fifo_status (ep); 371 return ep->ops->fifo_status(ep);
375 else 372 else
376 return -EOPNOTSUPP; 373 return -EOPNOTSUPP;
377} 374}
@@ -385,11 +382,10 @@ usb_ep_fifo_status (struct usb_ep *ep)
385 * must never be used except when endpoint is not being used for any 382 * must never be used except when endpoint is not being used for any
386 * protocol translation. 383 * protocol translation.
387 */ 384 */
388static inline void 385static inline void usb_ep_fifo_flush(struct usb_ep *ep)
389usb_ep_fifo_flush (struct usb_ep *ep)
390{ 386{
391 if (ep->ops->fifo_flush) 387 if (ep->ops->fifo_flush)
392 ep->ops->fifo_flush (ep); 388 ep->ops->fifo_flush(ep);
393} 389}
394 390
395 391
@@ -469,10 +465,10 @@ struct usb_gadget {
469 struct device dev; 465 struct device dev;
470}; 466};
471 467
472static inline void set_gadget_data (struct usb_gadget *gadget, void *data) 468static inline void set_gadget_data(struct usb_gadget *gadget, void *data)
473 { dev_set_drvdata (&gadget->dev, data); } 469 { dev_set_drvdata(&gadget->dev, data); }
474static inline void *get_gadget_data (struct usb_gadget *gadget) 470static inline void *get_gadget_data(struct usb_gadget *gadget)
475 { return dev_get_drvdata (&gadget->dev); } 471 { return dev_get_drvdata(&gadget->dev); }
476 472
477/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */ 473/* iterates the non-control endpoints; 'tmp' is a struct usb_ep pointer */
478#define gadget_for_each_ep(tmp,gadget) \ 474#define gadget_for_each_ep(tmp,gadget) \
@@ -511,7 +507,6 @@ static inline int gadget_is_otg(struct usb_gadget *g)
511#endif 507#endif
512} 508}
513 509
514
515/** 510/**
516 * usb_gadget_frame_number - returns the current frame number 511 * usb_gadget_frame_number - returns the current frame number
517 * @gadget: controller that reports the frame number 512 * @gadget: controller that reports the frame number
@@ -519,9 +514,9 @@ static inline int gadget_is_otg(struct usb_gadget *g)
519 * Returns the usb frame number, normally eleven bits from a SOF packet, 514 * Returns the usb frame number, normally eleven bits from a SOF packet,
520 * or negative errno if this device doesn't support this capability. 515 * or negative errno if this device doesn't support this capability.
521 */ 516 */
522static inline int usb_gadget_frame_number (struct usb_gadget *gadget) 517static inline int usb_gadget_frame_number(struct usb_gadget *gadget)
523{ 518{
524 return gadget->ops->get_frame (gadget); 519 return gadget->ops->get_frame(gadget);
525} 520}
526 521
527/** 522/**
@@ -537,11 +532,11 @@ static inline int usb_gadget_frame_number (struct usb_gadget *gadget)
537 * even if OTG isn't otherwise in use. OTG devices may also start 532 * even if OTG isn't otherwise in use. OTG devices may also start
538 * remote wakeup even when hosts don't explicitly enable it. 533 * remote wakeup even when hosts don't explicitly enable it.
539 */ 534 */
540static inline int usb_gadget_wakeup (struct usb_gadget *gadget) 535static inline int usb_gadget_wakeup(struct usb_gadget *gadget)
541{ 536{
542 if (!gadget->ops->wakeup) 537 if (!gadget->ops->wakeup)
543 return -EOPNOTSUPP; 538 return -EOPNOTSUPP;
544 return gadget->ops->wakeup (gadget); 539 return gadget->ops->wakeup(gadget);
545} 540}
546 541
547/** 542/**
@@ -553,12 +548,11 @@ static inline int usb_gadget_wakeup (struct usb_gadget *gadget)
553 * 548 *
554 * returns zero on success, else negative errno. 549 * returns zero on success, else negative errno.
555 */ 550 */
556static inline int 551static inline int usb_gadget_set_selfpowered(struct usb_gadget *gadget)
557usb_gadget_set_selfpowered (struct usb_gadget *gadget)
558{ 552{
559 if (!gadget->ops->set_selfpowered) 553 if (!gadget->ops->set_selfpowered)
560 return -EOPNOTSUPP; 554 return -EOPNOTSUPP;
561 return gadget->ops->set_selfpowered (gadget, 1); 555 return gadget->ops->set_selfpowered(gadget, 1);
562} 556}
563 557
564/** 558/**
@@ -571,12 +565,11 @@ usb_gadget_set_selfpowered (struct usb_gadget *gadget)
571 * 565 *
572 * returns zero on success, else negative errno. 566 * returns zero on success, else negative errno.
573 */ 567 */
574static inline int 568static inline int usb_gadget_clear_selfpowered(struct usb_gadget *gadget)
575usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
576{ 569{
577 if (!gadget->ops->set_selfpowered) 570 if (!gadget->ops->set_selfpowered)
578 return -EOPNOTSUPP; 571 return -EOPNOTSUPP;
579 return gadget->ops->set_selfpowered (gadget, 0); 572 return gadget->ops->set_selfpowered(gadget, 0);
580} 573}
581 574
582/** 575/**
@@ -591,12 +584,11 @@ usb_gadget_clear_selfpowered (struct usb_gadget *gadget)
591 * 584 *
592 * Returns zero on success, else negative errno. 585 * Returns zero on success, else negative errno.
593 */ 586 */
594static inline int 587static inline int usb_gadget_vbus_connect(struct usb_gadget *gadget)
595usb_gadget_vbus_connect(struct usb_gadget *gadget)
596{ 588{
597 if (!gadget->ops->vbus_session) 589 if (!gadget->ops->vbus_session)
598 return -EOPNOTSUPP; 590 return -EOPNOTSUPP;
599 return gadget->ops->vbus_session (gadget, 1); 591 return gadget->ops->vbus_session(gadget, 1);
600} 592}
601 593
602/** 594/**
@@ -611,12 +603,11 @@ usb_gadget_vbus_connect(struct usb_gadget *gadget)
611 * 603 *
612 * Returns zero on success, else negative errno. 604 * Returns zero on success, else negative errno.
613 */ 605 */
614static inline int 606static inline int usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
615usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
616{ 607{
617 if (!gadget->ops->vbus_draw) 608 if (!gadget->ops->vbus_draw)
618 return -EOPNOTSUPP; 609 return -EOPNOTSUPP;
619 return gadget->ops->vbus_draw (gadget, mA); 610 return gadget->ops->vbus_draw(gadget, mA);
620} 611}
621 612
622/** 613/**
@@ -629,12 +620,11 @@ usb_gadget_vbus_draw(struct usb_gadget *gadget, unsigned mA)
629 * 620 *
630 * Returns zero on success, else negative errno. 621 * Returns zero on success, else negative errno.
631 */ 622 */
632static inline int 623static inline int usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
633usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
634{ 624{
635 if (!gadget->ops->vbus_session) 625 if (!gadget->ops->vbus_session)
636 return -EOPNOTSUPP; 626 return -EOPNOTSUPP;
637 return gadget->ops->vbus_session (gadget, 0); 627 return gadget->ops->vbus_session(gadget, 0);
638} 628}
639 629
640/** 630/**
@@ -648,12 +638,11 @@ usb_gadget_vbus_disconnect(struct usb_gadget *gadget)
648 * 638 *
649 * Returns zero on success, else negative errno. 639 * Returns zero on success, else negative errno.
650 */ 640 */
651static inline int 641static inline int usb_gadget_connect(struct usb_gadget *gadget)
652usb_gadget_connect (struct usb_gadget *gadget)
653{ 642{
654 if (!gadget->ops->pullup) 643 if (!gadget->ops->pullup)
655 return -EOPNOTSUPP; 644 return -EOPNOTSUPP;
656 return gadget->ops->pullup (gadget, 1); 645 return gadget->ops->pullup(gadget, 1);
657} 646}
658 647
659/** 648/**
@@ -671,16 +660,14 @@ usb_gadget_connect (struct usb_gadget *gadget)
671 * 660 *
672 * Returns zero on success, else negative errno. 661 * Returns zero on success, else negative errno.
673 */ 662 */
674static inline int 663static inline int usb_gadget_disconnect(struct usb_gadget *gadget)
675usb_gadget_disconnect (struct usb_gadget *gadget)
676{ 664{
677 if (!gadget->ops->pullup) 665 if (!gadget->ops->pullup)
678 return -EOPNOTSUPP; 666 return -EOPNOTSUPP;
679 return gadget->ops->pullup (gadget, 0); 667 return gadget->ops->pullup(gadget, 0);
680} 668}
681 669
682 670
683
684/*-------------------------------------------------------------------------*/ 671/*-------------------------------------------------------------------------*/
685 672
686/** 673/**
@@ -764,7 +751,7 @@ struct usb_gadget_driver {
764 void (*suspend)(struct usb_gadget *); 751 void (*suspend)(struct usb_gadget *);
765 void (*resume)(struct usb_gadget *); 752 void (*resume)(struct usb_gadget *);
766 753
767 // FIXME support safe rmmod 754 /* FIXME support safe rmmod */
768 struct device_driver driver; 755 struct device_driver driver;
769}; 756};
770 757
@@ -790,7 +777,7 @@ struct usb_gadget_driver {
790 * the bind() functions will be in init sections. 777 * the bind() functions will be in init sections.
791 * This function must be called in a context that can sleep. 778 * This function must be called in a context that can sleep.
792 */ 779 */
793int usb_gadget_register_driver (struct usb_gadget_driver *driver); 780int usb_gadget_register_driver(struct usb_gadget_driver *driver);
794 781
795/** 782/**
796 * usb_gadget_unregister_driver - unregister a gadget driver 783 * usb_gadget_unregister_driver - unregister a gadget driver
@@ -805,7 +792,7 @@ int usb_gadget_register_driver (struct usb_gadget_driver *driver);
805 * will in in exit sections, so may not be linked in some kernels. 792 * will in in exit sections, so may not be linked in some kernels.
806 * This function must be called in a context that can sleep. 793 * This function must be called in a context that can sleep.
807 */ 794 */
808int usb_gadget_unregister_driver (struct usb_gadget_driver *driver); 795int usb_gadget_unregister_driver(struct usb_gadget_driver *driver);
809 796
810/*-------------------------------------------------------------------------*/ 797/*-------------------------------------------------------------------------*/
811 798
@@ -838,7 +825,7 @@ struct usb_gadget_strings {
838}; 825};
839 826
840/* put descriptor for string with that id into buf (buflen >= 256) */ 827/* put descriptor for string with that id into buf (buflen >= 256) */
841int usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf); 828int usb_gadget_get_string(struct usb_gadget_strings *table, int id, u8 *buf);
842 829
843/*-------------------------------------------------------------------------*/ 830/*-------------------------------------------------------------------------*/
844 831
@@ -856,10 +843,10 @@ int usb_gadget_config_buf(const struct usb_config_descriptor *config,
856 843
857/* utility wrapping a simple endpoint selection policy */ 844/* utility wrapping a simple endpoint selection policy */
858 845
859extern struct usb_ep *usb_ep_autoconfig (struct usb_gadget *, 846extern struct usb_ep *usb_ep_autoconfig(struct usb_gadget *,
860 struct usb_endpoint_descriptor *) __devinit; 847 struct usb_endpoint_descriptor *) __devinit;
861 848
862extern void usb_ep_autoconfig_reset (struct usb_gadget *) __devinit; 849extern void usb_ep_autoconfig_reset(struct usb_gadget *) __devinit;
863 850
864#endif /* __KERNEL__ */ 851#endif /* __KERNEL__ */
865 852
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h
index e8654c338729..c291ab1af747 100644
--- a/include/linux/usb/gadgetfs.h
+++ b/include/linux/usb/gadgetfs.h
@@ -36,7 +36,7 @@ enum usb_gadgetfs_event_type {
36 GADGETFS_DISCONNECT, 36 GADGETFS_DISCONNECT,
37 GADGETFS_SETUP, 37 GADGETFS_SETUP,
38 GADGETFS_SUSPEND, 38 GADGETFS_SUSPEND,
39 // and likely more ! 39 /* and likely more ! */
40}; 40};
41 41
42/* NOTE: this structure must stay the same size and layout on 42/* NOTE: this structure must stay the same size and layout on
@@ -44,21 +44,28 @@ enum usb_gadgetfs_event_type {
44 */ 44 */
45struct usb_gadgetfs_event { 45struct usb_gadgetfs_event {
46 union { 46 union {
47 // NOP, DISCONNECT, SUSPEND: nothing 47 /* NOP, DISCONNECT, SUSPEND: nothing
48 // ... some hardware can't report disconnection 48 * ... some hardware can't report disconnection
49 */
49 50
50 // CONNECT: just the speed 51 /* CONNECT: just the speed */
51 enum usb_device_speed speed; 52 enum usb_device_speed speed;
52 53
53 // SETUP: packet; DATA phase i/o precedes next event 54 /* SETUP: packet; DATA phase i/o precedes next event
54 // (setup.bmRequestType & USB_DIR_IN) flags direction 55 *(setup.bmRequestType & USB_DIR_IN) flags direction
55 // ... includes SET_CONFIGURATION, SET_INTERFACE 56 * ... includes SET_CONFIGURATION, SET_INTERFACE
57 */
56 struct usb_ctrlrequest setup; 58 struct usb_ctrlrequest setup;
57 } u; 59 } u;
58 enum usb_gadgetfs_event_type type; 60 enum usb_gadgetfs_event_type type;
59}; 61};
60 62
61 63
64/* The 'g' code is also used by printer gadget ioctl requests.
65 * Don't add any colliding codes to either driver, and keep
66 * them in unique ranges (size 0x20 for now).
67 */
68
62/* endpoint ioctls */ 69/* endpoint ioctls */
63 70
64/* IN transfers may be reported to the gadget driver as complete 71/* IN transfers may be reported to the gadget driver as complete
@@ -68,14 +75,14 @@ struct usb_gadgetfs_event {
68 * THIS returns how many bytes are "unclaimed" in the endpoint fifo 75 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
69 * (needed for precise fault handling, when the hardware allows it) 76 * (needed for precise fault handling, when the hardware allows it)
70 */ 77 */
71#define GADGETFS_FIFO_STATUS _IO('g',1) 78#define GADGETFS_FIFO_STATUS _IO('g', 1)
72 79
73/* discards any unclaimed data in the fifo. */ 80/* discards any unclaimed data in the fifo. */
74#define GADGETFS_FIFO_FLUSH _IO('g',2) 81#define GADGETFS_FIFO_FLUSH _IO('g', 2)
75 82
76/* resets endpoint halt+toggle; used to implement set_interface. 83/* resets endpoint halt+toggle; used to implement set_interface.
77 * some hardware (like pxa2xx) can't support this. 84 * some hardware (like pxa2xx) can't support this.
78 */ 85 */
79#define GADGETFS_CLEAR_HALT _IO('g',3) 86#define GADGETFS_CLEAR_HALT _IO('g', 3)
80 87
81#endif /* __LINUX_USB_GADGETFS_H */ 88#endif /* __LINUX_USB_GADGETFS_H */
diff --git a/include/linux/usb/iowarrior.h b/include/linux/usb/iowarrior.h
index cbbe020a4f5c..de6f380e17a2 100644
--- a/include/linux/usb/iowarrior.h
+++ b/include/linux/usb/iowarrior.h
@@ -14,14 +14,23 @@
14 this information. 14 this information.
15*/ 15*/
16struct iowarrior_info { 16struct iowarrior_info {
17 __u32 vendor; /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */ 17 /* vendor id : supposed to be USB_VENDOR_ID_CODEMERCS in all cases */
18 __u32 product; /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_XXXXX) */ 18 __u32 vendor;
19 __u8 serial[9]; /* the serial number of our chip (if a serial-number is not available this is empty string) */ 19 /* product id : depends on type of chip (USB_DEVICE_ID_CODEMERCS_X) */
20 __u32 revision; /* revision number of the chip */ 20 __u32 product;
21 __u32 speed; /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */ 21 /* the serial number of our chip (if a serial-number is not available
22 __u32 power; /* power consumption of the device in mA */ 22 * this is empty string) */
23 __u32 if_num; /* the number of the endpoint */ 23 __u8 serial[9];
24 __u32 report_size; /* size of the data-packets on this interface */ 24 /* revision number of the chip */
25 __u32 revision;
26 /* USB-speed of the device (0=UNKNOWN, 1=LOW, 2=FULL 3=HIGH) */
27 __u32 speed;
28 /* power consumption of the device in mA */
29 __u32 power;
30 /* the number of the endpoint */
31 __u32 if_num;
32 /* size of the data-packets on this interface */
33 __u32 report_size;
25}; 34};
26 35
27/* 36/*
diff --git a/include/linux/usb/isp116x.h b/include/linux/usb/isp116x.h
index 436dd8a2b64a..67d2826f34fe 100644
--- a/include/linux/usb/isp116x.h
+++ b/include/linux/usb/isp116x.h
@@ -25,5 +25,5 @@ struct isp116x_platform_data {
25 300ns delay between access to ADDR_REG and DATA_REG 25 300ns delay between access to ADDR_REG and DATA_REG
26 OE, WE MUST NOT be changed during these intervals 26 OE, WE MUST NOT be changed during these intervals
27 */ 27 */
28 void (*delay) (struct device * dev, int delay); 28 void (*delay) (struct device *dev, int delay);
29}; 29};
diff --git a/include/linux/usb/midi.h b/include/linux/usb/midi.h
index 11a97d5ffd34..80624c562921 100644
--- a/include/linux/usb/midi.h
+++ b/include/linux/usb/midi.h
@@ -47,9 +47,9 @@ struct usb_ms_header_descriptor {
47/* 6.1.2.2 MIDI IN Jack Descriptor */ 47/* 6.1.2.2 MIDI IN Jack Descriptor */
48struct usb_midi_in_jack_descriptor { 48struct usb_midi_in_jack_descriptor {
49 __u8 bLength; 49 __u8 bLength;
50 __u8 bDescriptorType; // USB_DT_CS_INTERFACE 50 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
51 __u8 bDescriptorSubtype; // USB_MS_MIDI_IN_JACK 51 __u8 bDescriptorSubtype; /* USB_MS_MIDI_IN_JACK */
52 __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL 52 __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
53 __u8 bJackID; 53 __u8 bJackID;
54 __u8 iJack; 54 __u8 iJack;
55} __attribute__ ((packed)); 55} __attribute__ ((packed));
@@ -64,12 +64,12 @@ struct usb_midi_source_pin {
64/* 6.1.2.3 MIDI OUT Jack Descriptor */ 64/* 6.1.2.3 MIDI OUT Jack Descriptor */
65struct usb_midi_out_jack_descriptor { 65struct usb_midi_out_jack_descriptor {
66 __u8 bLength; 66 __u8 bLength;
67 __u8 bDescriptorType; // USB_DT_CS_INTERFACE 67 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
68 __u8 bDescriptorSubtype; // USB_MS_MIDI_OUT_JACK 68 __u8 bDescriptorSubtype; /* USB_MS_MIDI_OUT_JACK */
69 __u8 bJackType; // USB_MS_EMBEDDED/EXTERNAL 69 __u8 bJackType; /* USB_MS_EMBEDDED/EXTERNAL */
70 __u8 bJackID; 70 __u8 bJackID;
71 __u8 bNrInputPins; // p 71 __u8 bNrInputPins; /* p */
72 struct usb_midi_source_pin pins[]; // [p] 72 struct usb_midi_source_pin pins[]; /* [p] */
73 /*__u8 iJack; -- ommitted due to variable-sized pins[] */ 73 /*__u8 iJack; -- ommitted due to variable-sized pins[] */
74} __attribute__ ((packed)); 74} __attribute__ ((packed));
75 75
@@ -90,11 +90,11 @@ struct usb_midi_out_jack_descriptor_##p { \
90 90
91/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */ 91/* 6.2.2 Class-Specific MS Bulk Data Endpoint Descriptor */
92struct usb_ms_endpoint_descriptor { 92struct usb_ms_endpoint_descriptor {
93 __u8 bLength; // 4+n 93 __u8 bLength; /* 4+n */
94 __u8 bDescriptorType; // USB_DT_CS_ENDPOINT 94 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
95 __u8 bDescriptorSubtype; // USB_MS_GENERAL 95 __u8 bDescriptorSubtype; /* USB_MS_GENERAL */
96 __u8 bNumEmbMIDIJack; // n 96 __u8 bNumEmbMIDIJack; /* n */
97 __u8 baAssocJackID[]; // [n] 97 __u8 baAssocJackID[]; /* [n] */
98} __attribute__ ((packed)); 98} __attribute__ ((packed));
99 99
100#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n)) 100#define USB_DT_MS_ENDPOINT_SIZE(n) (4 + (n))
diff --git a/include/linux/usb/net2280.h b/include/linux/usb/net2280.h
index c602f884f182..ec897cb844ab 100644
--- a/include/linux/usb/net2280.h
+++ b/include/linux/usb/net2280.h
@@ -37,7 +37,7 @@
37 37
38/* main registers, BAR0 + 0x0000 */ 38/* main registers, BAR0 + 0x0000 */
39struct net2280_regs { 39struct net2280_regs {
40 // offset 0x0000 40 /* offset 0x0000 */
41 u32 devinit; 41 u32 devinit;
42#define LOCAL_CLOCK_FREQUENCY 8 42#define LOCAL_CLOCK_FREQUENCY 8
43#define FORCE_PCI_RESET 7 43#define FORCE_PCI_RESET 7
@@ -61,7 +61,7 @@ struct net2280_regs {
61#define EEPROM_WRITE_DATA 0 61#define EEPROM_WRITE_DATA 0
62 u32 eeclkfreq; 62 u32 eeclkfreq;
63 u32 _unused0; 63 u32 _unused0;
64 // offset 0x0010 64 /* offset 0x0010 */
65 65
66 u32 pciirqenb0; /* interrupt PCI master ... */ 66 u32 pciirqenb0; /* interrupt PCI master ... */
67#define SETUP_PACKET_INTERRUPT_ENABLE 7 67#define SETUP_PACKET_INTERRUPT_ENABLE 7
@@ -131,7 +131,7 @@ struct net2280_regs {
131#define RESUME_INTERRUPT_ENABLE 1 131#define RESUME_INTERRUPT_ENABLE 1
132#define SOF_INTERRUPT_ENABLE 0 132#define SOF_INTERRUPT_ENABLE 0
133 133
134 // offset 0x0020 134 /* offset 0x0020 */
135 u32 _unused1; 135 u32 _unused1;
136 u32 usbirqenb1; 136 u32 usbirqenb1;
137#define USB_INTERRUPT_ENABLE 31 137#define USB_INTERRUPT_ENABLE 31
@@ -195,7 +195,7 @@ struct net2280_regs {
195#define SUSPEND_REQUEST_CHANGE_INTERRUPT 2 195#define SUSPEND_REQUEST_CHANGE_INTERRUPT 2
196#define RESUME_INTERRUPT 1 196#define RESUME_INTERRUPT 1
197#define SOF_INTERRUPT 0 197#define SOF_INTERRUPT 0
198 // offset 0x0030 198 /* offset 0x0030 */
199 u32 idxaddr; 199 u32 idxaddr;
200 u32 idxdata; 200 u32 idxdata;
201 u32 fifoctl; 201 u32 fifoctl;
@@ -204,7 +204,7 @@ struct net2280_regs {
204#define PCI_BASE2_SELECT 2 204#define PCI_BASE2_SELECT 2
205#define FIFO_CONFIGURATION_SELECT 0 205#define FIFO_CONFIGURATION_SELECT 0
206 u32 _unused2; 206 u32 _unused2;
207 // offset 0x0040 207 /* offset 0x0040 */
208 u32 memaddr; 208 u32 memaddr;
209#define START 28 209#define START 28
210#define DIRECTION 27 210#define DIRECTION 27
@@ -213,7 +213,7 @@ struct net2280_regs {
213 u32 memdata0; 213 u32 memdata0;
214 u32 memdata1; 214 u32 memdata1;
215 u32 _unused3; 215 u32 _unused3;
216 // offset 0x0050 216 /* offset 0x0050 */
217 u32 gpioctl; 217 u32 gpioctl;
218#define GPIO3_LED_SELECT 12 218#define GPIO3_LED_SELECT 12
219#define GPIO3_INTERRUPT_ENABLE 11 219#define GPIO3_INTERRUPT_ENABLE 11
@@ -237,7 +237,7 @@ struct net2280_regs {
237 237
238/* usb control, BAR0 + 0x0080 */ 238/* usb control, BAR0 + 0x0080 */
239struct net2280_usb_regs { 239struct net2280_usb_regs {
240 // offset 0x0080 240 /* offset 0x0080 */
241 u32 stdrsp; 241 u32 stdrsp;
242#define STALL_UNSUPPORTED_REQUESTS 31 242#define STALL_UNSUPPORTED_REQUESTS 31
243#define SET_TEST_MODE 16 243#define SET_TEST_MODE 16
@@ -275,7 +275,7 @@ struct net2280_usb_regs {
275#define PME_WAKEUP_ENABLE 2 275#define PME_WAKEUP_ENABLE 2
276#define DEVICE_REMOTE_WAKEUP_ENABLE 1 276#define DEVICE_REMOTE_WAKEUP_ENABLE 1
277#define SELF_POWERED_STATUS 0 277#define SELF_POWERED_STATUS 0
278 // offset 0x0090 278 /* offset 0x0090 */
279 u32 usbstat; 279 u32 usbstat;
280#define HIGH_SPEED 7 280#define HIGH_SPEED 7
281#define FULL_SPEED 6 281#define FULL_SPEED 6
@@ -291,7 +291,7 @@ struct net2280_usb_regs {
291#define TERMINATION_SELECT 0 291#define TERMINATION_SELECT 0
292 u32 setup0123; 292 u32 setup0123;
293 u32 setup4567; 293 u32 setup4567;
294 // offset 0x0090 294 /* offset 0x0090 */
295 u32 _unused0; 295 u32 _unused0;
296 u32 ouraddr; 296 u32 ouraddr;
297#define FORCE_IMMEDIATE 7 297#define FORCE_IMMEDIATE 7
@@ -301,7 +301,7 @@ struct net2280_usb_regs {
301 301
302/* pci control, BAR0 + 0x0100 */ 302/* pci control, BAR0 + 0x0100 */
303struct net2280_pci_regs { 303struct net2280_pci_regs {
304 // offset 0x0100 304 /* offset 0x0100 */
305 u32 pcimstctl; 305 u32 pcimstctl;
306#define PCI_ARBITER_PARK_SELECT 13 306#define PCI_ARBITER_PARK_SELECT 13
307#define PCI_MULTI LEVEL_ARBITER 12 307#define PCI_MULTI LEVEL_ARBITER 12
@@ -331,7 +331,7 @@ struct net2280_pci_regs {
331 * that can be loaded into some of these registers. 331 * that can be loaded into some of these registers.
332 */ 332 */
333struct net2280_dma_regs { /* [11.7] */ 333struct net2280_dma_regs { /* [11.7] */
334 // offset 0x0180, 0x01a0, 0x01c0, 0x01e0, 334 /* offset 0x0180, 0x01a0, 0x01c0, 0x01e0, */
335 u32 dmactl; 335 u32 dmactl;
336#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25 336#define DMA_SCATTER_GATHER_DONE_INTERRUPT_ENABLE 25
337#define DMA_CLEAR_COUNT_ENABLE 21 337#define DMA_CLEAR_COUNT_ENABLE 21
@@ -355,7 +355,7 @@ struct net2280_dma_regs { /* [11.7] */
355#define DMA_ABORT 1 355#define DMA_ABORT 1
356#define DMA_START 0 356#define DMA_START 0
357 u32 _unused0 [2]; 357 u32 _unused0 [2];
358 // offset 0x0190, 0x01b0, 0x01d0, 0x01f0, 358 /* offset 0x0190, 0x01b0, 0x01d0, 0x01f0, */
359 u32 dmacount; 359 u32 dmacount;
360#define VALID_BIT 31 360#define VALID_BIT 31
361#define DMA_DIRECTION 30 361#define DMA_DIRECTION 30
@@ -371,9 +371,9 @@ struct net2280_dma_regs { /* [11.7] */
371/* dedicated endpoint registers, BAR0 + 0x0200 */ 371/* dedicated endpoint registers, BAR0 + 0x0200 */
372 372
373struct net2280_dep_regs { /* [11.8] */ 373struct net2280_dep_regs { /* [11.8] */
374 // offset 0x0200, 0x0210, 0x220, 0x230, 0x240 374 /* offset 0x0200, 0x0210, 0x220, 0x230, 0x240 */
375 u32 dep_cfg; 375 u32 dep_cfg;
376 // offset 0x0204, 0x0214, 0x224, 0x234, 0x244 376 /* offset 0x0204, 0x0214, 0x224, 0x234, 0x244 */
377 u32 dep_rsp; 377 u32 dep_rsp;
378 u32 _unused [2]; 378 u32 _unused [2];
379} __attribute__ ((packed)); 379} __attribute__ ((packed));
@@ -383,7 +383,7 @@ struct net2280_dep_regs { /* [11.8] */
383 * ep0 reserved for control; E and F have only 64 bytes of fifo 383 * ep0 reserved for control; E and F have only 64 bytes of fifo
384 */ 384 */
385struct net2280_ep_regs { /* [11.9] */ 385struct net2280_ep_regs { /* [11.9] */
386 // offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 386 /* offset 0x0300, 0x0320, 0x0340, 0x0360, 0x0380, 0x03a0, 0x03c0 */
387 u32 ep_cfg; 387 u32 ep_cfg;
388#define ENDPOINT_BYTE_COUNT 16 388#define ENDPOINT_BYTE_COUNT 16
389#define ENDPOINT_ENABLE 10 389#define ENDPOINT_ENABLE 10
@@ -435,7 +435,7 @@ struct net2280_ep_regs { /* [11.9] */
435#define DATA_PACKET_TRANSMITTED_INTERRUPT 2 435#define DATA_PACKET_TRANSMITTED_INTERRUPT 2
436#define DATA_OUT_PING_TOKEN_INTERRUPT 1 436#define DATA_OUT_PING_TOKEN_INTERRUPT 1
437#define DATA_IN_TOKEN_INTERRUPT 0 437#define DATA_IN_TOKEN_INTERRUPT 0
438 // offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 438 /* offset 0x0310, 0x0330, 0x0350, 0x0370, 0x0390, 0x03b0, 0x03d0 */
439 u32 ep_avail; 439 u32 ep_avail;
440 u32 ep_data; 440 u32 ep_data;
441 u32 _unused0 [2]; 441 u32 _unused0 [2];
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index 9897f7a818c5..e007074ebe41 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -1,4 +1,4 @@
1// include/linux/usb/otg.h 1/* USB OTG (On The Go) defines */
2 2
3/* 3/*
4 * These APIs may be used between USB controllers. USB device drivers 4 * These APIs may be used between USB controllers. USB device drivers
diff --git a/include/linux/usb/rndis_host.h b/include/linux/usb/rndis_host.h
new file mode 100644
index 000000000000..edc1d4a0e272
--- /dev/null
+++ b/include/linux/usb/rndis_host.h
@@ -0,0 +1,274 @@
1/*
2 * Host Side support for RNDIS Networking Links
3 * Copyright (C) 2005 by David Brownell
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20
21#ifndef __RNDIS_HOST_H
22#define __RNDIS_HOST_H
23
24
25/*
26 * CONTROL uses CDC "encapsulated commands" with funky notifications.
27 * - control-out: SEND_ENCAPSULATED
28 * - interrupt-in: RESPONSE_AVAILABLE
29 * - control-in: GET_ENCAPSULATED
30 *
31 * We'll try to ignore the RESPONSE_AVAILABLE notifications.
32 *
33 * REVISIT some RNDIS implementations seem to have curious issues still
34 * to be resolved.
35 */
36struct rndis_msg_hdr {
37 __le32 msg_type; /* RNDIS_MSG_* */
38 __le32 msg_len;
39 // followed by data that varies between messages
40 __le32 request_id;
41 __le32 status;
42 // ... and more
43} __attribute__ ((packed));
44
45/* MS-Windows uses this strange size, but RNDIS spec says 1024 minimum */
46#define CONTROL_BUFFER_SIZE 1025
47
48/* RNDIS defines an (absurdly huge) 10 second control timeout,
49 * but ActiveSync seems to use a more usual 5 second timeout
50 * (which matches the USB 2.0 spec).
51 */
52#define RNDIS_CONTROL_TIMEOUT_MS (5 * 1000)
53
54
55#define ccpu2 __constant_cpu_to_le32
56
57#define RNDIS_MSG_COMPLETION ccpu2(0x80000000)
58
59/* codes for "msg_type" field of rndis messages;
60 * only the data channel uses packet messages (maybe batched);
61 * everything else goes on the control channel.
62 */
63#define RNDIS_MSG_PACKET ccpu2(0x00000001) /* 1-N packets */
64#define RNDIS_MSG_INIT ccpu2(0x00000002)
65#define RNDIS_MSG_INIT_C (RNDIS_MSG_INIT|RNDIS_MSG_COMPLETION)
66#define RNDIS_MSG_HALT ccpu2(0x00000003)
67#define RNDIS_MSG_QUERY ccpu2(0x00000004)
68#define RNDIS_MSG_QUERY_C (RNDIS_MSG_QUERY|RNDIS_MSG_COMPLETION)
69#define RNDIS_MSG_SET ccpu2(0x00000005)
70#define RNDIS_MSG_SET_C (RNDIS_MSG_SET|RNDIS_MSG_COMPLETION)
71#define RNDIS_MSG_RESET ccpu2(0x00000006)
72#define RNDIS_MSG_RESET_C (RNDIS_MSG_RESET|RNDIS_MSG_COMPLETION)
73#define RNDIS_MSG_INDICATE ccpu2(0x00000007)
74#define RNDIS_MSG_KEEPALIVE ccpu2(0x00000008)
75#define RNDIS_MSG_KEEPALIVE_C (RNDIS_MSG_KEEPALIVE|RNDIS_MSG_COMPLETION)
76
77/* codes for "status" field of completion messages */
78#define RNDIS_STATUS_SUCCESS ccpu2(0x00000000)
79#define RNDIS_STATUS_FAILURE ccpu2(0xc0000001)
80#define RNDIS_STATUS_INVALID_DATA ccpu2(0xc0010015)
81#define RNDIS_STATUS_NOT_SUPPORTED ccpu2(0xc00000bb)
82#define RNDIS_STATUS_MEDIA_CONNECT ccpu2(0x4001000b)
83#define RNDIS_STATUS_MEDIA_DISCONNECT ccpu2(0x4001000c)
84
85/* codes for OID_GEN_PHYSICAL_MEDIUM */
86#define RNDIS_PHYSICAL_MEDIUM_UNSPECIFIED ccpu2(0x00000000)
87#define RNDIS_PHYSICAL_MEDIUM_WIRELESS_LAN ccpu2(0x00000001)
88#define RNDIS_PHYSICAL_MEDIUM_CABLE_MODEM ccpu2(0x00000002)
89#define RNDIS_PHYSICAL_MEDIUM_PHONE_LINE ccpu2(0x00000003)
90#define RNDIS_PHYSICAL_MEDIUM_POWER_LINE ccpu2(0x00000004)
91#define RNDIS_PHYSICAL_MEDIUM_DSL ccpu2(0x00000005)
92#define RNDIS_PHYSICAL_MEDIUM_FIBRE_CHANNEL ccpu2(0x00000006)
93#define RNDIS_PHYSICAL_MEDIUM_1394 ccpu2(0x00000007)
94#define RNDIS_PHYSICAL_MEDIUM_WIRELESS_WAN ccpu2(0x00000008)
95#define RNDIS_PHYSICAL_MEDIUM_MAX ccpu2(0x00000009)
96
97struct rndis_data_hdr {
98 __le32 msg_type; /* RNDIS_MSG_PACKET */
99 __le32 msg_len; // rndis_data_hdr + data_len + pad
100 __le32 data_offset; // 36 -- right after header
101 __le32 data_len; // ... real packet size
102
103 __le32 oob_data_offset; // zero
104 __le32 oob_data_len; // zero
105 __le32 num_oob; // zero
106 __le32 packet_data_offset; // zero
107
108 __le32 packet_data_len; // zero
109 __le32 vc_handle; // zero
110 __le32 reserved; // zero
111} __attribute__ ((packed));
112
113struct rndis_init { /* OUT */
114 // header and:
115 __le32 msg_type; /* RNDIS_MSG_INIT */
116 __le32 msg_len; // 24
117 __le32 request_id;
118 __le32 major_version; // of rndis (1.0)
119 __le32 minor_version;
120 __le32 max_transfer_size;
121} __attribute__ ((packed));
122
123struct rndis_init_c { /* IN */
124 // header and:
125 __le32 msg_type; /* RNDIS_MSG_INIT_C */
126 __le32 msg_len;
127 __le32 request_id;
128 __le32 status;
129 __le32 major_version; // of rndis (1.0)
130 __le32 minor_version;
131 __le32 device_flags;
132 __le32 medium; // zero == 802.3
133 __le32 max_packets_per_message;
134 __le32 max_transfer_size;
135 __le32 packet_alignment; // max 7; (1<<n) bytes
136 __le32 af_list_offset; // zero
137 __le32 af_list_size; // zero
138} __attribute__ ((packed));
139
140struct rndis_halt { /* OUT (no reply) */
141 // header and:
142 __le32 msg_type; /* RNDIS_MSG_HALT */
143 __le32 msg_len;
144 __le32 request_id;
145} __attribute__ ((packed));
146
147struct rndis_query { /* OUT */
148 // header and:
149 __le32 msg_type; /* RNDIS_MSG_QUERY */
150 __le32 msg_len;
151 __le32 request_id;
152 __le32 oid;
153 __le32 len;
154 __le32 offset;
155/*?*/ __le32 handle; // zero
156} __attribute__ ((packed));
157
158struct rndis_query_c { /* IN */
159 // header and:
160 __le32 msg_type; /* RNDIS_MSG_QUERY_C */
161 __le32 msg_len;
162 __le32 request_id;
163 __le32 status;
164 __le32 len;
165 __le32 offset;
166} __attribute__ ((packed));
167
168struct rndis_set { /* OUT */
169 // header and:
170 __le32 msg_type; /* RNDIS_MSG_SET */
171 __le32 msg_len;
172 __le32 request_id;
173 __le32 oid;
174 __le32 len;
175 __le32 offset;
176/*?*/ __le32 handle; // zero
177} __attribute__ ((packed));
178
179struct rndis_set_c { /* IN */
180 // header and:
181 __le32 msg_type; /* RNDIS_MSG_SET_C */
182 __le32 msg_len;
183 __le32 request_id;
184 __le32 status;
185} __attribute__ ((packed));
186
187struct rndis_reset { /* IN */
188 // header and:
189 __le32 msg_type; /* RNDIS_MSG_RESET */
190 __le32 msg_len;
191 __le32 reserved;
192} __attribute__ ((packed));
193
194struct rndis_reset_c { /* OUT */
195 // header and:
196 __le32 msg_type; /* RNDIS_MSG_RESET_C */
197 __le32 msg_len;
198 __le32 status;
199 __le32 addressing_lost;
200} __attribute__ ((packed));
201
202struct rndis_indicate { /* IN (unrequested) */
203 // header and:
204 __le32 msg_type; /* RNDIS_MSG_INDICATE */
205 __le32 msg_len;
206 __le32 status;
207 __le32 length;
208 __le32 offset;
209/**/ __le32 diag_status;
210 __le32 error_offset;
211/**/ __le32 message;
212} __attribute__ ((packed));
213
214struct rndis_keepalive { /* OUT (optionally IN) */
215 // header and:
216 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE */
217 __le32 msg_len;
218 __le32 request_id;
219} __attribute__ ((packed));
220
221struct rndis_keepalive_c { /* IN (optionally OUT) */
222 // header and:
223 __le32 msg_type; /* RNDIS_MSG_KEEPALIVE_C */
224 __le32 msg_len;
225 __le32 request_id;
226 __le32 status;
227} __attribute__ ((packed));
228
229/* NOTE: about 30 OIDs are "mandatory" for peripherals to support ... and
230 * there are gobs more that may optionally be supported. We'll avoid as much
231 * of that mess as possible.
232 */
233#define OID_802_3_PERMANENT_ADDRESS ccpu2(0x01010101)
234#define OID_GEN_MAXIMUM_FRAME_SIZE ccpu2(0x00010106)
235#define OID_GEN_CURRENT_PACKET_FILTER ccpu2(0x0001010e)
236#define OID_GEN_PHYSICAL_MEDIUM ccpu2(0x00010202)
237
238/* packet filter bits used by OID_GEN_CURRENT_PACKET_FILTER */
239#define RNDIS_PACKET_TYPE_DIRECTED ccpu2(0x00000001)
240#define RNDIS_PACKET_TYPE_MULTICAST ccpu2(0x00000002)
241#define RNDIS_PACKET_TYPE_ALL_MULTICAST ccpu2(0x00000004)
242#define RNDIS_PACKET_TYPE_BROADCAST ccpu2(0x00000008)
243#define RNDIS_PACKET_TYPE_SOURCE_ROUTING ccpu2(0x00000010)
244#define RNDIS_PACKET_TYPE_PROMISCUOUS ccpu2(0x00000020)
245#define RNDIS_PACKET_TYPE_SMT ccpu2(0x00000040)
246#define RNDIS_PACKET_TYPE_ALL_LOCAL ccpu2(0x00000080)
247#define RNDIS_PACKET_TYPE_GROUP ccpu2(0x00001000)
248#define RNDIS_PACKET_TYPE_ALL_FUNCTIONAL ccpu2(0x00002000)
249#define RNDIS_PACKET_TYPE_FUNCTIONAL ccpu2(0x00004000)
250#define RNDIS_PACKET_TYPE_MAC_FRAME ccpu2(0x00008000)
251
252/* default filter used with RNDIS devices */
253#define RNDIS_DEFAULT_FILTER ( \
254 RNDIS_PACKET_TYPE_DIRECTED | \
255 RNDIS_PACKET_TYPE_BROADCAST | \
256 RNDIS_PACKET_TYPE_ALL_MULTICAST | \
257 RNDIS_PACKET_TYPE_PROMISCUOUS)
258
259/* Flags to require specific physical medium type for generic_rndis_bind() */
260#define FLAG_RNDIS_PHYM_NOT_WIRELESS 0x0001
261#define FLAG_RNDIS_PHYM_WIRELESS 0x0002
262
263
264extern void rndis_status(struct usbnet *dev, struct urb *urb);
265extern int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf);
266extern int
267generic_rndis_bind(struct usbnet *dev, struct usb_interface *intf, int flags);
268extern void rndis_unbind(struct usbnet *dev, struct usb_interface *intf);
269extern int rndis_rx_fixup(struct usbnet *dev, struct sk_buff *skb);
270extern struct sk_buff *
271rndis_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags);
272
273#endif /* __RNDIS_HOST_H */
274
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 488ce128885c..21b4a1c6f585 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -20,7 +20,8 @@
20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ 21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */
22 22
23#define MAX_NUM_PORTS 8 /* The maximum number of ports one device can grab at once */ 23/* The maximum number of ports one device can grab at once */
24#define MAX_NUM_PORTS 8
24 25
25/* parity check flag */ 26/* parity check flag */
26#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK)) 27#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
@@ -61,29 +62,29 @@
61 * ports of a device. 62 * ports of a device.
62 */ 63 */
63struct usb_serial_port { 64struct usb_serial_port {
64 struct usb_serial * serial; 65 struct usb_serial *serial;
65 struct tty_struct * tty; 66 struct tty_struct *tty;
66 spinlock_t lock; 67 spinlock_t lock;
67 struct mutex mutex; 68 struct mutex mutex;
68 unsigned char number; 69 unsigned char number;
69 70
70 unsigned char * interrupt_in_buffer; 71 unsigned char *interrupt_in_buffer;
71 struct urb * interrupt_in_urb; 72 struct urb *interrupt_in_urb;
72 __u8 interrupt_in_endpointAddress; 73 __u8 interrupt_in_endpointAddress;
73 74
74 unsigned char * interrupt_out_buffer; 75 unsigned char *interrupt_out_buffer;
75 int interrupt_out_size; 76 int interrupt_out_size;
76 struct urb * interrupt_out_urb; 77 struct urb *interrupt_out_urb;
77 __u8 interrupt_out_endpointAddress; 78 __u8 interrupt_out_endpointAddress;
78 79
79 unsigned char * bulk_in_buffer; 80 unsigned char *bulk_in_buffer;
80 int bulk_in_size; 81 int bulk_in_size;
81 struct urb * read_urb; 82 struct urb *read_urb;
82 __u8 bulk_in_endpointAddress; 83 __u8 bulk_in_endpointAddress;
83 84
84 unsigned char * bulk_out_buffer; 85 unsigned char *bulk_out_buffer;
85 int bulk_out_size; 86 int bulk_out_size;
86 struct urb * write_urb; 87 struct urb *write_urb;
87 int write_urb_busy; 88 int write_urb_busy;
88 __u8 bulk_out_endpointAddress; 89 __u8 bulk_out_endpointAddress;
89 90
@@ -92,17 +93,19 @@ struct usb_serial_port {
92 int open_count; 93 int open_count;
93 char throttled; 94 char throttled;
94 char throttle_req; 95 char throttle_req;
96 char console;
95 struct device dev; 97 struct device dev;
96}; 98};
97#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev) 99#define to_usb_serial_port(d) container_of(d, struct usb_serial_port, dev)
98 100
99/* get and set the port private data pointer helper functions */ 101/* get and set the port private data pointer helper functions */
100static inline void *usb_get_serial_port_data (struct usb_serial_port *port) 102static inline void *usb_get_serial_port_data(struct usb_serial_port *port)
101{ 103{
102 return dev_get_drvdata(&port->dev); 104 return dev_get_drvdata(&port->dev);
103} 105}
104 106
105static inline void usb_set_serial_port_data (struct usb_serial_port *port, void *data) 107static inline void usb_set_serial_port_data(struct usb_serial_port *port,
108 void *data)
106{ 109{
107 dev_set_drvdata(&port->dev, data); 110 dev_set_drvdata(&port->dev, data);
108} 111}
@@ -125,9 +128,10 @@ static inline void usb_set_serial_port_data (struct usb_serial_port *port, void
125 * usb_set_serial_data() to access this. 128 * usb_set_serial_data() to access this.
126 */ 129 */
127struct usb_serial { 130struct usb_serial {
128 struct usb_device * dev; 131 struct usb_device *dev;
129 struct usb_serial_driver * type; 132 struct usb_serial_driver *type;
130 struct usb_interface * interface; 133 struct usb_interface *interface;
134 unsigned char disconnected;
131 unsigned char minor; 135 unsigned char minor;
132 unsigned char num_ports; 136 unsigned char num_ports;
133 unsigned char num_port_pointers; 137 unsigned char num_port_pointers;
@@ -135,29 +139,30 @@ struct usb_serial {
135 char num_interrupt_out; 139 char num_interrupt_out;
136 char num_bulk_in; 140 char num_bulk_in;
137 char num_bulk_out; 141 char num_bulk_out;
138 struct usb_serial_port * port[MAX_NUM_PORTS]; 142 struct usb_serial_port *port[MAX_NUM_PORTS];
139 struct kref kref; 143 struct kref kref;
140 void * private; 144 struct mutex disc_mutex;
145 void *private;
141}; 146};
142#define to_usb_serial(d) container_of(d, struct usb_serial, kref) 147#define to_usb_serial(d) container_of(d, struct usb_serial, kref)
143 148
144#define NUM_DONT_CARE 99 149#define NUM_DONT_CARE 99
145 150
146/* get and set the serial private data pointer helper functions */ 151/* get and set the serial private data pointer helper functions */
147static inline void *usb_get_serial_data (struct usb_serial *serial) 152static inline void *usb_get_serial_data(struct usb_serial *serial)
148{ 153{
149 return serial->private; 154 return serial->private;
150} 155}
151 156
152static inline void usb_set_serial_data (struct usb_serial *serial, void *data) 157static inline void usb_set_serial_data(struct usb_serial *serial, void *data)
153{ 158{
154 serial->private = data; 159 serial->private = data;
155} 160}
156 161
157/** 162/**
158 * usb_serial_driver - describes a usb serial driver 163 * usb_serial_driver - describes a usb serial driver
159 * @description: pointer to a string that describes this driver. This string used 164 * @description: pointer to a string that describes this driver. This string
160 * in the syslog messages when a device is inserted or removed. 165 * used in the syslog messages when a device is inserted or removed.
161 * @id_table: pointer to a list of usb_device_id structures that define all 166 * @id_table: pointer to a list of usb_device_id structures that define all
162 * of the devices this structure can support. 167 * of the devices this structure can support.
163 * @num_interrupt_in: If a device doesn't have this many interrupt-in 168 * @num_interrupt_in: If a device doesn't have this many interrupt-in
@@ -218,82 +223,91 @@ struct usb_serial_driver {
218 struct usb_driver *usb_driver; 223 struct usb_driver *usb_driver;
219 struct usb_dynids dynids; 224 struct usb_dynids dynids;
220 225
221 int (*probe) (struct usb_serial *serial, const struct usb_device_id *id); 226 int (*probe)(struct usb_serial *serial, const struct usb_device_id *id);
222 int (*attach) (struct usb_serial *serial); 227 int (*attach)(struct usb_serial *serial);
223 int (*calc_num_ports) (struct usb_serial *serial); 228 int (*calc_num_ports) (struct usb_serial *serial);
224 229
225 void (*shutdown) (struct usb_serial *serial); 230 void (*shutdown)(struct usb_serial *serial);
226 231
227 int (*port_probe) (struct usb_serial_port *port); 232 int (*port_probe)(struct usb_serial_port *port);
228 int (*port_remove) (struct usb_serial_port *port); 233 int (*port_remove)(struct usb_serial_port *port);
229 234
230 int (*suspend) (struct usb_serial *serial, pm_message_t message); 235 int (*suspend)(struct usb_serial *serial, pm_message_t message);
231 int (*resume) (struct usb_serial *serial); 236 int (*resume)(struct usb_serial *serial);
232 237
233 /* serial function calls */ 238 /* serial function calls */
234 int (*open) (struct usb_serial_port *port, struct file * filp); 239 int (*open)(struct usb_serial_port *port, struct file *filp);
235 void (*close) (struct usb_serial_port *port, struct file * filp); 240 void (*close)(struct usb_serial_port *port, struct file *filp);
236 int (*write) (struct usb_serial_port *port, const unsigned char *buf, int count); 241 int (*write)(struct usb_serial_port *port, const unsigned char *buf,
237 int (*write_room) (struct usb_serial_port *port); 242 int count);
238 int (*ioctl) (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg); 243 int (*write_room)(struct usb_serial_port *port);
239 void (*set_termios) (struct usb_serial_port *port, struct ktermios * old); 244 int (*ioctl)(struct usb_serial_port *port, struct file *file,
240 void (*break_ctl) (struct usb_serial_port *port, int break_state); 245 unsigned int cmd, unsigned long arg);
241 int (*chars_in_buffer) (struct usb_serial_port *port); 246 void (*set_termios)(struct usb_serial_port *port, struct ktermios *old);
242 void (*throttle) (struct usb_serial_port *port); 247 void (*break_ctl)(struct usb_serial_port *port, int break_state);
243 void (*unthrottle) (struct usb_serial_port *port); 248 int (*chars_in_buffer)(struct usb_serial_port *port);
244 int (*tiocmget) (struct usb_serial_port *port, struct file *file); 249 void (*throttle)(struct usb_serial_port *port);
245 int (*tiocmset) (struct usb_serial_port *port, struct file *file, unsigned int set, unsigned int clear); 250 void (*unthrottle)(struct usb_serial_port *port);
251 int (*tiocmget)(struct usb_serial_port *port, struct file *file);
252 int (*tiocmset)(struct usb_serial_port *port, struct file *file,
253 unsigned int set, unsigned int clear);
246 254
247 void (*read_int_callback)(struct urb *urb); 255 void (*read_int_callback)(struct urb *urb);
248 void (*write_int_callback)(struct urb *urb); 256 void (*write_int_callback)(struct urb *urb);
249 void (*read_bulk_callback)(struct urb *urb); 257 void (*read_bulk_callback)(struct urb *urb);
250 void (*write_bulk_callback)(struct urb *urb); 258 void (*write_bulk_callback)(struct urb *urb);
251}; 259};
252#define to_usb_serial_driver(d) container_of(d, struct usb_serial_driver, driver) 260#define to_usb_serial_driver(d) \
261 container_of(d, struct usb_serial_driver, driver)
253 262
254extern int usb_serial_register(struct usb_serial_driver *driver); 263extern int usb_serial_register(struct usb_serial_driver *driver);
255extern void usb_serial_deregister(struct usb_serial_driver *driver); 264extern void usb_serial_deregister(struct usb_serial_driver *driver);
256extern void usb_serial_port_softint(struct usb_serial_port *port); 265extern void usb_serial_port_softint(struct usb_serial_port *port);
257 266
258extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); 267extern int usb_serial_probe(struct usb_interface *iface,
268 const struct usb_device_id *id);
259extern void usb_serial_disconnect(struct usb_interface *iface); 269extern void usb_serial_disconnect(struct usb_interface *iface);
260 270
261extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message); 271extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
262extern int usb_serial_resume(struct usb_interface *intf); 272extern int usb_serial_resume(struct usb_interface *intf);
263 273
264extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest); 274extern int ezusb_writememory(struct usb_serial *serial, int address,
265extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit); 275 unsigned char *data, int length, __u8 bRequest);
276extern int ezusb_set_reset(struct usb_serial *serial, unsigned char reset_bit);
266 277
267/* USB Serial console functions */ 278/* USB Serial console functions */
268#ifdef CONFIG_USB_SERIAL_CONSOLE 279#ifdef CONFIG_USB_SERIAL_CONSOLE
269extern void usb_serial_console_init (int debug, int minor); 280extern void usb_serial_console_init(int debug, int minor);
270extern void usb_serial_console_exit (void); 281extern void usb_serial_console_exit(void);
271extern void usb_serial_console_disconnect(struct usb_serial *serial); 282extern void usb_serial_console_disconnect(struct usb_serial *serial);
272#else 283#else
273static inline void usb_serial_console_init (int debug, int minor) { } 284static inline void usb_serial_console_init(int debug, int minor) { }
274static inline void usb_serial_console_exit (void) { } 285static inline void usb_serial_console_exit(void) { }
275static inline void usb_serial_console_disconnect(struct usb_serial *serial) {} 286static inline void usb_serial_console_disconnect(struct usb_serial *serial) {}
276#endif 287#endif
277 288
278/* Functions needed by other parts of the usbserial core */ 289/* Functions needed by other parts of the usbserial core */
279extern struct usb_serial *usb_serial_get_by_index (unsigned int minor); 290extern struct usb_serial *usb_serial_get_by_index(unsigned int minor);
280extern void usb_serial_put(struct usb_serial *serial); 291extern void usb_serial_put(struct usb_serial *serial);
281extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp); 292extern int usb_serial_generic_open(struct usb_serial_port *port,
282extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count); 293 struct file *filp);
283extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp); 294extern int usb_serial_generic_write(struct usb_serial_port *port,
284extern int usb_serial_generic_resume (struct usb_serial *serial); 295 const unsigned char *buf, int count);
285extern int usb_serial_generic_write_room (struct usb_serial_port *port); 296extern void usb_serial_generic_close(struct usb_serial_port *port,
286extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port); 297 struct file *filp);
287extern void usb_serial_generic_read_bulk_callback (struct urb *urb); 298extern int usb_serial_generic_resume(struct usb_serial *serial);
288extern void usb_serial_generic_write_bulk_callback (struct urb *urb); 299extern int usb_serial_generic_write_room(struct usb_serial_port *port);
289extern void usb_serial_generic_throttle (struct usb_serial_port *port); 300extern int usb_serial_generic_chars_in_buffer(struct usb_serial_port *port);
290extern void usb_serial_generic_unthrottle (struct usb_serial_port *port); 301extern void usb_serial_generic_read_bulk_callback(struct urb *urb);
291extern void usb_serial_generic_shutdown (struct usb_serial *serial); 302extern void usb_serial_generic_write_bulk_callback(struct urb *urb);
292extern int usb_serial_generic_register (int debug); 303extern void usb_serial_generic_throttle(struct usb_serial_port *port);
293extern void usb_serial_generic_deregister (void); 304extern void usb_serial_generic_unthrottle(struct usb_serial_port *port);
294 305extern void usb_serial_generic_shutdown(struct usb_serial *serial);
295extern int usb_serial_bus_register (struct usb_serial_driver *device); 306extern int usb_serial_generic_register(int debug);
296extern void usb_serial_bus_deregister (struct usb_serial_driver *device); 307extern void usb_serial_generic_deregister(void);
308
309extern int usb_serial_bus_register(struct usb_serial_driver *device);
310extern void usb_serial_bus_deregister(struct usb_serial_driver *device);
297 311
298extern struct usb_serial_driver usb_serial_generic_device; 312extern struct usb_serial_driver usb_serial_generic_device;
299extern struct bus_type usb_serial_bus_type; 313extern struct bus_type usb_serial_bus_type;
@@ -307,16 +321,22 @@ static inline void usb_serial_debug_data(int debug,
307 int i; 321 int i;
308 322
309 if (debug) { 323 if (debug) {
310 dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ", function, size); 324 dev_printk(KERN_DEBUG, dev, "%s - length = %d, data = ",
325 function, size);
311 for (i = 0; i < size; ++i) 326 for (i = 0; i < size; ++i)
312 printk ("%.2x ", data[i]); 327 printk("%.2x ", data[i]);
313 printk ("\n"); 328 printk("\n");
314 } 329 }
315} 330}
316 331
317/* Use our own dbg macro */ 332/* Use our own dbg macro */
318#undef dbg 333#undef dbg
319#define dbg(format, arg...) do { if (debug) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg); } while (0) 334#define dbg(format, arg...) \
335 do { \
336 if (debug) \
337 printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , \
338 ## arg); \
339 } while (0)
320 340
321 341
322 342
diff --git a/include/linux/usb/sl811.h b/include/linux/usb/sl811.h
index 397ee3b3d7f3..877373da410d 100644
--- a/include/linux/usb/sl811.h
+++ b/include/linux/usb/sl811.h
@@ -19,8 +19,8 @@ struct sl811_platform_data {
19 /* pulse sl811 nRST (probably with a GPIO) */ 19 /* pulse sl811 nRST (probably with a GPIO) */
20 void (*reset)(struct device *dev); 20 void (*reset)(struct device *dev);
21 21
22 // some boards need something like these: 22 /* some boards need something like these: */
23 // int (*check_overcurrent)(struct device *dev); 23 /* int (*check_overcurrent)(struct device *dev); */
24 // void (*clock_enable)(struct device *dev, int is_on); 24 /* void (*clock_enable)(struct device *dev, int is_on); */
25}; 25};
26 26
diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
new file mode 100644
index 000000000000..e0501da3dd11
--- /dev/null
+++ b/include/linux/usb/usbnet.h
@@ -0,0 +1,214 @@
1/*
2 * USB Networking Link Interface
3 *
4 * Copyright (C) 2000-2005 by David Brownell <dbrownell@users.sourceforge.net>
5 * Copyright (C) 2003-2005 David Hollis <dhollis@davehollis.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22
23#ifndef __USBNET_H
24#define __USBNET_H
25
26
27/* interface from usbnet core to each USB networking link we handle */
28struct usbnet {
29 /* housekeeping */
30 struct usb_device *udev;
31 struct usb_interface *intf;
32 struct driver_info *driver_info;
33 const char *driver_name;
34 void *driver_priv;
35 wait_queue_head_t *wait;
36 struct mutex phy_mutex;
37 unsigned char suspend_count;
38
39 /* i/o info: pipes etc */
40 unsigned in, out;
41 struct usb_host_endpoint *status;
42 unsigned maxpacket;
43 struct timer_list delay;
44
45 /* protocol/interface state */
46 struct net_device *net;
47 struct net_device_stats stats;
48 int msg_enable;
49 unsigned long data [5];
50 u32 xid;
51 u32 hard_mtu; /* count any extra framing */
52 size_t rx_urb_size; /* size for rx urbs */
53 struct mii_if_info mii;
54
55 /* various kinds of pending driver work */
56 struct sk_buff_head rxq;
57 struct sk_buff_head txq;
58 struct sk_buff_head done;
59 struct urb *interrupt;
60 struct tasklet_struct bh;
61
62 struct work_struct kevent;
63 unsigned long flags;
64# define EVENT_TX_HALT 0
65# define EVENT_RX_HALT 1
66# define EVENT_RX_MEMORY 2
67# define EVENT_STS_SPLIT 3
68# define EVENT_LINK_RESET 4
69};
70
71static inline struct usb_driver *driver_of(struct usb_interface *intf)
72{
73 return to_usb_driver(intf->dev.driver);
74}
75
76/* interface from the device/framing level "minidriver" to core */
77struct driver_info {
78 char *description;
79
80 int flags;
81/* framing is CDC Ethernet, not writing ZLPs (hw issues), or optionally: */
82#define FLAG_FRAMING_NC 0x0001 /* guard against device dropouts */
83#define FLAG_FRAMING_GL 0x0002 /* genelink batches packets */
84#define FLAG_FRAMING_Z 0x0004 /* zaurus adds a trailer */
85#define FLAG_FRAMING_RN 0x0008 /* RNDIS batches, plus huge header */
86
87#define FLAG_NO_SETINT 0x0010 /* device can't set_interface() */
88#define FLAG_ETHER 0x0020 /* maybe use "eth%d" names */
89
90#define FLAG_FRAMING_AX 0x0040 /* AX88772/178 packets */
91#define FLAG_WLAN 0x0080 /* use "wlan%d" names */
92
93
94 /* init device ... can sleep, or cause probe() failure */
95 int (*bind)(struct usbnet *, struct usb_interface *);
96
97 /* cleanup device ... can sleep, but can't fail */
98 void (*unbind)(struct usbnet *, struct usb_interface *);
99
100 /* reset device ... can sleep */
101 int (*reset)(struct usbnet *);
102
103 /* see if peer is connected ... can sleep */
104 int (*check_connect)(struct usbnet *);
105
106 /* for status polling */
107 void (*status)(struct usbnet *, struct urb *);
108
109 /* link reset handling, called from defer_kevent */
110 int (*link_reset)(struct usbnet *);
111
112 /* fixup rx packet (strip framing) */
113 int (*rx_fixup)(struct usbnet *dev, struct sk_buff *skb);
114
115 /* fixup tx packet (add framing) */
116 struct sk_buff *(*tx_fixup)(struct usbnet *dev,
117 struct sk_buff *skb, gfp_t flags);
118
119 /* early initialization code, can sleep. This is for minidrivers
120 * having 'subminidrivers' that need to do extra initialization
121 * right after minidriver have initialized hardware. */
122 int (*early_init)(struct usbnet *dev);
123
124 /* called by minidriver when link state changes, state: 0=disconnect,
125 * 1=connect */
126 void (*link_change)(struct usbnet *dev, int state);
127
128 /* for new devices, use the descriptor-reading code instead */
129 int in; /* rx endpoint */
130 int out; /* tx endpoint */
131
132 unsigned long data; /* Misc driver specific data */
133};
134
135/* Minidrivers are just drivers using the "usbnet" core as a powerful
136 * network-specific subroutine library ... that happens to do pretty
137 * much everything except custom framing and chip-specific stuff.
138 */
139extern int usbnet_probe(struct usb_interface *, const struct usb_device_id *);
140extern int usbnet_suspend (struct usb_interface *, pm_message_t );
141extern int usbnet_resume (struct usb_interface *);
142extern void usbnet_disconnect(struct usb_interface *);
143
144
145/* Drivers that reuse some of the standard USB CDC infrastructure
146 * (notably, using multiple interfaces according to the CDC
147 * union descriptor) get some helper code.
148 */
149struct cdc_state {
150 struct usb_cdc_header_desc *header;
151 struct usb_cdc_union_desc *u;
152 struct usb_cdc_ether_desc *ether;
153 struct usb_interface *control;
154 struct usb_interface *data;
155};
156
157extern int usbnet_generic_cdc_bind (struct usbnet *, struct usb_interface *);
158extern void usbnet_cdc_unbind (struct usbnet *, struct usb_interface *);
159
160/* CDC and RNDIS support the same host-chosen packet filters for IN transfers */
161#define DEFAULT_FILTER (USB_CDC_PACKET_TYPE_BROADCAST \
162 |USB_CDC_PACKET_TYPE_ALL_MULTICAST \
163 |USB_CDC_PACKET_TYPE_PROMISCUOUS \
164 |USB_CDC_PACKET_TYPE_DIRECTED)
165
166
167/* we record the state for each of our queued skbs */
168enum skb_state {
169 illegal = 0,
170 tx_start, tx_done,
171 rx_start, rx_done, rx_cleanup
172};
173
174struct skb_data { /* skb->cb is one of these */
175 struct urb *urb;
176 struct usbnet *dev;
177 enum skb_state state;
178 size_t length;
179};
180
181
182extern int usbnet_get_endpoints(struct usbnet *, struct usb_interface *);
183extern void usbnet_defer_kevent (struct usbnet *, int);
184extern void usbnet_skb_return (struct usbnet *, struct sk_buff *);
185extern void usbnet_unlink_rx_urbs(struct usbnet *);
186
187extern int usbnet_get_settings (struct net_device *net, struct ethtool_cmd *cmd);
188extern int usbnet_set_settings (struct net_device *net, struct ethtool_cmd *cmd);
189extern u32 usbnet_get_link (struct net_device *net);
190extern u32 usbnet_get_msglevel (struct net_device *);
191extern void usbnet_set_msglevel (struct net_device *, u32);
192extern void usbnet_get_drvinfo (struct net_device *, struct ethtool_drvinfo *);
193extern int usbnet_nway_reset(struct net_device *net);
194
195/* messaging support includes the interface name, so it must not be
196 * used before it has one ... notably, in minidriver bind() calls.
197 */
198#ifdef DEBUG
199#define devdbg(usbnet, fmt, arg...) \
200 printk(KERN_DEBUG "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
201#else
202#define devdbg(usbnet, fmt, arg...) do {} while(0)
203#endif
204
205#define deverr(usbnet, fmt, arg...) \
206 printk(KERN_ERR "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
207#define devwarn(usbnet, fmt, arg...) \
208 printk(KERN_WARNING "%s: " fmt "\n" , (usbnet)->net->name , ## arg)
209
210#define devinfo(usbnet, fmt, arg...) \
211 printk(KERN_INFO "%s: " fmt "\n" , (usbnet)->net->name , ## arg); \
212
213
214#endif /* __USBNET_H */
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h
index 1b792b9286ba..cee0623b3c7b 100644
--- a/include/linux/usb_usual.h
+++ b/include/linux/usb_usual.h
@@ -48,7 +48,10 @@
48 US_FLAG(IGNORE_DEVICE, 0x00000800) \ 48 US_FLAG(IGNORE_DEVICE, 0x00000800) \
49 /* Don't claim device */ \ 49 /* Don't claim device */ \
50 US_FLAG(CAPACITY_HEURISTICS, 0x00001000) \ 50 US_FLAG(CAPACITY_HEURISTICS, 0x00001000) \
51 /* sometimes sizes is too big */ 51 /* sometimes sizes is too big */ \
52 US_FLAG(MAX_SECTORS_MIN,0x00002000) \
53 /* Sets max_sectors to arch min */
54
52 55
53#define US_FLAG(name, value) US_FL_##name = value , 56#define US_FLAG(name, value) US_FL_##name = value ,
54enum { US_DO_ALL_FLAGS }; 57enum { US_DO_ALL_FLAGS };
@@ -77,10 +80,9 @@ enum { US_DO_ALL_FLAGS };
77#define US_SC_UFI 0x04 /* Floppy */ 80#define US_SC_UFI 0x04 /* Floppy */
78#define US_SC_8070 0x05 /* Removable media */ 81#define US_SC_8070 0x05 /* Removable media */
79#define US_SC_SCSI 0x06 /* Transparent */ 82#define US_SC_SCSI 0x06 /* Transparent */
80#define US_SC_ISD200 0x07 /* ISD200 ATA */ 83#define US_SC_LOCKABLE 0x07 /* Password-protected */
81#define US_SC_MIN US_SC_RBC
82#define US_SC_MAX US_SC_ISD200
83 84
85#define US_SC_ISD200 0xf0 /* ISD200 ATA */
84#define US_SC_DEVICE 0xff /* Use device's value */ 86#define US_SC_DEVICE 0xff /* Use device's value */
85 87
86/* Protocols */ 88/* Protocols */
diff --git a/include/linux/usbdevice_fs.h b/include/linux/usbdevice_fs.h
index 342dd5a7e8bb..17cb108b7db0 100644
--- a/include/linux/usbdevice_fs.h
+++ b/include/linux/usbdevice_fs.h
@@ -102,8 +102,9 @@ struct usbdevfs_urb {
102 int start_frame; 102 int start_frame;
103 int number_of_packets; 103 int number_of_packets;
104 int error_count; 104 int error_count;
105 unsigned int signr; /* signal to be sent on error, -1 if none should be sent */ 105 unsigned int signr; /* signal to be sent on completion,
106 void *usercontext; 106 or 0 if none should be sent. */
107 void __user *usercontext;
107 struct usbdevfs_iso_packet_desc iso_frame_desc[0]; 108 struct usbdevfs_iso_packet_desc iso_frame_desc[0];
108}; 109};
109 110
diff --git a/include/net/veth.h b/include/linux/veth.h
index 3354c1eb424e..3354c1eb424e 100644
--- a/include/net/veth.h
+++ b/include/linux/veth.h
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index ac69e7bb5a14..1a4ed49f6478 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -67,7 +67,7 @@ struct vring {
67}; 67};
68 68
69/* The standard layout for the ring is a continuous chunk of memory which looks 69/* The standard layout for the ring is a continuous chunk of memory which looks
70 * like this. The used fields will be aligned to a "num+1" boundary. 70 * like this. We assume num is a power of 2.
71 * 71 *
72 * struct vring 72 * struct vring
73 * { 73 * {
@@ -79,8 +79,8 @@ struct vring {
79 * __u16 avail_idx; 79 * __u16 avail_idx;
80 * __u16 available[num]; 80 * __u16 available[num];
81 * 81 *
82 * // Padding so a correctly-chosen num value will cache-align used_idx. 82 * // Padding to the next page boundary.
83 * char pad[sizeof(struct vring_desc) - sizeof(avail_flags)]; 83 * char pad[];
84 * 84 *
85 * // A ring of used descriptor heads with free-running index. 85 * // A ring of used descriptor heads with free-running index.
86 * __u16 used_flags; 86 * __u16 used_flags;
@@ -88,18 +88,21 @@ struct vring {
88 * struct vring_used_elem used[num]; 88 * struct vring_used_elem used[num];
89 * }; 89 * };
90 */ 90 */
91static inline void vring_init(struct vring *vr, unsigned int num, void *p) 91static inline void vring_init(struct vring *vr, unsigned int num, void *p,
92 unsigned int pagesize)
92{ 93{
93 vr->num = num; 94 vr->num = num;
94 vr->desc = p; 95 vr->desc = p;
95 vr->avail = p + num*sizeof(struct vring); 96 vr->avail = p + num*sizeof(struct vring_desc);
96 vr->used = p + (num+1)*(sizeof(struct vring) + sizeof(__u16)); 97 vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + pagesize-1)
98 & ~(pagesize - 1));
97} 99}
98 100
99static inline unsigned vring_size(unsigned int num) 101static inline unsigned vring_size(unsigned int num, unsigned int pagesize)
100{ 102{
101 return (num + 1) * (sizeof(struct vring_desc) + sizeof(__u16)) 103 return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
102 + sizeof(__u32) + num * sizeof(struct vring_used_elem); 104 + pagesize - 1) & ~(pagesize - 1))
105 + sizeof(__u16) * 2 + sizeof(struct vring_used_elem) * num;
103} 106}
104 107
105#ifdef __KERNEL__ 108#ifdef __KERNEL__
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 0e686280450b..1f4fb0a81ecd 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -152,14 +152,15 @@ int FASTCALL(out_of_line_wait_on_bit(void *, int, int (*)(void *), unsigned));
152int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned)); 152int FASTCALL(out_of_line_wait_on_bit_lock(void *, int, int (*)(void *), unsigned));
153wait_queue_head_t *FASTCALL(bit_waitqueue(void *, int)); 153wait_queue_head_t *FASTCALL(bit_waitqueue(void *, int));
154 154
155#define wake_up(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 1, NULL) 155#define wake_up(x) __wake_up(x, TASK_NORMAL, 1, NULL)
156#define wake_up_nr(x, nr) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, nr, NULL) 156#define wake_up_nr(x, nr) __wake_up(x, TASK_NORMAL, nr, NULL)
157#define wake_up_all(x) __wake_up(x, TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE, 0, NULL) 157#define wake_up_all(x) __wake_up(x, TASK_NORMAL, 0, NULL)
158#define wake_up_locked(x) __wake_up_locked((x), TASK_NORMAL)
159
158#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL) 160#define wake_up_interruptible(x) __wake_up(x, TASK_INTERRUPTIBLE, 1, NULL)
159#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL) 161#define wake_up_interruptible_nr(x, nr) __wake_up(x, TASK_INTERRUPTIBLE, nr, NULL)
160#define wake_up_interruptible_all(x) __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL) 162#define wake_up_interruptible_all(x) __wake_up(x, TASK_INTERRUPTIBLE, 0, NULL)
161#define wake_up_locked(x) __wake_up_locked((x), TASK_UNINTERRUPTIBLE | TASK_INTERRUPTIBLE) 163#define wake_up_interruptible_sync(x) __wake_up_sync((x), TASK_INTERRUPTIBLE, 1)
162#define wake_up_interruptible_sync(x) __wake_up_sync((x),TASK_INTERRUPTIBLE, 1)
163 164
164#define __wait_event(wq, condition) \ 165#define __wait_event(wq, condition) \
165do { \ 166do { \
@@ -345,6 +346,47 @@ do { \
345 __ret; \ 346 __ret; \
346}) 347})
347 348
349#define __wait_event_killable(wq, condition, ret) \
350do { \
351 DEFINE_WAIT(__wait); \
352 \
353 for (;;) { \
354 prepare_to_wait(&wq, &__wait, TASK_KILLABLE); \
355 if (condition) \
356 break; \
357 if (!fatal_signal_pending(current)) { \
358 schedule(); \
359 continue; \
360 } \
361 ret = -ERESTARTSYS; \
362 break; \
363 } \
364 finish_wait(&wq, &__wait); \
365} while (0)
366
367/**
368 * wait_event_killable - sleep until a condition gets true
369 * @wq: the waitqueue to wait on
370 * @condition: a C expression for the event to wait for
371 *
372 * The process is put to sleep (TASK_KILLABLE) until the
373 * @condition evaluates to true or a signal is received.
374 * The @condition is checked each time the waitqueue @wq is woken up.
375 *
376 * wake_up() has to be called after changing any variable that could
377 * change the result of the wait condition.
378 *
379 * The function will return -ERESTARTSYS if it was interrupted by a
380 * signal and 0 if @condition evaluated to true.
381 */
382#define wait_event_killable(wq, condition) \
383({ \
384 int __ret = 0; \
385 if (!(condition)) \
386 __wait_event_killable(wq, condition, __ret); \
387 __ret; \
388})
389
348/* 390/*
349 * Must be called with the spinlock in the wait_queue_head_t held. 391 * Must be called with the spinlock in the wait_queue_head_t held.
350 */ 392 */
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index 0987aa7a6cf5..74e84caa1e20 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -541,6 +541,16 @@
541/* Maximum size of returned data */ 541/* Maximum size of returned data */
542#define IW_SCAN_MAX_DATA 4096 /* In bytes */ 542#define IW_SCAN_MAX_DATA 4096 /* In bytes */
543 543
544/* Scan capability flags - in (struct iw_range *)->scan_capa */
545#define IW_SCAN_CAPA_NONE 0x00
546#define IW_SCAN_CAPA_ESSID 0x01
547#define IW_SCAN_CAPA_BSSID 0x02
548#define IW_SCAN_CAPA_CHANNEL 0x04
549#define IW_SCAN_CAPA_MODE 0x08
550#define IW_SCAN_CAPA_RATE 0x10
551#define IW_SCAN_CAPA_TYPE 0x20
552#define IW_SCAN_CAPA_TIME 0x40
553
544/* Max number of char in custom event - use multiple of them if needed */ 554/* Max number of char in custom event - use multiple of them if needed */
545#define IW_CUSTOM_MAX 256 /* In bytes */ 555#define IW_CUSTOM_MAX 256 /* In bytes */
546 556
@@ -963,6 +973,9 @@ struct iw_range
963 __u16 old_num_channels; 973 __u16 old_num_channels;
964 __u8 old_num_frequency; 974 __u8 old_num_frequency;
965 975
976 /* Scan capabilities */
977 __u8 scan_capa; /* IW_SCAN_CAPA_* bit field */
978
966 /* Wireless event capability bitmasks */ 979 /* Wireless event capability bitmasks */
967 __u32 event_capa[6]; 980 __u32 event_capa[6];
968 981
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 7daafdc2514b..7f28c32d9aca 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -149,19 +149,27 @@ struct execute_work {
149 149
150extern struct workqueue_struct * 150extern struct workqueue_struct *
151__create_workqueue_key(const char *name, int singlethread, 151__create_workqueue_key(const char *name, int singlethread,
152 int freezeable, struct lock_class_key *key); 152 int freezeable, struct lock_class_key *key,
153 const char *lock_name);
153 154
154#ifdef CONFIG_LOCKDEP 155#ifdef CONFIG_LOCKDEP
155#define __create_workqueue(name, singlethread, freezeable) \ 156#define __create_workqueue(name, singlethread, freezeable) \
156({ \ 157({ \
157 static struct lock_class_key __key; \ 158 static struct lock_class_key __key; \
159 const char *__lock_name; \
160 \
161 if (__builtin_constant_p(name)) \
162 __lock_name = (name); \
163 else \
164 __lock_name = #name; \
158 \ 165 \
159 __create_workqueue_key((name), (singlethread), \ 166 __create_workqueue_key((name), (singlethread), \
160 (freezeable), &__key); \ 167 (freezeable), &__key, \
168 __lock_name); \
161}) 169})
162#else 170#else
163#define __create_workqueue(name, singlethread, freezeable) \ 171#define __create_workqueue(name, singlethread, freezeable) \
164 __create_workqueue_key((name), (singlethread), (freezeable), NULL) 172 __create_workqueue_key((name), (singlethread), (freezeable), NULL, NULL)
165#endif 173#endif
166 174
167#define create_workqueue(name) __create_workqueue((name), 0, 0) 175#define create_workqueue(name) __create_workqueue((name), 0, 0)
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index bef7d66601cb..c6148bbf1250 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -62,7 +62,6 @@ struct writeback_control {
62 unsigned for_reclaim:1; /* Invoked from the page allocator */ 62 unsigned for_reclaim:1; /* Invoked from the page allocator */
63 unsigned for_writepages:1; /* This is a writepages() call */ 63 unsigned for_writepages:1; /* This is a writepages() call */
64 unsigned range_cyclic:1; /* range_start is cyclic */ 64 unsigned range_cyclic:1; /* range_start is cyclic */
65 unsigned more_io:1; /* more io to be dispatched */
66}; 65};
67 66
68/* 67/*
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index b58adc52448d..e31b8c84f2c9 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -91,8 +91,15 @@ struct xfrm_replay_state
91}; 91};
92 92
93struct xfrm_algo { 93struct xfrm_algo {
94 char alg_name[64];
95 unsigned int alg_key_len; /* in bits */
96 char alg_key[0];
97};
98
99struct xfrm_algo_aead {
94 char alg_name[64]; 100 char alg_name[64];
95 int alg_key_len; /* in bits */ 101 int alg_key_len; /* in bits */
102 int alg_icv_len; /* in bits */
96 char alg_key[0]; 103 char alg_key[0];
97}; 104};
98 105
@@ -114,6 +121,7 @@ enum
114 XFRM_POLICY_IN = 0, 121 XFRM_POLICY_IN = 0,
115 XFRM_POLICY_OUT = 1, 122 XFRM_POLICY_OUT = 1,
116 XFRM_POLICY_FWD = 2, 123 XFRM_POLICY_FWD = 2,
124 XFRM_POLICY_MASK = 3,
117 XFRM_POLICY_MAX = 3 125 XFRM_POLICY_MAX = 3
118}; 126};
119 127
@@ -269,6 +277,7 @@ enum xfrm_attr_type_t {
269 XFRMA_LASTUSED, 277 XFRMA_LASTUSED,
270 XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */ 278 XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */
271 XFRMA_MIGRATE, 279 XFRMA_MIGRATE,
280 XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */
272 __XFRMA_MAX 281 __XFRMA_MAX
273 282
274#define XFRMA_MAX (__XFRMA_MAX - 1) 283#define XFRMA_MAX (__XFRMA_MAX - 1)
@@ -328,6 +337,7 @@ struct xfrm_usersa_info {
328#define XFRM_STATE_DECAP_DSCP 2 337#define XFRM_STATE_DECAP_DSCP 2
329#define XFRM_STATE_NOPMTUDISC 4 338#define XFRM_STATE_NOPMTUDISC 4
330#define XFRM_STATE_WILDRECV 8 339#define XFRM_STATE_WILDRECV 8
340#define XFRM_STATE_ICMP 16
331}; 341};
332 342
333struct xfrm_usersa_id { 343struct xfrm_usersa_id {
@@ -362,6 +372,8 @@ struct xfrm_userpolicy_info {
362#define XFRM_POLICY_BLOCK 1 372#define XFRM_POLICY_BLOCK 1
363 __u8 flags; 373 __u8 flags;
364#define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */ 374#define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */
375 /* Automatically expand selector to include matching ICMP payloads. */
376#define XFRM_POLICY_ICMP 2
365 __u8 share; 377 __u8 share;
366}; 378};
367 379
diff --git a/include/media/cs5345.h b/include/media/cs5345.h
new file mode 100644
index 000000000000..6ccae24e65ed
--- /dev/null
+++ b/include/media/cs5345.h
@@ -0,0 +1,39 @@
1/*
2 cs5345.h - definition for cs5345 inputs and outputs
3
4 Copyright (C) 2007 Hans Verkuil (hverkuil@xs4all.nl)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _CS5345_H_
22#define _CS5345_H_
23
24/* CS5345 HW inputs */
25#define CS5345_IN_MIC 0
26#define CS5345_IN_1 1
27#define CS5345_IN_2 2
28#define CS5345_IN_3 3
29#define CS5345_IN_4 4
30#define CS5345_IN_5 5
31#define CS5345_IN_6 6
32
33#define CS5345_MCLK_1 0x00
34#define CS5345_MCLK_1_5 0x10
35#define CS5345_MCLK_2 0x20
36#define CS5345_MCLK_3 0x30
37#define CS5345_MCLK_4 0x40
38
39#endif
diff --git a/include/media/cx2341x.h b/include/media/cx2341x.h
index af8071d7620d..5f4608e88476 100644
--- a/include/media/cx2341x.h
+++ b/include/media/cx2341x.h
@@ -83,7 +83,7 @@ struct cx2341x_mpeg_params {
83#define CX2341X_MBOX_MAX_DATA 16 83#define CX2341X_MBOX_MAX_DATA 16
84 84
85extern const u32 cx2341x_mpeg_ctrls[]; 85extern const u32 cx2341x_mpeg_ctrls[];
86typedef int (*cx2341x_mbox_func)(void *priv, int cmd, int in, int out, 86typedef int (*cx2341x_mbox_func)(void *priv, u32 cmd, int in, int out,
87 u32 data[CX2341X_MBOX_MAX_DATA]); 87 u32 data[CX2341X_MBOX_MAX_DATA]);
88int cx2341x_update(void *priv, cx2341x_mbox_func func, 88int cx2341x_update(void *priv, cx2341x_mbox_func func,
89 const struct cx2341x_mpeg_params *old, 89 const struct cx2341x_mpeg_params *old,
diff --git a/include/media/cx25840.h b/include/media/cx25840.h
index 8e7e52d659a0..cd599ad29fb2 100644
--- a/include/media/cx25840.h
+++ b/include/media/cx25840.h
@@ -49,6 +49,25 @@ enum cx25840_video_input {
49 CX25840_SVIDEO2 = 0x620, 49 CX25840_SVIDEO2 = 0x620,
50 CX25840_SVIDEO3 = 0x730, 50 CX25840_SVIDEO3 = 0x730,
51 CX25840_SVIDEO4 = 0x840, 51 CX25840_SVIDEO4 = 0x840,
52
53 /* Allow frames to specify specific input configurations */
54 CX25840_VIN1_CH1 = 0x80000000,
55 CX25840_VIN2_CH1 = 0x80000001,
56 CX25840_VIN3_CH1 = 0x80000002,
57 CX25840_VIN4_CH1 = 0x80000003,
58 CX25840_VIN5_CH1 = 0x80000004,
59 CX25840_VIN6_CH1 = 0x80000005,
60 CX25840_VIN7_CH1 = 0x80000006,
61 CX25840_VIN8_CH1 = 0x80000007,
62 CX25840_VIN4_CH2 = 0x80000000,
63 CX25840_VIN5_CH2 = 0x80000010,
64 CX25840_VIN6_CH2 = 0x80000020,
65 CX25840_NONE_CH2 = 0x80000030,
66 CX25840_VIN7_CH3 = 0x80000000,
67 CX25840_VIN8_CH3 = 0x80000040,
68 CX25840_NONE0_CH3 = 0x80000080,
69 CX25840_NONE1_CH3 = 0x800000c0,
70 CX25840_SVIDEO_ON = 0x80000100,
52}; 71};
53 72
54enum cx25840_audio_input { 73enum cx25840_audio_input {
diff --git a/include/media/ir-common.h b/include/media/ir-common.h
index 7a785fa77212..831547d79683 100644
--- a/include/media/ir-common.h
+++ b/include/media/ir-common.h
@@ -97,7 +97,6 @@ int ir_dump_samples(u32 *samples, int count);
97int ir_decode_biphase(u32 *samples, int count, int low, int high); 97int ir_decode_biphase(u32 *samples, int count, int low, int high);
98int ir_decode_pulsedistance(u32 *samples, int count, int low, int high); 98int ir_decode_pulsedistance(u32 *samples, int count, int low, int high);
99 99
100u32 ir_rc5_decode(unsigned int code);
101void ir_rc5_timer_end(unsigned long data); 100void ir_rc5_timer_end(unsigned long data);
102void ir_rc5_timer_keyup(unsigned long data); 101void ir_rc5_timer_keyup(unsigned long data);
103 102
@@ -141,6 +140,8 @@ extern IR_KEYTAB_TYPE ir_codes_asus_pc39[IR_KEYTAB_SIZE];
141extern IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE]; 140extern IR_KEYTAB_TYPE ir_codes_encore_enltv[IR_KEYTAB_SIZE];
142extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE]; 141extern IR_KEYTAB_TYPE ir_codes_tt_1500[IR_KEYTAB_SIZE];
143extern IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE]; 142extern IR_KEYTAB_TYPE ir_codes_fusionhdtv_mce[IR_KEYTAB_SIZE];
143extern IR_KEYTAB_TYPE ir_codes_behold[IR_KEYTAB_SIZE];
144extern IR_KEYTAB_TYPE ir_codes_pinnacle_pctv_hd[IR_KEYTAB_SIZE];
144 145
145#endif 146#endif
146 147
diff --git a/include/media/m52790.h b/include/media/m52790.h
new file mode 100644
index 000000000000..7ddffae31a67
--- /dev/null
+++ b/include/media/m52790.h
@@ -0,0 +1,93 @@
1/*
2 m52790.h - definition for m52790 inputs and outputs
3
4 Copyright (C) 2007 Hans Verkuil (hverkuil@xs4all.nl)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef _M52790_H_
22#define _M52790_H_
23
24/* Input routing switch 1 */
25
26#define M52790_SW1_IN_MASK 0x0003
27#define M52790_SW1_IN_TUNER 0x0000
28#define M52790_SW1_IN_V2 0x0001
29#define M52790_SW1_IN_V3 0x0002
30#define M52790_SW1_IN_V4 0x0003
31
32/* Selects component input instead of composite */
33#define M52790_SW1_YCMIX 0x0004
34
35
36/* Input routing switch 2 */
37
38#define M52790_SW2_IN_MASK 0x0300
39#define M52790_SW2_IN_TUNER 0x0000
40#define M52790_SW2_IN_V2 0x0100
41#define M52790_SW2_IN_V3 0x0200
42#define M52790_SW2_IN_V4 0x0300
43
44/* Selects component input instead of composite */
45#define M52790_SW2_YCMIX 0x0400
46
47
48/* Output routing switch 1 */
49
50/* Enable 6dB amplifier for composite out */
51#define M52790_SW1_V_AMP 0x0008
52
53/* Enable 6dB amplifier for component out */
54#define M52790_SW1_YC_AMP 0x0010
55
56/* Audio output mode */
57#define M52790_SW1_AUDIO_MASK 0x00c0
58#define M52790_SW1_AUDIO_MUTE 0x0000
59#define M52790_SW1_AUDIO_R 0x0040
60#define M52790_SW1_AUDIO_L 0x0080
61#define M52790_SW1_AUDIO_STEREO 0x00c0
62
63
64/* Output routing switch 2 */
65
66/* Enable 6dB amplifier for composite out */
67#define M52790_SW2_V_AMP 0x0800
68
69/* Enable 6dB amplifier for component out */
70#define M52790_SW2_YC_AMP 0x1000
71
72/* Audio output mode */
73#define M52790_SW2_AUDIO_MASK 0xc000
74#define M52790_SW2_AUDIO_MUTE 0x0000
75#define M52790_SW2_AUDIO_R 0x4000
76#define M52790_SW2_AUDIO_L 0x8000
77#define M52790_SW2_AUDIO_STEREO 0xc000
78
79
80/* Common values */
81#define M52790_IN_TUNER (M52790_SW1_IN_TUNER | M52790_SW2_IN_TUNER)
82#define M52790_IN_V2 (M52790_SW1_IN_V2 | M52790_SW2_IN_V2)
83#define M52790_IN_V3 (M52790_SW1_IN_V3 | M52790_SW2_IN_V3)
84#define M52790_IN_V4 (M52790_SW1_IN_V4 | M52790_SW2_IN_V4)
85
86#define M52790_OUT_STEREO (M52790_SW1_AUDIO_STEREO | \
87 M52790_SW2_AUDIO_STEREO)
88#define M52790_OUT_AMP_STEREO (M52790_SW1_AUDIO_STEREO | \
89 M52790_SW1_V_AMP | \
90 M52790_SW2_AUDIO_STEREO | \
91 M52790_SW2_V_AMP)
92
93#endif
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index e49f7e156061..89c442eb8849 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -1,7 +1,6 @@
1#ifndef __SAA7146_VV__ 1#ifndef __SAA7146_VV__
2#define __SAA7146_VV__ 2#define __SAA7146_VV__
3 3
4#include <linux/videodev.h>
5#include <media/v4l2-common.h> 4#include <media/v4l2-common.h>
6#include <media/saa7146.h> 5#include <media/saa7146.h>
7#include <media/videobuf-dma-sg.h> 6#include <media/videobuf-dma-sg.h>
diff --git a/include/media/tuner.h b/include/media/tuner.h
index c03dceb92605..1bf24a6ed8f1 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -24,8 +24,6 @@
24 24
25#include <linux/videodev2.h> 25#include <linux/videodev2.h>
26 26
27extern int tuner_debug;
28
29#define ADDR_UNSET (255) 27#define ADDR_UNSET (255)
30 28
31#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */ 29#define TUNER_TEMIC_PAL 0 /* 4002 FH5 (3X 7756, 9483) */
@@ -117,12 +115,13 @@ extern int tuner_debug;
117#define TUNER_PHILIPS_TUV1236D 68 /* ATI HDTV Wonder */ 115#define TUNER_PHILIPS_TUV1236D 68 /* ATI HDTV Wonder */
118#define TUNER_TNF_5335MF 69 /* Sabrent Bt848 */ 116#define TUNER_TNF_5335MF 69 /* Sabrent Bt848 */
119#define TUNER_SAMSUNG_TCPN_2121P30A 70 /* Hauppauge PVR-500MCE NTSC */ 117#define TUNER_SAMSUNG_TCPN_2121P30A 70 /* Hauppauge PVR-500MCE NTSC */
120#define TUNER_XCEIVE_XC3028 71 118#define TUNER_XC2028 71
121 119
122#define TUNER_THOMSON_FE6600 72 /* DViCO FusionHDTV DVB-T Hybrid */ 120#define TUNER_THOMSON_FE6600 72 /* DViCO FusionHDTV DVB-T Hybrid */
123#define TUNER_SAMSUNG_TCPG_6121P30A 73 /* Hauppauge PVR-500 PAL */ 121#define TUNER_SAMSUNG_TCPG_6121P30A 73 /* Hauppauge PVR-500 PAL */
124#define TUNER_TDA9887 74 /* This tuner should be used only internally */ 122#define TUNER_TDA9887 74 /* This tuner should be used only internally */
125#define TUNER_TEA5761 75 /* Only FM Radio Tuner */ 123#define TUNER_TEA5761 75 /* Only FM Radio Tuner */
124#define TUNER_XC5000 76 /* Xceive Silicon Tuner */
126 125
127/* tv card specific */ 126/* tv card specific */
128#define TDA9887_PRESENT (1<<0) 127#define TDA9887_PRESENT (1<<0)
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 8ae42c41dd08..032bb75f69c2 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -68,6 +68,9 @@ enum {
68 /* module vp27smpx: just ident 2700 */ 68 /* module vp27smpx: just ident 2700 */
69 V4L2_IDENT_VP27SMPX = 2700, 69 V4L2_IDENT_VP27SMPX = 2700,
70 70
71 /* module cs5345: just ident 5345 */
72 V4L2_IDENT_CS5345 = 5345,
73
71 /* module wm8739: just ident 8739 */ 74 /* module wm8739: just ident 8739 */
72 V4L2_IDENT_WM8739 = 8739, 75 V4L2_IDENT_WM8739 = 8739,
73 76
@@ -83,6 +86,9 @@ enum {
83 /* module upd64083: just ident 64083 */ 86 /* module upd64083: just ident 64083 */
84 V4L2_IDENT_UPD64083 = 64083, 87 V4L2_IDENT_UPD64083 = 64083,
85 88
89 /* module m52790: just ident 52790 */
90 V4L2_IDENT_M52790 = 52790,
91
86 /* module msp34xx: reserved range 34000-34999 */ 92 /* module msp34xx: reserved range 34000-34999 */
87 V4L2_IDENT_MSP3400B = 34002, 93 V4L2_IDENT_MSP3400B = 34002,
88 V4L2_IDENT_MSP3410B = 34102, 94 V4L2_IDENT_MSP3410B = 34102,
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 181a40c46a52..475d0d8275e0 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -104,6 +104,17 @@ int v4l2_chip_match_host(u32 id_type, u32 chip_id);
104 104
105/* ------------------------------------------------------------------------- */ 105/* ------------------------------------------------------------------------- */
106 106
107/* Helper function for I2C legacy drivers */
108
109struct i2c_driver;
110struct i2c_adapter;
111struct i2c_client;
112
113int v4l2_i2c_attach(struct i2c_adapter *adapter, int address, struct i2c_driver *driver,
114 const char *name, int (*probe)(struct i2c_client *));
115
116/* ------------------------------------------------------------------------- */
117
107/* Internal ioctls */ 118/* Internal ioctls */
108 119
109/* VIDIOC_INT_DECODE_VBI_LINE */ 120/* VIDIOC_INT_DECODE_VBI_LINE */
@@ -116,6 +127,11 @@ struct v4l2_decode_vbi_line {
116 u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */ 127 u32 type; /* VBI service type (V4L2_SLICED_*). 0 if no service found */
117}; 128};
118 129
130struct v4l2_priv_tun_config {
131 int tuner;
132 void *priv;
133};
134
119/* audio ioctls */ 135/* audio ioctls */
120 136
121/* v4l device was opened in Radio mode, to be replaced by VIDIOC_INT_S_TUNER_MODE */ 137/* v4l device was opened in Radio mode, to be replaced by VIDIOC_INT_S_TUNER_MODE */
@@ -131,7 +147,7 @@ struct v4l2_decode_vbi_line {
131#define TUNER_SET_STANDBY _IOW('d', 91, int) 147#define TUNER_SET_STANDBY _IOW('d', 91, int)
132 148
133/* Sets tda9887 specific stuff, like port1, port2 and qss */ 149/* Sets tda9887 specific stuff, like port1, port2 and qss */
134#define TDA9887_SET_CONFIG _IOW('d', 92, int) 150#define TUNER_SET_CONFIG _IOW('d', 92, struct v4l2_priv_tun_config)
135 151
136/* Switch the tuner to a specific tuner mode. Replacement of AUDC_SET_RADIO */ 152/* Switch the tuner to a specific tuner mode. Replacement of AUDC_SET_RADIO */
137#define VIDIOC_INT_S_TUNER_MODE _IOW('d', 93, enum v4l2_tuner_type) 153#define VIDIOC_INT_S_TUNER_MODE _IOW('d', 93, enum v4l2_tuner_type)
diff --git a/include/media/v4l2-i2c-drv-legacy.h b/include/media/v4l2-i2c-drv-legacy.h
new file mode 100644
index 000000000000..e7645578fc22
--- /dev/null
+++ b/include/media/v4l2-i2c-drv-legacy.h
@@ -0,0 +1,140 @@
1/*
2 * v4l2-i2c-drv-legacy.h - contains I2C handling code that's identical
3 * for all V4L2 I2C drivers. Use this header if the
4 * I2C driver is used by both legacy drivers and
5 * drivers converted to the bus-based I2C API.
6 *
7 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24struct v4l2_i2c_driver_data {
25 const char * const name;
26 int driverid;
27 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
28 int (*probe)(struct i2c_client *client);
29 int (*remove)(struct i2c_client *client);
30 int (*suspend)(struct i2c_client *client, pm_message_t state);
31 int (*resume)(struct i2c_client *client);
32 int (*legacy_probe)(struct i2c_adapter *adapter);
33 int legacy_class;
34};
35
36static struct v4l2_i2c_driver_data v4l2_i2c_data;
37static const struct i2c_client_address_data addr_data;
38static struct i2c_driver v4l2_i2c_driver_legacy;
39static char v4l2_i2c_drv_name_legacy[32];
40
41static int v4l2_i2c_drv_attach_legacy(struct i2c_adapter *adapter, int address, int kind)
42{
43 return v4l2_i2c_attach(adapter, address, &v4l2_i2c_driver_legacy,
44 v4l2_i2c_drv_name_legacy, v4l2_i2c_data.probe);
45}
46
47static int v4l2_i2c_drv_probe_legacy(struct i2c_adapter *adapter)
48{
49 if (v4l2_i2c_data.legacy_probe) {
50 if (v4l2_i2c_data.legacy_probe(adapter))
51 return i2c_probe(adapter, &addr_data, v4l2_i2c_drv_attach_legacy);
52 return 0;
53 }
54 if (adapter->class & v4l2_i2c_data.legacy_class)
55 return i2c_probe(adapter, &addr_data, v4l2_i2c_drv_attach_legacy);
56 return 0;
57}
58
59static int v4l2_i2c_drv_detach_legacy(struct i2c_client *client)
60{
61 int err;
62
63 if (v4l2_i2c_data.remove)
64 v4l2_i2c_data.remove(client);
65
66 err = i2c_detach_client(client);
67 if (err)
68 return err;
69 kfree(client);
70
71 return 0;
72}
73
74static int v4l2_i2c_drv_suspend_helper(struct i2c_client *client, pm_message_t state)
75{
76 return v4l2_i2c_data.suspend ? v4l2_i2c_data.suspend(client, state) : 0;
77}
78
79static int v4l2_i2c_drv_resume_helper(struct i2c_client *client)
80{
81 return v4l2_i2c_data.resume ? v4l2_i2c_data.resume(client) : 0;
82}
83
84/* ----------------------------------------------------------------------- */
85
86/* i2c implementation */
87static struct i2c_driver v4l2_i2c_driver_legacy = {
88 .driver = {
89 .owner = THIS_MODULE,
90 },
91 .attach_adapter = v4l2_i2c_drv_probe_legacy,
92 .detach_client = v4l2_i2c_drv_detach_legacy,
93 .suspend = v4l2_i2c_drv_suspend_helper,
94 .resume = v4l2_i2c_drv_resume_helper,
95};
96
97/* ----------------------------------------------------------------------- */
98
99/* i2c implementation */
100static struct i2c_driver v4l2_i2c_driver = {
101 .suspend = v4l2_i2c_drv_suspend_helper,
102 .resume = v4l2_i2c_drv_resume_helper,
103};
104
105static int __init v4l2_i2c_drv_init(void)
106{
107 int err;
108
109 strlcpy(v4l2_i2c_drv_name_legacy, v4l2_i2c_data.name, sizeof(v4l2_i2c_drv_name_legacy));
110 strlcat(v4l2_i2c_drv_name_legacy, "'", sizeof(v4l2_i2c_drv_name_legacy));
111
112 if (v4l2_i2c_data.legacy_class == 0)
113 v4l2_i2c_data.legacy_class = I2C_CLASS_TV_ANALOG;
114
115 v4l2_i2c_driver_legacy.driver.name = v4l2_i2c_drv_name_legacy;
116 v4l2_i2c_driver_legacy.id = v4l2_i2c_data.driverid;
117 v4l2_i2c_driver_legacy.command = v4l2_i2c_data.command;
118 err = i2c_add_driver(&v4l2_i2c_driver_legacy);
119
120 if (err)
121 return err;
122 v4l2_i2c_driver.driver.name = v4l2_i2c_data.name;
123 v4l2_i2c_driver.id = v4l2_i2c_data.driverid;
124 v4l2_i2c_driver.command = v4l2_i2c_data.command;
125 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
126 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
127 err = i2c_add_driver(&v4l2_i2c_driver);
128 if (err)
129 i2c_del_driver(&v4l2_i2c_driver_legacy);
130 return err;
131}
132
133static void __exit v4l2_i2c_drv_cleanup(void)
134{
135 i2c_del_driver(&v4l2_i2c_driver_legacy);
136 i2c_del_driver(&v4l2_i2c_driver);
137}
138
139module_init(v4l2_i2c_drv_init);
140module_exit(v4l2_i2c_drv_cleanup);
diff --git a/include/media/v4l2-i2c-drv.h b/include/media/v4l2-i2c-drv.h
new file mode 100644
index 000000000000..9e4bab276915
--- /dev/null
+++ b/include/media/v4l2-i2c-drv.h
@@ -0,0 +1,68 @@
1/*
2 * v4l2-i2c-drv.h - contains I2C handling code that's identical for
3 * all V4L2 I2C drivers. Use this header if the
4 * I2C driver is only used by drivers converted
5 * to the bus-based I2C API.
6 *
7 * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#ifndef __V4L2_I2C_DRV_H__
25#define __V4L2_I2C_DRV_H__
26
27#include <media/v4l2-common.h>
28
29struct v4l2_i2c_driver_data {
30 const char * const name;
31 int driverid;
32 int (*command)(struct i2c_client *client, unsigned int cmd, void *arg);
33 int (*probe)(struct i2c_client *client);
34 int (*remove)(struct i2c_client *client);
35 int (*suspend)(struct i2c_client *client, pm_message_t state);
36 int (*resume)(struct i2c_client *client);
37 int (*legacy_probe)(struct i2c_adapter *adapter);
38 int legacy_class;
39};
40
41static struct v4l2_i2c_driver_data v4l2_i2c_data;
42static struct i2c_driver v4l2_i2c_driver;
43
44
45/* Bus-based I2C implementation for kernels >= 2.6.22 */
46
47static int __init v4l2_i2c_drv_init(void)
48{
49 v4l2_i2c_driver.driver.name = v4l2_i2c_data.name;
50 v4l2_i2c_driver.id = v4l2_i2c_data.driverid;
51 v4l2_i2c_driver.command = v4l2_i2c_data.command;
52 v4l2_i2c_driver.probe = v4l2_i2c_data.probe;
53 v4l2_i2c_driver.remove = v4l2_i2c_data.remove;
54 v4l2_i2c_driver.suspend = v4l2_i2c_data.suspend;
55 v4l2_i2c_driver.resume = v4l2_i2c_data.resume;
56 return i2c_add_driver(&v4l2_i2c_driver);
57}
58
59
60static void __exit v4l2_i2c_drv_cleanup(void)
61{
62 i2c_del_driver(&v4l2_i2c_driver);
63}
64
65module_init(v4l2_i2c_drv_init);
66module_exit(v4l2_i2c_drv_cleanup);
67
68#endif /* __V4L2_I2C_DRV_H__ */
diff --git a/include/media/v4l2-int-device.h b/include/media/v4l2-int-device.h
index 066ebfc4f983..c8b80e0f0651 100644
--- a/include/media/v4l2-int-device.h
+++ b/include/media/v4l2-int-device.h
@@ -44,9 +44,8 @@ enum v4l2_int_type {
44struct v4l2_int_device; 44struct v4l2_int_device;
45 45
46struct v4l2_int_master { 46struct v4l2_int_master {
47 int (*attach)(struct v4l2_int_device *master, 47 int (*attach)(struct v4l2_int_device *slave);
48 struct v4l2_int_device *slave); 48 void (*detach)(struct v4l2_int_device *slave);
49 void (*detach)(struct v4l2_int_device *master);
50}; 49};
51 50
52typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *); 51typedef int (v4l2_int_ioctl_func)(struct v4l2_int_device *);
diff --git a/include/media/videobuf-core.h b/include/media/videobuf-core.h
index 0fa5d5912555..97f14d469595 100644
--- a/include/media/videobuf-core.h
+++ b/include/media/videobuf-core.h
@@ -56,13 +56,13 @@ struct videobuf_mapping {
56}; 56};
57 57
58enum videobuf_state { 58enum videobuf_state {
59 STATE_NEEDS_INIT = 0, 59 VIDEOBUF_NEEDS_INIT = 0,
60 STATE_PREPARED = 1, 60 VIDEOBUF_PREPARED = 1,
61 STATE_QUEUED = 2, 61 VIDEOBUF_QUEUED = 2,
62 STATE_ACTIVE = 3, 62 VIDEOBUF_ACTIVE = 3,
63 STATE_DONE = 4, 63 VIDEOBUF_DONE = 4,
64 STATE_ERROR = 5, 64 VIDEOBUF_ERROR = 5,
65 STATE_IDLE = 6, 65 VIDEOBUF_IDLE = 6,
66}; 66};
67 67
68struct videobuf_buffer { 68struct videobuf_buffer {
@@ -162,12 +162,14 @@ struct videobuf_queue {
162 struct videobuf_queue_ops *ops; 162 struct videobuf_queue_ops *ops;
163 struct videobuf_qtype_ops *int_ops; 163 struct videobuf_qtype_ops *int_ops;
164 164
165 unsigned int streaming:1;
166 unsigned int reading:1;
167 unsigned int is_mmapped:1;
168
165 /* capture via mmap() + ioctl(QBUF/DQBUF) */ 169 /* capture via mmap() + ioctl(QBUF/DQBUF) */
166 unsigned int streaming;
167 struct list_head stream; 170 struct list_head stream;
168 171
169 /* capture via read() */ 172 /* capture via read() */
170 unsigned int reading;
171 unsigned int read_off; 173 unsigned int read_off;
172 struct videobuf_buffer *read_buf; 174 struct videobuf_buffer *read_buf;
173 175
@@ -208,6 +210,8 @@ int videobuf_cgmbuf(struct videobuf_queue *q,
208int videobuf_streamon(struct videobuf_queue *q); 210int videobuf_streamon(struct videobuf_queue *q);
209int videobuf_streamoff(struct videobuf_queue *q); 211int videobuf_streamoff(struct videobuf_queue *q);
210 212
213void videobuf_stop(struct videobuf_queue *q);
214
211int videobuf_read_start(struct videobuf_queue *q); 215int videobuf_read_start(struct videobuf_queue *q);
212void videobuf_read_stop(struct videobuf_queue *q); 216void videobuf_read_stop(struct videobuf_queue *q);
213ssize_t videobuf_read_stream(struct videobuf_queue *q, 217ssize_t videobuf_read_stream(struct videobuf_queue *q,
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 68b4eaf7719d..565eed8fe496 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -89,7 +89,7 @@ struct tc_action_ops {
89 int (*dump)(struct sk_buff *, struct tc_action *, int, int); 89 int (*dump)(struct sk_buff *, struct tc_action *, int, int);
90 int (*cleanup)(struct tc_action *, int bind); 90 int (*cleanup)(struct tc_action *, int bind);
91 int (*lookup)(struct tc_action *, u32); 91 int (*lookup)(struct tc_action *, u32);
92 int (*init)(struct rtattr *, struct rtattr *, struct tc_action *, int , int); 92 int (*init)(struct nlattr *, struct nlattr *, struct tc_action *, int , int);
93 int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *); 93 int (*walk)(struct sk_buff *, struct netlink_callback *, int, struct tc_action *);
94}; 94};
95 95
@@ -104,7 +104,7 @@ extern u32 tcf_hash_new_index(u32 *idx_gen, struct tcf_hashinfo *hinfo);
104extern int tcf_hash_search(struct tc_action *a, u32 index); 104extern int tcf_hash_search(struct tc_action *a, u32 index);
105extern struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, 105extern struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
106 int bind, struct tcf_hashinfo *hinfo); 106 int bind, struct tcf_hashinfo *hinfo);
107extern struct tcf_common *tcf_hash_create(u32 index, struct rtattr *est, 107extern struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
108 struct tc_action *a, int size, 108 struct tc_action *a, int size,
109 int bind, u32 *idx_gen, 109 int bind, u32 *idx_gen,
110 struct tcf_hashinfo *hinfo); 110 struct tcf_hashinfo *hinfo);
@@ -114,8 +114,8 @@ extern int tcf_register_action(struct tc_action_ops *a);
114extern int tcf_unregister_action(struct tc_action_ops *a); 114extern int tcf_unregister_action(struct tc_action_ops *a);
115extern void tcf_action_destroy(struct tc_action *a, int bind); 115extern void tcf_action_destroy(struct tc_action *a, int bind);
116extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res); 116extern int tcf_action_exec(struct sk_buff *skb, struct tc_action *a, struct tcf_result *res);
117extern struct tc_action *tcf_action_init(struct rtattr *rta, struct rtattr *est, char *n, int ovr, int bind, int *err); 117extern struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind);
118extern struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, char *n, int ovr, int bind, int *err); 118extern struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est, char *n, int ovr, int bind);
119extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int); 119extern int tcf_action_dump(struct sk_buff *skb, struct tc_action *a, int, int);
120extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int); 120extern int tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int, int);
121extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int); 121extern int tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int, int);
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 33b593e17441..496503c03846 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -17,6 +17,7 @@
17 17
18#define IPV6_MAX_ADDRESSES 16 18#define IPV6_MAX_ADDRESSES 16
19 19
20#include <linux/in.h>
20#include <linux/in6.h> 21#include <linux/in6.h>
21 22
22struct prefix_info { 23struct prefix_info {
@@ -58,15 +59,20 @@ extern int addrconf_add_ifaddr(void __user *arg);
58extern int addrconf_del_ifaddr(void __user *arg); 59extern int addrconf_del_ifaddr(void __user *arg);
59extern int addrconf_set_dstaddr(void __user *arg); 60extern int addrconf_set_dstaddr(void __user *arg);
60 61
61extern int ipv6_chk_addr(struct in6_addr *addr, 62extern int ipv6_chk_addr(struct net *net,
63 struct in6_addr *addr,
62 struct net_device *dev, 64 struct net_device *dev,
63 int strict); 65 int strict);
66
64#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 67#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
65extern int ipv6_chk_home_addr(struct in6_addr *addr); 68extern int ipv6_chk_home_addr(struct net *net,
69 struct in6_addr *addr);
66#endif 70#endif
67extern struct inet6_ifaddr * ipv6_get_ifaddr(struct in6_addr *addr, 71extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net,
68 struct net_device *dev, 72 struct in6_addr *addr,
69 int strict); 73 struct net_device *dev,
74 int strict);
75
70extern int ipv6_get_saddr(struct dst_entry *dst, 76extern int ipv6_get_saddr(struct dst_entry *dst,
71 struct in6_addr *daddr, 77 struct in6_addr *daddr,
72 struct in6_addr *saddr); 78 struct in6_addr *saddr);
@@ -84,6 +90,14 @@ extern void addrconf_leave_solict(struct inet6_dev *idev,
84 struct in6_addr *addr); 90 struct in6_addr *addr);
85 91
86/* 92/*
93 * IPv6 Address Label subsystem (addrlabel.c)
94 */
95extern int ipv6_addr_label_init(void);
96extern void ipv6_addr_label_rtnl_register(void);
97extern u32 ipv6_addr_label(const struct in6_addr *addr,
98 int type, int ifindex);
99
100/*
87 * multicast prototypes (mcast.c) 101 * multicast prototypes (mcast.c)
88 */ 102 */
89extern int ipv6_sock_mc_join(struct sock *sk, int ifindex, 103extern int ipv6_sock_mc_join(struct sock *sk, int ifindex,
@@ -241,6 +255,26 @@ static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr)
241 addr->s6_addr32[3] == htonl(0x00000002)); 255 addr->s6_addr32[3] == htonl(0x00000002));
242} 256}
243 257
258static inline int ipv6_isatap_eui64(u8 *eui, __be32 addr)
259{
260 eui[0] = (ipv4_is_zeronet(addr) || ipv4_is_private_10(addr) ||
261 ipv4_is_loopback(addr) || ipv4_is_linklocal_169(addr) ||
262 ipv4_is_private_172(addr) || ipv4_is_test_192(addr) ||
263 ipv4_is_anycast_6to4(addr) || ipv4_is_private_192(addr) ||
264 ipv4_is_test_198(addr) || ipv4_is_multicast(addr) ||
265 ipv4_is_lbcast(addr)) ? 0x00 : 0x02;
266 eui[1] = 0;
267 eui[2] = 0x5E;
268 eui[3] = 0xFE;
269 memcpy (eui+4, &addr, 4);
270 return 0;
271}
272
273static inline int ipv6_addr_is_isatap(const struct in6_addr *addr)
274{
275 return ((addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE));
276}
277
244#ifdef CONFIG_PROC_FS 278#ifdef CONFIG_PROC_FS
245extern int if6_proc_init(void); 279extern int if6_proc_init(void);
246extern void if6_proc_exit(void); 280extern void if6_proc_exit(void);
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 0864a775de24..2dfa96b0575e 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -12,7 +12,7 @@ extern void unix_gc(void);
12 12
13#define UNIX_HASH_SIZE 256 13#define UNIX_HASH_SIZE 256
14 14
15extern atomic_t unix_tot_inflight; 15extern unsigned int unix_tot_inflight;
16 16
17struct unix_address { 17struct unix_address {
18 atomic_t refcnt; 18 atomic_t refcnt;
@@ -59,12 +59,11 @@ struct unix_sock {
59#define unix_sk(__sk) ((struct unix_sock *)__sk) 59#define unix_sk(__sk) ((struct unix_sock *)__sk)
60 60
61#ifdef CONFIG_SYSCTL 61#ifdef CONFIG_SYSCTL
62extern int sysctl_unix_max_dgram_qlen; 62extern int unix_sysctl_register(struct net *net);
63extern void unix_sysctl_register(void); 63extern void unix_sysctl_unregister(struct net *net);
64extern void unix_sysctl_unregister(void);
65#else 64#else
66static inline void unix_sysctl_register(void) {} 65static inline int unix_sysctl_register(struct net *net) { return 0; }
67static inline void unix_sysctl_unregister(void) {} 66static inline void unix_sysctl_unregister(struct net *net) {}
68#endif 67#endif
69#endif 68#endif
70#endif 69#endif
diff --git a/include/net/arp.h b/include/net/arp.h
index f02664568600..c236270ec95e 100644
--- a/include/net/arp.h
+++ b/include/net/arp.h
@@ -5,24 +5,25 @@
5#include <linux/if_arp.h> 5#include <linux/if_arp.h>
6#include <net/neighbour.h> 6#include <net/neighbour.h>
7 7
8#define HAVE_ARP_CREATE
9 8
10extern struct neigh_table arp_tbl; 9extern struct neigh_table arp_tbl;
11 10
12extern void arp_init(void); 11extern void arp_init(void);
13extern int arp_find(unsigned char *haddr, struct sk_buff *skb); 12extern int arp_find(unsigned char *haddr, struct sk_buff *skb);
14extern int arp_ioctl(unsigned int cmd, void __user *arg); 13extern int arp_ioctl(struct net *net, unsigned int cmd, void __user *arg);
15extern void arp_send(int type, int ptype, __be32 dest_ip, 14extern void arp_send(int type, int ptype, __be32 dest_ip,
16 struct net_device *dev, __be32 src_ip, 15 struct net_device *dev, __be32 src_ip,
17 unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th); 16 const unsigned char *dest_hw,
17 const unsigned char *src_hw, const unsigned char *th);
18extern int arp_bind_neighbour(struct dst_entry *dst); 18extern int arp_bind_neighbour(struct dst_entry *dst);
19extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir); 19extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir);
20extern void arp_ifdown(struct net_device *dev); 20extern void arp_ifdown(struct net_device *dev);
21 21
22extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, 22extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
23 struct net_device *dev, __be32 src_ip, 23 struct net_device *dev, __be32 src_ip,
24 unsigned char *dest_hw, unsigned char *src_hw, 24 const unsigned char *dest_hw,
25 unsigned char *target_hw); 25 const unsigned char *src_hw,
26 const unsigned char *target_hw);
26extern void arp_xmit(struct sk_buff *skb); 27extern void arp_xmit(struct sk_buff *skb);
27 28
28extern struct neigh_ops arp_broken_ops; 29extern struct neigh_ops arp_broken_ops;
diff --git a/include/net/ax25.h b/include/net/ax25.h
index 4e3cd93f81fc..32a57e1dee3a 100644
--- a/include/net/ax25.h
+++ b/include/net/ax25.h
@@ -35,7 +35,7 @@
35#define AX25_P_ATALK 0xca /* Appletalk */ 35#define AX25_P_ATALK 0xca /* Appletalk */
36#define AX25_P_ATALK_ARP 0xcb /* Appletalk ARP */ 36#define AX25_P_ATALK_ARP 0xcb /* Appletalk ARP */
37#define AX25_P_IP 0xcc /* ARPA Internet Protocol */ 37#define AX25_P_IP 0xcc /* ARPA Internet Protocol */
38#define AX25_P_ARP 0xcd /* ARPA Adress Resolution */ 38#define AX25_P_ARP 0xcd /* ARPA Address Resolution */
39#define AX25_P_FLEXNET 0xce /* FlexNet */ 39#define AX25_P_FLEXNET 0xce /* FlexNet */
40#define AX25_P_NETROM 0xcf /* NET/ROM */ 40#define AX25_P_NETROM 0xcf /* NET/ROM */
41#define AX25_P_TEXT 0xF0 /* No layer 3 protocol impl. */ 41#define AX25_P_TEXT 0xF0 /* No layer 3 protocol impl. */
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index 25aa575db807..98ec7a320689 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -252,8 +252,8 @@ static inline void rfcomm_dlc_put(struct rfcomm_dlc *d)
252 rfcomm_dlc_free(d); 252 rfcomm_dlc_free(d);
253} 253}
254 254
255extern void FASTCALL(__rfcomm_dlc_throttle(struct rfcomm_dlc *d)); 255extern void __rfcomm_dlc_throttle(struct rfcomm_dlc *d);
256extern void FASTCALL(__rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)); 256extern void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d);
257 257
258static inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d) 258static inline void rfcomm_dlc_throttle(struct rfcomm_dlc *d)
259{ 259{
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index d30960e1755c..bcc480b8892a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -49,6 +49,120 @@ extern int ieee80211_radiotap_iterator_next(
49 struct ieee80211_radiotap_iterator *iterator); 49 struct ieee80211_radiotap_iterator *iterator);
50 50
51 51
52 /**
53 * struct key_params - key information
54 *
55 * Information about a key
56 *
57 * @key: key material
58 * @key_len: length of key material
59 * @cipher: cipher suite selector
60 * @seq: sequence counter (IV/PN) for TKIP and CCMP keys, only used
61 * with the get_key() callback, must be in little endian,
62 * length given by @seq_len.
63 */
64struct key_params {
65 u8 *key;
66 u8 *seq;
67 int key_len;
68 int seq_len;
69 u32 cipher;
70};
71
72/**
73 * struct beacon_parameters - beacon parameters
74 *
75 * Used to configure the beacon for an interface.
76 *
77 * @head: head portion of beacon (before TIM IE)
78 * or %NULL if not changed
79 * @tail: tail portion of beacon (after TIM IE)
80 * or %NULL if not changed
81 * @interval: beacon interval or zero if not changed
82 * @dtim_period: DTIM period or zero if not changed
83 * @head_len: length of @head
84 * @tail_len: length of @tail
85 */
86struct beacon_parameters {
87 u8 *head, *tail;
88 int interval, dtim_period;
89 int head_len, tail_len;
90};
91
92/**
93 * enum station_flags - station flags
94 *
95 * Station capability flags. Note that these must be the bits
96 * according to the nl80211 flags.
97 *
98 * @STATION_FLAG_CHANGED: station flags were changed
99 * @STATION_FLAG_AUTHORIZED: station is authorized to send frames (802.1X)
100 * @STATION_FLAG_SHORT_PREAMBLE: station is capable of receiving frames
101 * with short preambles
102 * @STATION_FLAG_WME: station is WME/QoS capable
103 */
104enum station_flags {
105 STATION_FLAG_CHANGED = 1<<0,
106 STATION_FLAG_AUTHORIZED = 1<<NL80211_STA_FLAG_AUTHORIZED,
107 STATION_FLAG_SHORT_PREAMBLE = 1<<NL80211_STA_FLAG_SHORT_PREAMBLE,
108 STATION_FLAG_WME = 1<<NL80211_STA_FLAG_WME,
109};
110
111/**
112 * struct station_parameters - station parameters
113 *
114 * Used to change and create a new station.
115 *
116 * @vlan: vlan interface station should belong to
117 * @supported_rates: supported rates in IEEE 802.11 format
118 * (or NULL for no change)
119 * @supported_rates_len: number of supported rates
120 * @station_flags: station flags (see &enum station_flags)
121 * @listen_interval: listen interval or -1 for no change
122 * @aid: AID or zero for no change
123 */
124struct station_parameters {
125 u8 *supported_rates;
126 struct net_device *vlan;
127 u32 station_flags;
128 int listen_interval;
129 u16 aid;
130 u8 supported_rates_len;
131};
132
133/**
134 * enum station_stats_flags - station statistics flags
135 *
136 * Used by the driver to indicate which info in &struct station_stats
137 * it has filled in during get_station().
138 *
139 * @STATION_STAT_INACTIVE_TIME: @inactive_time filled
140 * @STATION_STAT_RX_BYTES: @rx_bytes filled
141 * @STATION_STAT_TX_BYTES: @tx_bytes filled
142 */
143enum station_stats_flags {
144 STATION_STAT_INACTIVE_TIME = 1<<0,
145 STATION_STAT_RX_BYTES = 1<<1,
146 STATION_STAT_TX_BYTES = 1<<2,
147};
148
149/**
150 * struct station_stats - station statistics
151 *
152 * Station information filled by driver for get_station().
153 *
154 * @filled: bitflag of flags from &enum station_stats_flags
155 * @inactive_time: time since last station activity (tx/rx) in milliseconds
156 * @rx_bytes: bytes received from this station
157 * @tx_bytes: bytes transmitted to this station
158 */
159struct station_stats {
160 u32 filled;
161 u32 inactive_time;
162 u32 rx_bytes;
163 u32 tx_bytes;
164};
165
52/* from net/wireless.h */ 166/* from net/wireless.h */
53struct wiphy; 167struct wiphy;
54 168
@@ -71,6 +185,31 @@ struct wiphy;
71 * 185 *
72 * @change_virtual_intf: change type of virtual interface 186 * @change_virtual_intf: change type of virtual interface
73 * 187 *
188 * @add_key: add a key with the given parameters. @mac_addr will be %NULL
189 * when adding a group key.
190 *
191 * @get_key: get information about the key with the given parameters.
192 * @mac_addr will be %NULL when requesting information for a group
193 * key. All pointers given to the @callback function need not be valid
194 * after it returns.
195 *
196 * @del_key: remove a key given the @mac_addr (%NULL for a group key)
197 * and @key_index
198 *
199 * @set_default_key: set the default key on an interface
200 *
201 * @add_beacon: Add a beacon with given parameters, @head, @interval
202 * and @dtim_period will be valid, @tail is optional.
203 * @set_beacon: Change the beacon parameters for an access point mode
204 * interface. This should reject the call when no beacon has been
205 * configured.
206 * @del_beacon: Remove beacon configuration and stop sending the beacon.
207 *
208 * @add_station: Add a new station.
209 *
210 * @del_station: Remove a station; @mac may be NULL to remove all stations.
211 *
212 * @change_station: Modify a given station.
74 */ 213 */
75struct cfg80211_ops { 214struct cfg80211_ops {
76 int (*add_virtual_intf)(struct wiphy *wiphy, char *name, 215 int (*add_virtual_intf)(struct wiphy *wiphy, char *name,
@@ -78,6 +217,34 @@ struct cfg80211_ops {
78 int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex); 217 int (*del_virtual_intf)(struct wiphy *wiphy, int ifindex);
79 int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex, 218 int (*change_virtual_intf)(struct wiphy *wiphy, int ifindex,
80 enum nl80211_iftype type); 219 enum nl80211_iftype type);
220
221 int (*add_key)(struct wiphy *wiphy, struct net_device *netdev,
222 u8 key_index, u8 *mac_addr,
223 struct key_params *params);
224 int (*get_key)(struct wiphy *wiphy, struct net_device *netdev,
225 u8 key_index, u8 *mac_addr, void *cookie,
226 void (*callback)(void *cookie, struct key_params*));
227 int (*del_key)(struct wiphy *wiphy, struct net_device *netdev,
228 u8 key_index, u8 *mac_addr);
229 int (*set_default_key)(struct wiphy *wiphy,
230 struct net_device *netdev,
231 u8 key_index);
232
233 int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev,
234 struct beacon_parameters *info);
235 int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev,
236 struct beacon_parameters *info);
237 int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev);
238
239
240 int (*add_station)(struct wiphy *wiphy, struct net_device *dev,
241 u8 *mac, struct station_parameters *params);
242 int (*del_station)(struct wiphy *wiphy, struct net_device *dev,
243 u8 *mac);
244 int (*change_station)(struct wiphy *wiphy, struct net_device *dev,
245 u8 *mac, struct station_parameters *params);
246 int (*get_station)(struct wiphy *wiphy, struct net_device *dev,
247 u8 *mac, struct station_stats *stats);
81}; 248};
82 249
83#endif /* __NET_CFG80211_H */ 250#endif /* __NET_CFG80211_H */
diff --git a/include/net/checksum.h b/include/net/checksum.h
index 124246172a88..07602b7fa218 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -93,4 +93,29 @@ static inline __wsum csum_unfold(__sum16 n)
93} 93}
94 94
95#define CSUM_MANGLED_0 ((__force __sum16)0xffff) 95#define CSUM_MANGLED_0 ((__force __sum16)0xffff)
96
97static inline void csum_replace4(__sum16 *sum, __be32 from, __be32 to)
98{
99 __be32 diff[] = { ~from, to };
100
101 *sum = csum_fold(csum_partial((char *)diff, sizeof(diff), ~csum_unfold(*sum)));
102}
103
104static inline void csum_replace2(__sum16 *sum, __be16 from, __be16 to)
105{
106 csum_replace4(sum, (__force __be32)from, (__force __be32)to);
107}
108
109struct sk_buff;
110extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
111 __be32 from, __be32 to, int pseudohdr);
112
113static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb,
114 __be16 from, __be16 to,
115 int pseudohdr)
116{
117 inet_proto_csum_replace4(sum, skb, (__force __be32)from,
118 (__force __be32)to, pseudohdr);
119}
120
96#endif 121#endif
diff --git a/include/net/dsfield.h b/include/net/dsfield.h
index eb65bf2e2502..8a8d4e06900d 100644
--- a/include/net/dsfield.h
+++ b/include/net/dsfield.h
@@ -12,15 +12,15 @@
12#include <asm/byteorder.h> 12#include <asm/byteorder.h>
13 13
14 14
15static inline __u8 ipv4_get_dsfield(struct iphdr *iph) 15static inline __u8 ipv4_get_dsfield(const struct iphdr *iph)
16{ 16{
17 return iph->tos; 17 return iph->tos;
18} 18}
19 19
20 20
21static inline __u8 ipv6_get_dsfield(struct ipv6hdr *ipv6h) 21static inline __u8 ipv6_get_dsfield(const struct ipv6hdr *ipv6h)
22{ 22{
23 return ntohs(*(__be16 *) ipv6h) >> 4; 23 return ntohs(*(const __be16 *)ipv6h) >> 4;
24} 24}
25 25
26 26
diff --git a/include/net/dst.h b/include/net/dst.h
index e9ff4a4caef9..e3ac7d0fc4e1 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -50,14 +50,17 @@ struct dst_entry
50 unsigned long expires; 50 unsigned long expires;
51 51
52 unsigned short header_len; /* more space at head required */ 52 unsigned short header_len; /* more space at head required */
53 unsigned short nfheader_len; /* more non-fragment space at head required */
54 unsigned short trailer_len; /* space to reserve at tail */ 53 unsigned short trailer_len; /* space to reserve at tail */
55 54
56 u32 metrics[RTAX_MAX]; 55 u32 metrics[RTAX_MAX];
57 struct dst_entry *path; 56 struct dst_entry *path;
58 57
59 unsigned long rate_last; /* rate limiting for ICMP */ 58 unsigned long rate_last; /* rate limiting for ICMP */
60 unsigned long rate_tokens; 59 unsigned int rate_tokens;
60
61#ifdef CONFIG_NET_CLS_ROUTE
62 __u32 tclassid;
63#endif
61 64
62 struct neighbour *neighbour; 65 struct neighbour *neighbour;
63 struct hh_cache *hh; 66 struct hh_cache *hh;
@@ -66,10 +69,6 @@ struct dst_entry
66 int (*input)(struct sk_buff*); 69 int (*input)(struct sk_buff*);
67 int (*output)(struct sk_buff*); 70 int (*output)(struct sk_buff*);
68 71
69#ifdef CONFIG_NET_CLS_ROUTE
70 __u32 tclassid;
71#endif
72
73 struct dst_ops *ops; 72 struct dst_ops *ops;
74 73
75 unsigned long lastuse; 74 unsigned long lastuse;
@@ -81,7 +80,6 @@ struct dst_entry
81 struct rt6_info *rt6_next; 80 struct rt6_info *rt6_next;
82 struct dn_route *dn_next; 81 struct dn_route *dn_next;
83 }; 82 };
84 char info[0];
85}; 83};
86 84
87 85
@@ -91,7 +89,7 @@ struct dst_ops
91 __be16 protocol; 89 __be16 protocol;
92 unsigned gc_thresh; 90 unsigned gc_thresh;
93 91
94 int (*gc)(void); 92 int (*gc)(struct dst_ops *ops);
95 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); 93 struct dst_entry * (*check)(struct dst_entry *, __u32 cookie);
96 void (*destroy)(struct dst_entry *); 94 void (*destroy)(struct dst_entry *);
97 void (*ifdown)(struct dst_entry *, 95 void (*ifdown)(struct dst_entry *,
@@ -99,10 +97,12 @@ struct dst_ops
99 struct dst_entry * (*negative_advice)(struct dst_entry *); 97 struct dst_entry * (*negative_advice)(struct dst_entry *);
100 void (*link_failure)(struct sk_buff *); 98 void (*link_failure)(struct sk_buff *);
101 void (*update_pmtu)(struct dst_entry *dst, u32 mtu); 99 void (*update_pmtu)(struct dst_entry *dst, u32 mtu);
100 int (*local_out)(struct sk_buff *skb);
102 int entry_size; 101 int entry_size;
103 102
104 atomic_t entries; 103 atomic_t entries;
105 struct kmem_cache *kmem_cachep; 104 struct kmem_cache *kmem_cachep;
105 struct net *dst_net;
106}; 106};
107 107
108#ifdef __KERNEL__ 108#ifdef __KERNEL__
@@ -143,6 +143,13 @@ static inline void dst_hold(struct dst_entry * dst)
143 atomic_inc(&dst->__refcnt); 143 atomic_inc(&dst->__refcnt);
144} 144}
145 145
146static inline void dst_use(struct dst_entry *dst, unsigned long time)
147{
148 dst_hold(dst);
149 dst->__use++;
150 dst->lastuse = time;
151}
152
146static inline 153static inline
147struct dst_entry * dst_clone(struct dst_entry * dst) 154struct dst_entry * dst_clone(struct dst_entry * dst)
148{ 155{
@@ -173,6 +180,7 @@ static inline struct dst_entry *dst_pop(struct dst_entry *dst)
173 return child; 180 return child;
174} 181}
175 182
183extern int dst_discard(struct sk_buff *skb);
176extern void * dst_alloc(struct dst_ops * ops); 184extern void * dst_alloc(struct dst_ops * ops);
177extern void __dst_free(struct dst_entry * dst); 185extern void __dst_free(struct dst_entry * dst);
178extern struct dst_entry *dst_destroy(struct dst_entry * dst); 186extern struct dst_entry *dst_destroy(struct dst_entry * dst);
@@ -257,6 +265,12 @@ static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie)
257 265
258extern void dst_init(void); 266extern void dst_init(void);
259 267
268/* Flags for xfrm_lookup flags argument. */
269enum {
270 XFRM_LOOKUP_WAIT = 1 << 0,
271 XFRM_LOOKUP_ICMP = 1 << 1,
272};
273
260struct flowi; 274struct flowi;
261#ifndef CONFIG_XFRM 275#ifndef CONFIG_XFRM
262static inline int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl, 276static inline int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl,
diff --git a/include/net/esp.h b/include/net/esp.h
index c1bc529809da..d58451331dbd 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -1,58 +1,20 @@
1#ifndef _NET_ESP_H 1#ifndef _NET_ESP_H
2#define _NET_ESP_H 2#define _NET_ESP_H
3 3
4#include <linux/crypto.h> 4#include <linux/skbuff.h>
5#include <net/xfrm.h>
6#include <asm/scatterlist.h>
7 5
8#define ESP_NUM_FAST_SG 4 6struct crypto_aead;
9 7
10struct esp_data 8struct esp_data {
11{ 9 /* 0..255 */
12 struct scatterlist sgbuf[ESP_NUM_FAST_SG]; 10 int padlen;
13 11
14 /* Confidentiality */ 12 /* Confidentiality & Integrity */
15 struct { 13 struct crypto_aead *aead;
16 int padlen; /* 0..255 */
17 /* ivlen is offset from enc_data, where encrypted data start.
18 * It is logically different of crypto_tfm_alg_ivsize(tfm).
19 * We assume that it is either zero (no ivec), or
20 * >= crypto_tfm_alg_ivsize(tfm). */
21 int ivlen;
22 int ivinitted;
23 u8 *ivec; /* ivec buffer */
24 struct crypto_blkcipher *tfm; /* crypto handle */
25 } conf;
26
27 /* Integrity. It is active when icv_full_len != 0 */
28 struct {
29 u8 *work_icv;
30 int icv_full_len;
31 int icv_trunc_len;
32 struct crypto_hash *tfm;
33 } auth;
34}; 14};
35 15
36extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len); 16extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
37 17
38static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb,
39 int offset, int len)
40{
41 struct hash_desc desc;
42 int err;
43
44 desc.tfm = esp->auth.tfm;
45 desc.flags = 0;
46
47 err = crypto_hash_init(&desc);
48 if (unlikely(err))
49 return err;
50 err = skb_icv_walk(skb, &desc, offset, len, crypto_hash_update);
51 if (unlikely(err))
52 return err;
53 return crypto_hash_final(&desc, esp->auth.work_icv);
54}
55
56struct ip_esp_hdr; 18struct ip_esp_hdr;
57 19
58static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb) 20static inline struct ip_esp_hdr *ip_esp_hdr(const struct sk_buff *skb)
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h
index 017aebd90683..34349f9f4331 100644
--- a/include/net/fib_rules.h
+++ b/include/net/fib_rules.h
@@ -22,6 +22,7 @@ struct fib_rule
22 u32 target; 22 u32 target;
23 struct fib_rule * ctarget; 23 struct fib_rule * ctarget;
24 struct rcu_head rcu; 24 struct rcu_head rcu;
25 struct net * fr_net;
25}; 26};
26 27
27struct fib_lookup_arg 28struct fib_lookup_arg
@@ -56,7 +57,7 @@ struct fib_rules_ops
56 int (*fill)(struct fib_rule *, struct sk_buff *, 57 int (*fill)(struct fib_rule *, struct sk_buff *,
57 struct nlmsghdr *, 58 struct nlmsghdr *,
58 struct fib_rule_hdr *); 59 struct fib_rule_hdr *);
59 u32 (*default_pref)(void); 60 u32 (*default_pref)(struct fib_rules_ops *ops);
60 size_t (*nlmsg_payload)(struct fib_rule *); 61 size_t (*nlmsg_payload)(struct fib_rule *);
61 62
62 /* Called after modifications to the rules set, must flush 63 /* Called after modifications to the rules set, must flush
@@ -67,6 +68,7 @@ struct fib_rules_ops
67 const struct nla_policy *policy; 68 const struct nla_policy *policy;
68 struct list_head rules_list; 69 struct list_head rules_list;
69 struct module *owner; 70 struct module *owner;
71 struct net *fro_net;
70}; 72};
71 73
72#define FRA_GENERIC_POLICY \ 74#define FRA_GENERIC_POLICY \
@@ -101,10 +103,14 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla)
101 return frh->table; 103 return frh->table;
102} 104}
103 105
104extern int fib_rules_register(struct fib_rules_ops *); 106extern int fib_rules_register(struct fib_rules_ops *);
105extern int fib_rules_unregister(struct fib_rules_ops *); 107extern void fib_rules_unregister(struct fib_rules_ops *);
108extern void fib_rules_cleanup_ops(struct fib_rules_ops *);
106 109
107extern int fib_rules_lookup(struct fib_rules_ops *, 110extern int fib_rules_lookup(struct fib_rules_ops *,
108 struct flowi *, int flags, 111 struct flowi *, int flags,
109 struct fib_lookup_arg *); 112 struct fib_lookup_arg *);
113extern int fib_default_rule_add(struct fib_rules_ops *,
114 u32 pref, u32 table,
115 u32 flags);
110#endif 116#endif
diff --git a/include/net/flow.h b/include/net/flow.h
index af59fa5cc1f8..ad16e0076c89 100644
--- a/include/net/flow.h
+++ b/include/net/flow.h
@@ -48,7 +48,6 @@ struct flowi {
48 48
49 __u8 proto; 49 __u8 proto;
50 __u8 flags; 50 __u8 flags;
51#define FLOWI_FLAG_MULTIPATHOLDROUTE 0x01
52 union { 51 union {
53 struct { 52 struct {
54 __be16 sport; 53 __be16 sport;
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h
index 0b95cf031d6e..8cd8185fa2ed 100644
--- a/include/net/gen_stats.h
+++ b/include/net/gen_stats.h
@@ -10,7 +10,7 @@ struct gnet_dump
10{ 10{
11 spinlock_t * lock; 11 spinlock_t * lock;
12 struct sk_buff * skb; 12 struct sk_buff * skb;
13 struct rtattr * tail; 13 struct nlattr * tail;
14 14
15 /* Backward compatability */ 15 /* Backward compatability */
16 int compat_tc_stats; 16 int compat_tc_stats;
@@ -39,11 +39,11 @@ extern int gnet_stats_finish_copy(struct gnet_dump *d);
39 39
40extern int gen_new_estimator(struct gnet_stats_basic *bstats, 40extern int gen_new_estimator(struct gnet_stats_basic *bstats,
41 struct gnet_stats_rate_est *rate_est, 41 struct gnet_stats_rate_est *rate_est,
42 spinlock_t *stats_lock, struct rtattr *opt); 42 spinlock_t *stats_lock, struct nlattr *opt);
43extern void gen_kill_estimator(struct gnet_stats_basic *bstats, 43extern void gen_kill_estimator(struct gnet_stats_basic *bstats,
44 struct gnet_stats_rate_est *rate_est); 44 struct gnet_stats_rate_est *rate_est);
45extern int gen_replace_estimator(struct gnet_stats_basic *bstats, 45extern int gen_replace_estimator(struct gnet_stats_basic *bstats,
46 struct gnet_stats_rate_est *rate_est, 46 struct gnet_stats_rate_est *rate_est,
47 spinlock_t *stats_lock, struct rtattr *opt); 47 spinlock_t *stats_lock, struct nlattr *opt);
48 48
49#endif 49#endif
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h
index 164d13211165..285b2adfa648 100644
--- a/include/net/ieee80211.h
+++ b/include/net/ieee80211.h
@@ -115,8 +115,16 @@ extern u32 ieee80211_debug_level;
115do { if (ieee80211_debug_level & (level)) \ 115do { if (ieee80211_debug_level & (level)) \
116 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \ 116 printk(KERN_DEBUG "ieee80211: %c %s " fmt, \
117 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 117 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
118static inline bool ieee80211_ratelimit_debug(u32 level)
119{
120 return (ieee80211_debug_level & level) && net_ratelimit();
121}
118#else 122#else
119#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) 123#define IEEE80211_DEBUG(level, fmt, args...) do {} while (0)
124static inline bool ieee80211_ratelimit_debug(u32 level)
125{
126 return false;
127}
120#endif /* CONFIG_IEEE80211_DEBUG */ 128#endif /* CONFIG_IEEE80211_DEBUG */
121 129
122/* escape_essid() is intended to be used in debug (and possibly error) 130/* escape_essid() is intended to be used in debug (and possibly error)
@@ -669,7 +677,7 @@ struct ieee80211_probe_request {
669 677
670struct ieee80211_probe_response { 678struct ieee80211_probe_response {
671 struct ieee80211_hdr_3addr header; 679 struct ieee80211_hdr_3addr header;
672 u32 time_stamp[2]; 680 __le32 time_stamp[2];
673 __le16 beacon_interval; 681 __le16 beacon_interval;
674 __le16 capability; 682 __le16 capability;
675 /* SSID, supported rates, FH params, DS params, 683 /* SSID, supported rates, FH params, DS params,
@@ -710,8 +718,8 @@ struct ieee80211_txb {
710 u8 encrypted; 718 u8 encrypted;
711 u8 rts_included; 719 u8 rts_included;
712 u8 reserved; 720 u8 reserved;
713 __le16 frag_size; 721 u16 frag_size;
714 __le16 payload_size; 722 u16 payload_size;
715 struct sk_buff *fragments[0]; 723 struct sk_buff *fragments[0];
716}; 724};
717 725
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index 448eccb20638..b24508abb850 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -269,18 +269,21 @@ static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf)
269 buf[0] = 0x00; 269 buf[0] = 0x00;
270} 270}
271 271
272static inline void ipv6_ib_mc_map(struct in6_addr *addr, char *buf) 272static inline void ipv6_ib_mc_map(const struct in6_addr *addr,
273 const unsigned char *broadcast, char *buf)
273{ 274{
275 unsigned char scope = broadcast[5] & 0xF;
276
274 buf[0] = 0; /* Reserved */ 277 buf[0] = 0; /* Reserved */
275 buf[1] = 0xff; /* Multicast QPN */ 278 buf[1] = 0xff; /* Multicast QPN */
276 buf[2] = 0xff; 279 buf[2] = 0xff;
277 buf[3] = 0xff; 280 buf[3] = 0xff;
278 buf[4] = 0xff; 281 buf[4] = 0xff;
279 buf[5] = 0x12; /* link local scope */ 282 buf[5] = 0x10 | scope; /* scope from broadcast address */
280 buf[6] = 0x60; /* IPv6 signature */ 283 buf[6] = 0x60; /* IPv6 signature */
281 buf[7] = 0x1b; 284 buf[7] = 0x1b;
282 buf[8] = 0; /* P_Key */ 285 buf[8] = broadcast[8]; /* P_Key */
283 buf[9] = 0; 286 buf[9] = broadcast[9];
284 memcpy(buf + 10, addr->s6_addr + 6, 10); 287 memcpy(buf + 10, addr->s6_addr + 6, 10);
285} 288}
286#endif 289#endif
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h
index 668056b4bb0b..fdff630708ce 100644
--- a/include/net/inet6_hashtables.h
+++ b/include/net/inet6_hashtables.h
@@ -57,34 +57,37 @@ extern void __inet6_hash(struct inet_hashinfo *hashinfo, struct sock *sk);
57 * 57 *
58 * The sockhash lock must be held as a reader here. 58 * The sockhash lock must be held as a reader here.
59 */ 59 */
60extern struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, 60extern struct sock *__inet6_lookup_established(struct net *net,
61 struct inet_hashinfo *hashinfo,
61 const struct in6_addr *saddr, 62 const struct in6_addr *saddr,
62 const __be16 sport, 63 const __be16 sport,
63 const struct in6_addr *daddr, 64 const struct in6_addr *daddr,
64 const u16 hnum, 65 const u16 hnum,
65 const int dif); 66 const int dif);
66 67
67extern struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, 68extern struct sock *inet6_lookup_listener(struct net *net,
69 struct inet_hashinfo *hashinfo,
68 const struct in6_addr *daddr, 70 const struct in6_addr *daddr,
69 const unsigned short hnum, 71 const unsigned short hnum,
70 const int dif); 72 const int dif);
71 73
72static inline struct sock *__inet6_lookup(struct inet_hashinfo *hashinfo, 74static inline struct sock *__inet6_lookup(struct net *net,
75 struct inet_hashinfo *hashinfo,
73 const struct in6_addr *saddr, 76 const struct in6_addr *saddr,
74 const __be16 sport, 77 const __be16 sport,
75 const struct in6_addr *daddr, 78 const struct in6_addr *daddr,
76 const u16 hnum, 79 const u16 hnum,
77 const int dif) 80 const int dif)
78{ 81{
79 struct sock *sk = __inet6_lookup_established(hashinfo, saddr, sport, 82 struct sock *sk = __inet6_lookup_established(net, hashinfo, saddr,
80 daddr, hnum, dif); 83 sport, daddr, hnum, dif);
81 if (sk) 84 if (sk)
82 return sk; 85 return sk;
83 86
84 return inet6_lookup_listener(hashinfo, daddr, hnum, dif); 87 return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif);
85} 88}
86 89
87extern struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, 90extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo,
88 const struct in6_addr *saddr, const __be16 sport, 91 const struct in6_addr *saddr, const __be16 sport,
89 const struct in6_addr *daddr, const __be16 dport, 92 const struct in6_addr *daddr, const __be16 dport,
90 const int dif); 93 const int dif);
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index 227adcbdfec8..38d5a1e9980d 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -13,9 +13,6 @@ struct sock;
13struct sockaddr; 13struct sockaddr;
14struct socket; 14struct socket;
15 15
16extern void inet_remove_sock(struct sock *sk1);
17extern void inet_put_sock(unsigned short num,
18 struct sock *sk);
19extern int inet_release(struct socket *sock); 16extern int inet_release(struct socket *sock);
20extern int inet_stream_connect(struct socket *sock, 17extern int inet_stream_connect(struct socket *sock,
21 struct sockaddr * uaddr, 18 struct sockaddr * uaddr,
@@ -30,7 +27,6 @@ extern int inet_sendmsg(struct kiocb *iocb,
30 struct msghdr *msg, 27 struct msghdr *msg,
31 size_t size); 28 size_t size);
32extern int inet_shutdown(struct socket *sock, int how); 29extern int inet_shutdown(struct socket *sock, int how);
33extern unsigned int inet_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait);
34extern int inet_listen(struct socket *sock, int backlog); 30extern int inet_listen(struct socket *sock, int backlog);
35 31
36extern void inet_sock_destruct(struct sock *sk); 32extern void inet_sock_destruct(struct sock *sk);
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h
index de8399a79774..ba33db053854 100644
--- a/include/net/inet_ecn.h
+++ b/include/net/inet_ecn.h
@@ -83,9 +83,9 @@ static inline void IP_ECN_clear(struct iphdr *iph)
83 iph->tos &= ~INET_ECN_MASK; 83 iph->tos &= ~INET_ECN_MASK;
84} 84}
85 85
86static inline void ipv4_copy_dscp(struct iphdr *outer, struct iphdr *inner) 86static inline void ipv4_copy_dscp(unsigned int dscp, struct iphdr *inner)
87{ 87{
88 u32 dscp = ipv4_get_dsfield(outer) & ~INET_ECN_MASK; 88 dscp &= ~INET_ECN_MASK;
89 ipv4_change_dsfield(inner, INET_ECN_MASK, dscp); 89 ipv4_change_dsfield(inner, INET_ECN_MASK, dscp);
90} 90}
91 91
@@ -104,9 +104,9 @@ static inline void IP6_ECN_clear(struct ipv6hdr *iph)
104 *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20); 104 *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20);
105} 105}
106 106
107static inline void ipv6_copy_dscp(struct ipv6hdr *outer, struct ipv6hdr *inner) 107static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner)
108{ 108{
109 u32 dscp = ipv6_get_dsfield(outer) & ~INET_ECN_MASK; 109 dscp &= ~INET_ECN_MASK;
110 ipv6_change_dsfield(inner, INET_ECN_MASK, dscp); 110 ipv6_change_dsfield(inner, INET_ECN_MASK, dscp);
111} 111}
112 112
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h
index 954def408975..7374251b9787 100644
--- a/include/net/inet_frag.h
+++ b/include/net/inet_frag.h
@@ -1,8 +1,20 @@
1#ifndef __NET_FRAG_H__ 1#ifndef __NET_FRAG_H__
2#define __NET_FRAG_H__ 2#define __NET_FRAG_H__
3 3
4struct netns_frags {
5 int nqueues;
6 atomic_t mem;
7 struct list_head lru_list;
8
9 /* sysctls */
10 int timeout;
11 int high_thresh;
12 int low_thresh;
13};
14
4struct inet_frag_queue { 15struct inet_frag_queue {
5 struct hlist_node list; 16 struct hlist_node list;
17 struct netns_frags *net;
6 struct list_head lru_list; /* lru list member */ 18 struct list_head lru_list; /* lru list member */
7 spinlock_t lock; 19 spinlock_t lock;
8 atomic_t refcnt; 20 atomic_t refcnt;
@@ -20,23 +32,13 @@ struct inet_frag_queue {
20 32
21#define INETFRAGS_HASHSZ 64 33#define INETFRAGS_HASHSZ 64
22 34
23struct inet_frags_ctl {
24 int high_thresh;
25 int low_thresh;
26 int timeout;
27 int secret_interval;
28};
29
30struct inet_frags { 35struct inet_frags {
31 struct list_head lru_list;
32 struct hlist_head hash[INETFRAGS_HASHSZ]; 36 struct hlist_head hash[INETFRAGS_HASHSZ];
33 rwlock_t lock; 37 rwlock_t lock;
34 u32 rnd; 38 u32 rnd;
35 int nqueues;
36 int qsize; 39 int qsize;
37 atomic_t mem; 40 int secret_interval;
38 struct timer_list secret_timer; 41 struct timer_list secret_timer;
39 struct inet_frags_ctl *ctl;
40 42
41 unsigned int (*hashfn)(struct inet_frag_queue *); 43 unsigned int (*hashfn)(struct inet_frag_queue *);
42 void (*constructor)(struct inet_frag_queue *q, 44 void (*constructor)(struct inet_frag_queue *q,
@@ -51,12 +53,15 @@ struct inet_frags {
51void inet_frags_init(struct inet_frags *); 53void inet_frags_init(struct inet_frags *);
52void inet_frags_fini(struct inet_frags *); 54void inet_frags_fini(struct inet_frags *);
53 55
56void inet_frags_init_net(struct netns_frags *nf);
57void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f);
58
54void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); 59void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f);
55void inet_frag_destroy(struct inet_frag_queue *q, 60void inet_frag_destroy(struct inet_frag_queue *q,
56 struct inet_frags *f, int *work); 61 struct inet_frags *f, int *work);
57int inet_frag_evictor(struct inet_frags *f); 62int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f);
58struct inet_frag_queue *inet_frag_find(struct inet_frags *f, void *key, 63struct inet_frag_queue *inet_frag_find(struct netns_frags *nf,
59 unsigned int hash); 64 struct inet_frags *f, void *key, unsigned int hash);
60 65
61static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f) 66static inline void inet_frag_put(struct inet_frag_queue *q, struct inet_frags *f)
62{ 67{
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index 4427dcd1e53a..c23c4ed30724 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -23,6 +23,7 @@
23#include <linux/spinlock.h> 23#include <linux/spinlock.h>
24#include <linux/types.h> 24#include <linux/types.h>
25#include <linux/wait.h> 25#include <linux/wait.h>
26#include <linux/vmalloc.h>
26 27
27#include <net/inet_connection_sock.h> 28#include <net/inet_connection_sock.h>
28#include <net/inet_sock.h> 29#include <net/inet_sock.h>
@@ -37,7 +38,6 @@
37 * I'll experiment with dynamic table growth later. 38 * I'll experiment with dynamic table growth later.
38 */ 39 */
39struct inet_ehash_bucket { 40struct inet_ehash_bucket {
40 rwlock_t lock;
41 struct hlist_head chain; 41 struct hlist_head chain;
42 struct hlist_head twchain; 42 struct hlist_head twchain;
43}; 43};
@@ -74,6 +74,7 @@ struct inet_ehash_bucket {
74 * ports are created in O(1) time? I thought so. ;-) -DaveM 74 * ports are created in O(1) time? I thought so. ;-) -DaveM
75 */ 75 */
76struct inet_bind_bucket { 76struct inet_bind_bucket {
77 struct net *ib_net;
77 unsigned short port; 78 unsigned short port;
78 signed short fastreuse; 79 signed short fastreuse;
79 struct hlist_node node; 80 struct hlist_node node;
@@ -100,6 +101,9 @@ struct inet_hashinfo {
100 * TIME_WAIT sockets use a separate chain (twchain). 101 * TIME_WAIT sockets use a separate chain (twchain).
101 */ 102 */
102 struct inet_ehash_bucket *ehash; 103 struct inet_ehash_bucket *ehash;
104 rwlock_t *ehash_locks;
105 unsigned int ehash_size;
106 unsigned int ehash_locks_mask;
103 107
104 /* Ok, let's try this, I give up, we do need a local binding 108 /* Ok, let's try this, I give up, we do need a local binding
105 * TCP hash as well as the others for fast bind/connect. 109 * TCP hash as well as the others for fast bind/connect.
@@ -107,7 +111,7 @@ struct inet_hashinfo {
107 struct inet_bind_hashbucket *bhash; 111 struct inet_bind_hashbucket *bhash;
108 112
109 unsigned int bhash_size; 113 unsigned int bhash_size;
110 unsigned int ehash_size; 114 /* Note : 4 bytes padding on 64 bit arches */
111 115
112 /* All sockets in TCP_LISTEN state will be in here. This is the only 116 /* All sockets in TCP_LISTEN state will be in here. This is the only
113 * table where wildcard'd TCP sockets can exist. Hash function here 117 * table where wildcard'd TCP sockets can exist. Hash function here
@@ -134,8 +138,64 @@ static inline struct inet_ehash_bucket *inet_ehash_bucket(
134 return &hashinfo->ehash[hash & (hashinfo->ehash_size - 1)]; 138 return &hashinfo->ehash[hash & (hashinfo->ehash_size - 1)];
135} 139}
136 140
141static inline rwlock_t *inet_ehash_lockp(
142 struct inet_hashinfo *hashinfo,
143 unsigned int hash)
144{
145 return &hashinfo->ehash_locks[hash & hashinfo->ehash_locks_mask];
146}
147
148static inline int inet_ehash_locks_alloc(struct inet_hashinfo *hashinfo)
149{
150 unsigned int i, size = 256;
151#if defined(CONFIG_PROVE_LOCKING)
152 unsigned int nr_pcpus = 2;
153#else
154 unsigned int nr_pcpus = num_possible_cpus();
155#endif
156 if (nr_pcpus >= 4)
157 size = 512;
158 if (nr_pcpus >= 8)
159 size = 1024;
160 if (nr_pcpus >= 16)
161 size = 2048;
162 if (nr_pcpus >= 32)
163 size = 4096;
164 if (sizeof(rwlock_t) != 0) {
165#ifdef CONFIG_NUMA
166 if (size * sizeof(rwlock_t) > PAGE_SIZE)
167 hashinfo->ehash_locks = vmalloc(size * sizeof(rwlock_t));
168 else
169#endif
170 hashinfo->ehash_locks = kmalloc(size * sizeof(rwlock_t),
171 GFP_KERNEL);
172 if (!hashinfo->ehash_locks)
173 return ENOMEM;
174 for (i = 0; i < size; i++)
175 rwlock_init(&hashinfo->ehash_locks[i]);
176 }
177 hashinfo->ehash_locks_mask = size - 1;
178 return 0;
179}
180
181static inline void inet_ehash_locks_free(struct inet_hashinfo *hashinfo)
182{
183 if (hashinfo->ehash_locks) {
184#ifdef CONFIG_NUMA
185 unsigned int size = (hashinfo->ehash_locks_mask + 1) *
186 sizeof(rwlock_t);
187 if (size > PAGE_SIZE)
188 vfree(hashinfo->ehash_locks);
189 else
190#endif
191 kfree(hashinfo->ehash_locks);
192 hashinfo->ehash_locks = NULL;
193 }
194}
195
137extern struct inet_bind_bucket * 196extern struct inet_bind_bucket *
138 inet_bind_bucket_create(struct kmem_cache *cachep, 197 inet_bind_bucket_create(struct kmem_cache *cachep,
198 struct net *net,
139 struct inet_bind_hashbucket *head, 199 struct inet_bind_hashbucket *head,
140 const unsigned short snum); 200 const unsigned short snum);
141extern void inet_bind_bucket_destroy(struct kmem_cache *cachep, 201extern void inet_bind_bucket_destroy(struct kmem_cache *cachep,
@@ -206,37 +266,14 @@ static inline void inet_listen_unlock(struct inet_hashinfo *hashinfo)
206 wake_up(&hashinfo->lhash_wait); 266 wake_up(&hashinfo->lhash_wait);
207} 267}
208 268
209static inline void __inet_hash(struct inet_hashinfo *hashinfo, 269extern void __inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk);
210 struct sock *sk, const int listen_possible) 270extern void __inet_hash_nolisten(struct inet_hashinfo *hinfo, struct sock *sk);
211{
212 struct hlist_head *list;
213 rwlock_t *lock;
214
215 BUG_TRAP(sk_unhashed(sk));
216 if (listen_possible && sk->sk_state == TCP_LISTEN) {
217 list = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
218 lock = &hashinfo->lhash_lock;
219 inet_listen_wlock(hashinfo);
220 } else {
221 struct inet_ehash_bucket *head;
222 sk->sk_hash = inet_sk_ehashfn(sk);
223 head = inet_ehash_bucket(hashinfo, sk->sk_hash);
224 list = &head->chain;
225 lock = &head->lock;
226 write_lock(lock);
227 }
228 __sk_add_node(sk, list);
229 sock_prot_inc_use(sk->sk_prot);
230 write_unlock(lock);
231 if (listen_possible && sk->sk_state == TCP_LISTEN)
232 wake_up(&hashinfo->lhash_wait);
233}
234 271
235static inline void inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk) 272static inline void inet_hash(struct inet_hashinfo *hashinfo, struct sock *sk)
236{ 273{
237 if (sk->sk_state != TCP_CLOSE) { 274 if (sk->sk_state != TCP_CLOSE) {
238 local_bh_disable(); 275 local_bh_disable();
239 __inet_hash(hashinfo, sk, 1); 276 __inet_hash(hashinfo, sk);
240 local_bh_enable(); 277 local_bh_enable();
241 } 278 }
242} 279}
@@ -253,27 +290,29 @@ static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk)
253 inet_listen_wlock(hashinfo); 290 inet_listen_wlock(hashinfo);
254 lock = &hashinfo->lhash_lock; 291 lock = &hashinfo->lhash_lock;
255 } else { 292 } else {
256 lock = &inet_ehash_bucket(hashinfo, sk->sk_hash)->lock; 293 lock = inet_ehash_lockp(hashinfo, sk->sk_hash);
257 write_lock_bh(lock); 294 write_lock_bh(lock);
258 } 295 }
259 296
260 if (__sk_del_node_init(sk)) 297 if (__sk_del_node_init(sk))
261 sock_prot_dec_use(sk->sk_prot); 298 sock_prot_inuse_add(sk->sk_prot, -1);
262 write_unlock_bh(lock); 299 write_unlock_bh(lock);
263out: 300out:
264 if (sk->sk_state == TCP_LISTEN) 301 if (sk->sk_state == TCP_LISTEN)
265 wake_up(&hashinfo->lhash_wait); 302 wake_up(&hashinfo->lhash_wait);
266} 303}
267 304
268extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo, 305extern struct sock *__inet_lookup_listener(struct net *net,
306 struct inet_hashinfo *hashinfo,
269 const __be32 daddr, 307 const __be32 daddr,
270 const unsigned short hnum, 308 const unsigned short hnum,
271 const int dif); 309 const int dif);
272 310
273static inline struct sock *inet_lookup_listener(struct inet_hashinfo *hashinfo, 311static inline struct sock *inet_lookup_listener(struct net *net,
274 __be32 daddr, __be16 dport, int dif) 312 struct inet_hashinfo *hashinfo,
313 __be32 daddr, __be16 dport, int dif)
275{ 314{
276 return __inet_lookup_listener(hashinfo, daddr, ntohs(dport), dif); 315 return __inet_lookup_listener(net, hashinfo, daddr, ntohs(dport), dif);
277} 316}
278 317
279/* Socket demux engine toys. */ 318/* Socket demux engine toys. */
@@ -307,26 +346,26 @@ typedef __u64 __bitwise __addrpair;
307 (((__force __u64)(__be32)(__daddr)) << 32) | \ 346 (((__force __u64)(__be32)(__daddr)) << 32) | \
308 ((__force __u64)(__be32)(__saddr))); 347 ((__force __u64)(__be32)(__saddr)));
309#endif /* __BIG_ENDIAN */ 348#endif /* __BIG_ENDIAN */
310#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ 349#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
311 (((__sk)->sk_hash == (__hash)) && \ 350 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
312 ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ 351 ((*((__addrpair *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \
313 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 352 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
314 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 353 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
315#define INET_TW_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ 354#define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\
316 (((__sk)->sk_hash == (__hash)) && \ 355 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
317 ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ 356 ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \
318 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 357 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
319 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 358 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
320#else /* 32-bit arch */ 359#else /* 32-bit arch */
321#define INET_ADDR_COOKIE(__name, __saddr, __daddr) 360#define INET_ADDR_COOKIE(__name, __saddr, __daddr)
322#define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ 361#define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \
323 (((__sk)->sk_hash == (__hash)) && \ 362 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
324 (inet_sk(__sk)->daddr == (__saddr)) && \ 363 (inet_sk(__sk)->daddr == (__saddr)) && \
325 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ 364 (inet_sk(__sk)->rcv_saddr == (__daddr)) && \
326 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ 365 ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \
327 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) 366 (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
328#define INET_TW_MATCH(__sk, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ 367#define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \
329 (((__sk)->sk_hash == (__hash)) && \ 368 (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \
330 (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ 369 (inet_twsk(__sk)->tw_daddr == (__saddr)) && \
331 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ 370 (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \
332 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ 371 ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \
@@ -339,65 +378,36 @@ typedef __u64 __bitwise __addrpair;
339 * 378 *
340 * Local BH must be disabled here. 379 * Local BH must be disabled here.
341 */ 380 */
342static inline struct sock * 381extern struct sock * __inet_lookup_established(struct net *net,
343 __inet_lookup_established(struct inet_hashinfo *hashinfo, 382 struct inet_hashinfo *hashinfo,
344 const __be32 saddr, const __be16 sport, 383 const __be32 saddr, const __be16 sport,
345 const __be32 daddr, const u16 hnum, 384 const __be32 daddr, const u16 hnum, const int dif);
346 const int dif)
347{
348 INET_ADDR_COOKIE(acookie, saddr, daddr)
349 const __portpair ports = INET_COMBINED_PORTS(sport, hnum);
350 struct sock *sk;
351 const struct hlist_node *node;
352 /* Optimize here for direct hit, only listening connections can
353 * have wildcards anyways.
354 */
355 unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport);
356 struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash);
357
358 prefetch(head->chain.first);
359 read_lock(&head->lock);
360 sk_for_each(sk, node, &head->chain) {
361 if (INET_MATCH(sk, hash, acookie, saddr, daddr, ports, dif))
362 goto hit; /* You sunk my battleship! */
363 }
364
365 /* Must check for a TIME_WAIT'er before going to listener hash. */
366 sk_for_each(sk, node, &head->twchain) {
367 if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif))
368 goto hit;
369 }
370 sk = NULL;
371out:
372 read_unlock(&head->lock);
373 return sk;
374hit:
375 sock_hold(sk);
376 goto out;
377}
378 385
379static inline struct sock * 386static inline struct sock *
380 inet_lookup_established(struct inet_hashinfo *hashinfo, 387 inet_lookup_established(struct net *net, struct inet_hashinfo *hashinfo,
381 const __be32 saddr, const __be16 sport, 388 const __be32 saddr, const __be16 sport,
382 const __be32 daddr, const __be16 dport, 389 const __be32 daddr, const __be16 dport,
383 const int dif) 390 const int dif)
384{ 391{
385 return __inet_lookup_established(hashinfo, saddr, sport, daddr, 392 return __inet_lookup_established(net, hashinfo, saddr, sport, daddr,
386 ntohs(dport), dif); 393 ntohs(dport), dif);
387} 394}
388 395
389static inline struct sock *__inet_lookup(struct inet_hashinfo *hashinfo, 396static inline struct sock *__inet_lookup(struct net *net,
397 struct inet_hashinfo *hashinfo,
390 const __be32 saddr, const __be16 sport, 398 const __be32 saddr, const __be16 sport,
391 const __be32 daddr, const __be16 dport, 399 const __be32 daddr, const __be16 dport,
392 const int dif) 400 const int dif)
393{ 401{
394 u16 hnum = ntohs(dport); 402 u16 hnum = ntohs(dport);
395 struct sock *sk = __inet_lookup_established(hashinfo, saddr, sport, daddr, 403 struct sock *sk = __inet_lookup_established(net, hashinfo,
396 hnum, dif); 404 saddr, sport, daddr, hnum, dif);
397 return sk ? : __inet_lookup_listener(hashinfo, daddr, hnum, dif); 405
406 return sk ? : __inet_lookup_listener(net, hashinfo, daddr, hnum, dif);
398} 407}
399 408
400static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo, 409static inline struct sock *inet_lookup(struct net *net,
410 struct inet_hashinfo *hashinfo,
401 const __be32 saddr, const __be16 sport, 411 const __be32 saddr, const __be16 sport,
402 const __be32 daddr, const __be16 dport, 412 const __be32 daddr, const __be16 dport,
403 const int dif) 413 const int dif)
@@ -405,12 +415,17 @@ static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo,
405 struct sock *sk; 415 struct sock *sk;
406 416
407 local_bh_disable(); 417 local_bh_disable();
408 sk = __inet_lookup(hashinfo, saddr, sport, daddr, dport, dif); 418 sk = __inet_lookup(net, hashinfo, saddr, sport, daddr, dport, dif);
409 local_bh_enable(); 419 local_bh_enable();
410 420
411 return sk; 421 return sk;
412} 422}
413 423
424extern int __inet_hash_connect(struct inet_timewait_death_row *death_row,
425 struct sock *sk,
426 int (*check_established)(struct inet_timewait_death_row *,
427 struct sock *, __u16, struct inet_timewait_sock **),
428 void (*hash)(struct inet_hashinfo *, struct sock *));
414extern int inet_hash_connect(struct inet_timewait_death_row *death_row, 429extern int inet_hash_connect(struct inet_timewait_death_row *death_row,
415 struct sock *sk); 430 struct sock *sk);
416#endif /* _INET_HASHTABLES_H */ 431#endif /* _INET_HASHTABLES_H */
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h
index abaff0597270..67e925065aae 100644
--- a/include/net/inet_timewait_sock.h
+++ b/include/net/inet_timewait_sock.h
@@ -193,19 +193,7 @@ static inline __be32 inet_rcv_saddr(const struct sock *sk)
193 inet_sk(sk)->rcv_saddr : inet_twsk(sk)->tw_rcv_saddr; 193 inet_sk(sk)->rcv_saddr : inet_twsk(sk)->tw_rcv_saddr;
194} 194}
195 195
196static inline void inet_twsk_put(struct inet_timewait_sock *tw) 196extern void inet_twsk_put(struct inet_timewait_sock *tw);
197{
198 if (atomic_dec_and_test(&tw->tw_refcnt)) {
199 struct module *owner = tw->tw_prot->owner;
200 twsk_destructor((struct sock *)tw);
201#ifdef SOCK_REFCNT_DEBUG
202 printk(KERN_DEBUG "%s timewait_sock %p released\n",
203 tw->tw_prot->name, tw);
204#endif
205 kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw);
206 module_put(owner);
207 }
208}
209 197
210extern struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, 198extern struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
211 const int state); 199 const int state);
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index aa10a8178e70..ad8404b56113 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -22,7 +22,7 @@ struct inet_peer
22 __be32 v4daddr; /* peer's address */ 22 __be32 v4daddr; /* peer's address */
23 __u16 avl_height; 23 __u16 avl_height;
24 __u16 ip_id_count; /* IP ID for the next packet */ 24 __u16 ip_id_count; /* IP ID for the next packet */
25 struct inet_peer *unused_next, **unused_prevp; 25 struct list_head unused;
26 __u32 dtime; /* the time of last use of not 26 __u32 dtime; /* the time of last use of not
27 * referenced entries */ 27 * referenced entries */
28 atomic_t refcnt; 28 atomic_t refcnt;
diff --git a/include/net/ip.h b/include/net/ip.h
index 840dd91b513b..9f50d4f1f157 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -82,8 +82,6 @@ struct packet_type;
82struct rtable; 82struct rtable;
83struct sockaddr; 83struct sockaddr;
84 84
85extern void ip_mc_dropsocket(struct sock *);
86extern void ip_mc_dropdevice(struct net_device *dev);
87extern int igmp_mc_proc_init(void); 85extern int igmp_mc_proc_init(void);
88 86
89/* 87/*
@@ -102,6 +100,8 @@ extern int ip_mc_output(struct sk_buff *skb);
102extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); 100extern int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
103extern int ip_do_nat(struct sk_buff *skb); 101extern int ip_do_nat(struct sk_buff *skb);
104extern void ip_send_check(struct iphdr *ip); 102extern void ip_send_check(struct iphdr *ip);
103extern int __ip_local_out(struct sk_buff *skb);
104extern int ip_local_out(struct sk_buff *skb);
105extern int ip_queue_xmit(struct sk_buff *skb, int ipfragok); 105extern int ip_queue_xmit(struct sk_buff *skb, int ipfragok);
106extern void ip_init(void); 106extern void ip_init(void);
107extern int ip_append_data(struct sock *sk, 107extern int ip_append_data(struct sock *sk,
@@ -169,7 +169,7 @@ DECLARE_SNMP_STAT(struct linux_mib, net_statistics);
169#define NET_ADD_STATS_USER(field, adnd) SNMP_ADD_STATS_USER(net_statistics, field, adnd) 169#define NET_ADD_STATS_USER(field, adnd) SNMP_ADD_STATS_USER(net_statistics, field, adnd)
170 170
171extern unsigned long snmp_fold_field(void *mib[], int offt); 171extern unsigned long snmp_fold_field(void *mib[], int offt);
172extern int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign); 172extern int snmp_mib_init(void *ptr[2], size_t mibsize);
173extern void snmp_mib_free(void *ptr[2]); 173extern void snmp_mib_free(void *ptr[2]);
174 174
175extern void inet_get_local_port_range(int *low, int *high); 175extern void inet_get_local_port_range(int *low, int *high);
@@ -177,10 +177,7 @@ extern void inet_get_local_port_range(int *low, int *high);
177extern int sysctl_ip_default_ttl; 177extern int sysctl_ip_default_ttl;
178extern int sysctl_ip_nonlocal_bind; 178extern int sysctl_ip_nonlocal_bind;
179 179
180/* From ip_fragment.c */ 180extern struct ctl_path net_ipv4_ctl_path[];
181struct inet_frags_ctl;
182extern struct inet_frags_ctl ip4_frags_ctl;
183extern int sysctl_ipfrag_max_dist;
184 181
185/* From inetpeer.c */ 182/* From inetpeer.c */
186extern int inet_peer_threshold; 183extern int inet_peer_threshold;
@@ -266,20 +263,22 @@ static inline void ip_eth_mc_map(__be32 naddr, char *buf)
266 * Leave P_Key as 0 to be filled in by driver. 263 * Leave P_Key as 0 to be filled in by driver.
267 */ 264 */
268 265
269static inline void ip_ib_mc_map(__be32 naddr, char *buf) 266static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf)
270{ 267{
271 __u32 addr; 268 __u32 addr;
269 unsigned char scope = broadcast[5] & 0xF;
270
272 buf[0] = 0; /* Reserved */ 271 buf[0] = 0; /* Reserved */
273 buf[1] = 0xff; /* Multicast QPN */ 272 buf[1] = 0xff; /* Multicast QPN */
274 buf[2] = 0xff; 273 buf[2] = 0xff;
275 buf[3] = 0xff; 274 buf[3] = 0xff;
276 addr = ntohl(naddr); 275 addr = ntohl(naddr);
277 buf[4] = 0xff; 276 buf[4] = 0xff;
278 buf[5] = 0x12; /* link local scope */ 277 buf[5] = 0x10 | scope; /* scope from broadcast address */
279 buf[6] = 0x40; /* IPv4 signature */ 278 buf[6] = 0x40; /* IPv4 signature */
280 buf[7] = 0x1b; 279 buf[7] = 0x1b;
281 buf[8] = 0; /* P_Key */ 280 buf[8] = broadcast[8]; /* P_Key */
282 buf[9] = 0; 281 buf[9] = broadcast[9];
283 buf[10] = 0; 282 buf[10] = 0;
284 buf[11] = 0; 283 buf[11] = 0;
285 buf[12] = 0; 284 buf[12] = 0;
@@ -317,7 +316,7 @@ static __inline__ void inet_reset_saddr(struct sock *sk)
317extern int ip_call_ra_chain(struct sk_buff *skb); 316extern int ip_call_ra_chain(struct sk_buff *skb);
318 317
319/* 318/*
320 * Functions provided by ip_fragment.o 319 * Functions provided by ip_fragment.c
321 */ 320 */
322 321
323enum ip_defrag_users 322enum ip_defrag_users
@@ -332,15 +331,14 @@ enum ip_defrag_users
332}; 331};
333 332
334int ip_defrag(struct sk_buff *skb, u32 user); 333int ip_defrag(struct sk_buff *skb, u32 user);
335int ip_frag_mem(void); 334int ip_frag_mem(struct net *net);
336int ip_frag_nqueues(void); 335int ip_frag_nqueues(struct net *net);
337 336
338/* 337/*
339 * Functions provided by ip_forward.c 338 * Functions provided by ip_forward.c
340 */ 339 */
341 340
342extern int ip_forward(struct sk_buff *skb); 341extern int ip_forward(struct sk_buff *skb);
343extern int ip_net_unreachable(struct sk_buff *skb);
344 342
345/* 343/*
346 * Functions provided by ip_options.c 344 * Functions provided by ip_options.c
@@ -391,6 +389,4 @@ int ipv4_doint_and_flush_strategy(ctl_table *table, int __user *name, int nlen,
391extern int ip_misc_proc_init(void); 389extern int ip_misc_proc_init(void);
392#endif 390#endif
393 391
394extern struct ctl_table ipv4_table[];
395
396#endif /* _IP_H */ 392#endif /* _IP_H */
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index 857821360bb6..d8d85b13364d 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -99,16 +99,21 @@ struct rt6_info
99 u32 rt6i_flags; 99 u32 rt6i_flags;
100 u32 rt6i_metric; 100 u32 rt6i_metric;
101 atomic_t rt6i_ref; 101 atomic_t rt6i_ref;
102 struct fib6_table *rt6i_table;
103 102
104 struct rt6key rt6i_dst; 103 /* more non-fragment space at head required */
105 struct rt6key rt6i_src; 104 unsigned short rt6i_nfheader_len;
106 105
107 u8 rt6i_protocol; 106 u8 rt6i_protocol;
108 107
108 struct fib6_table *rt6i_table;
109
110 struct rt6key rt6i_dst;
111
109#ifdef CONFIG_XFRM 112#ifdef CONFIG_XFRM
110 u32 rt6i_flow_cache_genid; 113 u32 rt6i_flow_cache_genid;
111#endif 114#endif
115
116 struct rt6key rt6i_src;
112}; 117};
113 118
114static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst) 119static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst)
@@ -219,10 +224,20 @@ extern void fib6_run_gc(unsigned long dummy);
219 224
220extern void fib6_gc_cleanup(void); 225extern void fib6_gc_cleanup(void);
221 226
222extern void fib6_init(void); 227extern int fib6_init(void);
223 228
224extern void fib6_rules_init(void); 229#ifdef CONFIG_IPV6_MULTIPLE_TABLES
230extern int fib6_rules_init(void);
225extern void fib6_rules_cleanup(void); 231extern void fib6_rules_cleanup(void);
226 232#else
233static inline int fib6_rules_init(void)
234{
235 return 0;
236}
237static inline void fib6_rules_cleanup(void)
238{
239 return ;
240}
241#endif
227#endif 242#endif
228#endif 243#endif
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h
index 5456fdd6d047..faac0eee1ef3 100644
--- a/include/net/ip6_route.h
+++ b/include/net/ip6_route.h
@@ -43,14 +43,12 @@ extern struct rt6_info ip6_prohibit_entry;
43extern struct rt6_info ip6_blk_hole_entry; 43extern struct rt6_info ip6_blk_hole_entry;
44#endif 44#endif
45 45
46extern int ip6_rt_gc_interval;
47
48extern void ip6_route_input(struct sk_buff *skb); 46extern void ip6_route_input(struct sk_buff *skb);
49 47
50extern struct dst_entry * ip6_route_output(struct sock *sk, 48extern struct dst_entry * ip6_route_output(struct sock *sk,
51 struct flowi *fl); 49 struct flowi *fl);
52 50
53extern void ip6_route_init(void); 51extern int ip6_route_init(void);
54extern void ip6_route_cleanup(void); 52extern void ip6_route_cleanup(void);
55 53
56extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg); 54extern int ipv6_route_ioctl(unsigned int cmd, void __user *arg);
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h
index 29c9da707c7a..c17fa1fdc356 100644
--- a/include/net/ip6_tunnel.h
+++ b/include/net/ip6_tunnel.h
@@ -23,7 +23,7 @@ struct ip6_tnl {
23 struct net_device *dev; /* virtual device associated with tunnel */ 23 struct net_device *dev; /* virtual device associated with tunnel */
24 struct net_device_stats stat; /* statistics for tunnel device */ 24 struct net_device_stats stat; /* statistics for tunnel device */
25 int recursion; /* depth of hard_start_xmit recursion */ 25 int recursion; /* depth of hard_start_xmit recursion */
26 struct ip6_tnl_parm parms; /* tunnel configuration paramters */ 26 struct ip6_tnl_parm parms; /* tunnel configuration parameters */
27 struct flowi fl; /* flowi template for xmit */ 27 struct flowi fl; /* flowi template for xmit */
28 struct dst_entry *dst_cache; /* cached dst */ 28 struct dst_entry *dst_cache; /* cached dst */
29 u32 dst_cookie; 29 u32 dst_cookie;
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 8cadc77c7df4..90d1175f63de 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -69,6 +69,7 @@ struct fib_nh {
69struct fib_info { 69struct fib_info {
70 struct hlist_node fib_hash; 70 struct hlist_node fib_hash;
71 struct hlist_node fib_lhash; 71 struct hlist_node fib_lhash;
72 struct net *fib_net;
72 int fib_treeref; 73 int fib_treeref;
73 atomic_t fib_clntref; 74 atomic_t fib_clntref;
74 int fib_dead; 75 int fib_dead;
@@ -125,11 +126,15 @@ struct fib_result_nl {
125#define FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel]) 126#define FIB_RES_NH(res) ((res).fi->fib_nh[(res).nh_sel])
126#define FIB_RES_RESET(res) ((res).nh_sel = 0) 127#define FIB_RES_RESET(res) ((res).nh_sel = 0)
127 128
129#define FIB_TABLE_HASHSZ 2
130
128#else /* CONFIG_IP_ROUTE_MULTIPATH */ 131#else /* CONFIG_IP_ROUTE_MULTIPATH */
129 132
130#define FIB_RES_NH(res) ((res).fi->fib_nh[0]) 133#define FIB_RES_NH(res) ((res).fi->fib_nh[0])
131#define FIB_RES_RESET(res) 134#define FIB_RES_RESET(res)
132 135
136#define FIB_TABLE_HASHSZ 256
137
133#endif /* CONFIG_IP_ROUTE_MULTIPATH */ 138#endif /* CONFIG_IP_ROUTE_MULTIPATH */
134 139
135#define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res)) 140#define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res))
@@ -141,6 +146,7 @@ struct fib_table {
141 struct hlist_node tb_hlist; 146 struct hlist_node tb_hlist;
142 u32 tb_id; 147 u32 tb_id;
143 unsigned tb_stamp; 148 unsigned tb_stamp;
149 int tb_default;
144 int (*tb_lookup)(struct fib_table *tb, const struct flowi *flp, struct fib_result *res); 150 int (*tb_lookup)(struct fib_table *tb, const struct flowi *flp, struct fib_result *res);
145 int (*tb_insert)(struct fib_table *, struct fib_config *); 151 int (*tb_insert)(struct fib_table *, struct fib_config *);
146 int (*tb_delete)(struct fib_table *, struct fib_config *); 152 int (*tb_delete)(struct fib_table *, struct fib_config *);
@@ -155,44 +161,51 @@ struct fib_table {
155 161
156#ifndef CONFIG_IP_MULTIPLE_TABLES 162#ifndef CONFIG_IP_MULTIPLE_TABLES
157 163
158extern struct fib_table *ip_fib_local_table; 164#define TABLE_LOCAL_INDEX 0
159extern struct fib_table *ip_fib_main_table; 165#define TABLE_MAIN_INDEX 1
160 166
161static inline struct fib_table *fib_get_table(u32 id) 167static inline struct fib_table *fib_get_table(struct net *net, u32 id)
162{ 168{
163 if (id != RT_TABLE_LOCAL) 169 struct hlist_head *ptr;
164 return ip_fib_main_table;
165 return ip_fib_local_table;
166}
167 170
168static inline struct fib_table *fib_new_table(u32 id) 171 ptr = id == RT_TABLE_LOCAL ?
169{ 172 &net->ipv4.fib_table_hash[TABLE_LOCAL_INDEX] :
170 return fib_get_table(id); 173 &net->ipv4.fib_table_hash[TABLE_MAIN_INDEX];
174 return hlist_entry(ptr->first, struct fib_table, tb_hlist);
171} 175}
172 176
173static inline int fib_lookup(const struct flowi *flp, struct fib_result *res) 177static inline struct fib_table *fib_new_table(struct net *net, u32 id)
174{ 178{
175 if (ip_fib_local_table->tb_lookup(ip_fib_local_table, flp, res) && 179 return fib_get_table(net, id);
176 ip_fib_main_table->tb_lookup(ip_fib_main_table, flp, res))
177 return -ENETUNREACH;
178 return 0;
179} 180}
180 181
181static inline void fib_select_default(const struct flowi *flp, struct fib_result *res) 182static inline int fib_lookup(struct net *net, const struct flowi *flp,
183 struct fib_result *res)
182{ 184{
183 if (FIB_RES_GW(*res) && FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK) 185 struct fib_table *table;
184 ip_fib_main_table->tb_select_default(ip_fib_main_table, flp, res); 186
187 table = fib_get_table(net, RT_TABLE_LOCAL);
188 if (!table->tb_lookup(table, flp, res))
189 return 0;
190
191 table = fib_get_table(net, RT_TABLE_MAIN);
192 if (!table->tb_lookup(table, flp, res))
193 return 0;
194 return -ENETUNREACH;
185} 195}
186 196
187#else /* CONFIG_IP_MULTIPLE_TABLES */ 197#else /* CONFIG_IP_MULTIPLE_TABLES */
188#define ip_fib_local_table fib_get_table(RT_TABLE_LOCAL) 198extern int __net_init fib4_rules_init(struct net *net);
189#define ip_fib_main_table fib_get_table(RT_TABLE_MAIN) 199extern void __net_exit fib4_rules_exit(struct net *net);
190 200
191extern int fib_lookup(struct flowi *flp, struct fib_result *res); 201#ifdef CONFIG_NET_CLS_ROUTE
202extern u32 fib_rules_tclass(struct fib_result *res);
203#endif
192 204
193extern struct fib_table *fib_new_table(u32 id); 205extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res);
194extern struct fib_table *fib_get_table(u32 id); 206
195extern void fib_select_default(const struct flowi *flp, struct fib_result *res); 207extern struct fib_table *fib_new_table(struct net *net, u32 id);
208extern struct fib_table *fib_get_table(struct net *net, u32 id);
196 209
197#endif /* CONFIG_IP_MULTIPLE_TABLES */ 210#endif /* CONFIG_IP_MULTIPLE_TABLES */
198 211
@@ -201,27 +214,20 @@ extern const struct nla_policy rtm_ipv4_policy[];
201extern void ip_fib_init(void); 214extern void ip_fib_init(void);
202extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, 215extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
203 struct net_device *dev, __be32 *spec_dst, u32 *itag); 216 struct net_device *dev, __be32 *spec_dst, u32 *itag);
204extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); 217extern void fib_select_default(struct net *net, const struct flowi *flp,
205 218 struct fib_result *res);
206struct rtentry;
207 219
208/* Exported by fib_semantics.c */ 220/* Exported by fib_semantics.c */
209extern int ip_fib_check_default(__be32 gw, struct net_device *dev); 221extern int ip_fib_check_default(__be32 gw, struct net_device *dev);
210extern int fib_sync_down(__be32 local, struct net_device *dev, int force); 222extern int fib_sync_down_dev(struct net_device *dev, int force);
223extern int fib_sync_down_addr(struct net *net, __be32 local);
211extern int fib_sync_up(struct net_device *dev); 224extern int fib_sync_up(struct net_device *dev);
212extern __be32 __fib_res_prefsrc(struct fib_result *res); 225extern __be32 __fib_res_prefsrc(struct fib_result *res);
226extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res);
213 227
214/* Exported by fib_hash.c */ 228/* Exported by fib_{hash|trie}.c */
215extern struct fib_table *fib_hash_init(u32 id); 229extern void fib_hash_init(void);
216 230extern struct fib_table *fib_hash_table(u32 id);
217#ifdef CONFIG_IP_MULTIPLE_TABLES
218extern void __init fib4_rules_init(void);
219
220#ifdef CONFIG_NET_CLS_ROUTE
221extern u32 fib_rules_tclass(struct fib_result *res);
222#endif
223
224#endif
225 231
226static inline void fib_combine_itag(u32 *itag, struct fib_result *res) 232static inline void fib_combine_itag(u32 *itag, struct fib_result *res)
227{ 233{
@@ -258,8 +264,8 @@ static inline void fib_res_put(struct fib_result *res)
258} 264}
259 265
260#ifdef CONFIG_PROC_FS 266#ifdef CONFIG_PROC_FS
261extern int fib_proc_init(void); 267extern int __net_init fib_proc_init(struct net *net);
262extern void fib_proc_exit(void); 268extern void __net_exit fib_proc_exit(struct net *net);
263#endif 269#endif
264 270
265#endif /* _NET_FIB_H */ 271#endif /* _NET_FIB_H */
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 41870564df8e..56f3c94ae620 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -9,6 +9,8 @@
9#include <asm/types.h> /* For __uXX types */ 9#include <asm/types.h> /* For __uXX types */
10#include <linux/types.h> /* For __beXX types in userland */ 10#include <linux/types.h> /* For __beXX types in userland */
11 11
12#include <linux/sysctl.h> /* For ctl_path */
13
12#define IP_VS_VERSION_CODE 0x010201 14#define IP_VS_VERSION_CODE 0x010201
13#define NVERSION(version) \ 15#define NVERSION(version) \
14 (version >> 16) & 0xFF, \ 16 (version >> 16) & 0xFF, \
@@ -328,40 +330,6 @@ extern int ip_vs_get_debug_level(void);
328#define FTPDATA __constant_htons(20) 330#define FTPDATA __constant_htons(20)
329 331
330/* 332/*
331 * IPVS sysctl variables under the /proc/sys/net/ipv4/vs/
332 */
333#define NET_IPV4_VS 21
334
335enum {
336 NET_IPV4_VS_DEBUG_LEVEL=1,
337 NET_IPV4_VS_AMEMTHRESH=2,
338 NET_IPV4_VS_AMDROPRATE=3,
339 NET_IPV4_VS_DROP_ENTRY=4,
340 NET_IPV4_VS_DROP_PACKET=5,
341 NET_IPV4_VS_SECURE_TCP=6,
342 NET_IPV4_VS_TO_ES=7,
343 NET_IPV4_VS_TO_SS=8,
344 NET_IPV4_VS_TO_SR=9,
345 NET_IPV4_VS_TO_FW=10,
346 NET_IPV4_VS_TO_TW=11,
347 NET_IPV4_VS_TO_CL=12,
348 NET_IPV4_VS_TO_CW=13,
349 NET_IPV4_VS_TO_LA=14,
350 NET_IPV4_VS_TO_LI=15,
351 NET_IPV4_VS_TO_SA=16,
352 NET_IPV4_VS_TO_UDP=17,
353 NET_IPV4_VS_TO_ICMP=18,
354 NET_IPV4_VS_LBLC_EXPIRE=19,
355 NET_IPV4_VS_LBLCR_EXPIRE=20,
356 NET_IPV4_VS_CACHE_BYPASS=22,
357 NET_IPV4_VS_EXPIRE_NODEST_CONN=23,
358 NET_IPV4_VS_SYNC_THRESHOLD=24,
359 NET_IPV4_VS_NAT_ICMP_SEND=25,
360 NET_IPV4_VS_EXPIRE_QUIESCENT_TEMPLATE=26,
361 NET_IPV4_VS_LAST
362};
363
364/*
365 * TCP State Values 333 * TCP State Values
366 */ 334 */
367enum { 335enum {
@@ -520,6 +488,10 @@ struct ip_vs_conn {
520 spinlock_t lock; /* lock for state transition */ 488 spinlock_t lock; /* lock for state transition */
521 volatile __u16 flags; /* status flags */ 489 volatile __u16 flags; /* status flags */
522 volatile __u16 state; /* state info */ 490 volatile __u16 state; /* state info */
491 volatile __u16 old_state; /* old state, to be used for
492 * state transition triggerd
493 * synchronization
494 */
523 495
524 /* Control members */ 496 /* Control members */
525 struct ip_vs_conn *control; /* Master control connection */ 497 struct ip_vs_conn *control; /* Master control connection */
@@ -706,7 +678,6 @@ extern const char *ip_vs_proto_name(unsigned proto);
706extern void ip_vs_init_hash_table(struct list_head *table, int rows); 678extern void ip_vs_init_hash_table(struct list_head *table, int rows);
707#define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table(t, sizeof(t)/sizeof(t[0])) 679#define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table(t, sizeof(t)/sizeof(t[0]))
708 680
709#define IP_VS_APP_TYPE_UNSPEC 0
710#define IP_VS_APP_TYPE_FTP 1 681#define IP_VS_APP_TYPE_FTP 1
711 682
712/* 683/*
@@ -765,7 +736,6 @@ extern const char * ip_vs_state_name(__u16 proto, int state);
765 736
766extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); 737extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp);
767extern int ip_vs_check_template(struct ip_vs_conn *ct); 738extern int ip_vs_check_template(struct ip_vs_conn *ct);
768extern void ip_vs_secure_tcp_set(int on);
769extern void ip_vs_random_dropentry(void); 739extern void ip_vs_random_dropentry(void);
770extern int ip_vs_conn_init(void); 740extern int ip_vs_conn_init(void);
771extern void ip_vs_conn_cleanup(void); 741extern void ip_vs_conn_cleanup(void);
@@ -886,6 +856,7 @@ extern int sysctl_ip_vs_expire_quiescent_template;
886extern int sysctl_ip_vs_sync_threshold[2]; 856extern int sysctl_ip_vs_sync_threshold[2];
887extern int sysctl_ip_vs_nat_icmp_send; 857extern int sysctl_ip_vs_nat_icmp_send;
888extern struct ip_vs_stats ip_vs_stats; 858extern struct ip_vs_stats ip_vs_stats;
859extern struct ctl_path net_vs_ctl_path[];
889 860
890extern struct ip_vs_service * 861extern struct ip_vs_service *
891ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport); 862ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport);
@@ -901,6 +872,10 @@ extern int ip_vs_use_count_inc(void);
901extern void ip_vs_use_count_dec(void); 872extern void ip_vs_use_count_dec(void);
902extern int ip_vs_control_init(void); 873extern int ip_vs_control_init(void);
903extern void ip_vs_control_cleanup(void); 874extern void ip_vs_control_cleanup(void);
875extern struct ip_vs_dest *
876ip_vs_find_dest(__be32 daddr, __be16 dport,
877 __be32 vaddr, __be16 vport, __u16 protocol);
878extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
904 879
905 880
906/* 881/*
diff --git a/include/net/ipip.h b/include/net/ipip.h
index 7cdc914322f0..549e132bca9c 100644
--- a/include/net/ipip.h
+++ b/include/net/ipip.h
@@ -2,6 +2,7 @@
2#define __NET_IPIP_H 1 2#define __NET_IPIP_H 1
3 3
4#include <linux/if_tunnel.h> 4#include <linux/if_tunnel.h>
5#include <net/ip.h>
5 6
6/* Keep error state on tunnel for 30 sec */ 7/* Keep error state on tunnel for 30 sec */
7#define IPTUNNEL_ERR_TIMEO (30*HZ) 8#define IPTUNNEL_ERR_TIMEO (30*HZ)
@@ -30,11 +31,9 @@ struct ip_tunnel
30 int pkt_len = skb->len; \ 31 int pkt_len = skb->len; \
31 \ 32 \
32 skb->ip_summed = CHECKSUM_NONE; \ 33 skb->ip_summed = CHECKSUM_NONE; \
33 iph->tot_len = htons(skb->len); \
34 ip_select_ident(iph, &rt->u.dst, NULL); \ 34 ip_select_ident(iph, &rt->u.dst, NULL); \
35 ip_send_check(iph); \
36 \ 35 \
37 err = NF_HOOK(PF_INET, NF_IP_LOCAL_OUT, skb, NULL, rt->u.dst.dev, dst_output);\ 36 err = ip_local_out(skb); \
38 if (net_xmit_eval(err) == 0) { \ 37 if (net_xmit_eval(err) == 0) { \
39 stats->tx_bytes += pkt_len; \ 38 stats->tx_bytes += pkt_len; \
40 stats->tx_packets++; \ 39 stats->tx_packets++; \
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index ae328b680ff2..fa80ea48639d 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -109,9 +109,10 @@ struct frag_hdr {
109#include <net/sock.h> 109#include <net/sock.h>
110 110
111/* sysctls */ 111/* sysctls */
112extern int sysctl_ipv6_bindv6only;
113extern int sysctl_mld_max_msf; 112extern int sysctl_mld_max_msf;
114 113
114extern struct ctl_path net_ipv6_ctl_path[];
115
115#define _DEVINC(statname, modifier, idev, field) \ 116#define _DEVINC(statname, modifier, idev, field) \
116({ \ 117({ \
117 struct inet6_dev *_idev = (idev); \ 118 struct inet6_dev *_idev = (idev); \
@@ -143,14 +144,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
143#define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field) 144#define ICMP6_INC_STATS_BH(idev, field) _DEVINC(icmpv6, _BH, idev, field)
144#define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field) 145#define ICMP6_INC_STATS_USER(idev, field) _DEVINC(icmpv6, _USER, idev, field)
145 146
146#define ICMP6_INC_STATS_OFFSET_BH(idev, field, offset) ({ \
147 struct inet6_dev *_idev = idev; \
148 __typeof__(offset) _offset = (offset); \
149 if (likely(_idev != NULL)) \
150 SNMP_INC_STATS_OFFSET_BH(_idev->stats.icmpv6, field, _offset); \
151 SNMP_INC_STATS_OFFSET_BH(icmpv6_statistics, field, _offset); \
152})
153
154#define ICMP6MSGOUT_INC_STATS(idev, field) \ 147#define ICMP6MSGOUT_INC_STATS(idev, field) \
155 _DEVINC(icmpv6msg, , idev, field +256) 148 _DEVINC(icmpv6msg, , idev, field +256)
156#define ICMP6MSGOUT_INC_STATS_BH(idev, field) \ 149#define ICMP6MSGOUT_INC_STATS_BH(idev, field) \
@@ -164,15 +157,6 @@ DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
164#define ICMP6MSGIN_INC_STATS_USER(idev, field) \ 157#define ICMP6MSGIN_INC_STATS_USER(idev, field) \
165 _DEVINC(icmpv6msg, _USER, idev, field) 158 _DEVINC(icmpv6msg, _USER, idev, field)
166 159
167DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
168DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
169#define UDP6_INC_STATS_BH(field, is_udplite) do { \
170 if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
171 else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
172#define UDP6_INC_STATS_USER(field, is_udplite) do { \
173 if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
174 else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
175
176struct ip6_ra_chain 160struct ip6_ra_chain
177{ 161{
178 struct ip6_ra_chain *next; 162 struct ip6_ra_chain *next;
@@ -236,7 +220,7 @@ extern struct ipv6_txoptions *fl6_merge_options(struct ipv6_txoptions * opt_spac
236 struct ipv6_txoptions * fopt); 220 struct ipv6_txoptions * fopt);
237extern void fl6_free_socklist(struct sock *sk); 221extern void fl6_free_socklist(struct sock *sk);
238extern int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen); 222extern int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen);
239extern void ip6_flowlabel_init(void); 223extern int ip6_flowlabel_init(void);
240extern void ip6_flowlabel_cleanup(void); 224extern void ip6_flowlabel_cleanup(void);
241 225
242static inline void fl6_sock_release(struct ip6_flowlabel *fl) 226static inline void fl6_sock_release(struct ip6_flowlabel *fl)
@@ -261,8 +245,8 @@ struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space,
261 245
262extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); 246extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb);
263 247
264int ip6_frag_nqueues(void); 248int ip6_frag_nqueues(struct net *net);
265int ip6_frag_mem(void); 249int ip6_frag_mem(struct net *net);
266 250
267#define IPV6_FRAG_TIMEOUT (60*HZ) /* 60 seconds */ 251#define IPV6_FRAG_TIMEOUT (60*HZ) /* 60 seconds */
268 252
@@ -509,6 +493,9 @@ extern int ip6_forward(struct sk_buff *skb);
509extern int ip6_input(struct sk_buff *skb); 493extern int ip6_input(struct sk_buff *skb);
510extern int ip6_mc_input(struct sk_buff *skb); 494extern int ip6_mc_input(struct sk_buff *skb);
511 495
496extern int __ip6_local_out(struct sk_buff *skb);
497extern int ip6_local_out(struct sk_buff *skb);
498
512/* 499/*
513 * Extension header (options) processing 500 * Extension header (options) processing
514 */ 501 */
@@ -559,7 +546,7 @@ extern int compat_ipv6_getsockopt(struct sock *sk,
559 char __user *optval, 546 char __user *optval,
560 int __user *optlen); 547 int __user *optlen);
561 548
562extern void ipv6_packet_init(void); 549extern int ipv6_packet_init(void);
563 550
564extern void ipv6_packet_cleanup(void); 551extern void ipv6_packet_cleanup(void);
565 552
@@ -585,9 +572,6 @@ extern int inet6_hash_connect(struct inet_timewait_death_row *death_row,
585/* 572/*
586 * reassembly.c 573 * reassembly.c
587 */ 574 */
588struct inet_frags_ctl;
589extern struct inet_frags_ctl ip6_frags_ctl;
590
591extern const struct proto_ops inet6_stream_ops; 575extern const struct proto_ops inet6_stream_ops;
592extern const struct proto_ops inet6_dgram_ops; 576extern const struct proto_ops inet6_dgram_ops;
593 577
@@ -602,6 +586,9 @@ extern int ip6_mc_msfget(struct sock *sk, struct group_filter *gsf,
602 int __user *optlen); 586 int __user *optlen);
603 587
604#ifdef CONFIG_PROC_FS 588#ifdef CONFIG_PROC_FS
589extern struct ctl_table *ipv6_icmp_sysctl_init(struct net *net);
590extern struct ctl_table *ipv6_route_sysctl_init(struct net *net);
591
605extern int ac6_proc_init(void); 592extern int ac6_proc_init(void);
606extern void ac6_proc_exit(void); 593extern void ac6_proc_exit(void);
607extern int raw6_proc_init(void); 594extern int raw6_proc_init(void);
@@ -631,10 +618,10 @@ static inline int snmp6_unregister_dev(struct inet6_dev *idev)
631#endif 618#endif
632 619
633#ifdef CONFIG_SYSCTL 620#ifdef CONFIG_SYSCTL
634extern ctl_table ipv6_route_table[]; 621extern ctl_table ipv6_route_table_template[];
635extern ctl_table ipv6_icmp_table[]; 622extern ctl_table ipv6_icmp_table_template[];
636 623
637extern void ipv6_sysctl_register(void); 624extern int ipv6_sysctl_register(void);
638extern void ipv6_sysctl_unregister(void); 625extern void ipv6_sysctl_unregister(void);
639#endif 626#endif
640 627
diff --git a/include/net/irda/discovery.h b/include/net/irda/discovery.h
index eb0f9de47294..e4efad1f9eff 100644
--- a/include/net/irda/discovery.h
+++ b/include/net/irda/discovery.h
@@ -80,7 +80,7 @@ typedef struct discovery_t {
80 irda_queue_t q; /* Must be first! */ 80 irda_queue_t q; /* Must be first! */
81 81
82 discinfo_t data; /* Basic discovery information */ 82 discinfo_t data; /* Basic discovery information */
83 int name_len; /* Lenght of nickname */ 83 int name_len; /* Length of nickname */
84 84
85 LAP_REASON condition; /* More info about the discovery */ 85 LAP_REASON condition; /* More info about the discovery */
86 int gen_addr_bit; /* Need to generate a new device 86 int gen_addr_bit; /* Need to generate a new device
diff --git a/include/net/irda/irda_device.h b/include/net/irda/irda_device.h
index bca19ca7bdd4..f70e9b39ebaf 100644
--- a/include/net/irda/irda_device.h
+++ b/include/net/irda/irda_device.h
@@ -228,21 +228,8 @@ static inline int irda_device_txqueue_empty(const struct net_device *dev)
228int irda_device_set_raw_mode(struct net_device* self, int status); 228int irda_device_set_raw_mode(struct net_device* self, int status);
229struct net_device *alloc_irdadev(int sizeof_priv); 229struct net_device *alloc_irdadev(int sizeof_priv);
230 230
231/* Dongle interface */
232void irda_device_unregister_dongle(struct dongle_reg *dongle);
233int irda_device_register_dongle(struct dongle_reg *dongle);
234dongle_t *irda_device_dongle_init(struct net_device *dev, int type);
235int irda_device_dongle_cleanup(dongle_t *dongle);
236
237void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode); 231void irda_setup_dma(int channel, dma_addr_t buffer, int count, int mode);
238 232
239void irda_task_delete(struct irda_task *task);
240struct irda_task *irda_task_execute(void *instance,
241 IRDA_TASK_CALLBACK function,
242 IRDA_TASK_CALLBACK finished,
243 struct irda_task *parent, void *param);
244void irda_task_next_state(struct irda_task *task, IRDA_TASK_STATE state);
245
246/* 233/*
247 * Function irda_get_mtt (skb) 234 * Function irda_get_mtt (skb)
248 * 235 *
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 5fcc4c104340..9083bafb63ca 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -139,17 +139,54 @@ enum ieee80211_phymode {
139}; 139};
140 140
141/** 141/**
142 * struct ieee80211_ht_info - describing STA's HT capabilities
143 *
144 * This structure describes most essential parameters needed
145 * to describe 802.11n HT capabilities for an STA.
146 *
147 * @ht_supported: is HT supported by STA, 0: no, 1: yes
148 * @cap: HT capabilities map as described in 802.11n spec
149 * @ampdu_factor: Maximum A-MPDU length factor
150 * @ampdu_density: Minimum A-MPDU spacing
151 * @supp_mcs_set: Supported MCS set as described in 802.11n spec
152 */
153struct ieee80211_ht_info {
154 u8 ht_supported;
155 u16 cap; /* use IEEE80211_HT_CAP_ */
156 u8 ampdu_factor;
157 u8 ampdu_density;
158 u8 supp_mcs_set[16];
159};
160
161/**
162 * struct ieee80211_ht_bss_info - describing BSS's HT characteristics
163 *
164 * This structure describes most essential parameters needed
165 * to describe 802.11n HT characteristics in a BSS
166 *
167 * @primary_channel: channel number of primery channel
168 * @bss_cap: 802.11n's general BSS capabilities (e.g. channel width)
169 * @bss_op_mode: 802.11n's BSS operation modes (e.g. HT protection)
170 */
171struct ieee80211_ht_bss_info {
172 u8 primary_channel;
173 u8 bss_cap; /* use IEEE80211_HT_IE_CHA_ */
174 u8 bss_op_mode; /* use IEEE80211_HT_IE_ */
175};
176
177/**
142 * struct ieee80211_hw_mode - PHY mode definition 178 * struct ieee80211_hw_mode - PHY mode definition
143 * 179 *
144 * This structure describes the capabilities supported by the device 180 * This structure describes the capabilities supported by the device
145 * in a single PHY mode. 181 * in a single PHY mode.
146 * 182 *
183 * @list: internal
184 * @channels: pointer to array of supported channels
185 * @rates: pointer to array of supported bitrates
147 * @mode: the PHY mode for this definition 186 * @mode: the PHY mode for this definition
148 * @num_channels: number of supported channels 187 * @num_channels: number of supported channels
149 * @channels: pointer to array of supported channels
150 * @num_rates: number of supported bitrates 188 * @num_rates: number of supported bitrates
151 * @rates: pointer to array of supported bitrates 189 * @ht_info: PHY's 802.11n HT abilities for this mode
152 * @list: internal
153 */ 190 */
154struct ieee80211_hw_mode { 191struct ieee80211_hw_mode {
155 struct list_head list; 192 struct list_head list;
@@ -158,6 +195,7 @@ struct ieee80211_hw_mode {
158 enum ieee80211_phymode mode; 195 enum ieee80211_phymode mode;
159 int num_channels; 196 int num_channels;
160 int num_rates; 197 int num_rates;
198 struct ieee80211_ht_info ht_info;
161}; 199};
162 200
163/** 201/**
@@ -237,11 +275,49 @@ struct ieee80211_low_level_stats {
237 unsigned int dot11RTSSuccessCount; 275 unsigned int dot11RTSSuccessCount;
238}; 276};
239 277
278/**
279 * enum ieee80211_bss_change - BSS change notification flags
280 *
281 * These flags are used with the bss_info_changed() callback
282 * to indicate which BSS parameter changed.
283 *
284 * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated),
285 * also implies a change in the AID.
286 * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed
287 * @BSS_CHANGED_ERP_PREAMBLE: preamble changed
288 */
289enum ieee80211_bss_change {
290 BSS_CHANGED_ASSOC = 1<<0,
291 BSS_CHANGED_ERP_CTS_PROT = 1<<1,
292 BSS_CHANGED_ERP_PREAMBLE = 1<<2,
293};
294
295/**
296 * struct ieee80211_bss_conf - holds the BSS's changing parameters
297 *
298 * This structure keeps information about a BSS (and an association
299 * to that BSS) that can change during the lifetime of the BSS.
300 *
301 * @assoc: association status
302 * @aid: association ID number, valid only when @assoc is true
303 * @use_cts_prot: use CTS protection
304 * @use_short_preamble: use 802.11b short preamble
305 */
306struct ieee80211_bss_conf {
307 /* association related data */
308 bool assoc;
309 u16 aid;
310 /* erp related data */
311 bool use_cts_prot;
312 bool use_short_preamble;
313};
314
240/* Transmit control fields. This data structure is passed to low-level driver 315/* Transmit control fields. This data structure is passed to low-level driver
241 * with each TX frame. The low-level driver is responsible for configuring 316 * with each TX frame. The low-level driver is responsible for configuring
242 * the hardware to use given values (depending on what is supported). */ 317 * the hardware to use given values (depending on what is supported). */
243 318
244struct ieee80211_tx_control { 319struct ieee80211_tx_control {
320 struct ieee80211_vif *vif;
245 int tx_rate; /* Transmit rate, given as the hw specific value for the 321 int tx_rate; /* Transmit rate, given as the hw specific value for the
246 * rate (from struct ieee80211_rate) */ 322 * rate (from struct ieee80211_rate) */
247 int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw 323 int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw
@@ -269,6 +345,9 @@ struct ieee80211_tx_control {
269 * using the through 345 * using the through
270 * set_retry_limit configured 346 * set_retry_limit configured
271 * long retry value */ 347 * long retry value */
348#define IEEE80211_TXCTL_EAPOL_FRAME (1<<11) /* internal to mac80211 */
349#define IEEE80211_TXCTL_SEND_AFTER_DTIM (1<<12) /* send this frame after DTIM
350 * beacon */
272 u32 flags; /* tx control flags defined 351 u32 flags; /* tx control flags defined
273 * above */ 352 * above */
274 u8 key_idx; /* keyidx from hw->set_key(), undefined if 353 u8 key_idx; /* keyidx from hw->set_key(), undefined if
@@ -291,7 +370,6 @@ struct ieee80211_tx_control {
291 * packet dropping when probing higher rates, if hw 370 * packet dropping when probing higher rates, if hw
292 * supports multiple retry rates. -1 = not used */ 371 * supports multiple retry rates. -1 = not used */
293 int type; /* internal */ 372 int type; /* internal */
294 int ifindex; /* internal */
295}; 373};
296 374
297 375
@@ -312,6 +390,8 @@ struct ieee80211_tx_control {
312 * the frame. 390 * the frame.
313 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on 391 * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on
314 * the frame. 392 * the frame.
393 * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field)
394 * is valid.
315 */ 395 */
316enum mac80211_rx_flags { 396enum mac80211_rx_flags {
317 RX_FLAG_MMIC_ERROR = 1<<0, 397 RX_FLAG_MMIC_ERROR = 1<<0,
@@ -321,6 +401,7 @@ enum mac80211_rx_flags {
321 RX_FLAG_IV_STRIPPED = 1<<4, 401 RX_FLAG_IV_STRIPPED = 1<<4,
322 RX_FLAG_FAILED_FCS_CRC = 1<<5, 402 RX_FLAG_FAILED_FCS_CRC = 1<<5,
323 RX_FLAG_FAILED_PLCP_CRC = 1<<6, 403 RX_FLAG_FAILED_PLCP_CRC = 1<<6,
404 RX_FLAG_TSFT = 1<<7,
324}; 405};
325 406
326/** 407/**
@@ -406,11 +487,12 @@ struct ieee80211_tx_status {
406 * 487 *
407 * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time 488 * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time
408 * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported) 489 * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
409 * 490 * @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported)
410 */ 491 */
411enum ieee80211_conf_flags { 492enum ieee80211_conf_flags {
412 IEEE80211_CONF_SHORT_SLOT_TIME = 1<<0, 493 IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0),
413 IEEE80211_CONF_RADIOTAP = 1<<1, 494 IEEE80211_CONF_RADIOTAP = (1<<1),
495 IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2),
414}; 496};
415 497
416/** 498/**
@@ -434,6 +516,8 @@ enum ieee80211_conf_flags {
434 * @antenna_sel_tx: transmit antenna selection, 0: default/diversity, 516 * @antenna_sel_tx: transmit antenna selection, 0: default/diversity,
435 * 1/2: antenna 0/1 517 * 1/2: antenna 0/1
436 * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx 518 * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx
519 * @ht_conf: describes current self configuration of 802.11n HT capabilies
520 * @ht_bss_conf: describes current BSS configuration of 802.11n HT parameters
437 */ 521 */
438struct ieee80211_conf { 522struct ieee80211_conf {
439 int channel; /* IEEE 802.11 channel number */ 523 int channel; /* IEEE 802.11 channel number */
@@ -452,6 +536,9 @@ struct ieee80211_conf {
452 u8 antenna_max; 536 u8 antenna_max;
453 u8 antenna_sel_tx; 537 u8 antenna_sel_tx;
454 u8 antenna_sel_rx; 538 u8 antenna_sel_rx;
539
540 struct ieee80211_ht_info ht_conf;
541 struct ieee80211_ht_bss_info ht_bss_conf;
455}; 542};
456 543
457/** 544/**
@@ -480,13 +567,27 @@ enum ieee80211_if_types {
480}; 567};
481 568
482/** 569/**
570 * struct ieee80211_vif - per-interface data
571 *
572 * Data in this structure is continually present for driver
573 * use during the life of a virtual interface.
574 *
575 * @type: type of this virtual interface
576 * @drv_priv: data area for driver use, will always be aligned to
577 * sizeof(void *).
578 */
579struct ieee80211_vif {
580 enum ieee80211_if_types type;
581 /* must be last */
582 u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
583};
584
585/**
483 * struct ieee80211_if_init_conf - initial configuration of an interface 586 * struct ieee80211_if_init_conf - initial configuration of an interface
484 * 587 *
485 * @if_id: internal interface ID. This number has no particular meaning to 588 * @vif: pointer to a driver-use per-interface structure. The pointer
486 * drivers and the only allowed usage is to pass it to 589 * itself is also used for various functions including
487 * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions. 590 * ieee80211_beacon_get() and ieee80211_get_buffered_bc().
488 * This field is not valid for monitor interfaces
489 * (interfaces of %IEEE80211_IF_TYPE_MNTR type).
490 * @type: one of &enum ieee80211_if_types constants. Determines the type of 591 * @type: one of &enum ieee80211_if_types constants. Determines the type of
491 * added/removed interface. 592 * added/removed interface.
492 * @mac_addr: pointer to MAC address of the interface. This pointer is valid 593 * @mac_addr: pointer to MAC address of the interface. This pointer is valid
@@ -503,8 +604,8 @@ enum ieee80211_if_types {
503 * in pure monitor mode. 604 * in pure monitor mode.
504 */ 605 */
505struct ieee80211_if_init_conf { 606struct ieee80211_if_init_conf {
506 int if_id;
507 enum ieee80211_if_types type; 607 enum ieee80211_if_types type;
608 struct ieee80211_vif *vif;
508 void *mac_addr; 609 void *mac_addr;
509}; 610};
510 611
@@ -597,9 +698,6 @@ struct ieee80211_key_conf {
597 u8 key[0]; 698 u8 key[0];
598}; 699};
599 700
600#define IEEE80211_SEQ_COUNTER_RX 0
601#define IEEE80211_SEQ_COUNTER_TX 1
602
603/** 701/**
604 * enum set_key_cmd - key command 702 * enum set_key_cmd - key command
605 * 703 *
@@ -706,15 +804,24 @@ enum ieee80211_hw_flags {
706 * 804 *
707 * @queues: number of available hardware transmit queues for 805 * @queues: number of available hardware transmit queues for
708 * data packets. WMM/QoS requires at least four. 806 * data packets. WMM/QoS requires at least four.
807 *
808 * @rate_control_algorithm: rate control algorithm for this hardware.
809 * If unset (NULL), the default algorithm will be used. Must be
810 * set before calling ieee80211_register_hw().
811 *
812 * @vif_data_size: size (in bytes) of the drv_priv data area
813 * within &struct ieee80211_vif.
709 */ 814 */
710struct ieee80211_hw { 815struct ieee80211_hw {
711 struct ieee80211_conf conf; 816 struct ieee80211_conf conf;
712 struct wiphy *wiphy; 817 struct wiphy *wiphy;
713 struct workqueue_struct *workqueue; 818 struct workqueue_struct *workqueue;
819 const char *rate_control_algorithm;
714 void *priv; 820 void *priv;
715 u32 flags; 821 u32 flags;
716 unsigned int extra_tx_headroom; 822 unsigned int extra_tx_headroom;
717 int channel_change_time; 823 int channel_change_time;
824 int vif_data_size;
718 u8 queues; 825 u8 queues;
719 s8 max_rssi; 826 s8 max_rssi;
720 s8 max_signal; 827 s8 max_signal;
@@ -854,19 +961,18 @@ enum ieee80211_filter_flags {
854}; 961};
855 962
856/** 963/**
857 * enum ieee80211_erp_change_flags - erp change flags 964 * enum ieee80211_ampdu_mlme_action - A-MPDU actions
858 * 965 *
859 * These flags are used with the erp_ie_changed() callback in 966 * These flags are used with the ampdu_action() callback in
860 * &struct ieee80211_ops to indicate which parameter(s) changed. 967 * &struct ieee80211_ops to indicate which action is needed.
861 * @IEEE80211_ERP_CHANGE_PROTECTION: protection changed 968 * @IEEE80211_AMPDU_RX_START: start Rx aggregation
862 * @IEEE80211_ERP_CHANGE_PREAMBLE: barker preamble mode changed 969 * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation
863 */ 970 */
864enum ieee80211_erp_change_flags { 971enum ieee80211_ampdu_mlme_action {
865 IEEE80211_ERP_CHANGE_PROTECTION = 1<<0, 972 IEEE80211_AMPDU_RX_START,
866 IEEE80211_ERP_CHANGE_PREAMBLE = 1<<1, 973 IEEE80211_AMPDU_RX_STOP,
867}; 974};
868 975
869
870/** 976/**
871 * struct ieee80211_ops - callbacks from mac80211 to the driver 977 * struct ieee80211_ops - callbacks from mac80211 to the driver
872 * 978 *
@@ -922,6 +1028,14 @@ enum ieee80211_erp_change_flags {
922 * @config_interface: Handler for configuration requests related to interfaces 1028 * @config_interface: Handler for configuration requests related to interfaces
923 * (e.g. BSSID changes.) 1029 * (e.g. BSSID changes.)
924 * 1030 *
1031 * @bss_info_changed: Handler for configuration requests related to BSS
1032 * parameters that may vary during BSS's lifespan, and may affect low
1033 * level driver (e.g. assoc/disassoc status, erp parameters).
1034 * This function should not be used if no BSS has been set, unless
1035 * for association indication. The @changed parameter indicates which
1036 * of the bss parameters has changed when a call is made. This callback
1037 * has to be atomic.
1038 *
925 * @configure_filter: Configure the device's RX filter. 1039 * @configure_filter: Configure the device's RX filter.
926 * See the section "Frame filtering" for more information. 1040 * See the section "Frame filtering" for more information.
927 * This callback must be implemented and atomic. 1041 * This callback must be implemented and atomic.
@@ -936,30 +1050,14 @@ enum ieee80211_erp_change_flags {
936 * and remove_interface calls, i.e. while the interface with the 1050 * and remove_interface calls, i.e. while the interface with the
937 * given local_address is enabled. 1051 * given local_address is enabled.
938 * 1052 *
939 * @set_ieee8021x: Enable/disable IEEE 802.1X. This item requests wlan card
940 * to pass unencrypted EAPOL-Key frames even when encryption is
941 * configured. If the wlan card does not require such a configuration,
942 * this function pointer can be set to NULL.
943 *
944 * @set_port_auth: Set port authorization state (IEEE 802.1X PAE) to be
945 * authorized (@authorized=1) or unauthorized (=0). This function can be
946 * used if the wlan hardware or low-level driver implements PAE.
947 * mac80211 will filter frames based on authorization state in any case,
948 * so this function pointer can be NULL if low-level driver does not
949 * require event notification about port state changes.
950 *
951 * @hw_scan: Ask the hardware to service the scan request, no need to start 1053 * @hw_scan: Ask the hardware to service the scan request, no need to start
952 * the scan state machine in stack. 1054 * the scan state machine in stack.
953 * 1055 *
954 * @get_stats: return low-level statistics 1056 * @get_stats: return low-level statistics
955 * 1057 *
956 * @set_privacy_invoked: For devices that generate their own beacons and probe 1058 * @get_tkip_seq: If your device implements TKIP encryption in hardware this
957 * response or association responses this updates the state of privacy_invoked 1059 * callback should be provided to read the TKIP transmit IVs (both IV32
958 * returns 0 for success or an error number. 1060 * and IV16) for the given key from hardware.
959 *
960 * @get_sequence_counter: For devices that have internal sequence counters this
961 * callback allows mac80211 to access the current value of a counter.
962 * This callback seems not well-defined, tell us if you need it.
963 * 1061 *
964 * @set_rts_threshold: Configuration of RTS threshold (if device needs it) 1062 * @set_rts_threshold: Configuration of RTS threshold (if device needs it)
965 * 1063 *
@@ -972,8 +1070,6 @@ enum ieee80211_erp_change_flags {
972 * @sta_notify: Notifies low level driver about addition or removal 1070 * @sta_notify: Notifies low level driver about addition or removal
973 * of assocaited station or AP. 1071 * of assocaited station or AP.
974 * 1072 *
975 * @erp_ie_changed: Handle ERP IE change notifications. Must be atomic.
976 *
977 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), 1073 * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max),
978 * bursting) for a hardware TX queue. The @queue parameter uses the 1074 * bursting) for a hardware TX queue. The @queue parameter uses the
979 * %IEEE80211_TX_QUEUE_* constants. Must be atomic. 1075 * %IEEE80211_TX_QUEUE_* constants. Must be atomic.
@@ -1008,6 +1104,14 @@ enum ieee80211_erp_change_flags {
1008 * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us. 1104 * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us.
1009 * This is needed only for IBSS mode and the result of this function is 1105 * This is needed only for IBSS mode and the result of this function is
1010 * used to determine whether to reply to Probe Requests. 1106 * used to determine whether to reply to Probe Requests.
1107 *
1108 * @conf_ht: Configures low level driver with 802.11n HT data. Must be atomic.
1109 *
1110 * @ampdu_action: Perform a certain A-MPDU action
1111 * The RA/TID combination determines the destination and TID we want
1112 * the ampdu action to be performed for. The action is defined through
1113 * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn)
1114 * is the first frame we expect to perform the action on.
1011 */ 1115 */
1012struct ieee80211_ops { 1116struct ieee80211_ops {
1013 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, 1117 int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb,
@@ -1020,7 +1124,12 @@ struct ieee80211_ops {
1020 struct ieee80211_if_init_conf *conf); 1124 struct ieee80211_if_init_conf *conf);
1021 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); 1125 int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
1022 int (*config_interface)(struct ieee80211_hw *hw, 1126 int (*config_interface)(struct ieee80211_hw *hw,
1023 int if_id, struct ieee80211_if_conf *conf); 1127 struct ieee80211_vif *vif,
1128 struct ieee80211_if_conf *conf);
1129 void (*bss_info_changed)(struct ieee80211_hw *hw,
1130 struct ieee80211_vif *vif,
1131 struct ieee80211_bss_conf *info,
1132 u32 changed);
1024 void (*configure_filter)(struct ieee80211_hw *hw, 1133 void (*configure_filter)(struct ieee80211_hw *hw,
1025 unsigned int changed_flags, 1134 unsigned int changed_flags,
1026 unsigned int *total_flags, 1135 unsigned int *total_flags,
@@ -1029,25 +1138,17 @@ struct ieee80211_ops {
1029 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, 1138 int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1030 const u8 *local_address, const u8 *address, 1139 const u8 *local_address, const u8 *address,
1031 struct ieee80211_key_conf *key); 1140 struct ieee80211_key_conf *key);
1032 int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x);
1033 int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr,
1034 int authorized);
1035 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); 1141 int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len);
1036 int (*get_stats)(struct ieee80211_hw *hw, 1142 int (*get_stats)(struct ieee80211_hw *hw,
1037 struct ieee80211_low_level_stats *stats); 1143 struct ieee80211_low_level_stats *stats);
1038 int (*set_privacy_invoked)(struct ieee80211_hw *hw, 1144 void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx,
1039 int privacy_invoked); 1145 u32 *iv32, u16 *iv16);
1040 int (*get_sequence_counter)(struct ieee80211_hw *hw,
1041 u8* addr, u8 keyidx, u8 txrx,
1042 u32* iv32, u16* iv16);
1043 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); 1146 int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value);
1044 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); 1147 int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
1045 int (*set_retry_limit)(struct ieee80211_hw *hw, 1148 int (*set_retry_limit)(struct ieee80211_hw *hw,
1046 u32 short_retry, u32 long_retr); 1149 u32 short_retry, u32 long_retr);
1047 void (*sta_notify)(struct ieee80211_hw *hw, int if_id, 1150 void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1048 enum sta_notify_cmd, const u8 *addr); 1151 enum sta_notify_cmd, const u8 *addr);
1049 void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes,
1050 int cts_protection, int preamble);
1051 int (*conf_tx)(struct ieee80211_hw *hw, int queue, 1152 int (*conf_tx)(struct ieee80211_hw *hw, int queue,
1052 const struct ieee80211_tx_queue_params *params); 1153 const struct ieee80211_tx_queue_params *params);
1053 int (*get_tx_stats)(struct ieee80211_hw *hw, 1154 int (*get_tx_stats)(struct ieee80211_hw *hw,
@@ -1058,6 +1159,10 @@ struct ieee80211_ops {
1058 struct sk_buff *skb, 1159 struct sk_buff *skb,
1059 struct ieee80211_tx_control *control); 1160 struct ieee80211_tx_control *control);
1060 int (*tx_last_beacon)(struct ieee80211_hw *hw); 1161 int (*tx_last_beacon)(struct ieee80211_hw *hw);
1162 int (*conf_ht)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
1163 int (*ampdu_action)(struct ieee80211_hw *hw,
1164 enum ieee80211_ampdu_mlme_action action,
1165 const u8 *ra, u16 tid, u16 ssn);
1061}; 1166};
1062 1167
1063/** 1168/**
@@ -1089,6 +1194,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw);
1089extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); 1194extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw);
1090extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); 1195extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw);
1091extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); 1196extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw);
1197extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw);
1092#endif 1198#endif
1093/** 1199/**
1094 * ieee80211_get_tx_led_name - get name of TX LED 1200 * ieee80211_get_tx_led_name - get name of TX LED
@@ -1128,6 +1234,16 @@ static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw)
1128#endif 1234#endif
1129} 1235}
1130 1236
1237/**
1238 * ieee80211_get_assoc_led_name - get name of association LED
1239 *
1240 * mac80211 creates a association LED trigger for each wireless hardware
1241 * that can be used to drive LEDs if your driver registers a LED device.
1242 * This function returns the name (or %NULL if not configured for LEDs)
1243 * of the trigger so you can automatically link the LED device.
1244 *
1245 * @hw: the hardware to get the LED trigger name for
1246 */
1131static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) 1247static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
1132{ 1248{
1133#ifdef CONFIG_MAC80211_LEDS 1249#ifdef CONFIG_MAC80211_LEDS
@@ -1137,6 +1253,24 @@ static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw)
1137#endif 1253#endif
1138} 1254}
1139 1255
1256/**
1257 * ieee80211_get_radio_led_name - get name of radio LED
1258 *
1259 * mac80211 creates a radio change LED trigger for each wireless hardware
1260 * that can be used to drive LEDs if your driver registers a LED device.
1261 * This function returns the name (or %NULL if not configured for LEDs)
1262 * of the trigger so you can automatically link the LED device.
1263 *
1264 * @hw: the hardware to get the LED trigger name for
1265 */
1266static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw)
1267{
1268#ifdef CONFIG_MAC80211_LEDS
1269 return __ieee80211_get_radio_led_name(hw);
1270#else
1271 return NULL;
1272#endif
1273}
1140 1274
1141/* Register a new hardware PHYMODE capability to the stack. */ 1275/* Register a new hardware PHYMODE capability to the stack. */
1142int ieee80211_register_hwmode(struct ieee80211_hw *hw, 1276int ieee80211_register_hwmode(struct ieee80211_hw *hw,
@@ -1226,7 +1360,7 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1226/** 1360/**
1227 * ieee80211_beacon_get - beacon generation function 1361 * ieee80211_beacon_get - beacon generation function
1228 * @hw: pointer obtained from ieee80211_alloc_hw(). 1362 * @hw: pointer obtained from ieee80211_alloc_hw().
1229 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1363 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1230 * @control: will be filled with information needed to send this beacon. 1364 * @control: will be filled with information needed to send this beacon.
1231 * 1365 *
1232 * If the beacon frames are generated by the host system (i.e., not in 1366 * If the beacon frames are generated by the host system (i.e., not in
@@ -1237,13 +1371,13 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw,
1237 * is responsible of freeing it. 1371 * is responsible of freeing it.
1238 */ 1372 */
1239struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, 1373struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1240 int if_id, 1374 struct ieee80211_vif *vif,
1241 struct ieee80211_tx_control *control); 1375 struct ieee80211_tx_control *control);
1242 1376
1243/** 1377/**
1244 * ieee80211_rts_get - RTS frame generation function 1378 * ieee80211_rts_get - RTS frame generation function
1245 * @hw: pointer obtained from ieee80211_alloc_hw(). 1379 * @hw: pointer obtained from ieee80211_alloc_hw().
1246 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1380 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1247 * @frame: pointer to the frame that is going to be protected by the RTS. 1381 * @frame: pointer to the frame that is going to be protected by the RTS.
1248 * @frame_len: the frame length (in octets). 1382 * @frame_len: the frame length (in octets).
1249 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1383 * @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -1254,7 +1388,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
1254 * the next RTS frame from the 802.11 code. The low-level is responsible 1388 * the next RTS frame from the 802.11 code. The low-level is responsible
1255 * for calling this function before and RTS frame is needed. 1389 * for calling this function before and RTS frame is needed.
1256 */ 1390 */
1257void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, 1391void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1258 const void *frame, size_t frame_len, 1392 const void *frame, size_t frame_len,
1259 const struct ieee80211_tx_control *frame_txctl, 1393 const struct ieee80211_tx_control *frame_txctl,
1260 struct ieee80211_rts *rts); 1394 struct ieee80211_rts *rts);
@@ -1262,7 +1396,7 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
1262/** 1396/**
1263 * ieee80211_rts_duration - Get the duration field for an RTS frame 1397 * ieee80211_rts_duration - Get the duration field for an RTS frame
1264 * @hw: pointer obtained from ieee80211_alloc_hw(). 1398 * @hw: pointer obtained from ieee80211_alloc_hw().
1265 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1399 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1266 * @frame_len: the length of the frame that is going to be protected by the RTS. 1400 * @frame_len: the length of the frame that is going to be protected by the RTS.
1267 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1401 * @frame_txctl: &struct ieee80211_tx_control of the frame.
1268 * 1402 *
@@ -1270,14 +1404,14 @@ void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
1270 * the duration field, the low-level driver uses this function to receive 1404 * the duration field, the low-level driver uses this function to receive
1271 * the duration field value in little-endian byteorder. 1405 * the duration field value in little-endian byteorder.
1272 */ 1406 */
1273__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, 1407__le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
1274 size_t frame_len, 1408 struct ieee80211_vif *vif, size_t frame_len,
1275 const struct ieee80211_tx_control *frame_txctl); 1409 const struct ieee80211_tx_control *frame_txctl);
1276 1410
1277/** 1411/**
1278 * ieee80211_ctstoself_get - CTS-to-self frame generation function 1412 * ieee80211_ctstoself_get - CTS-to-self frame generation function
1279 * @hw: pointer obtained from ieee80211_alloc_hw(). 1413 * @hw: pointer obtained from ieee80211_alloc_hw().
1280 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1414 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1281 * @frame: pointer to the frame that is going to be protected by the CTS-to-self. 1415 * @frame: pointer to the frame that is going to be protected by the CTS-to-self.
1282 * @frame_len: the frame length (in octets). 1416 * @frame_len: the frame length (in octets).
1283 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1417 * @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -1288,7 +1422,8 @@ __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
1288 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible 1422 * the next CTS-to-self frame from the 802.11 code. The low-level is responsible
1289 * for calling this function before and CTS-to-self frame is needed. 1423 * for calling this function before and CTS-to-self frame is needed.
1290 */ 1424 */
1291void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, 1425void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
1426 struct ieee80211_vif *vif,
1292 const void *frame, size_t frame_len, 1427 const void *frame, size_t frame_len,
1293 const struct ieee80211_tx_control *frame_txctl, 1428 const struct ieee80211_tx_control *frame_txctl,
1294 struct ieee80211_cts *cts); 1429 struct ieee80211_cts *cts);
@@ -1296,7 +1431,7 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
1296/** 1431/**
1297 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame 1432 * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
1298 * @hw: pointer obtained from ieee80211_alloc_hw(). 1433 * @hw: pointer obtained from ieee80211_alloc_hw().
1299 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1434 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1300 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. 1435 * @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
1301 * @frame_txctl: &struct ieee80211_tx_control of the frame. 1436 * @frame_txctl: &struct ieee80211_tx_control of the frame.
1302 * 1437 *
@@ -1304,28 +1439,30 @@ void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
1304 * the duration field, the low-level driver uses this function to receive 1439 * the duration field, the low-level driver uses this function to receive
1305 * the duration field value in little-endian byteorder. 1440 * the duration field value in little-endian byteorder.
1306 */ 1441 */
1307__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, 1442__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
1443 struct ieee80211_vif *vif,
1308 size_t frame_len, 1444 size_t frame_len,
1309 const struct ieee80211_tx_control *frame_txctl); 1445 const struct ieee80211_tx_control *frame_txctl);
1310 1446
1311/** 1447/**
1312 * ieee80211_generic_frame_duration - Calculate the duration field for a frame 1448 * ieee80211_generic_frame_duration - Calculate the duration field for a frame
1313 * @hw: pointer obtained from ieee80211_alloc_hw(). 1449 * @hw: pointer obtained from ieee80211_alloc_hw().
1314 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1450 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1315 * @frame_len: the length of the frame. 1451 * @frame_len: the length of the frame.
1316 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. 1452 * @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
1317 * 1453 *
1318 * Calculate the duration field of some generic frame, given its 1454 * Calculate the duration field of some generic frame, given its
1319 * length and transmission rate (in 100kbps). 1455 * length and transmission rate (in 100kbps).
1320 */ 1456 */
1321__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, 1457__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
1458 struct ieee80211_vif *vif,
1322 size_t frame_len, 1459 size_t frame_len,
1323 int rate); 1460 int rate);
1324 1461
1325/** 1462/**
1326 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames 1463 * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
1327 * @hw: pointer as obtained from ieee80211_alloc_hw(). 1464 * @hw: pointer as obtained from ieee80211_alloc_hw().
1328 * @if_id: interface ID from &struct ieee80211_if_init_conf. 1465 * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
1329 * @control: will be filled with information needed to send returned frame. 1466 * @control: will be filled with information needed to send returned frame.
1330 * 1467 *
1331 * Function for accessing buffered broadcast and multicast frames. If 1468 * Function for accessing buffered broadcast and multicast frames. If
@@ -1344,7 +1481,7 @@ __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
1344 * use common code for all beacons. 1481 * use common code for all beacons.
1345 */ 1482 */
1346struct sk_buff * 1483struct sk_buff *
1347ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, 1484ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
1348 struct ieee80211_tx_control *control); 1485 struct ieee80211_tx_control *control);
1349 1486
1350/** 1487/**
@@ -1422,4 +1559,19 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw);
1422 */ 1559 */
1423void ieee80211_scan_completed(struct ieee80211_hw *hw); 1560void ieee80211_scan_completed(struct ieee80211_hw *hw);
1424 1561
1562/**
1563 * ieee80211_iterate_active_interfaces - iterate active interfaces
1564 *
1565 * This function iterates over the interfaces associated with a given
1566 * hardware that are currently active and calls the callback for them.
1567 *
1568 * @hw: the hardware struct of which the interfaces should be iterated over
1569 * @iterator: the iterator function to call, cannot sleep
1570 * @data: first argument of the iterator function
1571 */
1572void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
1573 void (*iterator)(void *data, u8 *mac,
1574 struct ieee80211_vif *vif),
1575 void *data);
1576
1425#endif /* MAC80211_H */ 1577#endif /* MAC80211_H */
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index a4f26187fc1a..ebbfb509822e 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -26,6 +26,10 @@
26#include <linux/sysctl.h> 26#include <linux/sysctl.h>
27#include <net/rtnetlink.h> 27#include <net/rtnetlink.h>
28 28
29/*
30 * NUD stands for "neighbor unreachability detection"
31 */
32
29#define NUD_IN_TIMER (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE) 33#define NUD_IN_TIMER (NUD_INCOMPLETE|NUD_REACHABLE|NUD_DELAY|NUD_PROBE)
30#define NUD_VALID (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY) 34#define NUD_VALID (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY)
31#define NUD_CONNECTED (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE) 35#define NUD_CONNECTED (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE)
@@ -34,6 +38,7 @@ struct neighbour;
34 38
35struct neigh_parms 39struct neigh_parms
36{ 40{
41 struct net *net;
37 struct net_device *dev; 42 struct net_device *dev;
38 struct neigh_parms *next; 43 struct neigh_parms *next;
39 int (*neigh_setup)(struct neighbour *); 44 int (*neigh_setup)(struct neighbour *);
@@ -126,7 +131,8 @@ struct neigh_ops
126struct pneigh_entry 131struct pneigh_entry
127{ 132{
128 struct pneigh_entry *next; 133 struct pneigh_entry *next;
129 struct net_device *dev; 134 struct net *net;
135 struct net_device *dev;
130 u8 flags; 136 u8 flags;
131 u8 key[0]; 137 u8 key[0];
132}; 138};
@@ -187,6 +193,7 @@ extern struct neighbour * neigh_lookup(struct neigh_table *tbl,
187 const void *pkey, 193 const void *pkey,
188 struct net_device *dev); 194 struct net_device *dev);
189extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl, 195extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl,
196 struct net *net,
190 const void *pkey); 197 const void *pkey);
191extern struct neighbour * neigh_create(struct neigh_table *tbl, 198extern struct neighbour * neigh_create(struct neigh_table *tbl,
192 const void *pkey, 199 const void *pkey,
@@ -206,13 +213,12 @@ extern struct neighbour *neigh_event_ns(struct neigh_table *tbl,
206 213
207extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl); 214extern struct neigh_parms *neigh_parms_alloc(struct net_device *dev, struct neigh_table *tbl);
208extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms); 215extern void neigh_parms_release(struct neigh_table *tbl, struct neigh_parms *parms);
209extern void neigh_parms_destroy(struct neigh_parms *parms);
210extern unsigned long neigh_rand_reach_time(unsigned long base); 216extern unsigned long neigh_rand_reach_time(unsigned long base);
211 217
212extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p, 218extern void pneigh_enqueue(struct neigh_table *tbl, struct neigh_parms *p,
213 struct sk_buff *skb); 219 struct sk_buff *skb);
214extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, const void *key, struct net_device *dev, int creat); 220extern struct pneigh_entry *pneigh_lookup(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev, int creat);
215extern int pneigh_delete(struct neigh_table *tbl, const void *key, struct net_device *dev); 221extern int pneigh_delete(struct neigh_table *tbl, struct net *net, const void *key, struct net_device *dev);
216 222
217extern void neigh_app_ns(struct neighbour *n); 223extern void neigh_app_ns(struct neighbour *n);
218extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie); 224extern void neigh_for_each(struct neigh_table *tbl, void (*cb)(struct neighbour *, void *), void *cookie);
@@ -220,6 +226,7 @@ extern void __neigh_for_each_release(struct neigh_table *tbl, int (*cb)(struct n
220extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *)); 226extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_entry *));
221 227
222struct neigh_seq_state { 228struct neigh_seq_state {
229 struct seq_net_private p;
223 struct neigh_table *tbl; 230 struct neigh_table *tbl;
224 void *(*neigh_sub_iter)(struct neigh_seq_state *state, 231 void *(*neigh_sub_iter)(struct neigh_seq_state *state,
225 struct neighbour *n, loff_t *pos); 232 struct neighbour *n, loff_t *pos);
@@ -246,12 +253,6 @@ static inline void __neigh_parms_put(struct neigh_parms *parms)
246 atomic_dec(&parms->refcnt); 253 atomic_dec(&parms->refcnt);
247} 254}
248 255
249static inline void neigh_parms_put(struct neigh_parms *parms)
250{
251 if (atomic_dec_and_test(&parms->refcnt))
252 neigh_parms_destroy(parms);
253}
254
255static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms) 256static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms)
256{ 257{
257 atomic_inc(&parms->refcnt); 258 atomic_inc(&parms->refcnt);
@@ -288,10 +289,6 @@ static inline int neigh_is_connected(struct neighbour *neigh)
288 return neigh->nud_state&NUD_CONNECTED; 289 return neigh->nud_state&NUD_CONNECTED;
289} 290}
290 291
291static inline int neigh_is_valid(struct neighbour *neigh)
292{
293 return neigh->nud_state&NUD_VALID;
294}
295 292
296static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) 293static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
297{ 294{
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 5279466606d2..28738b7d53eb 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -8,8 +8,17 @@
8#include <linux/workqueue.h> 8#include <linux/workqueue.h>
9#include <linux/list.h> 9#include <linux/list.h>
10 10
11#include <net/netns/unix.h>
12#include <net/netns/packet.h>
13#include <net/netns/ipv4.h>
14#include <net/netns/ipv6.h>
15#include <net/netns/x_tables.h>
16
11struct proc_dir_entry; 17struct proc_dir_entry;
12struct net_device; 18struct net_device;
19struct sock;
20struct ctl_table_header;
21
13struct net { 22struct net {
14 atomic_t count; /* To decided when the network 23 atomic_t count; /* To decided when the network
15 * namespace should be freed. 24 * namespace should be freed.
@@ -24,11 +33,33 @@ struct net {
24 struct proc_dir_entry *proc_net_stat; 33 struct proc_dir_entry *proc_net_stat;
25 struct proc_dir_entry *proc_net_root; 34 struct proc_dir_entry *proc_net_root;
26 35
36 struct list_head sysctl_table_headers;
37
27 struct net_device *loopback_dev; /* The loopback */ 38 struct net_device *loopback_dev; /* The loopback */
28 39
29 struct list_head dev_base_head; 40 struct list_head dev_base_head;
30 struct hlist_head *dev_name_head; 41 struct hlist_head *dev_name_head;
31 struct hlist_head *dev_index_head; 42 struct hlist_head *dev_index_head;
43
44 /* core fib_rules */
45 struct list_head rules_ops;
46 spinlock_t rules_mod_lock;
47
48 struct sock *rtnl; /* rtnetlink socket */
49
50 /* core sysctls */
51 struct ctl_table_header *sysctl_core_hdr;
52 int sysctl_somaxconn;
53
54 struct netns_packet packet;
55 struct netns_unix unx;
56 struct netns_ipv4 ipv4;
57#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
58 struct netns_ipv6 ipv6;
59#endif
60#ifdef CONFIG_NETFILTER
61 struct netns_xt xt;
62#endif
32}; 63};
33 64
34#ifdef CONFIG_NET 65#ifdef CONFIG_NET
@@ -51,13 +82,12 @@ static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)
51} 82}
52#endif 83#endif
53 84
85#ifdef CONFIG_NET_NS
54extern void __put_net(struct net *net); 86extern void __put_net(struct net *net);
55 87
56static inline struct net *get_net(struct net *net) 88static inline struct net *get_net(struct net *net)
57{ 89{
58#ifdef CONFIG_NET
59 atomic_inc(&net->count); 90 atomic_inc(&net->count);
60#endif
61 return net; 91 return net;
62} 92}
63 93
@@ -75,36 +105,56 @@ static inline struct net *maybe_get_net(struct net *net)
75 105
76static inline void put_net(struct net *net) 106static inline void put_net(struct net *net)
77{ 107{
78#ifdef CONFIG_NET
79 if (atomic_dec_and_test(&net->count)) 108 if (atomic_dec_and_test(&net->count))
80 __put_net(net); 109 __put_net(net);
81#endif
82} 110}
83 111
84static inline struct net *hold_net(struct net *net) 112static inline struct net *hold_net(struct net *net)
85{ 113{
86#ifdef CONFIG_NET
87 atomic_inc(&net->use_count); 114 atomic_inc(&net->use_count);
88#endif
89 return net; 115 return net;
90} 116}
91 117
92static inline void release_net(struct net *net) 118static inline void release_net(struct net *net)
93{ 119{
94#ifdef CONFIG_NET
95 atomic_dec(&net->use_count); 120 atomic_dec(&net->use_count);
96#endif 121}
122#else
123static inline struct net *get_net(struct net *net)
124{
125 return net;
126}
127
128static inline void put_net(struct net *net)
129{
97} 130}
98 131
132static inline struct net *hold_net(struct net *net)
133{
134 return net;
135}
136
137static inline void release_net(struct net *net)
138{
139}
140
141static inline struct net *maybe_get_net(struct net *net)
142{
143 return net;
144}
145#endif
146
99#define for_each_net(VAR) \ 147#define for_each_net(VAR) \
100 list_for_each_entry(VAR, &net_namespace_list, list) 148 list_for_each_entry(VAR, &net_namespace_list, list)
101 149
102#ifdef CONFIG_NET_NS 150#ifdef CONFIG_NET_NS
103#define __net_init 151#define __net_init
104#define __net_exit 152#define __net_exit
153#define __net_initdata
105#else 154#else
106#define __net_init __init 155#define __net_init __init
107#define __net_exit __exit_refok 156#define __net_exit __exit_refok
157#define __net_initdata __initdata
108#endif 158#endif
109 159
110struct pernet_operations { 160struct pernet_operations {
@@ -118,4 +168,11 @@ extern void unregister_pernet_subsys(struct pernet_operations *);
118extern int register_pernet_device(struct pernet_operations *); 168extern int register_pernet_device(struct pernet_operations *);
119extern void unregister_pernet_device(struct pernet_operations *); 169extern void unregister_pernet_device(struct pernet_operations *);
120 170
171struct ctl_path;
172struct ctl_table;
173struct ctl_table_header;
174extern struct ctl_table_header *register_net_sysctl_table(struct net *net,
175 const struct ctl_path *path, struct ctl_table *table);
176extern void unregister_net_sysctl_table(struct ctl_table_header *header);
177
121#endif /* __NET_NET_NAMESPACE_H */ 178#endif /* __NET_NET_NAMESPACE_H */
diff --git a/include/net/netevent.h b/include/net/netevent.h
index e5d216241423..e82b7bab3ff3 100644
--- a/include/net/netevent.h
+++ b/include/net/netevent.h
@@ -12,7 +12,7 @@
12 */ 12 */
13#ifdef __KERNEL__ 13#ifdef __KERNEL__
14 14
15#include <net/dst.h> 15struct dst_entry;
16 16
17struct netevent_redirect { 17struct netevent_redirect {
18 struct dst_entry *old; 18 struct dst_entry *old;
diff --git a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
index f703533fb4db..abc55ad75c2b 100644
--- a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
+++ b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h
@@ -16,6 +16,8 @@ extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
16 int (*okfn)(struct sk_buff *)); 16 int (*okfn)(struct sk_buff *));
17 17
18struct inet_frags_ctl; 18struct inet_frags_ctl;
19extern struct inet_frags_ctl nf_frags_ctl; 19
20#include <linux/sysctl.h>
21extern struct ctl_table nf_ct_ipv6_sysctl_table[];
20 22
21#endif /* _NF_CONNTRACK_IPV6_H*/ 23#endif /* _NF_CONNTRACK_IPV6_H*/
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 90fb66d99d0c..90b3e7f5df5f 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -129,6 +129,8 @@ struct nf_conn
129 129
130 /* Extensions */ 130 /* Extensions */
131 struct nf_ct_ext *ext; 131 struct nf_ct_ext *ext;
132
133 struct rcu_head rcu;
132}; 134};
133 135
134static inline struct nf_conn * 136static inline struct nf_conn *
@@ -143,7 +145,7 @@ nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash)
143 145
144/* Alter reply tuple (maybe alter helper). */ 146/* Alter reply tuple (maybe alter helper). */
145extern void 147extern void
146nf_conntrack_alter_reply(struct nf_conn *conntrack, 148nf_conntrack_alter_reply(struct nf_conn *ct,
147 const struct nf_conntrack_tuple *newreply); 149 const struct nf_conntrack_tuple *newreply);
148 150
149/* Is this tuple taken? (ignoring any belonging to the given 151/* Is this tuple taken? (ignoring any belonging to the given
@@ -171,13 +173,12 @@ static inline void nf_ct_put(struct nf_conn *ct)
171extern int nf_ct_l3proto_try_module_get(unsigned short l3proto); 173extern int nf_ct_l3proto_try_module_get(unsigned short l3proto);
172extern void nf_ct_l3proto_module_put(unsigned short l3proto); 174extern void nf_ct_l3proto_module_put(unsigned short l3proto);
173 175
174extern struct hlist_head *nf_ct_alloc_hashtable(int *sizep, int *vmalloced); 176extern struct hlist_head *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced);
175extern void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced, 177extern void nf_ct_free_hashtable(struct hlist_head *hash, int vmalloced,
176 int size); 178 unsigned int size);
177 179
178extern struct nf_conntrack_tuple_hash * 180extern struct nf_conntrack_tuple_hash *
179__nf_conntrack_find(const struct nf_conntrack_tuple *tuple, 181__nf_conntrack_find(const struct nf_conntrack_tuple *tuple);
180 const struct nf_conn *ignored_conntrack);
181 182
182extern void nf_conntrack_hash_insert(struct nf_conn *ct); 183extern void nf_conntrack_hash_insert(struct nf_conn *ct);
183 184
@@ -215,16 +216,14 @@ static inline void nf_ct_refresh(struct nf_conn *ct,
215 216
216/* These are for NAT. Icky. */ 217/* These are for NAT. Icky. */
217/* Update TCP window tracking data when NAT mangles the packet */ 218/* Update TCP window tracking data when NAT mangles the packet */
218extern void nf_conntrack_tcp_update(struct sk_buff *skb, 219extern void nf_conntrack_tcp_update(const struct sk_buff *skb,
219 unsigned int dataoff, 220 unsigned int dataoff,
220 struct nf_conn *conntrack, 221 struct nf_conn *ct,
221 int dir); 222 int dir);
222 223
223/* Fake conntrack entry for untracked connections */ 224/* Fake conntrack entry for untracked connections */
224extern struct nf_conn nf_conntrack_untracked; 225extern struct nf_conn nf_conntrack_untracked;
225 226
226extern int nf_ct_no_defrag;
227
228/* Iterate over all conntracks: if iter returns true, it's deleted. */ 227/* Iterate over all conntracks: if iter returns true, it's deleted. */
229extern void 228extern void
230nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data); 229nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data);
@@ -249,6 +248,7 @@ static inline int nf_ct_is_untracked(const struct sk_buff *skb)
249 return (skb->nfct == &nf_conntrack_untracked.ct_general); 248 return (skb->nfct == &nf_conntrack_untracked.ct_general);
250} 249}
251 250
251extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp);
252extern unsigned int nf_conntrack_htable_size; 252extern unsigned int nf_conntrack_htable_size;
253extern int nf_conntrack_checksum; 253extern int nf_conntrack_checksum;
254extern atomic_t nf_conntrack_count; 254extern atomic_t nf_conntrack_count;
@@ -263,10 +263,5 @@ do { \
263 local_bh_enable(); \ 263 local_bh_enable(); \
264} while (0) 264} while (0)
265 265
266extern int
267nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size);
268extern void
269nf_conntrack_unregister_cache(u_int32_t features);
270
271#endif /* __KERNEL__ */ 266#endif /* __KERNEL__ */
272#endif /* _NF_CONNTRACK_H */ 267#endif /* _NF_CONNTRACK_H */
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index a532e7b5ed6a..9ee26469c759 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -30,16 +30,6 @@ extern void nf_conntrack_cleanup(void);
30extern int nf_conntrack_proto_init(void); 30extern int nf_conntrack_proto_init(void);
31extern void nf_conntrack_proto_fini(void); 31extern void nf_conntrack_proto_fini(void);
32 32
33extern int nf_conntrack_helper_init(void);
34extern void nf_conntrack_helper_fini(void);
35
36struct nf_conntrack_l3proto;
37extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf);
38/* Like above, but you already have conntrack read lock. */
39extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto);
40
41struct nf_conntrack_l4proto;
42
43extern int 33extern int
44nf_ct_get_tuple(const struct sk_buff *skb, 34nf_ct_get_tuple(const struct sk_buff *skb,
45 unsigned int nhoff, 35 unsigned int nhoff,
@@ -76,15 +66,13 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
76 return ret; 66 return ret;
77} 67}
78 68
79extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb);
80
81int 69int
82print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple, 70print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
83 struct nf_conntrack_l3proto *l3proto, 71 const struct nf_conntrack_l3proto *l3proto,
84 struct nf_conntrack_l4proto *proto); 72 const struct nf_conntrack_l4proto *proto);
85 73
86extern struct hlist_head *nf_conntrack_hash; 74extern struct hlist_head *nf_conntrack_hash;
87extern rwlock_t nf_conntrack_lock ; 75extern spinlock_t nf_conntrack_lock ;
88extern struct hlist_head unconfirmed; 76extern struct hlist_head unconfirmed;
89 77
90#endif /* _NF_CONNTRACK_CORE_H */ 78#endif /* _NF_CONNTRACK_CORE_H */
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h
index b47c04f12dbe..cb608a1b44e5 100644
--- a/include/net/netfilter/nf_conntrack_expect.h
+++ b/include/net/netfilter/nf_conntrack_expect.h
@@ -49,6 +49,8 @@ struct nf_conntrack_expect
49 /* Direction relative to the master connection. */ 49 /* Direction relative to the master connection. */
50 enum ip_conntrack_dir dir; 50 enum ip_conntrack_dir dir;
51#endif 51#endif
52
53 struct rcu_head rcu;
52}; 54};
53 55
54#define NF_CT_EXPECT_PERMANENT 0x1 56#define NF_CT_EXPECT_PERMANENT 0x1
@@ -73,8 +75,8 @@ void nf_ct_unexpect_related(struct nf_conntrack_expect *exp);
73 nf_ct_expect_related. You will have to call put afterwards. */ 75 nf_ct_expect_related. You will have to call put afterwards. */
74struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me); 76struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me);
75void nf_ct_expect_init(struct nf_conntrack_expect *, int, 77void nf_ct_expect_init(struct nf_conntrack_expect *, int,
76 union nf_conntrack_address *, 78 union nf_inet_addr *,
77 union nf_conntrack_address *, 79 union nf_inet_addr *,
78 u_int8_t, __be16 *, __be16 *); 80 u_int8_t, __be16 *, __be16 *);
79void nf_ct_expect_put(struct nf_conntrack_expect *exp); 81void nf_ct_expect_put(struct nf_conntrack_expect *exp);
80int nf_ct_expect_related(struct nf_conntrack_expect *expect); 82int nf_ct_expect_related(struct nf_conntrack_expect *expect);
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h
index d7b2d5483a71..4ca125e9b3ce 100644
--- a/include/net/netfilter/nf_conntrack_helper.h
+++ b/include/net/netfilter/nf_conntrack_helper.h
@@ -43,12 +43,8 @@ extern struct nf_conntrack_helper *
43__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple); 43__nf_ct_helper_find(const struct nf_conntrack_tuple *tuple);
44 44
45extern struct nf_conntrack_helper * 45extern struct nf_conntrack_helper *
46nf_ct_helper_find_get( const struct nf_conntrack_tuple *tuple);
47
48extern struct nf_conntrack_helper *
49__nf_conntrack_helper_find_byname(const char *name); 46__nf_conntrack_helper_find_byname(const char *name);
50 47
51extern void nf_ct_helper_put(struct nf_conntrack_helper *helper);
52extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); 48extern int nf_conntrack_helper_register(struct nf_conntrack_helper *);
53extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); 49extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *);
54 50
@@ -58,4 +54,8 @@ static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct)
58{ 54{
59 return nf_ct_ext_find(ct, NF_CT_EXT_HELPER); 55 return nf_ct_ext_find(ct, NF_CT_EXT_HELPER);
60} 56}
57
58extern int nf_conntrack_helper_init(void);
59extern void nf_conntrack_helper_fini(void);
60
61#endif /*_NF_CONNTRACK_HELPER_H*/ 61#endif /*_NF_CONNTRACK_HELPER_H*/
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index 15888fc7b72d..b886e3ae6cad 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -42,11 +42,8 @@ struct nf_conntrack_l3proto
42 int (*print_tuple)(struct seq_file *s, 42 int (*print_tuple)(struct seq_file *s,
43 const struct nf_conntrack_tuple *); 43 const struct nf_conntrack_tuple *);
44 44
45 /* Print out the private part of the conntrack. */
46 int (*print_conntrack)(struct seq_file *s, const struct nf_conn *);
47
48 /* Returns verdict for packet, or -1 for invalid. */ 45 /* Returns verdict for packet, or -1 for invalid. */
49 int (*packet)(struct nf_conn *conntrack, 46 int (*packet)(struct nf_conn *ct,
50 const struct sk_buff *skb, 47 const struct sk_buff *skb,
51 enum ip_conntrack_info ctinfo); 48 enum ip_conntrack_info ctinfo);
52 49
@@ -54,7 +51,7 @@ struct nf_conntrack_l3proto
54 * Called when a new connection for this protocol found; 51 * Called when a new connection for this protocol found;
55 * returns TRUE if it's OK. If so, packet() called next. 52 * returns TRUE if it's OK. If so, packet() called next.
56 */ 53 */
57 int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb); 54 int (*new)(struct nf_conn *ct, const struct sk_buff *skb);
58 55
59 /* 56 /*
60 * Called before tracking. 57 * Called before tracking.
@@ -73,7 +70,7 @@ struct nf_conntrack_l3proto
73 70
74#ifdef CONFIG_SYSCTL 71#ifdef CONFIG_SYSCTL
75 struct ctl_table_header *ctl_table_header; 72 struct ctl_table_header *ctl_table_header;
76 struct ctl_table *ctl_table_path; 73 struct ctl_path *ctl_table_path;
77 struct ctl_table *ctl_table; 74 struct ctl_table *ctl_table;
78#endif /* CONFIG_SYSCTL */ 75#endif /* CONFIG_SYSCTL */
79 76
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index fb50c217ba0a..efc16eccddb1 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -23,9 +23,6 @@ struct nf_conntrack_l4proto
23 /* L4 Protocol number. */ 23 /* L4 Protocol number. */
24 u_int8_t l4proto; 24 u_int8_t l4proto;
25 25
26 /* Protocol name */
27 const char *name;
28
29 /* Try to fill in the third arg: dataoff is offset past network protocol 26 /* Try to fill in the third arg: dataoff is offset past network protocol
30 hdr. Return true if possible. */ 27 hdr. Return true if possible. */
31 int (*pkt_to_tuple)(const struct sk_buff *skb, 28 int (*pkt_to_tuple)(const struct sk_buff *skb,
@@ -38,15 +35,8 @@ struct nf_conntrack_l4proto
38 int (*invert_tuple)(struct nf_conntrack_tuple *inverse, 35 int (*invert_tuple)(struct nf_conntrack_tuple *inverse,
39 const struct nf_conntrack_tuple *orig); 36 const struct nf_conntrack_tuple *orig);
40 37
41 /* Print out the per-protocol part of the tuple. Return like seq_* */
42 int (*print_tuple)(struct seq_file *s,
43 const struct nf_conntrack_tuple *);
44
45 /* Print out the private part of the conntrack. */
46 int (*print_conntrack)(struct seq_file *s, const struct nf_conn *);
47
48 /* Returns verdict for packet, or -1 for invalid. */ 38 /* Returns verdict for packet, or -1 for invalid. */
49 int (*packet)(struct nf_conn *conntrack, 39 int (*packet)(struct nf_conn *ct,
50 const struct sk_buff *skb, 40 const struct sk_buff *skb,
51 unsigned int dataoff, 41 unsigned int dataoff,
52 enum ip_conntrack_info ctinfo, 42 enum ip_conntrack_info ctinfo,
@@ -55,16 +45,23 @@ struct nf_conntrack_l4proto
55 45
56 /* Called when a new connection for this protocol found; 46 /* Called when a new connection for this protocol found;
57 * returns TRUE if it's OK. If so, packet() called next. */ 47 * returns TRUE if it's OK. If so, packet() called next. */
58 int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb, 48 int (*new)(struct nf_conn *ct, const struct sk_buff *skb,
59 unsigned int dataoff); 49 unsigned int dataoff);
60 50
61 /* Called when a conntrack entry is destroyed */ 51 /* Called when a conntrack entry is destroyed */
62 void (*destroy)(struct nf_conn *conntrack); 52 void (*destroy)(struct nf_conn *ct);
63 53
64 int (*error)(struct sk_buff *skb, unsigned int dataoff, 54 int (*error)(struct sk_buff *skb, unsigned int dataoff,
65 enum ip_conntrack_info *ctinfo, 55 enum ip_conntrack_info *ctinfo,
66 int pf, unsigned int hooknum); 56 int pf, unsigned int hooknum);
67 57
58 /* Print out the per-protocol part of the tuple. Return like seq_* */
59 int (*print_tuple)(struct seq_file *s,
60 const struct nf_conntrack_tuple *);
61
62 /* Print out the private part of the conntrack. */
63 int (*print_conntrack)(struct seq_file *s, const struct nf_conn *);
64
68 /* convert protoinfo to nfnetink attributes */ 65 /* convert protoinfo to nfnetink attributes */
69 int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, 66 int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla,
70 const struct nf_conn *ct); 67 const struct nf_conn *ct);
@@ -87,6 +84,8 @@ struct nf_conntrack_l4proto
87 struct ctl_table *ctl_compat_table; 84 struct ctl_table *ctl_compat_table;
88#endif 85#endif
89#endif 86#endif
87 /* Protocol name */
88 const char *name;
90 89
91 /* Module (if any) which this is connected to. */ 90 /* Module (if any) which this is connected to. */
92 struct module *me; 91 struct module *me;
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h
index c48e390f4b0f..e69ab2e87597 100644
--- a/include/net/netfilter/nf_conntrack_tuple.h
+++ b/include/net/netfilter/nf_conntrack_tuple.h
@@ -10,6 +10,7 @@
10#ifndef _NF_CONNTRACK_TUPLE_H 10#ifndef _NF_CONNTRACK_TUPLE_H
11#define _NF_CONNTRACK_TUPLE_H 11#define _NF_CONNTRACK_TUPLE_H
12 12
13#include <linux/netfilter/x_tables.h>
13#include <linux/netfilter/nf_conntrack_tuple_common.h> 14#include <linux/netfilter/nf_conntrack_tuple_common.h>
14 15
15/* A `tuple' is a structure containing the information to uniquely 16/* A `tuple' is a structure containing the information to uniquely
@@ -20,15 +21,7 @@
20 "non-manipulatable" lines, for the benefit of the NAT code. 21 "non-manipulatable" lines, for the benefit of the NAT code.
21*/ 22*/
22 23
23#define NF_CT_TUPLE_L3SIZE 4 24#define NF_CT_TUPLE_L3SIZE ARRAY_SIZE(((union nf_inet_addr *)NULL)->all)
24
25/* The l3 protocol-specific manipulable parts of the tuple: always in
26 network order! */
27union nf_conntrack_address {
28 u_int32_t all[NF_CT_TUPLE_L3SIZE];
29 __be32 ip;
30 __be32 ip6[4];
31};
32 25
33/* The protocol-specific manipulable parts of the tuple: always in 26/* The protocol-specific manipulable parts of the tuple: always in
34 network order! */ 27 network order! */
@@ -57,7 +50,7 @@ union nf_conntrack_man_proto
57/* The manipulable part of the tuple. */ 50/* The manipulable part of the tuple. */
58struct nf_conntrack_man 51struct nf_conntrack_man
59{ 52{
60 union nf_conntrack_address u3; 53 union nf_inet_addr u3;
61 union nf_conntrack_man_proto u; 54 union nf_conntrack_man_proto u;
62 /* Layer 3 protocol */ 55 /* Layer 3 protocol */
63 u_int16_t l3num; 56 u_int16_t l3num;
@@ -70,7 +63,7 @@ struct nf_conntrack_tuple
70 63
71 /* These are the parts of the tuple which are fixed. */ 64 /* These are the parts of the tuple which are fixed. */
72 struct { 65 struct {
73 union nf_conntrack_address u3; 66 union nf_inet_addr u3;
74 union { 67 union {
75 /* Add other protocols here. */ 68 /* Add other protocols here. */
76 __be16 all; 69 __be16 all;
@@ -103,7 +96,7 @@ struct nf_conntrack_tuple
103struct nf_conntrack_tuple_mask 96struct nf_conntrack_tuple_mask
104{ 97{
105 struct { 98 struct {
106 union nf_conntrack_address u3; 99 union nf_inet_addr u3;
107 union nf_conntrack_man_proto u; 100 union nf_conntrack_man_proto u;
108 } src; 101 } src;
109}; 102};
@@ -139,34 +132,33 @@ struct nf_conntrack_tuple_hash
139 132
140#endif /* __KERNEL__ */ 133#endif /* __KERNEL__ */
141 134
142static inline int nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, 135static inline int __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1,
143 const struct nf_conntrack_tuple *t2) 136 const struct nf_conntrack_tuple *t2)
144{ 137{
145 return (t1->src.u3.all[0] == t2->src.u3.all[0] && 138 return (t1->src.u3.all[0] == t2->src.u3.all[0] &&
146 t1->src.u3.all[1] == t2->src.u3.all[1] && 139 t1->src.u3.all[1] == t2->src.u3.all[1] &&
147 t1->src.u3.all[2] == t2->src.u3.all[2] && 140 t1->src.u3.all[2] == t2->src.u3.all[2] &&
148 t1->src.u3.all[3] == t2->src.u3.all[3] && 141 t1->src.u3.all[3] == t2->src.u3.all[3] &&
149 t1->src.u.all == t2->src.u.all && 142 t1->src.u.all == t2->src.u.all &&
150 t1->src.l3num == t2->src.l3num && 143 t1->src.l3num == t2->src.l3num);
151 t1->dst.protonum == t2->dst.protonum);
152} 144}
153 145
154static inline int nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1, 146static inline int __nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1,
155 const struct nf_conntrack_tuple *t2) 147 const struct nf_conntrack_tuple *t2)
156{ 148{
157 return (t1->dst.u3.all[0] == t2->dst.u3.all[0] && 149 return (t1->dst.u3.all[0] == t2->dst.u3.all[0] &&
158 t1->dst.u3.all[1] == t2->dst.u3.all[1] && 150 t1->dst.u3.all[1] == t2->dst.u3.all[1] &&
159 t1->dst.u3.all[2] == t2->dst.u3.all[2] && 151 t1->dst.u3.all[2] == t2->dst.u3.all[2] &&
160 t1->dst.u3.all[3] == t2->dst.u3.all[3] && 152 t1->dst.u3.all[3] == t2->dst.u3.all[3] &&
161 t1->dst.u.all == t2->dst.u.all && 153 t1->dst.u.all == t2->dst.u.all &&
162 t1->src.l3num == t2->src.l3num &&
163 t1->dst.protonum == t2->dst.protonum); 154 t1->dst.protonum == t2->dst.protonum);
164} 155}
165 156
166static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1, 157static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1,
167 const struct nf_conntrack_tuple *t2) 158 const struct nf_conntrack_tuple *t2)
168{ 159{
169 return nf_ct_tuple_src_equal(t1, t2) && nf_ct_tuple_dst_equal(t1, t2); 160 return __nf_ct_tuple_src_equal(t1, t2) &&
161 __nf_ct_tuple_dst_equal(t1, t2);
170} 162}
171 163
172static inline int nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1, 164static inline int nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1,
@@ -206,7 +198,7 @@ static inline int nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t,
206 const struct nf_conntrack_tuple_mask *mask) 198 const struct nf_conntrack_tuple_mask *mask)
207{ 199{
208 return nf_ct_tuple_src_mask_cmp(t, tuple, mask) && 200 return nf_ct_tuple_src_mask_cmp(t, tuple, mask) &&
209 nf_ct_tuple_dst_equal(t, tuple); 201 __nf_ct_tuple_dst_equal(t, tuple);
210} 202}
211 203
212#endif /* _NF_CONNTRACK_TUPLE_H */ 204#endif /* _NF_CONNTRACK_TUPLE_H */
diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h
new file mode 100644
index 000000000000..8c6b5ae45534
--- /dev/null
+++ b/include/net/netfilter/nf_log.h
@@ -0,0 +1,59 @@
1#ifndef _NF_LOG_H
2#define _NF_LOG_H
3
4/* those NF_LOG_* defines and struct nf_loginfo are legacy definitios that will
5 * disappear once iptables is replaced with pkttables. Please DO NOT use them
6 * for any new code! */
7#define NF_LOG_TCPSEQ 0x01 /* Log TCP sequence numbers */
8#define NF_LOG_TCPOPT 0x02 /* Log TCP options */
9#define NF_LOG_IPOPT 0x04 /* Log IP options */
10#define NF_LOG_UID 0x08 /* Log UID owning local socket */
11#define NF_LOG_MASK 0x0f
12
13#define NF_LOG_TYPE_LOG 0x01
14#define NF_LOG_TYPE_ULOG 0x02
15
16struct nf_loginfo {
17 u_int8_t type;
18 union {
19 struct {
20 u_int32_t copy_len;
21 u_int16_t group;
22 u_int16_t qthreshold;
23 } ulog;
24 struct {
25 u_int8_t level;
26 u_int8_t logflags;
27 } log;
28 } u;
29};
30
31typedef void nf_logfn(unsigned int pf,
32 unsigned int hooknum,
33 const struct sk_buff *skb,
34 const struct net_device *in,
35 const struct net_device *out,
36 const struct nf_loginfo *li,
37 const char *prefix);
38
39struct nf_logger {
40 struct module *me;
41 nf_logfn *logfn;
42 char *name;
43};
44
45/* Function to register/unregister log function. */
46int nf_log_register(int pf, const struct nf_logger *logger);
47void nf_log_unregister(const struct nf_logger *logger);
48void nf_log_unregister_pf(int pf);
49
50/* Calls the registered backend logging function */
51void nf_log_packet(int pf,
52 unsigned int hooknum,
53 const struct sk_buff *skb,
54 const struct net_device *in,
55 const struct net_device *out,
56 const struct nf_loginfo *li,
57 const char *fmt, ...) __attribute__ ((format(printf,7,8)));
58
59#endif /* _NF_LOG_H */
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h
index 6ae52f7c9f55..9dc1039ff78b 100644
--- a/include/net/netfilter/nf_nat.h
+++ b/include/net/netfilter/nf_nat.h
@@ -12,7 +12,8 @@ enum nf_nat_manip_type
12}; 12};
13 13
14/* SRC manip occurs POST_ROUTING or LOCAL_IN */ 14/* SRC manip occurs POST_ROUTING or LOCAL_IN */
15#define HOOK2MANIP(hooknum) ((hooknum) != NF_IP_POST_ROUTING && (hooknum) != NF_IP_LOCAL_IN) 15#define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \
16 (hooknum) != NF_INET_LOCAL_IN)
16 17
17#define IP_NAT_RANGE_MAP_IPS 1 18#define IP_NAT_RANGE_MAP_IPS 1
18#define IP_NAT_RANGE_PROTO_SPECIFIED 2 19#define IP_NAT_RANGE_PROTO_SPECIFIED 2
@@ -79,7 +80,7 @@ struct nf_conn_nat
79/* Set up the info structure to map into this range. */ 80/* Set up the info structure to map into this range. */
80extern unsigned int nf_nat_setup_info(struct nf_conn *ct, 81extern unsigned int nf_nat_setup_info(struct nf_conn *ct,
81 const struct nf_nat_range *range, 82 const struct nf_nat_range *range,
82 unsigned int hooknum); 83 enum nf_nat_manip_type maniptype);
83 84
84/* Is this tuple already taken? (not by us)*/ 85/* Is this tuple already taken? (not by us)*/
85extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, 86extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h
index 04578bfe23e1..4aa0edbb5b96 100644
--- a/include/net/netfilter/nf_nat_protocol.h
+++ b/include/net/netfilter/nf_nat_protocol.h
@@ -46,21 +46,21 @@ struct nf_nat_protocol
46}; 46};
47 47
48/* Protocol registration. */ 48/* Protocol registration. */
49extern int nf_nat_protocol_register(struct nf_nat_protocol *proto); 49extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto);
50extern void nf_nat_protocol_unregister(struct nf_nat_protocol *proto); 50extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto);
51 51
52extern struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); 52extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol);
53extern void nf_nat_proto_put(struct nf_nat_protocol *proto); 53extern void nf_nat_proto_put(const struct nf_nat_protocol *proto);
54 54
55/* Built-in protocols. */ 55/* Built-in protocols. */
56extern struct nf_nat_protocol nf_nat_protocol_tcp; 56extern const struct nf_nat_protocol nf_nat_protocol_tcp;
57extern struct nf_nat_protocol nf_nat_protocol_udp; 57extern const struct nf_nat_protocol nf_nat_protocol_udp;
58extern struct nf_nat_protocol nf_nat_protocol_icmp; 58extern const struct nf_nat_protocol nf_nat_protocol_icmp;
59extern struct nf_nat_protocol nf_nat_unknown_protocol; 59extern const struct nf_nat_protocol nf_nat_unknown_protocol;
60 60
61extern int init_protocols(void) __init; 61extern int init_protocols(void) __init;
62extern void cleanup_protocols(void); 62extern void cleanup_protocols(void);
63extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); 63extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum);
64 64
65extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb, 65extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb,
66 const struct nf_nat_range *range); 66 const struct nf_nat_range *range);
diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h
new file mode 100644
index 000000000000..d030044e9235
--- /dev/null
+++ b/include/net/netfilter/nf_queue.h
@@ -0,0 +1,34 @@
1#ifndef _NF_QUEUE_H
2#define _NF_QUEUE_H
3
4/* Each queued (to userspace) skbuff has one of these. */
5struct nf_queue_entry {
6 struct list_head list;
7 struct sk_buff *skb;
8 unsigned int id;
9
10 struct nf_hook_ops *elem;
11 int pf;
12 unsigned int hook;
13 struct net_device *indev;
14 struct net_device *outdev;
15 int (*okfn)(struct sk_buff *);
16};
17
18#define nf_queue_entry_reroute(x) ((void *)x + sizeof(struct nf_queue_entry))
19
20/* Packet queuing */
21struct nf_queue_handler {
22 int (*outfn)(struct nf_queue_entry *entry,
23 unsigned int queuenum);
24 char *name;
25};
26
27extern int nf_register_queue_handler(int pf,
28 const struct nf_queue_handler *qh);
29extern int nf_unregister_queue_handler(int pf,
30 const struct nf_queue_handler *qh);
31extern void nf_unregister_queue_handlers(const struct nf_queue_handler *qh);
32extern void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict);
33
34#endif /* _NF_QUEUE_H */
diff --git a/include/net/netfilter/xt_rateest.h b/include/net/netfilter/xt_rateest.h
new file mode 100644
index 000000000000..65d594dffbff
--- /dev/null
+++ b/include/net/netfilter/xt_rateest.h
@@ -0,0 +1,17 @@
1#ifndef _XT_RATEEST_H
2#define _XT_RATEEST_H
3
4struct xt_rateest {
5 struct hlist_node list;
6 char name[IFNAMSIZ];
7 unsigned int refcnt;
8 spinlock_t lock;
9 struct gnet_estimator params;
10 struct gnet_stats_rate_est rstats;
11 struct gnet_stats_basic bstats;
12};
13
14extern struct xt_rateest *xt_rateest_lookup(const char *name);
15extern void xt_rateest_put(struct xt_rateest *est);
16
17#endif /* _XT_RATEEST_H */
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index 2e5b2f6f9fa0..b3213c7c5309 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -67,7 +67,11 @@
67 * NetLabel NETLINK protocol 67 * NetLabel NETLINK protocol
68 */ 68 */
69 69
70#define NETLBL_PROTO_VERSION 1 70/* NetLabel NETLINK protocol version
71 * 1: initial version
72 * 2: added static labels for unlabeled connections
73 */
74#define NETLBL_PROTO_VERSION 2
71 75
72/* NetLabel NETLINK types/families */ 76/* NetLabel NETLINK types/families */
73#define NETLBL_NLTYPE_NONE 0 77#define NETLBL_NLTYPE_NONE 0
@@ -105,17 +109,49 @@ struct netlbl_dom_map;
105/* Domain mapping operations */ 109/* Domain mapping operations */
106int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info); 110int netlbl_domhsh_remove(const char *domain, struct netlbl_audit *audit_info);
107 111
108/* LSM security attributes */ 112/*
113 * LSM security attributes
114 */
115
116/**
117 * struct netlbl_lsm_cache - NetLabel LSM security attribute cache
118 * @refcount: atomic reference counter
119 * @free: LSM supplied function to free the cache data
120 * @data: LSM supplied cache data
121 *
122 * Description:
123 * This structure is provided for LSMs which wish to make use of the NetLabel
124 * caching mechanism to store LSM specific data/attributes in the NetLabel
125 * cache. If the LSM has to perform a lot of translation from the NetLabel
126 * security attributes into it's own internal representation then the cache
127 * mechanism can provide a way to eliminate some or all of that translation
128 * overhead on a cache hit.
129 *
130 */
109struct netlbl_lsm_cache { 131struct netlbl_lsm_cache {
110 atomic_t refcount; 132 atomic_t refcount;
111 void (*free) (const void *data); 133 void (*free) (const void *data);
112 void *data; 134 void *data;
113}; 135};
114/* The catmap bitmap field MUST be a power of two in length and large 136
137/**
138 * struct netlbl_lsm_secattr_catmap - NetLabel LSM secattr category bitmap
139 * @startbit: the value of the lowest order bit in the bitmap
140 * @bitmap: the category bitmap
141 * @next: pointer to the next bitmap "node" or NULL
142 *
143 * Description:
144 * This structure is used to represent category bitmaps. Due to the large
145 * number of categories supported by most labeling protocols it is not
146 * practical to transfer a full bitmap internally so NetLabel adopts a sparse
147 * bitmap structure modeled after SELinux's ebitmap structure.
148 * The catmap bitmap field MUST be a power of two in length and large
115 * enough to hold at least 240 bits. Special care (i.e. check the code!) 149 * enough to hold at least 240 bits. Special care (i.e. check the code!)
116 * should be used when changing these values as the LSM implementation 150 * should be used when changing these values as the LSM implementation
117 * probably has functions which rely on the sizes of these types to speed 151 * probably has functions which rely on the sizes of these types to speed
118 * processing. */ 152 * processing.
153 *
154 */
119#define NETLBL_CATMAP_MAPTYPE u64 155#define NETLBL_CATMAP_MAPTYPE u64
120#define NETLBL_CATMAP_MAPCNT 4 156#define NETLBL_CATMAP_MAPCNT 4
121#define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8) 157#define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8)
@@ -127,22 +163,48 @@ struct netlbl_lsm_secattr_catmap {
127 NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT]; 163 NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT];
128 struct netlbl_lsm_secattr_catmap *next; 164 struct netlbl_lsm_secattr_catmap *next;
129}; 165};
166
167/**
168 * struct netlbl_lsm_secattr - NetLabel LSM security attributes
169 * @flags: indicate which attributes are contained in this structure
170 * @type: indicate the NLTYPE of the attributes
171 * @domain: the NetLabel LSM domain
172 * @cache: NetLabel LSM specific cache
173 * @attr.mls: MLS sensitivity label
174 * @attr.mls.cat: MLS category bitmap
175 * @attr.mls.lvl: MLS sensitivity level
176 * @attr.secid: LSM specific secid token
177 *
178 * Description:
179 * This structure is used to pass security attributes between NetLabel and the
180 * LSM modules. The flags field is used to specify which fields within the
181 * struct are valid and valid values can be created by bitwise OR'ing the
182 * NETLBL_SECATTR_* defines. The domain field is typically set by the LSM to
183 * specify domain specific configuration settings and is not usually used by
184 * NetLabel itself when returning security attributes to the LSM.
185 *
186 */
130#define NETLBL_SECATTR_NONE 0x00000000 187#define NETLBL_SECATTR_NONE 0x00000000
131#define NETLBL_SECATTR_DOMAIN 0x00000001 188#define NETLBL_SECATTR_DOMAIN 0x00000001
132#define NETLBL_SECATTR_CACHE 0x00000002 189#define NETLBL_SECATTR_CACHE 0x00000002
133#define NETLBL_SECATTR_MLS_LVL 0x00000004 190#define NETLBL_SECATTR_MLS_LVL 0x00000004
134#define NETLBL_SECATTR_MLS_CAT 0x00000008 191#define NETLBL_SECATTR_MLS_CAT 0x00000008
192#define NETLBL_SECATTR_SECID 0x00000010
135#define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \ 193#define NETLBL_SECATTR_CACHEABLE (NETLBL_SECATTR_MLS_LVL | \
136 NETLBL_SECATTR_MLS_CAT) 194 NETLBL_SECATTR_MLS_CAT | \
195 NETLBL_SECATTR_SECID)
137struct netlbl_lsm_secattr { 196struct netlbl_lsm_secattr {
138 u32 flags; 197 u32 flags;
139 198 u32 type;
140 char *domain; 199 char *domain;
141
142 u32 mls_lvl;
143 struct netlbl_lsm_secattr_catmap *mls_cat;
144
145 struct netlbl_lsm_cache *cache; 200 struct netlbl_lsm_cache *cache;
201 union {
202 struct {
203 struct netlbl_lsm_secattr_catmap *cat;
204 u32 lvl;
205 } mls;
206 u32 secid;
207 } attr;
146}; 208};
147 209
148/* 210/*
@@ -231,10 +293,7 @@ static inline void netlbl_secattr_catmap_free(
231 */ 293 */
232static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr) 294static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
233{ 295{
234 secattr->flags = 0; 296 memset(secattr, 0, sizeof(*secattr));
235 secattr->domain = NULL;
236 secattr->mls_cat = NULL;
237 secattr->cache = NULL;
238} 297}
239 298
240/** 299/**
@@ -248,11 +307,11 @@ static inline void netlbl_secattr_init(struct netlbl_lsm_secattr *secattr)
248 */ 307 */
249static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr) 308static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
250{ 309{
251 if (secattr->cache)
252 netlbl_secattr_cache_free(secattr->cache);
253 kfree(secattr->domain); 310 kfree(secattr->domain);
254 if (secattr->mls_cat) 311 if (secattr->flags & NETLBL_SECATTR_CACHE)
255 netlbl_secattr_catmap_free(secattr->mls_cat); 312 netlbl_secattr_cache_free(secattr->cache);
313 if (secattr->flags & NETLBL_SECATTR_MLS_CAT)
314 netlbl_secattr_catmap_free(secattr->attr.mls.cat);
256} 315}
257 316
258/** 317/**
@@ -300,7 +359,7 @@ int netlbl_secattr_catmap_setrng(struct netlbl_lsm_secattr_catmap *catmap,
300 gfp_t flags); 359 gfp_t flags);
301 360
302/* 361/*
303 * LSM protocol operations 362 * LSM protocol operations (NetLabel LSM/kernel API)
304 */ 363 */
305int netlbl_enabled(void); 364int netlbl_enabled(void);
306int netlbl_sock_setattr(struct sock *sk, 365int netlbl_sock_setattr(struct sock *sk,
@@ -308,6 +367,7 @@ int netlbl_sock_setattr(struct sock *sk,
308int netlbl_sock_getattr(struct sock *sk, 367int netlbl_sock_getattr(struct sock *sk,
309 struct netlbl_lsm_secattr *secattr); 368 struct netlbl_lsm_secattr *secattr);
310int netlbl_skbuff_getattr(const struct sk_buff *skb, 369int netlbl_skbuff_getattr(const struct sk_buff *skb,
370 u16 family,
311 struct netlbl_lsm_secattr *secattr); 371 struct netlbl_lsm_secattr *secattr);
312void netlbl_skbuff_err(struct sk_buff *skb, int error); 372void netlbl_skbuff_err(struct sk_buff *skb, int error);
313 373
@@ -360,6 +420,7 @@ static inline int netlbl_sock_getattr(struct sock *sk,
360 return -ENOSYS; 420 return -ENOSYS;
361} 421}
362static inline int netlbl_skbuff_getattr(const struct sk_buff *skb, 422static inline int netlbl_skbuff_getattr(const struct sk_buff *skb,
423 u16 family,
363 struct netlbl_lsm_secattr *secattr) 424 struct netlbl_lsm_secattr *secattr)
364{ 425{
365 return -ENOSYS; 426 return -ENOSYS;
diff --git a/include/net/netlink.h b/include/net/netlink.h
index 9298218c07f9..a5506c42f03c 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -91,6 +91,7 @@
91 * nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr 91 * nla_reserve_nohdr(skb, len) reserve room for an attribute w/o hdr
92 * nla_put(skb, type, len, data) add attribute to skb 92 * nla_put(skb, type, len, data) add attribute to skb
93 * nla_put_nohdr(skb, len, data) add attribute w/o hdr 93 * nla_put_nohdr(skb, len, data) add attribute w/o hdr
94 * nla_append(skb, len, data) append data to skb
94 * 95 *
95 * Attribute Construction for Basic Types: 96 * Attribute Construction for Basic Types:
96 * nla_put_u8(skb, type, value) add u8 attribute to skb 97 * nla_put_u8(skb, type, value) add u8 attribute to skb
@@ -217,6 +218,7 @@ struct nla_policy {
217 */ 218 */
218struct nl_info { 219struct nl_info {
219 struct nlmsghdr *nlh; 220 struct nlmsghdr *nlh;
221 struct net *nl_net;
220 u32 pid; 222 u32 pid;
221}; 223};
222 224
@@ -253,6 +255,8 @@ extern int nla_put(struct sk_buff *skb, int attrtype,
253 int attrlen, const void *data); 255 int attrlen, const void *data);
254extern int nla_put_nohdr(struct sk_buff *skb, int attrlen, 256extern int nla_put_nohdr(struct sk_buff *skb, int attrlen,
255 const void *data); 257 const void *data);
258extern int nla_append(struct sk_buff *skb, int attrlen,
259 const void *data);
256 260
257/************************************************************************** 261/**************************************************************************
258 * Netlink Messages 262 * Netlink Messages
@@ -862,7 +866,7 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
862 866
863#define NLA_PUT(skb, attrtype, attrlen, data) \ 867#define NLA_PUT(skb, attrtype, attrlen, data) \
864 do { \ 868 do { \
865 if (nla_put(skb, attrtype, attrlen, data) < 0) \ 869 if (unlikely(nla_put(skb, attrtype, attrlen, data) < 0)) \
866 goto nla_put_failure; \ 870 goto nla_put_failure; \
867 } while(0) 871 } while(0)
868 872
@@ -881,6 +885,9 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype,
881#define NLA_PUT_LE16(skb, attrtype, value) \ 885#define NLA_PUT_LE16(skb, attrtype, value) \
882 NLA_PUT_TYPE(skb, __le16, attrtype, value) 886 NLA_PUT_TYPE(skb, __le16, attrtype, value)
883 887
888#define NLA_PUT_BE16(skb, attrtype, value) \
889 NLA_PUT_TYPE(skb, __be16, attrtype, value)
890
884#define NLA_PUT_U32(skb, attrtype, value) \ 891#define NLA_PUT_U32(skb, attrtype, value) \
885 NLA_PUT_TYPE(skb, u32, attrtype, value) 892 NLA_PUT_TYPE(skb, u32, attrtype, value)
886 893
@@ -927,6 +934,15 @@ static inline u16 nla_get_u16(struct nlattr *nla)
927} 934}
928 935
929/** 936/**
937 * nla_get_be16 - return payload of __be16 attribute
938 * @nla: __be16 netlink attribute
939 */
940static inline __be16 nla_get_be16(struct nlattr *nla)
941{
942 return *(__be16 *) nla_data(nla);
943}
944
945/**
930 * nla_get_le16 - return payload of __le16 attribute 946 * nla_get_le16 - return payload of __le16 attribute
931 * @nla: __le16 netlink attribute 947 * @nla: __le16 netlink attribute
932 */ 948 */
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
new file mode 100644
index 000000000000..a9b4f6086294
--- /dev/null
+++ b/include/net/netns/ipv4.h
@@ -0,0 +1,37 @@
1/*
2 * ipv4 in net namespaces
3 */
4
5#ifndef __NETNS_IPV4_H__
6#define __NETNS_IPV4_H__
7
8#include <net/inet_frag.h>
9
10struct ctl_table_header;
11struct ipv4_devconf;
12struct fib_rules_ops;
13struct hlist_head;
14struct sock;
15
16struct netns_ipv4 {
17#ifdef CONFIG_SYSCTL
18 struct ctl_table_header *forw_hdr;
19 struct ctl_table_header *frags_hdr;
20#endif
21 struct ipv4_devconf *devconf_all;
22 struct ipv4_devconf *devconf_dflt;
23#ifdef CONFIG_IP_MULTIPLE_TABLES
24 struct fib_rules_ops *rules_ops;
25#endif
26 struct hlist_head *fib_table_hash;
27 struct sock *fibnl;
28
29 struct netns_frags frags;
30#ifdef CONFIG_NETFILTER
31 struct xt_table *iptable_filter;
32 struct xt_table *iptable_mangle;
33 struct xt_table *iptable_raw;
34 struct xt_table *arptable_filter;
35#endif
36};
37#endif
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
new file mode 100644
index 000000000000..1dd7de4e4195
--- /dev/null
+++ b/include/net/netns/ipv6.h
@@ -0,0 +1,40 @@
1/*
2 * ipv6 in net namespaces
3 */
4
5#include <net/inet_frag.h>
6
7#ifndef __NETNS_IPV6_H__
8#define __NETNS_IPV6_H__
9
10struct ctl_table_header;
11
12struct netns_sysctl_ipv6 {
13#ifdef CONFIG_SYSCTL
14 struct ctl_table_header *table;
15 struct ctl_table_header *frags_hdr;
16#endif
17 int bindv6only;
18 int flush_delay;
19 int ip6_rt_max_size;
20 int ip6_rt_gc_min_interval;
21 int ip6_rt_gc_timeout;
22 int ip6_rt_gc_interval;
23 int ip6_rt_gc_elasticity;
24 int ip6_rt_mtu_expires;
25 int ip6_rt_min_advmss;
26 int icmpv6_time;
27};
28
29struct netns_ipv6 {
30 struct netns_sysctl_ipv6 sysctl;
31 struct ipv6_devconf *devconf_all;
32 struct ipv6_devconf *devconf_dflt;
33 struct netns_frags frags;
34#ifdef CONFIG_NETFILTER
35 struct xt_table *ip6table_filter;
36 struct xt_table *ip6table_mangle;
37 struct xt_table *ip6table_raw;
38#endif
39};
40#endif
diff --git a/include/net/netns/packet.h b/include/net/netns/packet.h
new file mode 100644
index 000000000000..637daf698884
--- /dev/null
+++ b/include/net/netns/packet.h
@@ -0,0 +1,15 @@
1/*
2 * Packet network namespace
3 */
4#ifndef __NETNS_PACKET_H__
5#define __NETNS_PACKET_H__
6
7#include <linux/list.h>
8#include <linux/spinlock.h>
9
10struct netns_packet {
11 rwlock_t sklist_lock;
12 struct hlist_head sklist;
13};
14
15#endif /* __NETNS_PACKET_H__ */
diff --git a/include/net/netns/unix.h b/include/net/netns/unix.h
new file mode 100644
index 000000000000..284649d4dfb4
--- /dev/null
+++ b/include/net/netns/unix.h
@@ -0,0 +1,13 @@
1/*
2 * Unix network namespace
3 */
4#ifndef __NETNS_UNIX_H__
5#define __NETNS_UNIX_H__
6
7struct ctl_table_header;
8struct netns_unix {
9 int sysctl_max_dgram_qlen;
10 struct ctl_table_header *ctl;
11};
12
13#endif /* __NETNS_UNIX_H__ */
diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h
new file mode 100644
index 000000000000..0cb63ed2c1fc
--- /dev/null
+++ b/include/net/netns/x_tables.h
@@ -0,0 +1,10 @@
1#ifndef __NETNS_X_TABLES_H
2#define __NETNS_X_TABLES_H
3
4#include <linux/list.h>
5#include <linux/net.h>
6
7struct netns_xt {
8 struct list_head tables[NPROTO];
9};
10#endif
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
index f285de69c615..d349c66ef828 100644
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -2,7 +2,6 @@
2#define __NET_PKT_CLS_H 2#define __NET_PKT_CLS_H
3 3
4#include <linux/pkt_cls.h> 4#include <linux/pkt_cls.h>
5#include <net/net_namespace.h>
6#include <net/sch_generic.h> 5#include <net/sch_generic.h>
7#include <net/act_api.h> 6#include <net/act_api.h>
8 7
@@ -130,16 +129,16 @@ tcf_exts_exec(struct sk_buff *skb, struct tcf_exts *exts,
130 return 0; 129 return 0;
131} 130}
132 131
133extern int tcf_exts_validate(struct tcf_proto *tp, struct rtattr **tb, 132extern int tcf_exts_validate(struct tcf_proto *tp, struct nlattr **tb,
134 struct rtattr *rate_tlv, struct tcf_exts *exts, 133 struct nlattr *rate_tlv, struct tcf_exts *exts,
135 struct tcf_ext_map *map); 134 const struct tcf_ext_map *map);
136extern void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts); 135extern void tcf_exts_destroy(struct tcf_proto *tp, struct tcf_exts *exts);
137extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst, 136extern void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst,
138 struct tcf_exts *src); 137 struct tcf_exts *src);
139extern int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts, 138extern int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts,
140 struct tcf_ext_map *map); 139 const struct tcf_ext_map *map);
141extern int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts, 140extern int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts,
142 struct tcf_ext_map *map); 141 const struct tcf_ext_map *map);
143 142
144/** 143/**
145 * struct tcf_pkt_info - packet information 144 * struct tcf_pkt_info - packet information
@@ -248,7 +247,7 @@ struct tcf_ematch_ops
248 247
249extern int tcf_em_register(struct tcf_ematch_ops *); 248extern int tcf_em_register(struct tcf_ematch_ops *);
250extern int tcf_em_unregister(struct tcf_ematch_ops *); 249extern int tcf_em_unregister(struct tcf_ematch_ops *);
251extern int tcf_em_tree_validate(struct tcf_proto *, struct rtattr *, 250extern int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *,
252 struct tcf_ematch_tree *); 251 struct tcf_ematch_tree *);
253extern void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *); 252extern void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *);
254extern int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int); 253extern int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int);
@@ -336,10 +335,12 @@ static inline int tcf_valid_offset(const struct sk_buff *skb,
336} 335}
337 336
338#ifdef CONFIG_NET_CLS_IND 337#ifdef CONFIG_NET_CLS_IND
338#include <net/net_namespace.h>
339
339static inline int 340static inline int
340tcf_change_indev(struct tcf_proto *tp, char *indev, struct rtattr *indev_tlv) 341tcf_change_indev(struct tcf_proto *tp, char *indev, struct nlattr *indev_tlv)
341{ 342{
342 if (rtattr_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ) 343 if (nla_strlcpy(indev, indev_tlv, IFNAMSIZ) >= IFNAMSIZ)
343 return -EINVAL; 344 return -EINVAL;
344 return 0; 345 return 0;
345} 346}
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index ab61809a9616..46fb4d80c74a 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -77,7 +77,7 @@ extern int unregister_qdisc(struct Qdisc_ops *qops);
77extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle); 77extern struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);
78extern struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle); 78extern struct Qdisc *qdisc_lookup_class(struct net_device *dev, u32 handle);
79extern struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, 79extern struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r,
80 struct rtattr *tab); 80 struct nlattr *tab);
81extern void qdisc_put_rtab(struct qdisc_rate_table *tab); 81extern void qdisc_put_rtab(struct qdisc_rate_table *tab);
82 82
83extern void __qdisc_run(struct net_device *dev); 83extern void __qdisc_run(struct net_device *dev);
diff --git a/include/net/protocol.h b/include/net/protocol.h
index 1166ffb4b3ec..ad8c584233a6 100644
--- a/include/net/protocol.h
+++ b/include/net/protocol.h
@@ -102,7 +102,7 @@ extern void inet_unregister_protosw(struct inet_protosw *p);
102#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) 102#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
103extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num); 103extern int inet6_add_protocol(struct inet6_protocol *prot, unsigned char num);
104extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num); 104extern int inet6_del_protocol(struct inet6_protocol *prot, unsigned char num);
105extern void inet6_register_protosw(struct inet_protosw *p); 105extern int inet6_register_protosw(struct inet_protosw *p);
106extern void inet6_unregister_protosw(struct inet_protosw *p); 106extern void inet6_unregister_protosw(struct inet_protosw *p);
107#endif 107#endif
108 108
diff --git a/include/net/raw.h b/include/net/raw.h
index e4af59781949..1828f81fe374 100644
--- a/include/net/raw.h
+++ b/include/net/raw.h
@@ -22,27 +22,38 @@
22 22
23extern struct proto raw_prot; 23extern struct proto raw_prot;
24 24
25extern void raw_err(struct sock *, struct sk_buff *, u32 info); 25void raw_icmp_error(struct sk_buff *, int, u32);
26extern int raw_rcv(struct sock *, struct sk_buff *); 26int raw_local_deliver(struct sk_buff *, int);
27
28/* Note: v4 ICMP wants to get at this stuff, if you change the
29 * hashing mechanism, make sure you update icmp.c as well.
30 */
31#define RAWV4_HTABLE_SIZE MAX_INET_PROTOS
32extern struct hlist_head raw_v4_htable[RAWV4_HTABLE_SIZE];
33
34extern rwlock_t raw_v4_lock;
35 27
28extern int raw_rcv(struct sock *, struct sk_buff *);
36 29
37extern struct sock *__raw_v4_lookup(struct sock *sk, unsigned short num, 30#define RAW_HTABLE_SIZE MAX_INET_PROTOS
38 __be32 raddr, __be32 laddr,
39 int dif);
40 31
41extern int raw_v4_input(struct sk_buff *skb, struct iphdr *iph, int hash); 32struct raw_hashinfo {
33 rwlock_t lock;
34 struct hlist_head ht[RAW_HTABLE_SIZE];
35};
42 36
43#ifdef CONFIG_PROC_FS 37#ifdef CONFIG_PROC_FS
44extern int raw_proc_init(void); 38extern int raw_proc_init(void);
45extern void raw_proc_exit(void); 39extern void raw_proc_exit(void);
40
41struct raw_iter_state {
42 struct seq_net_private p;
43 int bucket;
44 struct raw_hashinfo *h;
45};
46
47#define raw_seq_private(seq) ((struct raw_iter_state *)(seq)->private)
48void *raw_seq_start(struct seq_file *seq, loff_t *pos);
49void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
50void raw_seq_stop(struct seq_file *seq, void *v);
51int raw_seq_open(struct inode *ino, struct file *file,
52 struct raw_hashinfo *h, const struct seq_operations *ops);
53
46#endif 54#endif
47 55
56void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h);
57void raw_unhash_sk(struct sock *sk, struct raw_hashinfo *h);
58
48#endif /* _RAW_H */ 59#endif /* _RAW_H */
diff --git a/include/net/rawv6.h b/include/net/rawv6.h
index a5819891d525..8a22599f26ba 100644
--- a/include/net/rawv6.h
+++ b/include/net/rawv6.h
@@ -5,26 +5,13 @@
5 5
6#include <net/protocol.h> 6#include <net/protocol.h>
7 7
8#define RAWV6_HTABLE_SIZE MAX_INET_PROTOS 8void raw6_icmp_error(struct sk_buff *, int nexthdr,
9extern struct hlist_head raw_v6_htable[RAWV6_HTABLE_SIZE]; 9 int type, int code, int inner_offset, __be32);
10extern rwlock_t raw_v6_lock; 10int raw6_local_deliver(struct sk_buff *, int);
11
12extern int ipv6_raw_deliver(struct sk_buff *skb, int nexthdr);
13
14extern struct sock *__raw_v6_lookup(struct sock *sk, unsigned short num,
15 struct in6_addr *loc_addr, struct in6_addr *rmt_addr,
16 int dif);
17 11
18extern int rawv6_rcv(struct sock *sk, 12extern int rawv6_rcv(struct sock *sk,
19 struct sk_buff *skb); 13 struct sk_buff *skb);
20 14
21
22extern void rawv6_err(struct sock *sk,
23 struct sk_buff *skb,
24 struct inet6_skb_parm *opt,
25 int type, int code,
26 int offset, __be32 info);
27
28#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) 15#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
29int rawv6_mh_filter_register(int (*filter)(struct sock *sock, 16int rawv6_mh_filter_register(int (*filter)(struct sock *sock,
30 struct sk_buff *skb)); 17 struct sk_buff *skb));
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 7aed02ce2b65..cff4608179c1 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -124,23 +124,7 @@ struct request_sock_queue {
124extern int reqsk_queue_alloc(struct request_sock_queue *queue, 124extern int reqsk_queue_alloc(struct request_sock_queue *queue,
125 unsigned int nr_table_entries); 125 unsigned int nr_table_entries);
126 126
127static inline struct listen_sock *reqsk_queue_yank_listen_sk(struct request_sock_queue *queue) 127extern void __reqsk_queue_destroy(struct request_sock_queue *queue);
128{
129 struct listen_sock *lopt;
130
131 write_lock_bh(&queue->syn_wait_lock);
132 lopt = queue->listen_opt;
133 queue->listen_opt = NULL;
134 write_unlock_bh(&queue->syn_wait_lock);
135
136 return lopt;
137}
138
139static inline void __reqsk_queue_destroy(struct request_sock_queue *queue)
140{
141 kfree(reqsk_queue_yank_listen_sk(queue));
142}
143
144extern void reqsk_queue_destroy(struct request_sock_queue *queue); 128extern void reqsk_queue_destroy(struct request_sock_queue *queue);
145 129
146static inline struct request_sock * 130static inline struct request_sock *
diff --git a/include/net/route.h b/include/net/route.h
index f7ce6259f86f..eadad5901429 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -27,12 +27,14 @@
27#include <net/dst.h> 27#include <net/dst.h>
28#include <net/inetpeer.h> 28#include <net/inetpeer.h>
29#include <net/flow.h> 29#include <net/flow.h>
30#include <net/sock.h>
30#include <linux/in_route.h> 31#include <linux/in_route.h>
31#include <linux/rtnetlink.h> 32#include <linux/rtnetlink.h>
32#include <linux/route.h> 33#include <linux/route.h>
33#include <linux/ip.h> 34#include <linux/ip.h>
34#include <linux/cache.h> 35#include <linux/cache.h>
35#include <linux/security.h> 36#include <linux/security.h>
37#include <net/sock.h>
36 38
37#ifndef __KERNEL__ 39#ifndef __KERNEL__
38#warning This file is not supposed to be used outside of kernel. 40#warning This file is not supposed to be used outside of kernel.
@@ -60,6 +62,7 @@ struct rtable
60 62
61 struct in_device *idev; 63 struct in_device *idev;
62 64
65 int rt_genid;
63 unsigned rt_flags; 66 unsigned rt_flags;
64 __u16 rt_type; 67 __u16 rt_type;
65 68
@@ -109,18 +112,18 @@ struct in_device;
109extern int ip_rt_init(void); 112extern int ip_rt_init(void);
110extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, 113extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw,
111 __be32 src, struct net_device *dev); 114 __be32 src, struct net_device *dev);
112extern void ip_rt_advice(struct rtable **rp, int advice);
113extern void rt_cache_flush(int how); 115extern void rt_cache_flush(int how);
114extern int __ip_route_output_key(struct rtable **, const struct flowi *flp); 116extern int __ip_route_output_key(struct net *, struct rtable **, const struct flowi *flp);
115extern int ip_route_output_key(struct rtable **, struct flowi *flp); 117extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp);
116extern int ip_route_output_flow(struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); 118extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags);
117extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin); 119extern int ip_route_input(struct sk_buff*, __be32 dst, __be32 src, u8 tos, struct net_device *devin);
118extern unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu); 120extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu);
119extern void ip_rt_send_redirect(struct sk_buff *skb); 121extern void ip_rt_send_redirect(struct sk_buff *skb);
120 122
121extern unsigned inet_addr_type(__be32 addr); 123extern unsigned inet_addr_type(struct net *net, __be32 addr);
124extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr);
122extern void ip_rt_multicast_event(struct in_device *); 125extern void ip_rt_multicast_event(struct in_device *);
123extern int ip_rt_ioctl(unsigned int cmd, void __user *arg); 126extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg);
124extern void ip_rt_get_source(u8 *src, struct rtable *rt); 127extern void ip_rt_get_source(u8 *src, struct rtable *rt);
125extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); 128extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb);
126 129
@@ -148,6 +151,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
148 int flags) 151 int flags)
149{ 152{
150 struct flowi fl = { .oif = oif, 153 struct flowi fl = { .oif = oif,
154 .mark = sk->sk_mark,
151 .nl_u = { .ip4_u = { .daddr = dst, 155 .nl_u = { .ip4_u = { .daddr = dst,
152 .saddr = src, 156 .saddr = src,
153 .tos = tos } }, 157 .tos = tos } },
@@ -157,8 +161,9 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
157 .dport = dport } } }; 161 .dport = dport } } };
158 162
159 int err; 163 int err;
164 struct net *net = sk->sk_net;
160 if (!dst || !src) { 165 if (!dst || !src) {
161 err = __ip_route_output_key(rp, &fl); 166 err = __ip_route_output_key(net, rp, &fl);
162 if (err) 167 if (err)
163 return err; 168 return err;
164 fl.fl4_dst = (*rp)->rt_dst; 169 fl.fl4_dst = (*rp)->rt_dst;
@@ -167,7 +172,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
167 *rp = NULL; 172 *rp = NULL;
168 } 173 }
169 security_sk_classify_flow(sk, &fl); 174 security_sk_classify_flow(sk, &fl);
170 return ip_route_output_flow(rp, &fl, sk, flags); 175 return ip_route_output_flow(net, rp, &fl, sk, flags);
171} 176}
172 177
173static inline int ip_route_newports(struct rtable **rp, u8 protocol, 178static inline int ip_route_newports(struct rtable **rp, u8 protocol,
@@ -184,7 +189,7 @@ static inline int ip_route_newports(struct rtable **rp, u8 protocol,
184 ip_rt_put(*rp); 189 ip_rt_put(*rp);
185 *rp = NULL; 190 *rp = NULL;
186 security_sk_classify_flow(sk, &fl); 191 security_sk_classify_flow(sk, &fl);
187 return ip_route_output_flow(rp, &fl, sk, 0); 192 return ip_route_output_flow(sk->sk_net, rp, &fl, sk, 0);
188 } 193 }
189 return 0; 194 return 0;
190} 195}
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index c9265518a378..ab502ec1c61c 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -66,7 +66,7 @@ struct Qdisc_class_ops
66 unsigned long (*get)(struct Qdisc *, u32 classid); 66 unsigned long (*get)(struct Qdisc *, u32 classid);
67 void (*put)(struct Qdisc *, unsigned long); 67 void (*put)(struct Qdisc *, unsigned long);
68 int (*change)(struct Qdisc *, u32, u32, 68 int (*change)(struct Qdisc *, u32, u32,
69 struct rtattr **, unsigned long *); 69 struct nlattr **, unsigned long *);
70 int (*delete)(struct Qdisc *, unsigned long); 70 int (*delete)(struct Qdisc *, unsigned long);
71 void (*walk)(struct Qdisc *, struct qdisc_walker * arg); 71 void (*walk)(struct Qdisc *, struct qdisc_walker * arg);
72 72
@@ -86,7 +86,7 @@ struct Qdisc_class_ops
86struct Qdisc_ops 86struct Qdisc_ops
87{ 87{
88 struct Qdisc_ops *next; 88 struct Qdisc_ops *next;
89 struct Qdisc_class_ops *cl_ops; 89 const struct Qdisc_class_ops *cl_ops;
90 char id[IFNAMSIZ]; 90 char id[IFNAMSIZ];
91 int priv_size; 91 int priv_size;
92 92
@@ -95,10 +95,10 @@ struct Qdisc_ops
95 int (*requeue)(struct sk_buff *, struct Qdisc *); 95 int (*requeue)(struct sk_buff *, struct Qdisc *);
96 unsigned int (*drop)(struct Qdisc *); 96 unsigned int (*drop)(struct Qdisc *);
97 97
98 int (*init)(struct Qdisc *, struct rtattr *arg); 98 int (*init)(struct Qdisc *, struct nlattr *arg);
99 void (*reset)(struct Qdisc *); 99 void (*reset)(struct Qdisc *);
100 void (*destroy)(struct Qdisc *); 100 void (*destroy)(struct Qdisc *);
101 int (*change)(struct Qdisc *, struct rtattr *arg); 101 int (*change)(struct Qdisc *, struct nlattr *arg);
102 102
103 int (*dump)(struct Qdisc *, struct sk_buff *); 103 int (*dump)(struct Qdisc *, struct sk_buff *);
104 int (*dump_stats)(struct Qdisc *, struct gnet_dump *); 104 int (*dump_stats)(struct Qdisc *, struct gnet_dump *);
@@ -126,7 +126,7 @@ struct tcf_proto_ops
126 unsigned long (*get)(struct tcf_proto*, u32 handle); 126 unsigned long (*get)(struct tcf_proto*, u32 handle);
127 void (*put)(struct tcf_proto*, unsigned long); 127 void (*put)(struct tcf_proto*, unsigned long);
128 int (*change)(struct tcf_proto*, unsigned long, 128 int (*change)(struct tcf_proto*, unsigned long,
129 u32 handle, struct rtattr **, 129 u32 handle, struct nlattr **,
130 unsigned long *); 130 unsigned long *);
131 int (*delete)(struct tcf_proto*, unsigned long); 131 int (*delete)(struct tcf_proto*, unsigned long);
132 void (*walk)(struct tcf_proto*, struct tcf_walker *arg); 132 void (*walk)(struct tcf_proto*, struct tcf_walker *arg);
@@ -325,7 +325,6 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask)
325 n->tc_verd = SET_TC_VERD(n->tc_verd, 0); 325 n->tc_verd = SET_TC_VERD(n->tc_verd, 0);
326 n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd); 326 n->tc_verd = CLR_TC_OK2MUNGE(n->tc_verd);
327 n->tc_verd = CLR_TC_MUNGED(n->tc_verd); 327 n->tc_verd = CLR_TC_MUNGED(n->tc_verd);
328 n->iif = skb->iif;
329 } 328 }
330 return n; 329 return n;
331} 330}
diff --git a/include/net/sctp/auth.h b/include/net/sctp/auth.h
index 9e8f13b7da5a..5db261a1e85e 100644
--- a/include/net/sctp/auth.h
+++ b/include/net/sctp/auth.h
@@ -103,7 +103,7 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc);
103void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc, 103void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc,
104 struct sctp_hmac_algo_param *hmacs); 104 struct sctp_hmac_algo_param *hmacs);
105int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc, 105int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc,
106 __u16 hmac_id); 106 __be16 hmac_id);
107int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc); 107int sctp_auth_send_cid(sctp_cid_t chunk, const struct sctp_association *asoc);
108int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc); 108int sctp_auth_recv_cid(sctp_cid_t chunk, const struct sctp_association *asoc);
109void sctp_auth_calculate_hmac(const struct sctp_association *asoc, 109void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h
new file mode 100644
index 000000000000..ba75c67cb992
--- /dev/null
+++ b/include/net/sctp/checksum.h
@@ -0,0 +1,78 @@
1/* SCTP kernel reference Implementation
2 * Copyright (c) 1999-2001 Motorola, Inc.
3 * Copyright (c) 2001-2003 International Business Machines, Corp.
4 *
5 * This file is part of the SCTP kernel reference Implementation
6 *
7 * SCTP Checksum functions
8 *
9 * The SCTP reference implementation is free software;
10 * you can redistribute it and/or modify it under the terms of
11 * the GNU General Public License as published by
12 * the Free Software Foundation; either version 2, or (at your option)
13 * any later version.
14 *
15 * The SCTP reference implementation is distributed in the hope that it
16 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
17 * ************************
18 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with GNU CC; see the file COPYING. If not, write to
23 * the Free Software Foundation, 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA.
25 *
26 * Please send any bug reports or fixes you make to the
27 * email address(es):
28 * lksctp developers <lksctp-developers@lists.sourceforge.net>
29 *
30 * Or submit a bug report through the following website:
31 * http://www.sf.net/projects/lksctp
32 *
33 * Written or modified by:
34 * Dinakaran Joseph
35 * Jon Grimm <jgrimm@us.ibm.com>
36 * Sridhar Samudrala <sri@us.ibm.com>
37 *
38 * Rewritten to use libcrc32c by:
39 * Vlad Yasevich <vladislav.yasevich@hp.com>
40 *
41 * Any bugs reported given to us we will try to fix... any fixes shared will
42 * be incorporated into the next SCTP release.
43 */
44
45#include <linux/types.h>
46#include <net/sctp/sctp.h>
47#include <linux/crc32c.h>
48
49static inline __u32 sctp_start_cksum(__u8 *buffer, __u16 length)
50{
51 __u32 crc = ~(__u32) 0;
52 __u8 zero[sizeof(__u32)] = {0};
53
54 /* Optimize this routine to be SCTP specific, knowing how
55 * to skip the checksum field of the SCTP header.
56 */
57
58 /* Calculate CRC up to the checksum. */
59 crc = crc32c(crc, buffer, sizeof(struct sctphdr) - sizeof(__u32));
60
61 /* Skip checksum field of the header. */
62 crc = crc32c(crc, zero, sizeof(__u32));
63
64 /* Calculate the rest of the CRC. */
65 crc = crc32c(crc, &buffer[sizeof(struct sctphdr)],
66 length - sizeof(struct sctphdr));
67 return crc;
68}
69
70static inline __u32 sctp_update_cksum(__u8 *buffer, __u16 length, __u32 crc32)
71{
72 return crc32c(crc32, buffer, length);
73}
74
75static inline __u32 sctp_end_cksum(__u32 crc32)
76{
77 return ntohl(~crc32);
78}
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h
index b8733364557f..c1f797673571 100644
--- a/include/net/sctp/command.h
+++ b/include/net/sctp/command.h
@@ -103,6 +103,7 @@ typedef enum {
103 SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */ 103 SCTP_CMD_ASSOC_CHANGE, /* generate and send assoc_change event */
104 SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */ 104 SCTP_CMD_ADAPTATION_IND, /* generate and send adaptation event */
105 SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */ 105 SCTP_CMD_ASSOC_SHKEY, /* generate the association shared keys */
106 SCTP_CMD_T1_RETRAN, /* Mark for retransmission after T1 timeout */
106 SCTP_CMD_LAST 107 SCTP_CMD_LAST
107} sctp_verb_t; 108} sctp_verb_t;
108 109
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h
index da8354e8e33c..fefcba67bd1e 100644
--- a/include/net/sctp/constants.h
+++ b/include/net/sctp/constants.h
@@ -186,6 +186,8 @@ typedef enum {
186 SCTP_IERROR_AUTH_BAD_HMAC, 186 SCTP_IERROR_AUTH_BAD_HMAC,
187 SCTP_IERROR_AUTH_BAD_KEYID, 187 SCTP_IERROR_AUTH_BAD_KEYID,
188 SCTP_IERROR_PROTO_VIOLATION, 188 SCTP_IERROR_PROTO_VIOLATION,
189 SCTP_IERROR_ERROR,
190 SCTP_IERROR_ABORT,
189} sctp_ierror_t; 191} sctp_ierror_t;
190 192
191 193
@@ -363,36 +365,12 @@ typedef enum {
363 * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP 365 * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
364 * addresses. 366 * addresses.
365 */ 367 */
366#define IS_IPV4_UNUSABLE_ADDRESS(a) \ 368#define IS_IPV4_UNUSABLE_ADDRESS(a) \
367 ((htonl(INADDR_BROADCAST) == *a) || \ 369 ((htonl(INADDR_BROADCAST) == a) || \
368 (MULTICAST(*a)) || \ 370 ipv4_is_multicast(a) || \
369 (((unsigned char *)(a))[0] == 0) || \ 371 ipv4_is_zeronet(a) || \
370 ((((unsigned char *)(a))[0] == 198) && \ 372 ipv4_is_test_198(a) || \
371 (((unsigned char *)(a))[1] == 18) && \ 373 ipv4_is_anycast_6to4(a))
372 (((unsigned char *)(a))[2] == 0)) || \
373 ((((unsigned char *)(a))[0] == 192) && \
374 (((unsigned char *)(a))[1] == 88) && \
375 (((unsigned char *)(a))[2] == 99)))
376
377/* IPv4 Link-local addresses: 169.254.0.0/16. */
378#define IS_IPV4_LINK_ADDRESS(a) \
379 ((((unsigned char *)(a))[0] == 169) && \
380 (((unsigned char *)(a))[1] == 254))
381
382/* RFC 1918 "Address Allocation for Private Internets" defines the IPv4
383 * private address space as the following:
384 *
385 * 10.0.0.0 - 10.255.255.255 (10/8 prefix)
386 * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix)
387 * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
388 */
389#define IS_IPV4_PRIVATE_ADDRESS(a) \
390 ((((unsigned char *)(a))[0] == 10) || \
391 ((((unsigned char *)(a))[0] == 172) && \
392 (((unsigned char *)(a))[1] >= 16) && \
393 (((unsigned char *)(a))[1] < 32)) || \
394 ((((unsigned char *)(a))[0] == 192) && \
395 (((unsigned char *)(a))[1] == 168)))
396 374
397/* Flags used for the bind address copy functions. */ 375/* Flags used for the bind address copy functions. */
398#define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by 376#define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by
@@ -407,6 +385,7 @@ typedef enum {
407 SCTP_RTXR_T3_RTX, 385 SCTP_RTXR_T3_RTX,
408 SCTP_RTXR_FAST_RTX, 386 SCTP_RTXR_FAST_RTX,
409 SCTP_RTXR_PMTUD, 387 SCTP_RTXR_PMTUD,
388 SCTP_RTXR_T1_RTX,
410} sctp_retransmit_reason_t; 389} sctp_retransmit_reason_t;
411 390
412/* Reasons to lower cwnd. */ 391/* Reasons to lower cwnd. */
@@ -438,11 +417,14 @@ enum {
438 SCTP_AUTH_HMAC_ID_RESERVED_0, 417 SCTP_AUTH_HMAC_ID_RESERVED_0,
439 SCTP_AUTH_HMAC_ID_SHA1, 418 SCTP_AUTH_HMAC_ID_SHA1,
440 SCTP_AUTH_HMAC_ID_RESERVED_2, 419 SCTP_AUTH_HMAC_ID_RESERVED_2,
441 SCTP_AUTH_HMAC_ID_SHA256 420#if defined (CONFIG_CRYPTO_SHA256) || defined (CONFIG_CRYPTO_SHA256_MODULE)
421 SCTP_AUTH_HMAC_ID_SHA256,
422#endif
423 __SCTP_AUTH_HMAC_MAX
442}; 424};
443 425
444#define SCTP_AUTH_HMAC_ID_MAX SCTP_AUTH_HMAC_ID_SHA256 426#define SCTP_AUTH_HMAC_ID_MAX __SCTP_AUTH_HMAC_MAX - 1
445#define SCTP_AUTH_NUM_HMACS (SCTP_AUTH_HMAC_ID_SHA256 + 1) 427#define SCTP_AUTH_NUM_HMACS __SCTP_AUTH_HMAC_MAX
446#define SCTP_SHA1_SIG_SIZE 20 428#define SCTP_SHA1_SIG_SIZE 20
447#define SCTP_SHA256_SIG_SIZE 32 429#define SCTP_SHA256_SIG_SIZE 32
448 430
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 93eb708609e7..4977b0a81535 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -65,7 +65,6 @@
65 65
66 66
67#ifdef TEST_FRAME 67#ifdef TEST_FRAME
68#undef CONFIG_PROC_FS
69#undef CONFIG_SCTP_DBG_OBJCNT 68#undef CONFIG_SCTP_DBG_OBJCNT
70#undef CONFIG_SYSCTL 69#undef CONFIG_SYSCTL
71#endif /* TEST_FRAME */ 70#endif /* TEST_FRAME */
@@ -151,13 +150,6 @@ int sctp_primitive_REQUESTHEARTBEAT(struct sctp_association *, void *arg);
151int sctp_primitive_ASCONF(struct sctp_association *, void *arg); 150int sctp_primitive_ASCONF(struct sctp_association *, void *arg);
152 151
153/* 152/*
154 * sctp/crc32c.c
155 */
156__u32 sctp_start_cksum(__u8 *ptr, __u16 count);
157__u32 sctp_update_cksum(__u8 *ptr, __u16 count, __u32 cksum);
158__u32 sctp_end_cksum(__u32 cksum);
159
160/*
161 * sctp/input.c 153 * sctp/input.c
162 */ 154 */
163int sctp_rcv(struct sk_buff *skb); 155int sctp_rcv(struct sk_buff *skb);
@@ -267,6 +259,7 @@ enum
267 SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS, 259 SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS,
268 SCTP_MIB_DELAY_SACK_EXPIREDS, 260 SCTP_MIB_DELAY_SACK_EXPIREDS,
269 SCTP_MIB_AUTOCLOSE_EXPIREDS, 261 SCTP_MIB_AUTOCLOSE_EXPIREDS,
262 SCTP_MIB_T1_RETRANSMITS,
270 SCTP_MIB_T3_RETRANSMITS, 263 SCTP_MIB_T3_RETRANSMITS,
271 SCTP_MIB_PMTUD_RETRANSMITS, 264 SCTP_MIB_PMTUD_RETRANSMITS,
272 SCTP_MIB_FAST_RETRANSMITS, 265 SCTP_MIB_FAST_RETRANSMITS,
@@ -470,8 +463,7 @@ static inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
470 skb->destructor = sctp_sock_rfree; 463 skb->destructor = sctp_sock_rfree;
471 atomic_add(event->rmem_len, &sk->sk_rmem_alloc); 464 atomic_add(event->rmem_len, &sk->sk_rmem_alloc);
472 /* 465 /*
473 * This mimics the behavior of 466 * This mimics the behavior of skb_set_owner_r
474 * sk_stream_set_owner_r
475 */ 467 */
476 sk->sk_forward_alloc -= event->rmem_len; 468 sk->sk_forward_alloc -= event->rmem_len;
477} 469}
@@ -664,6 +656,9 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
664 return (h & (sctp_assoc_hashsize-1)); 656 return (h & (sctp_assoc_hashsize-1));
665} 657}
666 658
659#define sctp_for_each_hentry(epb, node, head) \
660 hlist_for_each_entry(epb, node, head, node)
661
667/* Is a socket of this style? */ 662/* Is a socket of this style? */
668#define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style)) 663#define sctp_style(sk, style) __sctp_style((sk), (SCTP_SOCKET_##style))
669static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style) 664static inline int __sctp_style(const struct sock *sk, sctp_socket_type_t style)
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index ef892e00c833..4d591bfce452 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -100,20 +100,19 @@ struct crypto_hash;
100struct sctp_bind_bucket { 100struct sctp_bind_bucket {
101 unsigned short port; 101 unsigned short port;
102 unsigned short fastreuse; 102 unsigned short fastreuse;
103 struct sctp_bind_bucket *next; 103 struct hlist_node node;
104 struct sctp_bind_bucket **pprev;
105 struct hlist_head owner; 104 struct hlist_head owner;
106}; 105};
107 106
108struct sctp_bind_hashbucket { 107struct sctp_bind_hashbucket {
109 spinlock_t lock; 108 spinlock_t lock;
110 struct sctp_bind_bucket *chain; 109 struct hlist_head chain;
111}; 110};
112 111
113/* Used for hashing all associations. */ 112/* Used for hashing all associations. */
114struct sctp_hashbucket { 113struct sctp_hashbucket {
115 rwlock_t lock; 114 rwlock_t lock;
116 struct sctp_ep_common *chain; 115 struct hlist_head chain;
117} __attribute__((__aligned__(8))); 116} __attribute__((__aligned__(8)));
118 117
119 118
@@ -212,6 +211,7 @@ extern struct sctp_globals {
212 211
213 /* Flag to indicate if addip is enabled. */ 212 /* Flag to indicate if addip is enabled. */
214 int addip_enable; 213 int addip_enable;
214 int addip_noauth_enable;
215 215
216 /* Flag to indicate if PR-SCTP is enabled. */ 216 /* Flag to indicate if PR-SCTP is enabled. */
217 int prsctp_enable; 217 int prsctp_enable;
@@ -249,6 +249,7 @@ extern struct sctp_globals {
249#define sctp_local_addr_list (sctp_globals.local_addr_list) 249#define sctp_local_addr_list (sctp_globals.local_addr_list)
250#define sctp_local_addr_lock (sctp_globals.addr_list_lock) 250#define sctp_local_addr_lock (sctp_globals.addr_list_lock)
251#define sctp_addip_enable (sctp_globals.addip_enable) 251#define sctp_addip_enable (sctp_globals.addip_enable)
252#define sctp_addip_noauth (sctp_globals.addip_noauth_enable)
252#define sctp_prsctp_enable (sctp_globals.prsctp_enable) 253#define sctp_prsctp_enable (sctp_globals.prsctp_enable)
253#define sctp_auth_enable (sctp_globals.auth_enable) 254#define sctp_auth_enable (sctp_globals.auth_enable)
254 255
@@ -300,7 +301,7 @@ struct sctp_sock {
300 /* The default SACK delay timeout for new associations. */ 301 /* The default SACK delay timeout for new associations. */
301 __u32 sackdelay; 302 __u32 sackdelay;
302 303
303 /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ 304 /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */
304 __u32 param_flags; 305 __u32 param_flags;
305 306
306 struct sctp_initmsg initmsg; 307 struct sctp_initmsg initmsg;
@@ -450,6 +451,7 @@ union sctp_params {
450 struct sctp_random_param *random; 451 struct sctp_random_param *random;
451 struct sctp_chunks_param *chunks; 452 struct sctp_chunks_param *chunks;
452 struct sctp_hmac_algo_param *hmac_algo; 453 struct sctp_hmac_algo_param *hmac_algo;
454 struct sctp_addip_param *addip;
453}; 455};
454 456
455/* RFC 2960. Section 3.3.5 Heartbeat. 457/* RFC 2960. Section 3.3.5 Heartbeat.
@@ -742,6 +744,7 @@ struct sctp_chunk {
742 __u8 tsn_missing_report; /* Data chunk missing counter. */ 744 __u8 tsn_missing_report; /* Data chunk missing counter. */
743 __u8 data_accepted; /* At least 1 chunk in this packet accepted */ 745 __u8 data_accepted; /* At least 1 chunk in this packet accepted */
744 __u8 auth; /* IN: was auth'ed | OUT: needs auth */ 746 __u8 auth; /* IN: was auth'ed | OUT: needs auth */
747 __u8 has_asconf; /* IN: have seen an asconf before */
745}; 748};
746 749
747void sctp_chunk_hold(struct sctp_chunk *); 750void sctp_chunk_hold(struct sctp_chunk *);
@@ -757,12 +760,18 @@ void sctp_init_addrs(struct sctp_chunk *, union sctp_addr *,
757 union sctp_addr *); 760 union sctp_addr *);
758const union sctp_addr *sctp_source(const struct sctp_chunk *chunk); 761const union sctp_addr *sctp_source(const struct sctp_chunk *chunk);
759 762
763enum {
764 SCTP_ADDR_NEW, /* new address added to assoc/ep */
765 SCTP_ADDR_SRC, /* address can be used as source */
766 SCTP_ADDR_DEL, /* address about to be deleted */
767};
768
760/* This is a structure for holding either an IPv6 or an IPv4 address. */ 769/* This is a structure for holding either an IPv6 or an IPv4 address. */
761struct sctp_sockaddr_entry { 770struct sctp_sockaddr_entry {
762 struct list_head list; 771 struct list_head list;
763 struct rcu_head rcu; 772 struct rcu_head rcu;
764 union sctp_addr a; 773 union sctp_addr a;
765 __u8 use_as_src; 774 __u8 state;
766 __u8 valid; 775 __u8 valid;
767}; 776};
768 777
@@ -873,10 +882,11 @@ struct sctp_transport {
873 * address list derived from the INIT or INIT ACK chunk, a 882 * address list derived from the INIT or INIT ACK chunk, a
874 * number of data elements needs to be maintained including: 883 * number of data elements needs to be maintained including:
875 */ 884 */
876 __u32 rtt; /* This is the most recent RTT. */
877
878 /* RTO : The current retransmission timeout value. */ 885 /* RTO : The current retransmission timeout value. */
879 unsigned long rto; 886 unsigned long rto;
887 unsigned long last_rto;
888
889 __u32 rtt; /* This is the most recent RTT. */
880 890
881 /* RTTVAR : The current RTT variation. */ 891 /* RTTVAR : The current RTT variation. */
882 __u32 rttvar; 892 __u32 rttvar;
@@ -953,7 +963,7 @@ struct sctp_transport {
953 /* PMTU : The current known path MTU. */ 963 /* PMTU : The current known path MTU. */
954 __u32 pathmtu; 964 __u32 pathmtu;
955 965
956 /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ 966 /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */
957 __u32 param_flags; 967 __u32 param_flags;
958 968
959 /* The number of times INIT has been sent on this transport. */ 969 /* The number of times INIT has been sent on this transport. */
@@ -1182,13 +1192,16 @@ int sctp_bind_addr_copy(struct sctp_bind_addr *dest,
1182 const struct sctp_bind_addr *src, 1192 const struct sctp_bind_addr *src,
1183 sctp_scope_t scope, gfp_t gfp, 1193 sctp_scope_t scope, gfp_t gfp,
1184 int flags); 1194 int flags);
1195int sctp_bind_addr_dup(struct sctp_bind_addr *dest,
1196 const struct sctp_bind_addr *src,
1197 gfp_t gfp);
1185int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, 1198int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *,
1186 __u8 use_as_src, gfp_t gfp); 1199 __u8 addr_state, gfp_t gfp);
1187int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *, 1200int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *);
1188 void fastcall (*rcu_call)(struct rcu_head *,
1189 void (*func)(struct rcu_head *)));
1190int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, 1201int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *,
1191 struct sctp_sock *); 1202 struct sctp_sock *);
1203int sctp_bind_addr_state(const struct sctp_bind_addr *bp,
1204 const union sctp_addr *addr);
1192union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, 1205union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
1193 const union sctp_addr *addrs, 1206 const union sctp_addr *addrs,
1194 int addrcnt, 1207 int addrcnt,
@@ -1229,8 +1242,7 @@ typedef enum {
1229 1242
1230struct sctp_ep_common { 1243struct sctp_ep_common {
1231 /* Fields to help us manage our entries in the hash tables. */ 1244 /* Fields to help us manage our entries in the hash tables. */
1232 struct sctp_ep_common *next; 1245 struct hlist_node node;
1233 struct sctp_ep_common **pprev;
1234 int hashent; 1246 int hashent;
1235 1247
1236 /* Runtime type information. What kind of endpoint is this? */ 1248 /* Runtime type information. What kind of endpoint is this? */
@@ -1541,7 +1553,6 @@ struct sctp_association {
1541 __u8 asconf_capable; /* Does peer support ADDIP? */ 1553 __u8 asconf_capable; /* Does peer support ADDIP? */
1542 __u8 prsctp_capable; /* Can peer do PR-SCTP? */ 1554 __u8 prsctp_capable; /* Can peer do PR-SCTP? */
1543 __u8 auth_capable; /* Is peer doing SCTP-AUTH? */ 1555 __u8 auth_capable; /* Is peer doing SCTP-AUTH? */
1544 __u8 addip_capable; /* Can peer do ADD-IP */
1545 1556
1546 __u32 adaptation_ind; /* Adaptation Code point. */ 1557 __u32 adaptation_ind; /* Adaptation Code point. */
1547 1558
@@ -1637,7 +1648,7 @@ struct sctp_association {
1637 */ 1648 */
1638 __u32 pathmtu; 1649 __u32 pathmtu;
1639 1650
1640 /* Flags controling Heartbeat, SACK delay, and Path MTU Discovery. */ 1651 /* Flags controlling Heartbeat, SACK delay, and Path MTU Discovery. */
1641 __u32 param_flags; 1652 __u32 param_flags;
1642 1653
1643 /* SACK delay timeout */ 1654 /* SACK delay timeout */
@@ -1783,20 +1794,16 @@ struct sctp_association {
1783 */ 1794 */
1784 struct sctp_chunk *addip_last_asconf; 1795 struct sctp_chunk *addip_last_asconf;
1785 1796
1786 /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk. 1797 /* ADDIP Section 5.2 Upon reception of an ASCONF Chunk.
1787 * 1798 *
1788 * IMPLEMENTATION NOTE: As an optimization a receiver may wish 1799 * This is needed to implement itmes E1 - E4 of the updated
1789 * to save the last ASCONF-ACK for some predetermined period 1800 * spec. Here is the justification:
1790 * of time and instead of re-processing the ASCONF (with the
1791 * same serial number) it may just re-transmit the
1792 * ASCONF-ACK. It may wish to use the arrival of a new serial
1793 * number to discard the previously saved ASCONF-ACK or any
1794 * other means it may choose to expire the saved ASCONF-ACK.
1795 * 1801 *
1796 * [This is our saved ASCONF-ACK. We invalidate it when a new 1802 * Since the peer may bundle multiple ASCONF chunks toward us,
1797 * ASCONF serial number arrives.] 1803 * we now need the ability to cache multiple ACKs. The section
1804 * describes in detail how they are cached and cleaned up.
1798 */ 1805 */
1799 struct sctp_chunk *addip_last_asconf_ack; 1806 struct list_head asconf_ack_list;
1800 1807
1801 /* These ASCONF chunks are waiting to be sent. 1808 /* These ASCONF chunks are waiting to be sent.
1802 * 1809 *
@@ -1937,12 +1944,19 @@ void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned);
1937void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned); 1944void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned);
1938void sctp_assoc_set_primary(struct sctp_association *, 1945void sctp_assoc_set_primary(struct sctp_association *,
1939 struct sctp_transport *); 1946 struct sctp_transport *);
1947void sctp_assoc_del_nonprimary_peers(struct sctp_association *,
1948 struct sctp_transport *);
1940int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, 1949int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *,
1941 gfp_t); 1950 gfp_t);
1942int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, 1951int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *,
1943 struct sctp_cookie*, 1952 struct sctp_cookie*,
1944 gfp_t gfp); 1953 gfp_t gfp);
1945int sctp_assoc_set_id(struct sctp_association *, gfp_t); 1954int sctp_assoc_set_id(struct sctp_association *, gfp_t);
1955void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc);
1956struct sctp_chunk *sctp_assoc_lookup_asconf_ack(
1957 const struct sctp_association *asoc,
1958 __be32 serial);
1959
1946 1960
1947int sctp_cmp_addr_exact(const union sctp_addr *ss1, 1961int sctp_cmp_addr_exact(const union sctp_addr *ss1,
1948 const union sctp_addr *ss2); 1962 const union sctp_addr *ss2);
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 00848b641f59..954090b1e354 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -450,7 +450,7 @@ enum sctp_sn_type {
450 SCTP_SHUTDOWN_EVENT, 450 SCTP_SHUTDOWN_EVENT,
451 SCTP_PARTIAL_DELIVERY_EVENT, 451 SCTP_PARTIAL_DELIVERY_EVENT,
452 SCTP_ADAPTATION_INDICATION, 452 SCTP_ADAPTATION_INDICATION,
453 SCTP_AUTHENTICATION_EVENT, 453 SCTP_AUTHENTICATION_INDICATION,
454}; 454};
455 455
456/* Notification error codes used to fill up the error fields in some 456/* Notification error codes used to fill up the error fields in some
diff --git a/include/net/snmp.h b/include/net/snmp.h
index ea206bff0dc4..ce2f48507510 100644
--- a/include/net/snmp.h
+++ b/include/net/snmp.h
@@ -23,6 +23,7 @@
23 23
24#include <linux/cache.h> 24#include <linux/cache.h>
25#include <linux/snmp.h> 25#include <linux/snmp.h>
26#include <linux/smp.h>
26 27
27/* 28/*
28 * Mibs are stored in array of unsigned long. 29 * Mibs are stored in array of unsigned long.
@@ -117,6 +118,11 @@ struct linux_mib {
117 unsigned long mibs[LINUX_MIB_MAX]; 118 unsigned long mibs[LINUX_MIB_MAX];
118}; 119};
119 120
121/* Linux Xfrm */
122#define LINUX_MIB_XFRMMAX __LINUX_MIB_XFRMMAX
123struct linux_xfrm_mib {
124 unsigned long mibs[LINUX_MIB_XFRMMAX];
125};
120 126
121/* 127/*
122 * FIXME: On x86 and some other CPUs the split into user and softirq parts 128 * FIXME: On x86 and some other CPUs the split into user and softirq parts
@@ -134,17 +140,27 @@ struct linux_mib {
134 140
135#define SNMP_INC_STATS_BH(mib, field) \ 141#define SNMP_INC_STATS_BH(mib, field) \
136 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++) 142 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field]++)
137#define SNMP_INC_STATS_OFFSET_BH(mib, field, offset) \
138 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field + (offset)]++)
139#define SNMP_INC_STATS_USER(mib, field) \ 143#define SNMP_INC_STATS_USER(mib, field) \
140 (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field]++) 144 do { \
145 per_cpu_ptr(mib[1], get_cpu())->mibs[field]++; \
146 put_cpu(); \
147 } while (0)
141#define SNMP_INC_STATS(mib, field) \ 148#define SNMP_INC_STATS(mib, field) \
142 (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]++) 149 do { \
150 per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]++; \
151 put_cpu(); \
152 } while (0)
143#define SNMP_DEC_STATS(mib, field) \ 153#define SNMP_DEC_STATS(mib, field) \
144 (per_cpu_ptr(mib[!in_softirq()], raw_smp_processor_id())->mibs[field]--) 154 do { \
155 per_cpu_ptr(mib[!in_softirq()], get_cpu())->mibs[field]--; \
156 put_cpu(); \
157 } while (0)
145#define SNMP_ADD_STATS_BH(mib, field, addend) \ 158#define SNMP_ADD_STATS_BH(mib, field, addend) \
146 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend) 159 (per_cpu_ptr(mib[0], raw_smp_processor_id())->mibs[field] += addend)
147#define SNMP_ADD_STATS_USER(mib, field, addend) \ 160#define SNMP_ADD_STATS_USER(mib, field, addend) \
148 (per_cpu_ptr(mib[1], raw_smp_processor_id())->mibs[field] += addend) 161 do { \
162 per_cpu_ptr(mib[1], get_cpu())->mibs[field] += addend; \
163 put_cpu(); \
164 } while (0)
149 165
150#endif 166#endif
diff --git a/include/net/sock.h b/include/net/sock.h
index 43fc3fa50d62..e3fb4c047f4c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -47,6 +47,7 @@
47#include <linux/module.h> 47#include <linux/module.h>
48#include <linux/lockdep.h> 48#include <linux/lockdep.h>
49#include <linux/netdevice.h> 49#include <linux/netdevice.h>
50#include <linux/pcounter.h>
50#include <linux/skbuff.h> /* struct sk_buff */ 51#include <linux/skbuff.h> /* struct sk_buff */
51#include <linux/mm.h> 52#include <linux/mm.h>
52#include <linux/security.h> 53#include <linux/security.h>
@@ -56,7 +57,6 @@
56#include <asm/atomic.h> 57#include <asm/atomic.h>
57#include <net/dst.h> 58#include <net/dst.h>
58#include <net/checksum.h> 59#include <net/checksum.h>
59#include <net/net_namespace.h>
60 60
61/* 61/*
62 * This structure really needs to be cleaned up. 62 * This structure really needs to be cleaned up.
@@ -94,6 +94,7 @@ typedef struct {
94 94
95struct sock; 95struct sock;
96struct proto; 96struct proto;
97struct net;
97 98
98/** 99/**
99 * struct sock_common - minimal network layer representation of sockets 100 * struct sock_common - minimal network layer representation of sockets
@@ -145,7 +146,8 @@ struct sock_common {
145 * @sk_forward_alloc: space allocated forward 146 * @sk_forward_alloc: space allocated forward
146 * @sk_allocation: allocation mode 147 * @sk_allocation: allocation mode
147 * @sk_sndbuf: size of send buffer in bytes 148 * @sk_sndbuf: size of send buffer in bytes
148 * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings 149 * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE,
150 * %SO_OOBINLINE settings
149 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets 151 * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
150 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) 152 * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
151 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) 153 * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
@@ -153,9 +155,12 @@ struct sock_common {
153 * @sk_backlog: always used with the per-socket spinlock held 155 * @sk_backlog: always used with the per-socket spinlock held
154 * @sk_callback_lock: used with the callbacks in the end of this struct 156 * @sk_callback_lock: used with the callbacks in the end of this struct
155 * @sk_error_queue: rarely used 157 * @sk_error_queue: rarely used
156 * @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance) 158 * @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt,
159 * IPV6_ADDRFORM for instance)
157 * @sk_err: last error 160 * @sk_err: last error
158 * @sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out' 161 * @sk_err_soft: errors that don't cause failure but are the cause of a
162 * persistent failure not just 'timed out'
163 * @sk_drops: raw drops counter
159 * @sk_ack_backlog: current listen backlog 164 * @sk_ack_backlog: current listen backlog
160 * @sk_max_ack_backlog: listen backlog set in listen() 165 * @sk_max_ack_backlog: listen backlog set in listen()
161 * @sk_priority: %SO_PRIORITY setting 166 * @sk_priority: %SO_PRIORITY setting
@@ -239,6 +244,7 @@ struct sock {
239 rwlock_t sk_callback_lock; 244 rwlock_t sk_callback_lock;
240 int sk_err, 245 int sk_err,
241 sk_err_soft; 246 sk_err_soft;
247 atomic_t sk_drops;
242 unsigned short sk_ack_backlog; 248 unsigned short sk_ack_backlog;
243 unsigned short sk_max_ack_backlog; 249 unsigned short sk_max_ack_backlog;
244 __u32 sk_priority; 250 __u32 sk_priority;
@@ -256,6 +262,8 @@ struct sock {
256 __u32 sk_sndmsg_off; 262 __u32 sk_sndmsg_off;
257 int sk_write_pending; 263 int sk_write_pending;
258 void *sk_security; 264 void *sk_security;
265 __u32 sk_mark;
266 /* XXX 4 bytes hole on 64 bit */
259 void (*sk_state_change)(struct sock *sk); 267 void (*sk_state_change)(struct sock *sk);
260 void (*sk_data_ready)(struct sock *sk, int bytes); 268 void (*sk_data_ready)(struct sock *sk, int bytes);
261 void (*sk_write_space)(struct sock *sk); 269 void (*sk_write_space)(struct sock *sk);
@@ -439,7 +447,7 @@ static inline int sk_acceptq_is_full(struct sock *sk)
439 */ 447 */
440static inline int sk_stream_min_wspace(struct sock *sk) 448static inline int sk_stream_min_wspace(struct sock *sk)
441{ 449{
442 return sk->sk_wmem_queued / 2; 450 return sk->sk_wmem_queued >> 1;
443} 451}
444 452
445static inline int sk_stream_wspace(struct sock *sk) 453static inline int sk_stream_wspace(struct sock *sk)
@@ -454,25 +462,6 @@ static inline int sk_stream_memory_free(struct sock *sk)
454 return sk->sk_wmem_queued < sk->sk_sndbuf; 462 return sk->sk_wmem_queued < sk->sk_sndbuf;
455} 463}
456 464
457extern void sk_stream_rfree(struct sk_buff *skb);
458
459static inline void sk_stream_set_owner_r(struct sk_buff *skb, struct sock *sk)
460{
461 skb->sk = sk;
462 skb->destructor = sk_stream_rfree;
463 atomic_add(skb->truesize, &sk->sk_rmem_alloc);
464 sk->sk_forward_alloc -= skb->truesize;
465}
466
467static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb)
468{
469 skb_truesize_check(skb);
470 sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
471 sk->sk_wmem_queued -= skb->truesize;
472 sk->sk_forward_alloc += skb->truesize;
473 __kfree_skb(skb);
474}
475
476/* The per-socket spinlock must be held here. */ 465/* The per-socket spinlock must be held here. */
477static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb) 466static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb)
478{ 467{
@@ -560,6 +549,11 @@ struct proto {
560 void (*unhash)(struct sock *sk); 549 void (*unhash)(struct sock *sk);
561 int (*get_port)(struct sock *sk, unsigned short snum); 550 int (*get_port)(struct sock *sk, unsigned short snum);
562 551
552 /* Keeping track of sockets in use */
553#ifdef CONFIG_PROC_FS
554 struct pcounter inuse;
555#endif
556
563 /* Memory pressure */ 557 /* Memory pressure */
564 void (*enter_memory_pressure)(void); 558 void (*enter_memory_pressure)(void);
565 atomic_t *memory_allocated; /* Current allocated memory. */ 559 atomic_t *memory_allocated; /* Current allocated memory. */
@@ -567,7 +561,7 @@ struct proto {
567 /* 561 /*
568 * Pressure flag: try to collapse. 562 * Pressure flag: try to collapse.
569 * Technical note: it is used by multiple contexts non atomically. 563 * Technical note: it is used by multiple contexts non atomically.
570 * All the sk_stream_mem_schedule() is of this nature: accounting 564 * All the __sk_mem_schedule() is of this nature: accounting
571 * is strict, actions are advisory and have some latency. 565 * is strict, actions are advisory and have some latency.
572 */ 566 */
573 int *memory_pressure; 567 int *memory_pressure;
@@ -592,10 +586,6 @@ struct proto {
592#ifdef SOCK_REFCNT_DEBUG 586#ifdef SOCK_REFCNT_DEBUG
593 atomic_t socks; 587 atomic_t socks;
594#endif 588#endif
595 struct {
596 int inuse;
597 u8 __pad[SMP_CACHE_BYTES - sizeof(int)];
598 } stats[NR_CPUS];
599}; 589};
600 590
601extern int proto_register(struct proto *prot, int alloc_slab); 591extern int proto_register(struct proto *prot, int alloc_slab);
@@ -626,16 +616,42 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)
626#define sk_refcnt_debug_release(sk) do { } while (0) 616#define sk_refcnt_debug_release(sk) do { } while (0)
627#endif /* SOCK_REFCNT_DEBUG */ 617#endif /* SOCK_REFCNT_DEBUG */
628 618
619
620#ifdef CONFIG_PROC_FS
621# define DEFINE_PROTO_INUSE(NAME) DEFINE_PCOUNTER(NAME)
622# define REF_PROTO_INUSE(NAME) PCOUNTER_MEMBER_INITIALIZER(NAME, .inuse)
629/* Called with local bh disabled */ 623/* Called with local bh disabled */
630static __inline__ void sock_prot_inc_use(struct proto *prot) 624static inline void sock_prot_inuse_add(struct proto *prot, int inc)
631{ 625{
632 prot->stats[smp_processor_id()].inuse++; 626 pcounter_add(&prot->inuse, inc);
633} 627}
634 628static inline int sock_prot_inuse_init(struct proto *proto)
635static __inline__ void sock_prot_dec_use(struct proto *prot) 629{
630 return pcounter_alloc(&proto->inuse);
631}
632static inline int sock_prot_inuse_get(struct proto *proto)
633{
634 return pcounter_getval(&proto->inuse);
635}
636static inline void sock_prot_inuse_free(struct proto *proto)
637{
638 pcounter_free(&proto->inuse);
639}
640#else
641# define DEFINE_PROTO_INUSE(NAME)
642# define REF_PROTO_INUSE(NAME)
643static void inline sock_prot_inuse_add(struct proto *prot, int inc)
644{
645}
646static int inline sock_prot_inuse_init(struct proto *proto)
636{ 647{
637 prot->stats[smp_processor_id()].inuse--; 648 return 0;
638} 649}
650static void inline sock_prot_inuse_free(struct proto *proto)
651{
652}
653#endif
654
639 655
640/* With per-bucket locks this operation is not-atomic, so that 656/* With per-bucket locks this operation is not-atomic, so that
641 * this version is not worse. 657 * this version is not worse.
@@ -699,32 +715,81 @@ static inline struct inode *SOCK_INODE(struct socket *socket)
699 return &container_of(socket, struct socket_alloc, socket)->vfs_inode; 715 return &container_of(socket, struct socket_alloc, socket)->vfs_inode;
700} 716}
701 717
702extern void __sk_stream_mem_reclaim(struct sock *sk); 718/*
703extern int sk_stream_mem_schedule(struct sock *sk, int size, int kind); 719 * Functions for memory accounting
720 */
721extern int __sk_mem_schedule(struct sock *sk, int size, int kind);
722extern void __sk_mem_reclaim(struct sock *sk);
704 723
705#define SK_STREAM_MEM_QUANTUM ((int)PAGE_SIZE) 724#define SK_MEM_QUANTUM ((int)PAGE_SIZE)
725#define SK_MEM_QUANTUM_SHIFT ilog2(SK_MEM_QUANTUM)
726#define SK_MEM_SEND 0
727#define SK_MEM_RECV 1
706 728
707static inline int sk_stream_pages(int amt) 729static inline int sk_mem_pages(int amt)
708{ 730{
709 return DIV_ROUND_UP(amt, SK_STREAM_MEM_QUANTUM); 731 return (amt + SK_MEM_QUANTUM - 1) >> SK_MEM_QUANTUM_SHIFT;
710} 732}
711 733
712static inline void sk_stream_mem_reclaim(struct sock *sk) 734static inline int sk_has_account(struct sock *sk)
713{ 735{
714 if (sk->sk_forward_alloc >= SK_STREAM_MEM_QUANTUM) 736 /* return true if protocol supports memory accounting */
715 __sk_stream_mem_reclaim(sk); 737 return !!sk->sk_prot->memory_allocated;
716} 738}
717 739
718static inline int sk_stream_rmem_schedule(struct sock *sk, struct sk_buff *skb) 740static inline int sk_wmem_schedule(struct sock *sk, int size)
719{ 741{
720 return (int)skb->truesize <= sk->sk_forward_alloc || 742 if (!sk_has_account(sk))
721 sk_stream_mem_schedule(sk, skb->truesize, 1); 743 return 1;
744 return size <= sk->sk_forward_alloc ||
745 __sk_mem_schedule(sk, size, SK_MEM_SEND);
722} 746}
723 747
724static inline int sk_stream_wmem_schedule(struct sock *sk, int size) 748static inline int sk_rmem_schedule(struct sock *sk, int size)
725{ 749{
750 if (!sk_has_account(sk))
751 return 1;
726 return size <= sk->sk_forward_alloc || 752 return size <= sk->sk_forward_alloc ||
727 sk_stream_mem_schedule(sk, size, 0); 753 __sk_mem_schedule(sk, size, SK_MEM_RECV);
754}
755
756static inline void sk_mem_reclaim(struct sock *sk)
757{
758 if (!sk_has_account(sk))
759 return;
760 if (sk->sk_forward_alloc >= SK_MEM_QUANTUM)
761 __sk_mem_reclaim(sk);
762}
763
764static inline void sk_mem_reclaim_partial(struct sock *sk)
765{
766 if (!sk_has_account(sk))
767 return;
768 if (sk->sk_forward_alloc > SK_MEM_QUANTUM)
769 __sk_mem_reclaim(sk);
770}
771
772static inline void sk_mem_charge(struct sock *sk, int size)
773{
774 if (!sk_has_account(sk))
775 return;
776 sk->sk_forward_alloc -= size;
777}
778
779static inline void sk_mem_uncharge(struct sock *sk, int size)
780{
781 if (!sk_has_account(sk))
782 return;
783 sk->sk_forward_alloc += size;
784}
785
786static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
787{
788 skb_truesize_check(skb);
789 sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
790 sk->sk_wmem_queued -= skb->truesize;
791 sk_mem_uncharge(sk, skb->truesize);
792 __kfree_skb(skb);
728} 793}
729 794
730/* Used by processes to "lock" a socket state, so that 795/* Used by processes to "lock" a socket state, so that
@@ -761,14 +826,14 @@ do { \
761 lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \ 826 lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \
762} while (0) 827} while (0)
763 828
764extern void FASTCALL(lock_sock_nested(struct sock *sk, int subclass)); 829extern void lock_sock_nested(struct sock *sk, int subclass);
765 830
766static inline void lock_sock(struct sock *sk) 831static inline void lock_sock(struct sock *sk)
767{ 832{
768 lock_sock_nested(sk, 0); 833 lock_sock_nested(sk, 0);
769} 834}
770 835
771extern void FASTCALL(release_sock(struct sock *sk)); 836extern void release_sock(struct sock *sk);
772 837
773/* BH context may only use the following locking interface. */ 838/* BH context may only use the following locking interface. */
774#define bh_lock_sock(__sk) spin_lock(&((__sk)->sk_lock.slock)) 839#define bh_lock_sock(__sk) spin_lock(&((__sk)->sk_lock.slock))
@@ -779,7 +844,7 @@ extern void FASTCALL(release_sock(struct sock *sk));
779 844
780extern struct sock *sk_alloc(struct net *net, int family, 845extern struct sock *sk_alloc(struct net *net, int family,
781 gfp_t priority, 846 gfp_t priority,
782 struct proto *prot, int zero_it); 847 struct proto *prot);
783extern void sk_free(struct sock *sk); 848extern void sk_free(struct sock *sk);
784extern struct sock *sk_clone(const struct sock *sk, 849extern struct sock *sk_clone(const struct sock *sk,
785 const gfp_t priority); 850 const gfp_t priority);
@@ -893,7 +958,7 @@ static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
893 return err; 958 return err;
894 959
895 rcu_read_lock_bh(); 960 rcu_read_lock_bh();
896 filter = sk->sk_filter; 961 filter = rcu_dereference(sk->sk_filter);
897 if (filter) { 962 if (filter) {
898 unsigned int pkt_len = sk_run_filter(skb, filter->insns, 963 unsigned int pkt_len = sk_run_filter(skb, filter->insns,
899 filter->len); 964 filter->len);
@@ -993,20 +1058,6 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)
993 write_unlock_bh(&sk->sk_callback_lock); 1058 write_unlock_bh(&sk->sk_callback_lock);
994} 1059}
995 1060
996static inline void sock_copy(struct sock *nsk, const struct sock *osk)
997{
998#ifdef CONFIG_SECURITY_NETWORK
999 void *sptr = nsk->sk_security;
1000#endif
1001
1002 memcpy(nsk, osk, osk->sk_prot->obj_size);
1003 get_net(nsk->sk_net);
1004#ifdef CONFIG_SECURITY_NETWORK
1005 nsk->sk_security = sptr;
1006 security_sk_clone(osk, nsk);
1007#endif
1008}
1009
1010extern int sock_i_uid(struct sock *sk); 1061extern int sock_i_uid(struct sock *sk);
1011extern unsigned long sock_i_ino(struct sock *sk); 1062extern unsigned long sock_i_ino(struct sock *sk);
1012 1063
@@ -1076,12 +1127,6 @@ static inline int sk_can_gso(const struct sock *sk)
1076 1127
1077extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); 1128extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst);
1078 1129
1079static inline void sk_charge_skb(struct sock *sk, struct sk_buff *skb)
1080{
1081 sk->sk_wmem_queued += skb->truesize;
1082 sk->sk_forward_alloc -= skb->truesize;
1083}
1084
1085static inline int skb_copy_to_page(struct sock *sk, char __user *from, 1130static inline int skb_copy_to_page(struct sock *sk, char __user *from,
1086 struct sk_buff *skb, struct page *page, 1131 struct sk_buff *skb, struct page *page,
1087 int off, int copy) 1132 int off, int copy)
@@ -1101,7 +1146,7 @@ static inline int skb_copy_to_page(struct sock *sk, char __user *from,
1101 skb->data_len += copy; 1146 skb->data_len += copy;
1102 skb->truesize += copy; 1147 skb->truesize += copy;
1103 sk->sk_wmem_queued += copy; 1148 sk->sk_wmem_queued += copy;
1104 sk->sk_forward_alloc -= copy; 1149 sk_mem_charge(sk, copy);
1105 return 0; 1150 return 0;
1106} 1151}
1107 1152
@@ -1127,6 +1172,7 @@ static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
1127 skb->sk = sk; 1172 skb->sk = sk;
1128 skb->destructor = sock_rfree; 1173 skb->destructor = sock_rfree;
1129 atomic_add(skb->truesize, &sk->sk_rmem_alloc); 1174 atomic_add(skb->truesize, &sk->sk_rmem_alloc);
1175 sk_mem_charge(sk, skb->truesize);
1130} 1176}
1131 1177
1132extern void sk_reset_timer(struct sock *sk, struct timer_list* timer, 1178extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
@@ -1188,40 +1234,12 @@ static inline void sk_wake_async(struct sock *sk, int how, int band)
1188static inline void sk_stream_moderate_sndbuf(struct sock *sk) 1234static inline void sk_stream_moderate_sndbuf(struct sock *sk)
1189{ 1235{
1190 if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) { 1236 if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) {
1191 sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued / 2); 1237 sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued >> 1);
1192 sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF); 1238 sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF);
1193 } 1239 }
1194} 1240}
1195 1241
1196static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, 1242struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
1197 int size, int mem,
1198 gfp_t gfp)
1199{
1200 struct sk_buff *skb;
1201 int hdr_len;
1202
1203 hdr_len = SKB_DATA_ALIGN(sk->sk_prot->max_header);
1204 skb = alloc_skb_fclone(size + hdr_len, gfp);
1205 if (skb) {
1206 skb->truesize += mem;
1207 if (sk_stream_wmem_schedule(sk, skb->truesize)) {
1208 skb_reserve(skb, hdr_len);
1209 return skb;
1210 }
1211 __kfree_skb(skb);
1212 } else {
1213 sk->sk_prot->enter_memory_pressure();
1214 sk_stream_moderate_sndbuf(sk);
1215 }
1216 return NULL;
1217}
1218
1219static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk,
1220 int size,
1221 gfp_t gfp)
1222{
1223 return sk_stream_alloc_pskb(sk, size, 0, gfp);
1224}
1225 1243
1226static inline struct page *sk_stream_alloc_page(struct sock *sk) 1244static inline struct page *sk_stream_alloc_page(struct sock *sk)
1227{ 1245{
@@ -1240,7 +1258,7 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk)
1240 */ 1258 */
1241static inline int sock_writeable(const struct sock *sk) 1259static inline int sock_writeable(const struct sock *sk)
1242{ 1260{
1243 return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2); 1261 return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf >> 1);
1244} 1262}
1245 1263
1246static inline gfp_t gfp_any(void) 1264static inline gfp_t gfp_any(void)
@@ -1349,23 +1367,11 @@ extern int net_msg_warn;
1349 lock_sock(sk); \ 1367 lock_sock(sk); \
1350 } 1368 }
1351 1369
1352static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool)
1353{
1354 if (valbool)
1355 sock_set_flag(sk, bit);
1356 else
1357 sock_reset_flag(sk, bit);
1358}
1359
1360extern __u32 sysctl_wmem_max; 1370extern __u32 sysctl_wmem_max;
1361extern __u32 sysctl_rmem_max; 1371extern __u32 sysctl_rmem_max;
1362 1372
1363extern void sk_init(void); 1373extern void sk_init(void);
1364 1374
1365#ifdef CONFIG_SYSCTL
1366extern struct ctl_table core_table[];
1367#endif
1368
1369extern int sysctl_optmem_max; 1375extern int sysctl_optmem_max;
1370 1376
1371extern __u32 sysctl_wmem_default; 1377extern __u32 sysctl_wmem_default;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index d695cea7730d..7de4ea3a04d9 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -309,6 +309,9 @@ extern int tcp_twsk_unique(struct sock *sk,
309 309
310extern void tcp_twsk_destructor(struct sock *sk); 310extern void tcp_twsk_destructor(struct sock *sk);
311 311
312extern ssize_t tcp_splice_read(struct socket *sk, loff_t *ppos,
313 struct pipe_inode_info *pipe, size_t len, unsigned int flags);
314
312static inline void tcp_dec_quickack_mode(struct sock *sk, 315static inline void tcp_dec_quickack_mode(struct sock *sk,
313 const unsigned int pkts) 316 const unsigned int pkts)
314{ 317{
@@ -575,10 +578,6 @@ struct tcp_skb_cb {
575#define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ 578#define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */
576#define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) 579#define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS)
577 580
578#define TCPCB_URG 0x20 /* Urgent pointer advanced here */
579
580#define TCPCB_AT_TAIL (TCPCB_URG)
581
582 __u16 urg_ptr; /* Valid w/URG flags is set. */ 581 __u16 urg_ptr; /* Valid w/URG flags is set. */
583 __u32 ack_seq; /* Sequence number ACK'd */ 582 __u32 ack_seq; /* Sequence number ACK'd */
584}; 583};
@@ -649,7 +648,7 @@ struct tcp_congestion_ops {
649 /* lower bound for congestion window (optional) */ 648 /* lower bound for congestion window (optional) */
650 u32 (*min_cwnd)(const struct sock *sk); 649 u32 (*min_cwnd)(const struct sock *sk);
651 /* do new cwnd calculation (required) */ 650 /* do new cwnd calculation (required) */
652 void (*cong_avoid)(struct sock *sk, u32 ack, u32 in_flight, int good_ack); 651 void (*cong_avoid)(struct sock *sk, u32 ack, u32 in_flight);
653 /* call before changing ca_state (optional) */ 652 /* call before changing ca_state (optional) */
654 void (*set_state)(struct sock *sk, u8 new_state); 653 void (*set_state)(struct sock *sk, u8 new_state);
655 /* call when cwnd event occurs (optional) */ 654 /* call when cwnd event occurs (optional) */
@@ -680,7 +679,7 @@ extern void tcp_slow_start(struct tcp_sock *tp);
680 679
681extern struct tcp_congestion_ops tcp_init_congestion_ops; 680extern struct tcp_congestion_ops tcp_init_congestion_ops;
682extern u32 tcp_reno_ssthresh(struct sock *sk); 681extern u32 tcp_reno_ssthresh(struct sock *sk);
683extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight, int flag); 682extern void tcp_reno_cong_avoid(struct sock *sk, u32 ack, u32 in_flight);
684extern u32 tcp_reno_min_cwnd(const struct sock *sk); 683extern u32 tcp_reno_min_cwnd(const struct sock *sk);
685extern struct tcp_congestion_ops tcp_reno; 684extern struct tcp_congestion_ops tcp_reno;
686 685
@@ -782,26 +781,12 @@ static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp)
782 return 3; 781 return 3;
783} 782}
784 783
785/* RFC2861 Check whether we are limited by application or congestion window 784/* Returns end sequence number of the receiver's advertised window */
786 * This is the inverse of cwnd check in tcp_tso_should_defer 785static inline u32 tcp_wnd_end(const struct tcp_sock *tp)
787 */
788static inline int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight)
789{ 786{
790 const struct tcp_sock *tp = tcp_sk(sk); 787 return tp->snd_una + tp->snd_wnd;
791 u32 left;
792
793 if (in_flight >= tp->snd_cwnd)
794 return 1;
795
796 if (!sk_can_gso(sk))
797 return 0;
798
799 left = tp->snd_cwnd - in_flight;
800 if (sysctl_tcp_tso_win_divisor)
801 return left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd;
802 else
803 return left <= tcp_max_burst(tp);
804} 788}
789extern int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight);
805 790
806static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss, 791static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss,
807 const struct sk_buff *skb) 792 const struct sk_buff *skb)
@@ -921,40 +906,7 @@ static const char *statename[]={
921 "Close Wait","Last ACK","Listen","Closing" 906 "Close Wait","Last ACK","Listen","Closing"
922}; 907};
923#endif 908#endif
924 909extern void tcp_set_state(struct sock *sk, int state);
925static inline void tcp_set_state(struct sock *sk, int state)
926{
927 int oldstate = sk->sk_state;
928
929 switch (state) {
930 case TCP_ESTABLISHED:
931 if (oldstate != TCP_ESTABLISHED)
932 TCP_INC_STATS(TCP_MIB_CURRESTAB);
933 break;
934
935 case TCP_CLOSE:
936 if (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)
937 TCP_INC_STATS(TCP_MIB_ESTABRESETS);
938
939 sk->sk_prot->unhash(sk);
940 if (inet_csk(sk)->icsk_bind_hash &&
941 !(sk->sk_userlocks & SOCK_BINDPORT_LOCK))
942 inet_put_port(&tcp_hashinfo, sk);
943 /* fall through */
944 default:
945 if (oldstate==TCP_ESTABLISHED)
946 TCP_DEC_STATS(TCP_MIB_CURRESTAB);
947 }
948
949 /* Change state AFTER socket is unhashed to avoid closed
950 * socket sitting in hash tables.
951 */
952 sk->sk_state = state;
953
954#ifdef STATE_TRACE
955 SOCK_DEBUG(sk, "TCP sk=%p, State %s -> %s\n",sk, statename[oldstate],statename[state]);
956#endif
957}
958 910
959extern void tcp_done(struct sock *sk); 911extern void tcp_done(struct sock *sk);
960 912
@@ -1078,7 +1030,6 @@ static inline void tcp_clear_retrans_hints_partial(struct tcp_sock *tp)
1078static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp) 1030static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp)
1079{ 1031{
1080 tcp_clear_retrans_hints_partial(tp); 1032 tcp_clear_retrans_hints_partial(tp);
1081 tp->fastpath_skb_hint = NULL;
1082} 1033}
1083 1034
1084/* MD5 Signature */ 1035/* MD5 Signature */
@@ -1153,7 +1104,8 @@ extern int tcp_v4_calc_md5_hash(char *md5_hash,
1153 struct dst_entry *dst, 1104 struct dst_entry *dst,
1154 struct request_sock *req, 1105 struct request_sock *req,
1155 struct tcphdr *th, 1106 struct tcphdr *th,
1156 int protocol, int tcplen); 1107 int protocol,
1108 unsigned int tcplen);
1157extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, 1109extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk,
1158 struct sock *addr_sk); 1110 struct sock *addr_sk);
1159 1111
@@ -1193,8 +1145,8 @@ static inline void tcp_write_queue_purge(struct sock *sk)
1193 struct sk_buff *skb; 1145 struct sk_buff *skb;
1194 1146
1195 while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL) 1147 while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL)
1196 sk_stream_free_skb(sk, skb); 1148 sk_wmem_free_skb(sk, skb);
1197 sk_stream_mem_reclaim(sk); 1149 sk_mem_reclaim(sk);
1198} 1150}
1199 1151
1200static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) 1152static inline struct sk_buff *tcp_write_queue_head(struct sock *sk)
@@ -1227,6 +1179,11 @@ static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_bu
1227 for (; (skb != (struct sk_buff *)&(sk)->sk_write_queue);\ 1179 for (; (skb != (struct sk_buff *)&(sk)->sk_write_queue);\
1228 skb = skb->next) 1180 skb = skb->next)
1229 1181
1182#define tcp_for_write_queue_from_safe(skb, tmp, sk) \
1183 for (tmp = skb->next; \
1184 (skb != (struct sk_buff *)&(sk)->sk_write_queue); \
1185 skb = tmp, tmp = skb->next)
1186
1230static inline struct sk_buff *tcp_send_head(struct sock *sk) 1187static inline struct sk_buff *tcp_send_head(struct sock *sk)
1231{ 1188{
1232 return sk->sk_send_head; 1189 return sk->sk_send_head;
@@ -1234,14 +1191,9 @@ static inline struct sk_buff *tcp_send_head(struct sock *sk)
1234 1191
1235static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) 1192static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb)
1236{ 1193{
1237 struct tcp_sock *tp = tcp_sk(sk);
1238
1239 sk->sk_send_head = skb->next; 1194 sk->sk_send_head = skb->next;
1240 if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue) 1195 if (sk->sk_send_head == (struct sk_buff *)&sk->sk_write_queue)
1241 sk->sk_send_head = NULL; 1196 sk->sk_send_head = NULL;
1242 /* Don't override Nagle indefinately with F-RTO */
1243 if (tp->frto_counter == 2)
1244 tp->frto_counter = 3;
1245} 1197}
1246 1198
1247static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked) 1199static inline void tcp_check_send_head(struct sock *sk, struct sk_buff *skb_unlinked)
@@ -1265,8 +1217,12 @@ static inline void tcp_add_write_queue_tail(struct sock *sk, struct sk_buff *skb
1265 __tcp_add_write_queue_tail(sk, skb); 1217 __tcp_add_write_queue_tail(sk, skb);
1266 1218
1267 /* Queue it, remembering where we must start sending. */ 1219 /* Queue it, remembering where we must start sending. */
1268 if (sk->sk_send_head == NULL) 1220 if (sk->sk_send_head == NULL) {
1269 sk->sk_send_head = skb; 1221 sk->sk_send_head = skb;
1222
1223 if (tcp_sk(sk)->highest_sack == NULL)
1224 tcp_sk(sk)->highest_sack = skb;
1225 }
1270} 1226}
1271 1227
1272static inline void __tcp_add_write_queue_head(struct sock *sk, struct sk_buff *skb) 1228static inline void __tcp_add_write_queue_head(struct sock *sk, struct sk_buff *skb)
@@ -1288,6 +1244,9 @@ static inline void tcp_insert_write_queue_before(struct sk_buff *new,
1288 struct sock *sk) 1244 struct sock *sk)
1289{ 1245{
1290 __skb_insert(new, skb->prev, skb, &sk->sk_write_queue); 1246 __skb_insert(new, skb->prev, skb, &sk->sk_write_queue);
1247
1248 if (sk->sk_send_head == skb)
1249 sk->sk_send_head = new;
1291} 1250}
1292 1251
1293static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk) 1252static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk)
@@ -1306,6 +1265,45 @@ static inline int tcp_write_queue_empty(struct sock *sk)
1306 return skb_queue_empty(&sk->sk_write_queue); 1265 return skb_queue_empty(&sk->sk_write_queue);
1307} 1266}
1308 1267
1268/* Start sequence of the highest skb with SACKed bit, valid only if
1269 * sacked > 0 or when the caller has ensured validity by itself.
1270 */
1271static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp)
1272{
1273 if (!tp->sacked_out)
1274 return tp->snd_una;
1275
1276 if (tp->highest_sack == NULL)
1277 return tp->snd_nxt;
1278
1279 return TCP_SKB_CB(tp->highest_sack)->seq;
1280}
1281
1282static inline void tcp_advance_highest_sack(struct sock *sk, struct sk_buff *skb)
1283{
1284 tcp_sk(sk)->highest_sack = tcp_skb_is_last(sk, skb) ? NULL :
1285 tcp_write_queue_next(sk, skb);
1286}
1287
1288static inline struct sk_buff *tcp_highest_sack(struct sock *sk)
1289{
1290 return tcp_sk(sk)->highest_sack;
1291}
1292
1293static inline void tcp_highest_sack_reset(struct sock *sk)
1294{
1295 tcp_sk(sk)->highest_sack = tcp_write_queue_head(sk);
1296}
1297
1298/* Called when old skb is about to be deleted (to be combined with new skb) */
1299static inline void tcp_highest_sack_combine(struct sock *sk,
1300 struct sk_buff *old,
1301 struct sk_buff *new)
1302{
1303 if (tcp_sk(sk)->sacked_out && (old == tcp_sk(sk)->highest_sack))
1304 tcp_sk(sk)->highest_sack = new;
1305}
1306
1309/* /proc */ 1307/* /proc */
1310enum tcp_seq_states { 1308enum tcp_seq_states {
1311 TCP_SEQ_STATE_LISTENING, 1309 TCP_SEQ_STATE_LISTENING,
@@ -1356,7 +1354,8 @@ struct tcp_sock_af_ops {
1356 struct dst_entry *dst, 1354 struct dst_entry *dst,
1357 struct request_sock *req, 1355 struct request_sock *req,
1358 struct tcphdr *th, 1356 struct tcphdr *th,
1359 int protocol, int len); 1357 int protocol,
1358 unsigned int len);
1360 int (*md5_add) (struct sock *sk, 1359 int (*md5_add) (struct sock *sk,
1361 struct sock *addr_sk, 1360 struct sock *addr_sk,
1362 u8 *newkey, 1361 u8 *newkey,
diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h
index 409da3a9a455..27394e0447d8 100644
--- a/include/net/transp_v6.h
+++ b/include/net/transp_v6.h
@@ -17,16 +17,20 @@ extern struct proto tcpv6_prot;
17struct flowi; 17struct flowi;
18 18
19/* extention headers */ 19/* extention headers */
20extern void ipv6_rthdr_init(void); 20extern int ipv6_exthdrs_init(void);
21extern void ipv6_frag_init(void); 21extern void ipv6_exthdrs_exit(void);
22extern void ipv6_nodata_init(void); 22extern int ipv6_frag_init(void);
23extern void ipv6_destopt_init(void); 23extern void ipv6_frag_exit(void);
24 24
25/* transport protocols */ 25/* transport protocols */
26extern void rawv6_init(void); 26extern int rawv6_init(void);
27extern void udpv6_init(void); 27extern void rawv6_exit(void);
28extern void udplitev6_init(void); 28extern int udpv6_init(void);
29extern void tcpv6_init(void); 29extern void udpv6_exit(void);
30extern int udplitev6_init(void);
31extern void udplitev6_exit(void);
32extern int tcpv6_init(void);
33extern void tcpv6_exit(void);
30 34
31extern int udpv6_connect(struct sock *sk, 35extern int udpv6_connect(struct sock *sk,
32 struct sockaddr *uaddr, 36 struct sockaddr *uaddr,
diff --git a/include/net/udp.h b/include/net/udp.h
index 98755ebaf163..c6669c0a74c7 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -65,6 +65,13 @@ extern rwlock_t udp_hash_lock;
65 65
66extern struct proto udp_prot; 66extern struct proto udp_prot;
67 67
68extern atomic_t udp_memory_allocated;
69
70/* sysctl variables for udp */
71extern int sysctl_udp_mem[3];
72extern int sysctl_udp_rmem_min;
73extern int sysctl_udp_wmem_min;
74
68struct sk_buff; 75struct sk_buff;
69 76
70/* 77/*
@@ -108,7 +115,7 @@ static inline void udp_lib_unhash(struct sock *sk)
108 write_lock_bh(&udp_hash_lock); 115 write_lock_bh(&udp_hash_lock);
109 if (sk_del_node_init(sk)) { 116 if (sk_del_node_init(sk)) {
110 inet_sk(sk)->num = 0; 117 inet_sk(sk)->num = 0;
111 sock_prot_dec_use(sk->sk_prot); 118 sock_prot_inuse_add(sk->sk_prot, -1);
112 } 119 }
113 write_unlock_bh(&udp_hash_lock); 120 write_unlock_bh(&udp_hash_lock);
114} 121}
@@ -139,6 +146,12 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname,
139 int (*push_pending_frames)(struct sock *)); 146 int (*push_pending_frames)(struct sock *));
140 147
141DECLARE_SNMP_STAT(struct udp_mib, udp_statistics); 148DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
149DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
150
151/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
152DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
153DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
154
142/* 155/*
143 * SNMP statistics for UDP and UDP-Lite 156 * SNMP statistics for UDP and UDP-Lite
144 */ 157 */
@@ -149,6 +162,25 @@ DECLARE_SNMP_STAT(struct udp_mib, udp_statistics);
149 if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \ 162 if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field); \
150 else SNMP_INC_STATS_BH(udp_statistics, field); } while(0) 163 else SNMP_INC_STATS_BH(udp_statistics, field); } while(0)
151 164
165#define UDP6_INC_STATS_BH(field, is_udplite) do { \
166 if (is_udplite) SNMP_INC_STATS_BH(udplite_stats_in6, field); \
167 else SNMP_INC_STATS_BH(udp_stats_in6, field); } while(0)
168#define UDP6_INC_STATS_USER(field, is_udplite) do { \
169 if (is_udplite) SNMP_INC_STATS_USER(udplite_stats_in6, field); \
170 else SNMP_INC_STATS_USER(udp_stats_in6, field); } while(0)
171
172#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
173#define UDPX_INC_STATS_BH(sk, field) \
174 do { \
175 if ((sk)->sk_family == AF_INET) \
176 UDP_INC_STATS_BH(field, 0); \
177 else \
178 UDP6_INC_STATS_BH(field, 0); \
179 } while (0);
180#else
181#define UDPX_INC_STATS_BH(sk, field) UDP_INC_STATS_BH(field, 0)
182#endif
183
152/* /proc */ 184/* /proc */
153struct udp_seq_afinfo { 185struct udp_seq_afinfo {
154 struct module *owner; 186 struct module *owner;
@@ -173,4 +205,6 @@ extern void udp_proc_unregister(struct udp_seq_afinfo *afinfo);
173extern int udp4_proc_init(void); 205extern int udp4_proc_init(void);
174extern void udp4_proc_exit(void); 206extern void udp4_proc_exit(void);
175#endif 207#endif
208
209extern void udp_init(void);
176#endif /* _UDP_H */ 210#endif /* _UDP_H */
diff --git a/include/net/udplite.h b/include/net/udplite.h
index 635b0eafca95..b76b2e377af4 100644
--- a/include/net/udplite.h
+++ b/include/net/udplite.h
@@ -13,9 +13,6 @@
13extern struct proto udplite_prot; 13extern struct proto udplite_prot;
14extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE]; 14extern struct hlist_head udplite_hash[UDP_HTABLE_SIZE];
15 15
16/* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
17DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
18
19/* 16/*
20 * Checksum computation is all in software, hence simpler getfrag. 17 * Checksum computation is all in software, hence simpler getfrag.
21 */ 18 */
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 58dfa82889aa..ac72116636ca 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -19,6 +19,9 @@
19#include <net/route.h> 19#include <net/route.h>
20#include <net/ipv6.h> 20#include <net/ipv6.h>
21#include <net/ip6_fib.h> 21#include <net/ip6_fib.h>
22#ifdef CONFIG_XFRM_STATISTICS
23#include <net/snmp.h>
24#endif
22 25
23#define XFRM_PROTO_ESP 50 26#define XFRM_PROTO_ESP 50
24#define XFRM_PROTO_AH 51 27#define XFRM_PROTO_AH 51
@@ -34,6 +37,17 @@
34#define MODULE_ALIAS_XFRM_TYPE(family, proto) \ 37#define MODULE_ALIAS_XFRM_TYPE(family, proto) \
35 MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto)) 38 MODULE_ALIAS("xfrm-type-" __stringify(family) "-" __stringify(proto))
36 39
40#ifdef CONFIG_XFRM_STATISTICS
41DECLARE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics);
42#define XFRM_INC_STATS(field) SNMP_INC_STATS(xfrm_statistics, field)
43#define XFRM_INC_STATS_BH(field) SNMP_INC_STATS_BH(xfrm_statistics, field)
44#define XFRM_INC_STATS_USER(field) SNMP_INC_STATS_USER(xfrm_statistics, field)
45#else
46#define XFRM_INC_STATS(field)
47#define XFRM_INC_STATS_BH(field)
48#define XFRM_INC_STATS_USER(field)
49#endif
50
37extern struct sock *xfrm_nl; 51extern struct sock *xfrm_nl;
38extern u32 sysctl_xfrm_aevent_etime; 52extern u32 sysctl_xfrm_aevent_etime;
39extern u32 sysctl_xfrm_aevent_rseqth; 53extern u32 sysctl_xfrm_aevent_rseqth;
@@ -145,6 +159,7 @@ struct xfrm_state
145 struct xfrm_algo *aalg; 159 struct xfrm_algo *aalg;
146 struct xfrm_algo *ealg; 160 struct xfrm_algo *ealg;
147 struct xfrm_algo *calg; 161 struct xfrm_algo *calg;
162 struct xfrm_algo_aead *aead;
148 163
149 /* Data for encapsulator */ 164 /* Data for encapsulator */
150 struct xfrm_encap_tmpl *encap; 165 struct xfrm_encap_tmpl *encap;
@@ -183,11 +198,11 @@ struct xfrm_state
183 struct timer_list timer; 198 struct timer_list timer;
184 199
185 /* Last used time */ 200 /* Last used time */
186 u64 lastused; 201 unsigned long lastused;
187 202
188 /* Reference to data common to all the instances of this 203 /* Reference to data common to all the instances of this
189 * transformer. */ 204 * transformer. */
190 struct xfrm_type *type; 205 const struct xfrm_type *type;
191 struct xfrm_mode *inner_mode; 206 struct xfrm_mode *inner_mode;
192 struct xfrm_mode *outer_mode; 207 struct xfrm_mode *outer_mode;
193 208
@@ -227,22 +242,26 @@ struct km_event
227 u32 event; 242 u32 event;
228}; 243};
229 244
245struct net_device;
230struct xfrm_type; 246struct xfrm_type;
231struct xfrm_dst; 247struct xfrm_dst;
232struct xfrm_policy_afinfo { 248struct xfrm_policy_afinfo {
233 unsigned short family; 249 unsigned short family;
234 struct dst_ops *dst_ops; 250 struct dst_ops *dst_ops;
235 void (*garbage_collect)(void); 251 void (*garbage_collect)(void);
236 int (*dst_lookup)(struct xfrm_dst **dst, struct flowi *fl); 252 struct dst_entry *(*dst_lookup)(int tos, xfrm_address_t *saddr,
253 xfrm_address_t *daddr);
237 int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr); 254 int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr);
238 struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy); 255 struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy);
239 int (*bundle_create)(struct xfrm_policy *policy,
240 struct xfrm_state **xfrm,
241 int nx,
242 struct flowi *fl,
243 struct dst_entry **dst_p);
244 void (*decode_session)(struct sk_buff *skb, 256 void (*decode_session)(struct sk_buff *skb,
245 struct flowi *fl); 257 struct flowi *fl,
258 int reverse);
259 int (*get_tos)(struct flowi *fl);
260 int (*init_path)(struct xfrm_dst *path,
261 struct dst_entry *dst,
262 int nfheader_len);
263 int (*fill_dst)(struct xfrm_dst *xdst,
264 struct net_device *dev);
246}; 265};
247 266
248extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); 267extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
@@ -257,8 +276,10 @@ extern int __xfrm_state_delete(struct xfrm_state *x);
257 276
258struct xfrm_state_afinfo { 277struct xfrm_state_afinfo {
259 unsigned int family; 278 unsigned int family;
279 unsigned int proto;
280 unsigned int eth_proto;
260 struct module *owner; 281 struct module *owner;
261 struct xfrm_type *type_map[IPPROTO_MAX]; 282 const struct xfrm_type *type_map[IPPROTO_MAX];
262 struct xfrm_mode *mode_map[XFRM_MODE_MAX]; 283 struct xfrm_mode *mode_map[XFRM_MODE_MAX];
263 int (*init_flags)(struct xfrm_state *x); 284 int (*init_flags)(struct xfrm_state *x);
264 void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl, 285 void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl,
@@ -267,6 +288,12 @@ struct xfrm_state_afinfo {
267 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); 288 int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n);
268 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); 289 int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n);
269 int (*output)(struct sk_buff *skb); 290 int (*output)(struct sk_buff *skb);
291 int (*extract_input)(struct xfrm_state *x,
292 struct sk_buff *skb);
293 int (*extract_output)(struct xfrm_state *x,
294 struct sk_buff *skb);
295 int (*transport_finish)(struct sk_buff *skb,
296 int async);
270}; 297};
271 298
272extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo); 299extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
@@ -282,6 +309,8 @@ struct xfrm_type
282 __u8 flags; 309 __u8 flags;
283#define XFRM_TYPE_NON_FRAGMENT 1 310#define XFRM_TYPE_NON_FRAGMENT 1
284#define XFRM_TYPE_REPLAY_PROT 2 311#define XFRM_TYPE_REPLAY_PROT 2
312#define XFRM_TYPE_LOCAL_COADDR 4
313#define XFRM_TYPE_REMOTE_COADDR 8
285 314
286 int (*init_state)(struct xfrm_state *x); 315 int (*init_state)(struct xfrm_state *x);
287 void (*destructor)(struct xfrm_state *); 316 void (*destructor)(struct xfrm_state *);
@@ -289,16 +318,35 @@ struct xfrm_type
289 int (*output)(struct xfrm_state *, struct sk_buff *pskb); 318 int (*output)(struct xfrm_state *, struct sk_buff *pskb);
290 int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); 319 int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *);
291 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); 320 int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **);
292 xfrm_address_t *(*local_addr)(struct xfrm_state *, xfrm_address_t *);
293 xfrm_address_t *(*remote_addr)(struct xfrm_state *, xfrm_address_t *);
294 /* Estimate maximal size of result of transformation of a dgram */ 321 /* Estimate maximal size of result of transformation of a dgram */
295 u32 (*get_mtu)(struct xfrm_state *, int size); 322 u32 (*get_mtu)(struct xfrm_state *, int size);
296}; 323};
297 324
298extern int xfrm_register_type(struct xfrm_type *type, unsigned short family); 325extern int xfrm_register_type(const struct xfrm_type *type, unsigned short family);
299extern int xfrm_unregister_type(struct xfrm_type *type, unsigned short family); 326extern int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family);
300 327
301struct xfrm_mode { 328struct xfrm_mode {
329 /*
330 * Remove encapsulation header.
331 *
332 * The IP header will be moved over the top of the encapsulation
333 * header.
334 *
335 * On entry, the transport header shall point to where the IP header
336 * should be and the network header shall be set to where the IP
337 * header currently is. skb->data shall point to the start of the
338 * payload.
339 */
340 int (*input2)(struct xfrm_state *x, struct sk_buff *skb);
341
342 /*
343 * This is the actual input entry point.
344 *
345 * For transport mode and equivalent this would be identical to
346 * input2 (which does not need to be set). While tunnel mode
347 * and equivalent would set this to the tunnel encapsulation function
348 * xfrm4_prepare_input that would in turn call input2.
349 */
302 int (*input)(struct xfrm_state *x, struct sk_buff *skb); 350 int (*input)(struct xfrm_state *x, struct sk_buff *skb);
303 351
304 /* 352 /*
@@ -312,7 +360,18 @@ struct xfrm_mode {
312 * header. The value of the network header will always point 360 * header. The value of the network header will always point
313 * to the top IP header while skb->data will point to the payload. 361 * to the top IP header while skb->data will point to the payload.
314 */ 362 */
315 int (*output)(struct xfrm_state *x,struct sk_buff *skb); 363 int (*output2)(struct xfrm_state *x,struct sk_buff *skb);
364
365 /*
366 * This is the actual output entry point.
367 *
368 * For transport mode and equivalent this would be identical to
369 * output2 (which does not need to be set). While tunnel mode
370 * and equivalent would set this to a tunnel encapsulation function
371 * (xfrm4_prepare_output or xfrm6_prepare_output) that would in turn
372 * call output2.
373 */
374 int (*output)(struct xfrm_state *x, struct sk_buff *skb);
316 375
317 struct xfrm_state_afinfo *afinfo; 376 struct xfrm_state_afinfo *afinfo;
318 struct module *owner; 377 struct module *owner;
@@ -454,6 +513,51 @@ struct xfrm_skb_cb {
454 513
455#define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0])) 514#define XFRM_SKB_CB(__skb) ((struct xfrm_skb_cb *)&((__skb)->cb[0]))
456 515
516/*
517 * This structure is used by the afinfo prepare_input/prepare_output functions
518 * to transmit header information to the mode input/output functions.
519 */
520struct xfrm_mode_skb_cb {
521 union {
522 struct inet_skb_parm h4;
523 struct inet6_skb_parm h6;
524 } header;
525
526 /* Copied from header for IPv4, always set to zero and DF for IPv6. */
527 __be16 id;
528 __be16 frag_off;
529
530 /* TOS for IPv4, class for IPv6. */
531 u8 tos;
532
533 /* TTL for IPv4, hop limitfor IPv6. */
534 u8 ttl;
535
536 /* Protocol for IPv4, NH for IPv6. */
537 u8 protocol;
538
539 /* Used by IPv6 only, zero for IPv4. */
540 u8 flow_lbl[3];
541};
542
543#define XFRM_MODE_SKB_CB(__skb) ((struct xfrm_mode_skb_cb *)&((__skb)->cb[0]))
544
545/*
546 * This structure is used by the input processing to locate the SPI and
547 * related information.
548 */
549struct xfrm_spi_skb_cb {
550 union {
551 struct inet_skb_parm h4;
552 struct inet6_skb_parm h6;
553 } header;
554
555 unsigned int daddroff;
556 unsigned int family;
557};
558
559#define XFRM_SPI_SKB_CB(__skb) ((struct xfrm_spi_skb_cb *)&((__skb)->cb[0]))
560
457/* Audit Information */ 561/* Audit Information */
458struct xfrm_audit 562struct xfrm_audit
459{ 563{
@@ -462,41 +566,59 @@ struct xfrm_audit
462}; 566};
463 567
464#ifdef CONFIG_AUDITSYSCALL 568#ifdef CONFIG_AUDITSYSCALL
465static inline struct audit_buffer *xfrm_audit_start(u32 auid, u32 sid) 569static inline struct audit_buffer *xfrm_audit_start(const char *op)
466{ 570{
467 struct audit_buffer *audit_buf = NULL; 571 struct audit_buffer *audit_buf = NULL;
468 char *secctx;
469 u32 secctx_len;
470 572
573 if (audit_enabled == 0)
574 return NULL;
471 audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC, 575 audit_buf = audit_log_start(current->audit_context, GFP_ATOMIC,
472 AUDIT_MAC_IPSEC_EVENT); 576 AUDIT_MAC_IPSEC_EVENT);
473 if (audit_buf == NULL) 577 if (audit_buf == NULL)
474 return NULL; 578 return NULL;
579 audit_log_format(audit_buf, "op=%s", op);
580 return audit_buf;
581}
475 582
476 audit_log_format(audit_buf, "auid=%u", auid); 583static inline void xfrm_audit_helper_usrinfo(u32 auid, u32 secid,
584 struct audit_buffer *audit_buf)
585{
586 char *secctx;
587 u32 secctx_len;
477 588
478 if (sid != 0 && 589 audit_log_format(audit_buf, " auid=%u", auid);
479 security_secid_to_secctx(sid, &secctx, &secctx_len) == 0) { 590 if (secid != 0 &&
591 security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) {
480 audit_log_format(audit_buf, " subj=%s", secctx); 592 audit_log_format(audit_buf, " subj=%s", secctx);
481 security_release_secctx(secctx, secctx_len); 593 security_release_secctx(secctx, secctx_len);
482 } else 594 } else
483 audit_log_task_context(audit_buf); 595 audit_log_task_context(audit_buf);
484 return audit_buf;
485} 596}
486 597
487extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, 598extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result,
488 u32 auid, u32 sid); 599 u32 auid, u32 secid);
489extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, 600extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result,
490 u32 auid, u32 sid); 601 u32 auid, u32 secid);
491extern void xfrm_audit_state_add(struct xfrm_state *x, int result, 602extern void xfrm_audit_state_add(struct xfrm_state *x, int result,
492 u32 auid, u32 sid); 603 u32 auid, u32 secid);
493extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, 604extern void xfrm_audit_state_delete(struct xfrm_state *x, int result,
494 u32 auid, u32 sid); 605 u32 auid, u32 secid);
606extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x,
607 struct sk_buff *skb);
608extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family);
609extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family,
610 __be32 net_spi, __be32 net_seq);
611extern void xfrm_audit_state_icvfail(struct xfrm_state *x,
612 struct sk_buff *skb, u8 proto);
495#else 613#else
496#define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0) 614#define xfrm_audit_policy_add(x, r, a, s) do { ; } while (0)
497#define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0) 615#define xfrm_audit_policy_delete(x, r, a, s) do { ; } while (0)
498#define xfrm_audit_state_add(x, r, a, s) do { ; } while (0) 616#define xfrm_audit_state_add(x, r, a, s) do { ; } while (0)
499#define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0) 617#define xfrm_audit_state_delete(x, r, a, s) do { ; } while (0)
618#define xfrm_audit_state_replay_overflow(x, s) do { ; } while (0)
619#define xfrm_audit_state_notfound_simple(s, f) do { ; } while (0)
620#define xfrm_audit_state_notfound(s, f, sp, sq) do { ; } while (0)
621#define xfrm_audit_state_icvfail(x, s, p) do { ; } while (0)
500#endif /* CONFIG_AUDITSYSCALL */ 622#endif /* CONFIG_AUDITSYSCALL */
501 623
502static inline void xfrm_pol_hold(struct xfrm_policy *policy) 624static inline void xfrm_pol_hold(struct xfrm_policy *policy)
@@ -505,12 +627,12 @@ static inline void xfrm_pol_hold(struct xfrm_policy *policy)
505 atomic_inc(&policy->refcnt); 627 atomic_inc(&policy->refcnt);
506} 628}
507 629
508extern void __xfrm_policy_destroy(struct xfrm_policy *policy); 630extern void xfrm_policy_destroy(struct xfrm_policy *policy);
509 631
510static inline void xfrm_pol_put(struct xfrm_policy *policy) 632static inline void xfrm_pol_put(struct xfrm_policy *policy)
511{ 633{
512 if (atomic_dec_and_test(&policy->refcnt)) 634 if (atomic_dec_and_test(&policy->refcnt))
513 __xfrm_policy_destroy(policy); 635 xfrm_policy_destroy(policy);
514} 636}
515 637
516#ifdef CONFIG_XFRM_SUB_POLICY 638#ifdef CONFIG_XFRM_SUB_POLICY
@@ -757,17 +879,25 @@ xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short
757} 879}
758 880
759#ifdef CONFIG_XFRM 881#ifdef CONFIG_XFRM
760
761extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family); 882extern int __xfrm_policy_check(struct sock *, int dir, struct sk_buff *skb, unsigned short family);
762 883
763static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family) 884static inline int __xfrm_policy_check2(struct sock *sk, int dir,
885 struct sk_buff *skb,
886 unsigned int family, int reverse)
764{ 887{
888 int ndir = dir | (reverse ? XFRM_POLICY_MASK + 1 : 0);
889
765 if (sk && sk->sk_policy[XFRM_POLICY_IN]) 890 if (sk && sk->sk_policy[XFRM_POLICY_IN])
766 return __xfrm_policy_check(sk, dir, skb, family); 891 return __xfrm_policy_check(sk, ndir, skb, family);
767 892
768 return (!xfrm_policy_count[dir] && !skb->sp) || 893 return (!xfrm_policy_count[dir] && !skb->sp) ||
769 (skb->dst->flags & DST_NOPOLICY) || 894 (skb->dst->flags & DST_NOPOLICY) ||
770 __xfrm_policy_check(sk, dir, skb, family); 895 __xfrm_policy_check(sk, ndir, skb, family);
896}
897
898static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, unsigned short family)
899{
900 return __xfrm_policy_check2(sk, dir, skb, family, 0);
771} 901}
772 902
773static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb) 903static inline int xfrm4_policy_check(struct sock *sk, int dir, struct sk_buff *skb)
@@ -780,7 +910,34 @@ static inline int xfrm6_policy_check(struct sock *sk, int dir, struct sk_buff *s
780 return xfrm_policy_check(sk, dir, skb, AF_INET6); 910 return xfrm_policy_check(sk, dir, skb, AF_INET6);
781} 911}
782 912
783extern int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl, unsigned short family); 913static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir,
914 struct sk_buff *skb)
915{
916 return __xfrm_policy_check2(sk, dir, skb, AF_INET, 1);
917}
918
919static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
920 struct sk_buff *skb)
921{
922 return __xfrm_policy_check2(sk, dir, skb, AF_INET6, 1);
923}
924
925extern int __xfrm_decode_session(struct sk_buff *skb, struct flowi *fl,
926 unsigned int family, int reverse);
927
928static inline int xfrm_decode_session(struct sk_buff *skb, struct flowi *fl,
929 unsigned int family)
930{
931 return __xfrm_decode_session(skb, fl, family, 0);
932}
933
934static inline int xfrm_decode_session_reverse(struct sk_buff *skb,
935 struct flowi *fl,
936 unsigned int family)
937{
938 return __xfrm_decode_session(skb, fl, family, 1);
939}
940
784extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family); 941extern int __xfrm_route_forward(struct sk_buff *skb, unsigned short family);
785 942
786static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family) 943static inline int xfrm_route_forward(struct sk_buff *skb, unsigned short family)
@@ -841,6 +998,22 @@ static inline int xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *sk
841{ 998{
842 return 1; 999 return 1;
843} 1000}
1001static inline int xfrm_decode_session_reverse(struct sk_buff *skb,
1002 struct flowi *fl,
1003 unsigned int family)
1004{
1005 return -ENOSYS;
1006}
1007static inline int xfrm4_policy_check_reverse(struct sock *sk, int dir,
1008 struct sk_buff *skb)
1009{
1010 return 1;
1011}
1012static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
1013 struct sk_buff *skb)
1014{
1015 return 1;
1016}
844#endif 1017#endif
845 1018
846static __inline__ 1019static __inline__
@@ -936,6 +1109,10 @@ static inline int xfrm_id_proto_match(u8 proto, u8 userproto)
936/* 1109/*
937 * xfrm algorithm information 1110 * xfrm algorithm information
938 */ 1111 */
1112struct xfrm_algo_aead_info {
1113 u16 icv_truncbits;
1114};
1115
939struct xfrm_algo_auth_info { 1116struct xfrm_algo_auth_info {
940 u16 icv_truncbits; 1117 u16 icv_truncbits;
941 u16 icv_fullbits; 1118 u16 icv_fullbits;
@@ -955,6 +1132,7 @@ struct xfrm_algo_desc {
955 char *compat; 1132 char *compat;
956 u8 available:1; 1133 u8 available:1;
957 union { 1134 union {
1135 struct xfrm_algo_aead_info aead;
958 struct xfrm_algo_auth_info auth; 1136 struct xfrm_algo_auth_info auth;
959 struct xfrm_algo_encr_info encr; 1137 struct xfrm_algo_encr_info encr;
960 struct xfrm_algo_comp_info comp; 1138 struct xfrm_algo_comp_info comp;
@@ -981,12 +1159,27 @@ struct xfrm6_tunnel {
981 1159
982extern void xfrm_init(void); 1160extern void xfrm_init(void);
983extern void xfrm4_init(void); 1161extern void xfrm4_init(void);
984extern void xfrm6_init(void);
985extern void xfrm6_fini(void);
986extern void xfrm_state_init(void); 1162extern void xfrm_state_init(void);
987extern void xfrm4_state_init(void); 1163extern void xfrm4_state_init(void);
988extern void xfrm6_state_init(void); 1164#ifdef CONFIG_XFRM
1165extern int xfrm6_init(void);
1166extern void xfrm6_fini(void);
1167extern int xfrm6_state_init(void);
989extern void xfrm6_state_fini(void); 1168extern void xfrm6_state_fini(void);
1169#else
1170static inline int xfrm6_init(void)
1171{
1172 return 0;
1173}
1174static inline void xfrm6_fini(void)
1175{
1176 ;
1177}
1178#endif
1179
1180#ifdef CONFIG_XFRM_STATISTICS
1181extern int xfrm_proc_init(void);
1182#endif
990 1183
991extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *); 1184extern int xfrm_state_walk(u8 proto, int (*func)(struct xfrm_state *, int, void*), void *);
992extern struct xfrm_state *xfrm_state_alloc(void); 1185extern struct xfrm_state *xfrm_state_alloc(void);
@@ -1045,14 +1238,23 @@ extern int xfrm_state_delete(struct xfrm_state *x);
1045extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info); 1238extern int xfrm_state_flush(u8 proto, struct xfrm_audit *audit_info);
1046extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si); 1239extern void xfrm_sad_getinfo(struct xfrmk_sadinfo *si);
1047extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si); 1240extern void xfrm_spd_getinfo(struct xfrmk_spdinfo *si);
1048extern int xfrm_replay_check(struct xfrm_state *x, __be32 seq); 1241extern int xfrm_replay_check(struct xfrm_state *x,
1242 struct sk_buff *skb, __be32 seq);
1049extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); 1243extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq);
1050extern void xfrm_replay_notify(struct xfrm_state *x, int event); 1244extern void xfrm_replay_notify(struct xfrm_state *x, int event);
1051extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); 1245extern int xfrm_state_mtu(struct xfrm_state *x, int mtu);
1052extern int xfrm_init_state(struct xfrm_state *x); 1246extern int xfrm_init_state(struct xfrm_state *x);
1247extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb);
1248extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi,
1249 int encap_type);
1250extern int xfrm_input_resume(struct sk_buff *skb, int nexthdr);
1251extern int xfrm_output_resume(struct sk_buff *skb, int err);
1053extern int xfrm_output(struct sk_buff *skb); 1252extern int xfrm_output(struct sk_buff *skb);
1253extern int xfrm4_extract_header(struct sk_buff *skb);
1254extern int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb);
1054extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, 1255extern int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi,
1055 int encap_type); 1256 int encap_type);
1257extern int xfrm4_transport_finish(struct sk_buff *skb, int async);
1056extern int xfrm4_rcv(struct sk_buff *skb); 1258extern int xfrm4_rcv(struct sk_buff *skb);
1057 1259
1058static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) 1260static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi)
@@ -1060,10 +1262,15 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi)
1060 return xfrm4_rcv_encap(skb, nexthdr, spi, 0); 1262 return xfrm4_rcv_encap(skb, nexthdr, spi, 0);
1061} 1263}
1062 1264
1265extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1266extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1063extern int xfrm4_output(struct sk_buff *skb); 1267extern int xfrm4_output(struct sk_buff *skb);
1064extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); 1268extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family);
1065extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); 1269extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family);
1270extern int xfrm6_extract_header(struct sk_buff *skb);
1271extern int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb);
1066extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); 1272extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi);
1273extern int xfrm6_transport_finish(struct sk_buff *skb, int async);
1067extern int xfrm6_rcv(struct sk_buff *skb); 1274extern int xfrm6_rcv(struct sk_buff *skb);
1068extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, 1275extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
1069 xfrm_address_t *saddr, u8 proto); 1276 xfrm_address_t *saddr, u8 proto);
@@ -1072,6 +1279,8 @@ extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short
1072extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr); 1279extern __be32 xfrm6_tunnel_alloc_spi(xfrm_address_t *saddr);
1073extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr); 1280extern void xfrm6_tunnel_free_spi(xfrm_address_t *saddr);
1074extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr); 1281extern __be32 xfrm6_tunnel_spi_lookup(xfrm_address_t *saddr);
1282extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb);
1283extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb);
1075extern int xfrm6_output(struct sk_buff *skb); 1284extern int xfrm6_output(struct sk_buff *skb);
1076extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, 1285extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
1077 u8 **prevhdr); 1286 u8 **prevhdr);
@@ -1079,7 +1288,6 @@ extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
1079#ifdef CONFIG_XFRM 1288#ifdef CONFIG_XFRM
1080extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb); 1289extern int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb);
1081extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen); 1290extern int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen);
1082extern int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family);
1083#else 1291#else
1084static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen) 1292static inline int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen)
1085{ 1293{
@@ -1092,11 +1300,6 @@ static inline int xfrm4_udp_encap_rcv(struct sock *sk, struct sk_buff *skb)
1092 kfree_skb(skb); 1300 kfree_skb(skb);
1093 return 0; 1301 return 0;
1094} 1302}
1095
1096static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsigned short family)
1097{
1098 return -EINVAL;
1099}
1100#endif 1303#endif
1101 1304
1102struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); 1305struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp);
@@ -1113,11 +1316,9 @@ extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi);
1113struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto, 1316struct xfrm_state * xfrm_find_acq(u8 mode, u32 reqid, u8 proto,
1114 xfrm_address_t *daddr, xfrm_address_t *saddr, 1317 xfrm_address_t *daddr, xfrm_address_t *saddr,
1115 int create, unsigned short family); 1318 int create, unsigned short family);
1116extern int xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info);
1117extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); 1319extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol);
1118extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, 1320extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst,
1119 struct flowi *fl, int family, int strict); 1321 struct flowi *fl, int family, int strict);
1120extern void xfrm_init_pmtu(struct dst_entry *dst);
1121 1322
1122#ifdef CONFIG_XFRM_MIGRATE 1323#ifdef CONFIG_XFRM_MIGRATE
1123extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, 1324extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
@@ -1148,6 +1349,8 @@ extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id);
1148extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe); 1349extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe);
1149extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe); 1350extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe);
1150extern struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe); 1351extern struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe);
1352extern struct xfrm_algo_desc *xfrm_aead_get_byname(char *name, int icv_len,
1353 int probe);
1151 1354
1152struct hash_desc; 1355struct hash_desc;
1153struct scatterlist; 1356struct scatterlist;
@@ -1188,10 +1391,15 @@ static inline int xfrm_aevent_is_on(void)
1188 return ret; 1391 return ret;
1189} 1392}
1190 1393
1394static inline int xfrm_alg_len(struct xfrm_algo *alg)
1395{
1396 return sizeof(*alg) + ((alg->alg_key_len + 7) / 8);
1397}
1398
1191#ifdef CONFIG_XFRM_MIGRATE 1399#ifdef CONFIG_XFRM_MIGRATE
1192static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) 1400static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
1193{ 1401{
1194 return (struct xfrm_algo *)kmemdup(orig, sizeof(*orig) + orig->alg_key_len, GFP_KERNEL); 1402 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);
1195} 1403}
1196 1404
1197static inline void xfrm_states_put(struct xfrm_state **states, int n) 1405static inline void xfrm_states_put(struct xfrm_state **states, int n)
@@ -1209,4 +1417,9 @@ static inline void xfrm_states_delete(struct xfrm_state **states, int n)
1209} 1417}
1210#endif 1418#endif
1211 1419
1420static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb)
1421{
1422 return skb->sp->xvec[skb->sp->len - 1];
1423}
1424
1212#endif /* _NET_XFRM_H */ 1425#endif /* _NET_XFRM_H */
diff --git a/include/pcmcia/cs_types.h b/include/pcmcia/cs_types.h
index c1d1629fcd27..5f388035687d 100644
--- a/include/pcmcia/cs_types.h
+++ b/include/pcmcia/cs_types.h
@@ -21,7 +21,7 @@
21#include <sys/types.h> 21#include <sys/types.h>
22#endif 22#endif
23 23
24#if defined(__arm__) || defined(__mips__) 24#if defined(__arm__) || defined(__mips__) || defined(__avr32__)
25/* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */ 25/* This (ioaddr_t) is exposed to userspace & hence cannot be changed. */
26typedef u_int ioaddr_t; 26typedef u_int ioaddr_t;
27#else 27#else
diff --git a/include/rdma/ib_mad.h b/include/rdma/ib_mad.h
index 8ec3799e42e1..7228c056b9e9 100644
--- a/include/rdma/ib_mad.h
+++ b/include/rdma/ib_mad.h
@@ -230,7 +230,9 @@ struct ib_class_port_info
230 * @seg_count: The number of RMPP segments allocated for this send. 230 * @seg_count: The number of RMPP segments allocated for this send.
231 * @seg_size: Size of each RMPP segment. 231 * @seg_size: Size of each RMPP segment.
232 * @timeout_ms: Time to wait for a response. 232 * @timeout_ms: Time to wait for a response.
233 * @retries: Number of times to retry a request for a response. 233 * @retries: Number of times to retry a request for a response. For MADs
234 * using RMPP, this applies per window. On completion, returns the number
235 * of retries needed to complete the transfer.
234 * 236 *
235 * Users are responsible for initializing the MAD buffer itself, with the 237 * Users are responsible for initializing the MAD buffer itself, with the
236 * exception of any RMPP header. Additional segment buffer space allocated 238 * exception of any RMPP header. Additional segment buffer space allocated
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 4bea182d7116..cfbd38fe2998 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -48,9 +48,9 @@
48#include <linux/kref.h> 48#include <linux/kref.h>
49#include <linux/list.h> 49#include <linux/list.h>
50#include <linux/rwsem.h> 50#include <linux/rwsem.h>
51#include <linux/scatterlist.h>
51 52
52#include <asm/atomic.h> 53#include <asm/atomic.h>
53#include <asm/scatterlist.h>
54#include <asm/uaccess.h> 54#include <asm/uaccess.h>
55 55
56union ib_gid { 56union ib_gid {
@@ -1026,7 +1026,7 @@ struct ib_device {
1026 1026
1027 struct module *owner; 1027 struct module *owner;
1028 struct class_device class_dev; 1028 struct class_device class_dev;
1029 struct kobject ports_parent; 1029 struct kobject *ports_parent;
1030 struct list_head port_list; 1030 struct list_head port_list;
1031 1031
1032 enum { 1032 enum {
diff --git a/include/rdma/rdma_user_cm.h b/include/rdma/rdma_user_cm.h
index 9749c1b34d00..c55705460b87 100644
--- a/include/rdma/rdma_user_cm.h
+++ b/include/rdma/rdma_user_cm.h
@@ -60,7 +60,8 @@ enum {
60 RDMA_USER_CM_CMD_SET_OPTION, 60 RDMA_USER_CM_CMD_SET_OPTION,
61 RDMA_USER_CM_CMD_NOTIFY, 61 RDMA_USER_CM_CMD_NOTIFY,
62 RDMA_USER_CM_CMD_JOIN_MCAST, 62 RDMA_USER_CM_CMD_JOIN_MCAST,
63 RDMA_USER_CM_CMD_LEAVE_MCAST 63 RDMA_USER_CM_CMD_LEAVE_MCAST,
64 RDMA_USER_CM_CMD_MIGRATE_ID
64}; 65};
65 66
66/* 67/*
@@ -230,4 +231,14 @@ struct rdma_ucm_set_option {
230 __u32 optlen; 231 __u32 optlen;
231}; 232};
232 233
234struct rdma_ucm_migrate_id {
235 __u64 response;
236 __u32 id;
237 __u32 fd;
238};
239
240struct rdma_ucm_migrate_resp {
241 __u32 events_reported;
242};
243
233#endif /* RDMA_USER_CM_H */ 244#endif /* RDMA_USER_CM_H */
diff --git a/include/scsi/iscsi_if.h b/include/scsi/iscsi_if.h
index 50e907f42048..e19e58423166 100644
--- a/include/scsi/iscsi_if.h
+++ b/include/scsi/iscsi_if.h
@@ -49,12 +49,15 @@ enum iscsi_uevent_e {
49 49
50 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15, 50 ISCSI_UEVENT_TGT_DSCVR = UEVENT_BASE + 15,
51 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16, 51 ISCSI_UEVENT_SET_HOST_PARAM = UEVENT_BASE + 16,
52 ISCSI_UEVENT_UNBIND_SESSION = UEVENT_BASE + 17,
52 53
53 /* up events */ 54 /* up events */
54 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1, 55 ISCSI_KEVENT_RECV_PDU = KEVENT_BASE + 1,
55 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2, 56 ISCSI_KEVENT_CONN_ERROR = KEVENT_BASE + 2,
56 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3, 57 ISCSI_KEVENT_IF_ERROR = KEVENT_BASE + 3,
57 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4, 58 ISCSI_KEVENT_DESTROY_SESSION = KEVENT_BASE + 4,
59 ISCSI_KEVENT_UNBIND_SESSION = KEVENT_BASE + 5,
60 ISCSI_KEVENT_CREATE_SESSION = KEVENT_BASE + 6,
58}; 61};
59 62
60enum iscsi_tgt_dscvr { 63enum iscsi_tgt_dscvr {
@@ -156,6 +159,10 @@ struct iscsi_uevent {
156 uint32_t sid; 159 uint32_t sid;
157 uint32_t cid; 160 uint32_t cid;
158 } c_conn_ret; 161 } c_conn_ret;
162 struct msg_unbind_session {
163 uint32_t sid;
164 uint32_t host_no;
165 } unbind_session;
159 struct msg_recv_req { 166 struct msg_recv_req {
160 uint32_t sid; 167 uint32_t sid;
161 uint32_t cid; 168 uint32_t cid;
@@ -236,6 +243,13 @@ enum iscsi_param {
236 ISCSI_PARAM_PASSWORD, 243 ISCSI_PARAM_PASSWORD,
237 ISCSI_PARAM_PASSWORD_IN, 244 ISCSI_PARAM_PASSWORD_IN,
238 245
246 ISCSI_PARAM_FAST_ABORT,
247 ISCSI_PARAM_ABORT_TMO,
248 ISCSI_PARAM_LU_RESET_TMO,
249 ISCSI_PARAM_HOST_RESET_TMO,
250
251 ISCSI_PARAM_PING_TMO,
252 ISCSI_PARAM_RECV_TMO,
239 /* must always be last */ 253 /* must always be last */
240 ISCSI_PARAM_MAX, 254 ISCSI_PARAM_MAX,
241}; 255};
@@ -266,6 +280,12 @@ enum iscsi_param {
266#define ISCSI_USERNAME_IN (1 << ISCSI_PARAM_USERNAME_IN) 280#define ISCSI_USERNAME_IN (1 << ISCSI_PARAM_USERNAME_IN)
267#define ISCSI_PASSWORD (1 << ISCSI_PARAM_PASSWORD) 281#define ISCSI_PASSWORD (1 << ISCSI_PARAM_PASSWORD)
268#define ISCSI_PASSWORD_IN (1 << ISCSI_PARAM_PASSWORD_IN) 282#define ISCSI_PASSWORD_IN (1 << ISCSI_PARAM_PASSWORD_IN)
283#define ISCSI_FAST_ABORT (1 << ISCSI_PARAM_FAST_ABORT)
284#define ISCSI_ABORT_TMO (1 << ISCSI_PARAM_ABORT_TMO)
285#define ISCSI_LU_RESET_TMO (1 << ISCSI_PARAM_LU_RESET_TMO)
286#define ISCSI_HOST_RESET_TMO (1 << ISCSI_PARAM_HOST_RESET_TMO)
287#define ISCSI_PING_TMO (1 << ISCSI_PARAM_PING_TMO)
288#define ISCSI_RECV_TMO (1 << ISCSI_PARAM_RECV_TMO)
269 289
270/* iSCSI HBA params */ 290/* iSCSI HBA params */
271enum iscsi_host_param { 291enum iscsi_host_param {
diff --git a/include/scsi/iscsi_proto.h b/include/scsi/iscsi_proto.h
index 8d1e4e8026fe..318a909e7ae1 100644
--- a/include/scsi/iscsi_proto.h
+++ b/include/scsi/iscsi_proto.h
@@ -21,13 +21,15 @@
21#ifndef ISCSI_PROTO_H 21#ifndef ISCSI_PROTO_H
22#define ISCSI_PROTO_H 22#define ISCSI_PROTO_H
23 23
24#include <linux/types.h>
25
24#define ISCSI_DRAFT20_VERSION 0x00 26#define ISCSI_DRAFT20_VERSION 0x00
25 27
26/* default iSCSI listen port for incoming connections */ 28/* default iSCSI listen port for incoming connections */
27#define ISCSI_LISTEN_PORT 3260 29#define ISCSI_LISTEN_PORT 3260
28 30
29/* Padding word length */ 31/* Padding word length */
30#define PAD_WORD_LEN 4 32#define ISCSI_PAD_LEN 4
31 33
32/* 34/*
33 * useful common(control and data pathes) macro 35 * useful common(control and data pathes) macro
@@ -147,6 +149,14 @@ struct iscsi_rlength_ahdr {
147 __be32 read_length; 149 __be32 read_length;
148}; 150};
149 151
152/* Extended CDB AHS */
153struct iscsi_ecdb_ahdr {
154 __be16 ahslength; /* CDB length - 15, including reserved byte */
155 uint8_t ahstype;
156 uint8_t reserved;
157 uint8_t ecdb[260 - 16]; /* 4-byte aligned extended CDB spillover */
158};
159
150/* SCSI Response Header */ 160/* SCSI Response Header */
151struct iscsi_cmd_rsp { 161struct iscsi_cmd_rsp {
152 uint8_t opcode; 162 uint8_t opcode;
@@ -600,6 +610,8 @@ struct iscsi_reject {
600#define ISCSI_MIN_MAX_BURST_LEN 512 610#define ISCSI_MIN_MAX_BURST_LEN 512
601#define ISCSI_MAX_MAX_BURST_LEN 16777215 611#define ISCSI_MAX_MAX_BURST_LEN 16777215
602 612
613#define ISCSI_DEF_TIME2WAIT 2
614
603/************************* RFC 3720 End *****************************/ 615/************************* RFC 3720 End *****************************/
604 616
605#endif /* ISCSI_PROTO_H */ 617#endif /* ISCSI_PROTO_H */
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index b4b31132618b..889f51fabab9 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -57,11 +57,14 @@ struct iscsi_nopin;
57#define ISCSI_MAX_CMD_PER_LUN 128 57#define ISCSI_MAX_CMD_PER_LUN 128
58 58
59/* Task Mgmt states */ 59/* Task Mgmt states */
60#define TMABORT_INITIAL 0x0 60enum {
61#define TMABORT_SUCCESS 0x1 61 TMF_INITIAL,
62#define TMABORT_FAILED 0x2 62 TMF_QUEUED,
63#define TMABORT_TIMEDOUT 0x3 63 TMF_SUCCESS,
64#define TMABORT_NOT_FOUND 0x4 64 TMF_FAILED,
65 TMF_TIMEDOUT,
66 TMF_NOT_FOUND,
67};
65 68
66/* Connection suspend "bit" */ 69/* Connection suspend "bit" */
67#define ISCSI_SUSPEND_BIT 1 70#define ISCSI_SUSPEND_BIT 1
@@ -74,6 +77,13 @@ struct iscsi_nopin;
74 77
75#define ISCSI_ADDRESS_BUF_LEN 64 78#define ISCSI_ADDRESS_BUF_LEN 64
76 79
80enum {
81 /* this is the maximum possible storage for AHSs */
82 ISCSI_MAX_AHS_SIZE = sizeof(struct iscsi_ecdb_ahdr) +
83 sizeof(struct iscsi_rlength_ahdr),
84 ISCSI_DIGEST_SIZE = sizeof(__u32),
85};
86
77struct iscsi_mgmt_task { 87struct iscsi_mgmt_task {
78 /* 88 /*
79 * Becuae LLDs allocate their hdr differently, this is a pointer to 89 * Becuae LLDs allocate their hdr differently, this is a pointer to
@@ -91,15 +101,17 @@ enum {
91 ISCSI_TASK_COMPLETED, 101 ISCSI_TASK_COMPLETED,
92 ISCSI_TASK_PENDING, 102 ISCSI_TASK_PENDING,
93 ISCSI_TASK_RUNNING, 103 ISCSI_TASK_RUNNING,
94 ISCSI_TASK_ABORTING,
95}; 104};
96 105
97struct iscsi_cmd_task { 106struct iscsi_cmd_task {
98 /* 107 /*
99 * Becuae LLDs allocate their hdr differently, this is a pointer to 108 * Because LLDs allocate their hdr differently, this is a pointer
100 * that storage. It must be setup at session creation time. 109 * and length to that storage. It must be setup at session
110 * creation time.
101 */ 111 */
102 struct iscsi_cmd *hdr; 112 struct iscsi_cmd *hdr;
113 unsigned short hdr_max;
114 unsigned short hdr_len; /* accumulated size of hdr used */
103 int itt; /* this ITT */ 115 int itt; /* this ITT */
104 116
105 uint32_t unsol_datasn; 117 uint32_t unsol_datasn;
@@ -110,7 +122,6 @@ struct iscsi_cmd_task {
110 unsigned data_count; /* remaining Data-Out */ 122 unsigned data_count; /* remaining Data-Out */
111 struct scsi_cmnd *sc; /* associated SCSI cmd*/ 123 struct scsi_cmnd *sc; /* associated SCSI cmd*/
112 struct iscsi_conn *conn; /* used connection */ 124 struct iscsi_conn *conn; /* used connection */
113 struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */
114 125
115 /* state set/tested under session->lock */ 126 /* state set/tested under session->lock */
116 int state; 127 int state;
@@ -119,6 +130,11 @@ struct iscsi_cmd_task {
119 void *dd_data; /* driver/transport data */ 130 void *dd_data; /* driver/transport data */
120}; 131};
121 132
133static inline void* iscsi_next_hdr(struct iscsi_cmd_task *ctask)
134{
135 return (void*)ctask->hdr + ctask->hdr_len;
136}
137
122struct iscsi_conn { 138struct iscsi_conn {
123 struct iscsi_cls_conn *cls_conn; /* ptr to class connection */ 139 struct iscsi_cls_conn *cls_conn; /* ptr to class connection */
124 void *dd_data; /* iscsi_transport data */ 140 void *dd_data; /* iscsi_transport data */
@@ -132,6 +148,12 @@ struct iscsi_conn {
132 * conn_stop() flag: stop to recover, stop to terminate 148 * conn_stop() flag: stop to recover, stop to terminate
133 */ 149 */
134 int stop_stage; 150 int stop_stage;
151 struct timer_list transport_timer;
152 unsigned long last_recv;
153 unsigned long last_ping;
154 int ping_timeout;
155 int recv_timeout;
156 struct iscsi_mgmt_task *ping_mtask;
135 157
136 /* iSCSI connection-wide sequencing */ 158 /* iSCSI connection-wide sequencing */
137 uint32_t exp_statsn; 159 uint32_t exp_statsn;
@@ -152,10 +174,11 @@ struct iscsi_conn {
152 struct iscsi_cmd_task *ctask; /* xmit ctask in progress */ 174 struct iscsi_cmd_task *ctask; /* xmit ctask in progress */
153 175
154 /* xmit */ 176 /* xmit */
155 struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */ 177 struct list_head mgmtqueue; /* mgmt (control) xmit queue */
156 struct list_head mgmt_run_list; /* list of control tasks */ 178 struct list_head mgmt_run_list; /* list of control tasks */
157 struct list_head xmitqueue; /* data-path cmd queue */ 179 struct list_head xmitqueue; /* data-path cmd queue */
158 struct list_head run_list; /* list of cmds in progress */ 180 struct list_head run_list; /* list of cmds in progress */
181 struct list_head requeue; /* tasks needing another run */
159 struct work_struct xmitwork; /* per-conn. xmit workqueue */ 182 struct work_struct xmitwork; /* per-conn. xmit workqueue */
160 unsigned long suspend_tx; /* suspend Tx */ 183 unsigned long suspend_tx; /* suspend Tx */
161 unsigned long suspend_rx; /* suspend Rx */ 184 unsigned long suspend_rx; /* suspend Rx */
@@ -163,8 +186,8 @@ struct iscsi_conn {
163 /* abort */ 186 /* abort */
164 wait_queue_head_t ehwait; /* used in eh_abort() */ 187 wait_queue_head_t ehwait; /* used in eh_abort() */
165 struct iscsi_tm tmhdr; 188 struct iscsi_tm tmhdr;
166 struct timer_list tmabort_timer; 189 struct timer_list tmf_timer;
167 int tmabort_state; /* see TMABORT_INITIAL, etc.*/ 190 int tmf_state; /* see TMF_INITIAL, etc.*/
168 191
169 /* negotiated params */ 192 /* negotiated params */
170 unsigned max_recv_dlength; /* initiator_max_recv_dsl*/ 193 unsigned max_recv_dlength; /* initiator_max_recv_dsl*/
@@ -198,7 +221,7 @@ struct iscsi_conn {
198 uint32_t eh_abort_cnt; 221 uint32_t eh_abort_cnt;
199}; 222};
200 223
201struct iscsi_queue { 224struct iscsi_pool {
202 struct kfifo *queue; /* FIFO Queue */ 225 struct kfifo *queue; /* FIFO Queue */
203 void **pool; /* Pool of elements */ 226 void **pool; /* Pool of elements */
204 int max; /* Max number of elements */ 227 int max; /* Max number of elements */
@@ -221,6 +244,8 @@ struct iscsi_session {
221 uint32_t queued_cmdsn; 244 uint32_t queued_cmdsn;
222 245
223 /* configuration */ 246 /* configuration */
247 int abort_timeout;
248 int lu_reset_timeout;
224 int initial_r2t_en; 249 int initial_r2t_en;
225 unsigned max_r2t; 250 unsigned max_r2t;
226 int imm_data_en; 251 int imm_data_en;
@@ -231,6 +256,7 @@ struct iscsi_session {
231 int pdu_inorder_en; 256 int pdu_inorder_en;
232 int dataseq_inorder_en; 257 int dataseq_inorder_en;
233 int erl; 258 int erl;
259 int fast_abort;
234 int tpgt; 260 int tpgt;
235 char *username; 261 char *username;
236 char *username_in; 262 char *username_in;
@@ -256,10 +282,10 @@ struct iscsi_session {
256 282
257 int cmds_max; /* size of cmds array */ 283 int cmds_max; /* size of cmds array */
258 struct iscsi_cmd_task **cmds; /* Original Cmds arr */ 284 struct iscsi_cmd_task **cmds; /* Original Cmds arr */
259 struct iscsi_queue cmdpool; /* PDU's pool */ 285 struct iscsi_pool cmdpool; /* PDU's pool */
260 int mgmtpool_max; /* size of mgmt array */ 286 int mgmtpool_max; /* size of mgmt array */
261 struct iscsi_mgmt_task **mgmt_cmds; /* Original mgmt arr */ 287 struct iscsi_mgmt_task **mgmt_cmds; /* Original mgmt arr */
262 struct iscsi_queue mgmtpool; /* Mgmt PDU's pool */ 288 struct iscsi_pool mgmtpool; /* Mgmt PDU's pool */
263}; 289};
264 290
265/* 291/*
@@ -268,6 +294,7 @@ struct iscsi_session {
268extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth); 294extern int iscsi_change_queue_depth(struct scsi_device *sdev, int depth);
269extern int iscsi_eh_abort(struct scsi_cmnd *sc); 295extern int iscsi_eh_abort(struct scsi_cmnd *sc);
270extern int iscsi_eh_host_reset(struct scsi_cmnd *sc); 296extern int iscsi_eh_host_reset(struct scsi_cmnd *sc);
297extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
271extern int iscsi_queuecommand(struct scsi_cmnd *sc, 298extern int iscsi_queuecommand(struct scsi_cmnd *sc,
272 void (*done)(struct scsi_cmnd *)); 299 void (*done)(struct scsi_cmnd *));
273 300
@@ -326,11 +353,32 @@ extern int __iscsi_complete_pdu(struct iscsi_conn *, struct iscsi_hdr *,
326 char *, int); 353 char *, int);
327extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *, 354extern int iscsi_verify_itt(struct iscsi_conn *, struct iscsi_hdr *,
328 uint32_t *); 355 uint32_t *);
356extern void iscsi_requeue_ctask(struct iscsi_cmd_task *ctask);
357extern void iscsi_free_mgmt_task(struct iscsi_conn *conn,
358 struct iscsi_mgmt_task *mtask);
329 359
330/* 360/*
331 * generic helpers 361 * generic helpers
332 */ 362 */
333extern void iscsi_pool_free(struct iscsi_queue *, void **); 363extern void iscsi_pool_free(struct iscsi_pool *);
334extern int iscsi_pool_init(struct iscsi_queue *, int, void ***, int); 364extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
365
366/*
367 * inline functions to deal with padding.
368 */
369static inline unsigned int
370iscsi_padded(unsigned int len)
371{
372 return (len + ISCSI_PAD_LEN - 1) & ~(ISCSI_PAD_LEN - 1);
373}
374
375static inline unsigned int
376iscsi_padding(unsigned int len)
377{
378 len &= (ISCSI_PAD_LEN - 1);
379 if (len)
380 len = ISCSI_PAD_LEN - len;
381 return len;
382}
335 383
336#endif 384#endif
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 8dda2d66b5b9..3ffd6b582a97 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -36,7 +36,7 @@
36#include <scsi/scsi_device.h> 36#include <scsi/scsi_device.h>
37#include <scsi/scsi_cmnd.h> 37#include <scsi/scsi_cmnd.h>
38#include <scsi/scsi_transport_sas.h> 38#include <scsi/scsi_transport_sas.h>
39#include <asm/scatterlist.h> 39#include <linux/scatterlist.h>
40 40
41struct block_device; 41struct block_device;
42 42
@@ -91,8 +91,6 @@ enum discover_event {
91 91
92/* ---------- Expander Devices ---------- */ 92/* ---------- Expander Devices ---------- */
93 93
94#define ETASK 0xFA
95
96#define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj) 94#define to_dom_device(_obj) container_of(_obj, struct domain_device, dev_obj)
97#define to_dev_attr(_attr) container_of(_attr, struct domain_dev_attribute,\ 95#define to_dev_attr(_attr) container_of(_attr, struct domain_dev_attribute,\
98 attr) 96 attr)
@@ -122,8 +120,8 @@ struct ex_phy {
122 u8 attached_sata_dev:1; 120 u8 attached_sata_dev:1;
123 u8 attached_sata_ps:1; 121 u8 attached_sata_ps:1;
124 122
125 enum sas_proto attached_tproto; 123 enum sas_protocol attached_tproto;
126 enum sas_proto attached_iproto; 124 enum sas_protocol attached_iproto;
127 125
128 u8 attached_sas_addr[SAS_ADDR_SIZE]; 126 u8 attached_sas_addr[SAS_ADDR_SIZE];
129 u8 attached_phy_id; 127 u8 attached_phy_id;
@@ -191,8 +189,8 @@ struct domain_device {
191 189
192 struct list_head dev_list_node; 190 struct list_head dev_list_node;
193 191
194 enum sas_proto iproto; 192 enum sas_protocol iproto;
195 enum sas_proto tproto; 193 enum sas_protocol tproto;
196 194
197 struct sas_rphy *rphy; 195 struct sas_rphy *rphy;
198 196
@@ -245,8 +243,8 @@ struct asd_sas_port {
245 enum sas_class class; 243 enum sas_class class;
246 u8 sas_addr[SAS_ADDR_SIZE]; 244 u8 sas_addr[SAS_ADDR_SIZE];
247 u8 attached_sas_addr[SAS_ADDR_SIZE]; 245 u8 attached_sas_addr[SAS_ADDR_SIZE];
248 enum sas_proto iproto; 246 enum sas_protocol iproto;
249 enum sas_proto tproto; 247 enum sas_protocol tproto;
250 248
251 enum sas_oob_mode oob_mode; 249 enum sas_oob_mode oob_mode;
252 250
@@ -289,8 +287,8 @@ struct asd_sas_phy {
289 287
290 int id; /* must be set */ 288 int id; /* must be set */
291 enum sas_class class; 289 enum sas_class class;
292 enum sas_proto iproto; 290 enum sas_protocol iproto;
293 enum sas_proto tproto; 291 enum sas_protocol tproto;
294 292
295 enum sas_phy_type type; 293 enum sas_phy_type type;
296 enum sas_phy_role role; 294 enum sas_phy_role role;
@@ -537,7 +535,7 @@ struct sas_task {
537 spinlock_t task_state_lock; 535 spinlock_t task_state_lock;
538 unsigned task_state_flags; 536 unsigned task_state_flags;
539 537
540 enum sas_proto task_proto; 538 enum sas_protocol task_proto;
541 539
542 /* Used by the discovery code. */ 540 /* Used by the discovery code. */
543 struct timer_list timer; 541 struct timer_list timer;
@@ -563,7 +561,7 @@ struct sas_task {
563 struct work_struct abort_work; 561 struct work_struct abort_work;
564}; 562};
565 563
566 564extern struct kmem_cache *sas_task_cache;
567 565
568#define SAS_TASK_STATE_PENDING 1 566#define SAS_TASK_STATE_PENDING 1
569#define SAS_TASK_STATE_DONE 2 567#define SAS_TASK_STATE_DONE 2
@@ -573,7 +571,6 @@ struct sas_task {
573 571
574static inline struct sas_task *sas_alloc_task(gfp_t flags) 572static inline struct sas_task *sas_alloc_task(gfp_t flags)
575{ 573{
576 extern struct kmem_cache *sas_task_cache;
577 struct sas_task *task = kmem_cache_zalloc(sas_task_cache, flags); 574 struct sas_task *task = kmem_cache_zalloc(sas_task_cache, flags);
578 575
579 if (task) { 576 if (task) {
@@ -590,7 +587,6 @@ static inline struct sas_task *sas_alloc_task(gfp_t flags)
590static inline void sas_free_task(struct sas_task *task) 587static inline void sas_free_task(struct sas_task *task)
591{ 588{
592 if (task) { 589 if (task) {
593 extern struct kmem_cache *sas_task_cache;
594 BUG_ON(!list_empty(&task->list)); 590 BUG_ON(!list_empty(&task->list));
595 kmem_cache_free(sas_task_cache, task); 591 kmem_cache_free(sas_task_cache, task);
596 } 592 }
@@ -676,4 +672,8 @@ extern int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg);
676 672
677extern int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy, 673extern int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
678 struct request *req); 674 struct request *req);
675
676extern void sas_ssp_task_response(struct device *dev, struct sas_task *task,
677 struct ssp_response_iu *iu);
678
679#endif /* _SASLIB_H_ */ 679#endif /* _SASLIB_H_ */
diff --git a/include/scsi/sas.h b/include/scsi/sas.h
index 2f4b6afa34fc..e9fd02281381 100644
--- a/include/scsi/sas.h
+++ b/include/scsi/sas.h
@@ -102,13 +102,12 @@ enum sas_dev_type {
102 SATA_PM_PORT= 8, 102 SATA_PM_PORT= 8,
103}; 103};
104 104
105/* Partly from IDENTIFY address frame. */ 105enum sas_protocol {
106enum sas_proto { 106 SAS_PROTOCOL_SATA = 0x01,
107 SATA_PROTO = 1, 107 SAS_PROTOCOL_SMP = 0x02,
108 SAS_PROTO_SMP = 2, /* protocol */ 108 SAS_PROTOCOL_STP = 0x04,
109 SAS_PROTO_STP = 4, /* protocol */ 109 SAS_PROTOCOL_SSP = 0x08,
110 SAS_PROTO_SSP = 8, /* protocol */ 110 SAS_PROTOCOL_ALL = 0x0E,
111 SAS_PROTO_ALL = 0xE,
112}; 111};
113 112
114/* From the spec; local phys only */ 113/* From the spec; local phys only */
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 702fcfeb37f1..82251575a9b4 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -11,6 +11,25 @@
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13/* 13/*
14 * The maximum number of SG segments that we will put inside a
15 * scatterlist (unless chaining is used). Should ideally fit inside a
16 * single page, to avoid a higher order allocation. We could define this
17 * to SG_MAX_SINGLE_ALLOC to pack correctly at the highest order. The
18 * minimum value is 32
19 */
20#define SCSI_MAX_SG_SEGMENTS 128
21
22/*
23 * Like SCSI_MAX_SG_SEGMENTS, but for archs that have sg chaining. This limit
24 * is totally arbitrary, a setting of 2048 will get you at least 8mb ios.
25 */
26#ifdef ARCH_HAS_SG_CHAIN
27#define SCSI_MAX_SG_CHAIN_SEGMENTS 2048
28#else
29#define SCSI_MAX_SG_CHAIN_SEGMENTS SCSI_MAX_SG_SEGMENTS
30#endif
31
32/*
14 * SCSI command lengths 33 * SCSI command lengths
15 */ 34 */
16 35
@@ -83,6 +102,7 @@ extern const unsigned char scsi_command_size[8];
83#define READ_TOC 0x43 102#define READ_TOC 0x43
84#define LOG_SELECT 0x4c 103#define LOG_SELECT 0x4c
85#define LOG_SENSE 0x4d 104#define LOG_SENSE 0x4d
105#define XDWRITEREAD_10 0x53
86#define MODE_SELECT_10 0x55 106#define MODE_SELECT_10 0x55
87#define RESERVE_10 0x56 107#define RESERVE_10 0x56
88#define RELEASE_10 0x57 108#define RELEASE_10 0x57
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 3f47e522a1ec..de28aab820b0 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -2,16 +2,20 @@
2#define _SCSI_SCSI_CMND_H 2#define _SCSI_SCSI_CMND_H
3 3
4#include <linux/dma-mapping.h> 4#include <linux/dma-mapping.h>
5#include <linux/blkdev.h>
5#include <linux/list.h> 6#include <linux/list.h>
6#include <linux/types.h> 7#include <linux/types.h>
7#include <linux/timer.h> 8#include <linux/timer.h>
8#include <linux/scatterlist.h> 9#include <linux/scatterlist.h>
9 10
10struct request;
11struct scatterlist;
12struct Scsi_Host; 11struct Scsi_Host;
13struct scsi_device; 12struct scsi_device;
14 13
14struct scsi_data_buffer {
15 struct sg_table table;
16 unsigned length;
17 int resid;
18};
15 19
16/* embedded in scsi_cmnd */ 20/* embedded in scsi_cmnd */
17struct scsi_pointer { 21struct scsi_pointer {
@@ -62,15 +66,11 @@ struct scsi_cmnd {
62 /* These elements define the operation we are about to perform */ 66 /* These elements define the operation we are about to perform */
63#define MAX_COMMAND_SIZE 16 67#define MAX_COMMAND_SIZE 16
64 unsigned char cmnd[MAX_COMMAND_SIZE]; 68 unsigned char cmnd[MAX_COMMAND_SIZE];
65 unsigned request_bufflen; /* Actual request size */
66 69
67 struct timer_list eh_timeout; /* Used to time out the command. */ 70 struct timer_list eh_timeout; /* Used to time out the command. */
68 void *request_buffer; /* Actual requested buffer */
69 71
70 /* These elements define the operation we ultimately want to perform */ 72 /* These elements define the operation we ultimately want to perform */
71 unsigned short use_sg; /* Number of pieces of scatter-gather */ 73 struct scsi_data_buffer sdb;
72 unsigned short __use_sg;
73
74 unsigned underflow; /* Return error if less than 74 unsigned underflow; /* Return error if less than
75 this amount is transferred */ 75 this amount is transferred */
76 76
@@ -80,15 +80,11 @@ struct scsi_cmnd {
80 reconnects. Probably == sector 80 reconnects. Probably == sector
81 size */ 81 size */
82 82
83 int resid; /* Number of bytes requested to be
84 transferred less actual number
85 transferred (0 if not supported) */
86
87 struct request *request; /* The command we are 83 struct request *request; /* The command we are
88 working on */ 84 working on */
89 85
90#define SCSI_SENSE_BUFFERSIZE 96 86#define SCSI_SENSE_BUFFERSIZE 96
91 unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE]; 87 unsigned char *sense_buffer;
92 /* obtained by REQUEST SENSE when 88 /* obtained by REQUEST SENSE when
93 * CHECK CONDITION is received on original 89 * CHECK CONDITION is received on original
94 * command (auto-sense) */ 90 * command (auto-sense) */
@@ -128,27 +124,55 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
128 size_t *offset, size_t *len); 124 size_t *offset, size_t *len);
129extern void scsi_kunmap_atomic_sg(void *virt); 125extern void scsi_kunmap_atomic_sg(void *virt);
130 126
131extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t); 127extern int scsi_init_io(struct scsi_cmnd *cmd, gfp_t gfp_mask);
132extern void scsi_free_sgtable(struct scsi_cmnd *); 128extern void scsi_release_buffers(struct scsi_cmnd *cmd);
133 129
134extern int scsi_dma_map(struct scsi_cmnd *cmd); 130extern int scsi_dma_map(struct scsi_cmnd *cmd);
135extern void scsi_dma_unmap(struct scsi_cmnd *cmd); 131extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
136 132
137#define scsi_sg_count(cmd) ((cmd)->use_sg) 133static inline unsigned scsi_sg_count(struct scsi_cmnd *cmd)
138#define scsi_sglist(cmd) ((struct scatterlist *)(cmd)->request_buffer) 134{
139#define scsi_bufflen(cmd) ((cmd)->request_bufflen) 135 return cmd->sdb.table.nents;
136}
137
138static inline struct scatterlist *scsi_sglist(struct scsi_cmnd *cmd)
139{
140 return cmd->sdb.table.sgl;
141}
142
143static inline unsigned scsi_bufflen(struct scsi_cmnd *cmd)
144{
145 return cmd->sdb.length;
146}
140 147
141static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid) 148static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)
142{ 149{
143 cmd->resid = resid; 150 cmd->sdb.resid = resid;
144} 151}
145 152
146static inline int scsi_get_resid(struct scsi_cmnd *cmd) 153static inline int scsi_get_resid(struct scsi_cmnd *cmd)
147{ 154{
148 return cmd->resid; 155 return cmd->sdb.resid;
149} 156}
150 157
151#define scsi_for_each_sg(cmd, sg, nseg, __i) \ 158#define scsi_for_each_sg(cmd, sg, nseg, __i) \
152 for_each_sg(scsi_sglist(cmd), sg, nseg, __i) 159 for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
153 160
161static inline int scsi_bidi_cmnd(struct scsi_cmnd *cmd)
162{
163 return blk_bidi_rq(cmd->request) &&
164 (cmd->request->next_rq->special != NULL);
165}
166
167static inline struct scsi_data_buffer *scsi_in(struct scsi_cmnd *cmd)
168{
169 return scsi_bidi_cmnd(cmd) ?
170 cmd->request->next_rq->special : &cmd->sdb;
171}
172
173static inline struct scsi_data_buffer *scsi_out(struct scsi_cmnd *cmd)
174{
175 return &cmd->sdb;
176}
177
154#endif /* _SCSI_SCSI_CMND_H */ 178#endif /* _SCSI_SCSI_CMND_H */
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index d5057bc338ff..ab7acbe80960 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -46,6 +46,22 @@ enum scsi_device_state {
46 * to the scsi lld. */ 46 * to the scsi lld. */
47}; 47};
48 48
49enum scsi_device_event {
50 SDEV_EVT_MEDIA_CHANGE = 1, /* media has changed */
51
52 SDEV_EVT_LAST = SDEV_EVT_MEDIA_CHANGE,
53 SDEV_EVT_MAXBITS = SDEV_EVT_LAST + 1
54};
55
56struct scsi_event {
57 enum scsi_device_event evt_type;
58 struct list_head node;
59
60 /* put union of data structures, for non-simple event types,
61 * here
62 */
63};
64
49struct scsi_device { 65struct scsi_device {
50 struct Scsi_Host *host; 66 struct Scsi_Host *host;
51 struct request_queue *request_queue; 67 struct request_queue *request_queue;
@@ -106,9 +122,6 @@ struct scsi_device {
106 unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */ 122 unsigned tagged_supported:1; /* Supports SCSI-II tagged queuing */
107 unsigned simple_tags:1; /* simple queue tag messages are enabled */ 123 unsigned simple_tags:1; /* simple queue tag messages are enabled */
108 unsigned ordered_tags:1;/* ordered queue tag messages are enabled */ 124 unsigned ordered_tags:1;/* ordered queue tag messages are enabled */
109 unsigned single_lun:1; /* Indicates we should only allow I/O to
110 * one of the luns for the device at a
111 * time. */
112 unsigned was_reset:1; /* There was a bus reset on the bus for 125 unsigned was_reset:1; /* There was a bus reset on the bus for
113 * this device */ 126 * this device */
114 unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN 127 unsigned expecting_cc_ua:1; /* Expecting a CHECK_CONDITION/UNIT_ATTN
@@ -126,6 +139,11 @@ struct scsi_device {
126 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */ 139 unsigned fix_capacity:1; /* READ_CAPACITY is too high by 1 */
127 unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */ 140 unsigned guess_capacity:1; /* READ_CAPACITY might be too high by 1 */
128 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */ 141 unsigned retry_hwerror:1; /* Retry HARDWARE_ERROR */
142 unsigned last_sector_bug:1; /* Always read last sector in a 1 sector read */
143
144 DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */
145 struct list_head event_list; /* asserted events */
146 struct work_struct event_work;
129 147
130 unsigned int device_blocked; /* Device returned QUEUE_FULL. */ 148 unsigned int device_blocked; /* Device returned QUEUE_FULL. */
131 149
@@ -182,6 +200,9 @@ struct scsi_target {
182 unsigned int id; /* target id ... replace 200 unsigned int id; /* target id ... replace
183 * scsi_device.id eventually */ 201 * scsi_device.id eventually */
184 unsigned int create:1; /* signal that it needs to be added */ 202 unsigned int create:1; /* signal that it needs to be added */
203 unsigned int single_lun:1; /* Indicates we should only
204 * allow I/O to one of the luns
205 * for the device at a time. */
185 unsigned int pdt_1f_for_no_lun; /* PDT = 0x1f */ 206 unsigned int pdt_1f_for_no_lun; /* PDT = 0x1f */
186 /* means no lun present */ 207 /* means no lun present */
187 208
@@ -222,6 +243,9 @@ extern struct scsi_device *__scsi_device_lookup_by_target(struct scsi_target *,
222 uint); 243 uint);
223extern void starget_for_each_device(struct scsi_target *, void *, 244extern void starget_for_each_device(struct scsi_target *, void *,
224 void (*fn)(struct scsi_device *, void *)); 245 void (*fn)(struct scsi_device *, void *));
246extern void __starget_for_each_device(struct scsi_target *, void *,
247 void (*fn)(struct scsi_device *,
248 void *));
225 249
226/* only exposed to implement shost_for_each_device */ 250/* only exposed to implement shost_for_each_device */
227extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *, 251extern struct scsi_device *__scsi_iterate_devices(struct Scsi_Host *,
@@ -272,9 +296,14 @@ extern int scsi_mode_select(struct scsi_device *sdev, int pf, int sp,
272 struct scsi_mode_data *data, 296 struct scsi_mode_data *data,
273 struct scsi_sense_hdr *); 297 struct scsi_sense_hdr *);
274extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout, 298extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
275 int retries); 299 int retries, struct scsi_sense_hdr *sshdr);
276extern int scsi_device_set_state(struct scsi_device *sdev, 300extern int scsi_device_set_state(struct scsi_device *sdev,
277 enum scsi_device_state state); 301 enum scsi_device_state state);
302extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
303 gfp_t gfpflags);
304extern void sdev_evt_send(struct scsi_device *sdev, struct scsi_event *evt);
305extern void sdev_evt_send_simple(struct scsi_device *sdev,
306 enum scsi_device_event evt_type, gfp_t gfpflags);
278extern int scsi_device_quiesce(struct scsi_device *sdev); 307extern int scsi_device_quiesce(struct scsi_device *sdev);
279extern void scsi_device_resume(struct scsi_device *sdev); 308extern void scsi_device_resume(struct scsi_device *sdev);
280extern void scsi_target_quiesce(struct scsi_target *); 309extern void scsi_target_quiesce(struct scsi_target *);
@@ -358,6 +387,10 @@ static inline int scsi_device_qas(struct scsi_device *sdev)
358 return 0; 387 return 0;
359 return sdev->inquiry[56] & 0x02; 388 return sdev->inquiry[56] & 0x02;
360} 389}
390static inline int scsi_device_enclosure(struct scsi_device *sdev)
391{
392 return sdev->inquiry[6] & (1<<6);
393}
361 394
362#define MODULE_ALIAS_SCSI_DEVICE(type) \ 395#define MODULE_ALIAS_SCSI_DEVICE(type) \
363 MODULE_ALIAS("scsi:t-" __stringify(type) "*") 396 MODULE_ALIAS("scsi:t-" __stringify(type) "*")
diff --git a/include/scsi/scsi_eh.h b/include/scsi/scsi_eh.h
index d21b8913ceb3..25071d5d9bf8 100644
--- a/include/scsi/scsi_eh.h
+++ b/include/scsi/scsi_eh.h
@@ -68,16 +68,15 @@ extern int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
68extern int scsi_reset_provider(struct scsi_device *, int); 68extern int scsi_reset_provider(struct scsi_device *, int);
69 69
70struct scsi_eh_save { 70struct scsi_eh_save {
71 /* saved state */
71 int result; 72 int result;
72 enum dma_data_direction data_direction; 73 enum dma_data_direction data_direction;
73 unsigned char cmd_len; 74 unsigned char cmd_len;
74 unsigned char cmnd[MAX_COMMAND_SIZE]; 75 unsigned char cmnd[MAX_COMMAND_SIZE];
76 struct scsi_data_buffer sdb;
77 struct request *next_rq;
75 78
76 void *buffer; 79 /* new command support */
77 unsigned bufflen;
78 unsigned short use_sg;
79 int resid;
80
81 struct scatterlist sense_sgl; 80 struct scatterlist sense_sgl;
82}; 81};
83 82
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 0fd4746ee39d..5c58d594126a 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -39,9 +39,6 @@ struct blk_queue_tags;
39#define DISABLE_CLUSTERING 0 39#define DISABLE_CLUSTERING 0
40#define ENABLE_CLUSTERING 1 40#define ENABLE_CLUSTERING 1
41 41
42#define DISABLE_SG_CHAINING 0
43#define ENABLE_SG_CHAINING 1
44
45enum scsi_eh_timer_return { 42enum scsi_eh_timer_return {
46 EH_NOT_HANDLED, 43 EH_NOT_HANDLED,
47 EH_HANDLED, 44 EH_HANDLED,
@@ -136,9 +133,9 @@ struct scsi_host_template {
136 * the done callback is invoked. 133 * the done callback is invoked.
137 * 134 *
138 * This is called to inform the LLD to transfer 135 * This is called to inform the LLD to transfer
139 * cmd->request_bufflen bytes. The cmd->use_sg speciefies the 136 * scsi_bufflen(cmd) bytes. scsi_sg_count(cmd) speciefies the
140 * number of scatterlist entried in the command and 137 * number of scatterlist entried in the command and
141 * cmd->request_buffer contains the scatterlist. 138 * scsi_sglist(cmd) returns the scatterlist.
142 * 139 *
143 * return values: see queuecommand 140 * return values: see queuecommand
144 * 141 *
@@ -446,15 +443,6 @@ struct scsi_host_template {
446 unsigned ordered_tag:1; 443 unsigned ordered_tag:1;
447 444
448 /* 445 /*
449 * true if the low-level driver can support sg chaining. this
450 * will be removed eventually when all the drivers are
451 * converted to support sg chaining.
452 *
453 * Status: OBSOLETE
454 */
455 unsigned use_sg_chaining:1;
456
457 /*
458 * Countdown for host blocking with no commands outstanding 446 * Countdown for host blocking with no commands outstanding
459 */ 447 */
460 unsigned int max_host_blocked; 448 unsigned int max_host_blocked;
@@ -598,7 +586,6 @@ struct Scsi_Host {
598 unsigned unchecked_isa_dma:1; 586 unsigned unchecked_isa_dma:1;
599 unsigned use_clustering:1; 587 unsigned use_clustering:1;
600 unsigned use_blk_tcq:1; 588 unsigned use_blk_tcq:1;
601 unsigned use_sg_chaining:1;
602 589
603 /* 590 /*
604 * Host has requested that no further requests come through for the 591 * Host has requested that no further requests come through for the
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 7ff6199cbd55..404f11d331d6 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -118,7 +118,7 @@ struct iscsi_transport {
118 char *data, uint32_t data_size); 118 char *data, uint32_t data_size);
119 void (*get_stats) (struct iscsi_cls_conn *conn, 119 void (*get_stats) (struct iscsi_cls_conn *conn,
120 struct iscsi_stats *stats); 120 struct iscsi_stats *stats);
121 void (*init_cmd_task) (struct iscsi_cmd_task *ctask); 121 int (*init_cmd_task) (struct iscsi_cmd_task *ctask);
122 void (*init_mgmt_task) (struct iscsi_conn *conn, 122 void (*init_mgmt_task) (struct iscsi_conn *conn,
123 struct iscsi_mgmt_task *mtask); 123 struct iscsi_mgmt_task *mtask);
124 int (*xmit_cmd_task) (struct iscsi_conn *conn, 124 int (*xmit_cmd_task) (struct iscsi_conn *conn,
@@ -176,6 +176,7 @@ struct iscsi_cls_conn {
176#define ISCSI_STATE_TERMINATE 4 176#define ISCSI_STATE_TERMINATE 4
177#define ISCSI_STATE_IN_RECOVERY 5 177#define ISCSI_STATE_IN_RECOVERY 5
178#define ISCSI_STATE_RECOVERY_FAILED 6 178#define ISCSI_STATE_RECOVERY_FAILED 6
179#define ISCSI_STATE_LOGGING_OUT 7
179 180
180struct iscsi_cls_session { 181struct iscsi_cls_session {
181 struct list_head sess_list; /* item in session_list */ 182 struct list_head sess_list; /* item in session_list */
@@ -185,6 +186,7 @@ struct iscsi_cls_session {
185 /* recovery fields */ 186 /* recovery fields */
186 int recovery_tmo; 187 int recovery_tmo;
187 struct delayed_work recovery_work; 188 struct delayed_work recovery_work;
189 struct work_struct unbind_work;
188 190
189 int target_id; 191 int target_id;
190 192
@@ -205,6 +207,8 @@ struct iscsi_cls_session {
205struct iscsi_host { 207struct iscsi_host {
206 struct list_head sessions; 208 struct list_head sessions;
207 struct mutex mutex; 209 struct mutex mutex;
210 struct workqueue_struct *unbind_workq;
211 char unbind_workq_name[KOBJ_NAME_LEN];
208}; 212};
209 213
210/* 214/*
@@ -214,8 +218,8 @@ extern struct iscsi_cls_session *iscsi_alloc_session(struct Scsi_Host *shost,
214 struct iscsi_transport *transport); 218 struct iscsi_transport *transport);
215extern int iscsi_add_session(struct iscsi_cls_session *session, 219extern int iscsi_add_session(struct iscsi_cls_session *session,
216 unsigned int target_id); 220 unsigned int target_id);
217extern int iscsi_if_create_session_done(struct iscsi_cls_conn *conn); 221extern int iscsi_session_event(struct iscsi_cls_session *session,
218extern int iscsi_if_destroy_session_done(struct iscsi_cls_conn *conn); 222 enum iscsi_uevent_e event);
219extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost, 223extern struct iscsi_cls_session *iscsi_create_session(struct Scsi_Host *shost,
220 struct iscsi_transport *t, 224 struct iscsi_transport *t,
221 unsigned int target_id); 225 unsigned int target_id);
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index abdfd2e27dd7..09125fa95b93 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -4,23 +4,17 @@
4#include <linux/transport_class.h> 4#include <linux/transport_class.h>
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/mutex.h> 6#include <linux/mutex.h>
7#include <scsi/sas.h>
7 8
8struct scsi_transport_template; 9struct scsi_transport_template;
9struct sas_rphy; 10struct sas_rphy;
10struct request; 11struct request;
11 12
12enum sas_device_type { 13enum sas_device_type {
13 SAS_PHY_UNUSED, 14 SAS_PHY_UNUSED = 0,
14 SAS_END_DEVICE, 15 SAS_END_DEVICE = 1,
15 SAS_EDGE_EXPANDER_DEVICE, 16 SAS_EDGE_EXPANDER_DEVICE = 2,
16 SAS_FANOUT_EXPANDER_DEVICE, 17 SAS_FANOUT_EXPANDER_DEVICE = 3,
17};
18
19enum sas_protocol {
20 SAS_PROTOCOL_SATA = 0x01,
21 SAS_PROTOCOL_SMP = 0x02,
22 SAS_PROTOCOL_STP = 0x04,
23 SAS_PROTOCOL_SSP = 0x08,
24}; 18};
25 19
26static inline int sas_protocol_ata(enum sas_protocol proto) 20static inline int sas_protocol_ata(enum sas_protocol proto)
diff --git a/include/scsi/sd.h b/include/scsi/sd.h
index f7513313ef0d..8ea9f7358ac1 100644
--- a/include/scsi/sd.h
+++ b/include/scsi/sd.h
@@ -41,6 +41,7 @@ struct scsi_disk {
41 u32 index; 41 u32 index;
42 u8 media_present; 42 u8 media_present;
43 u8 write_prot; 43 u8 write_prot;
44 unsigned previous_state : 1;
44 unsigned WCE : 1; /* state of disk WCE bit */ 45 unsigned WCE : 1; /* state of disk WCE bit */
45 unsigned RCD : 1; /* state of disk RCD bit, unused */ 46 unsigned RCD : 1; /* state of disk RCD bit, unused */
46 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */ 47 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
diff --git a/include/sound/ad1848.h b/include/sound/ad1848.h
index d04f9e78c7c1..d9aebdf6db63 100644
--- a/include/sound/ad1848.h
+++ b/include/sound/ad1848.h
@@ -48,7 +48,7 @@
48#define AD1848_IFACE_CTRL 0x09 /* interface control - bits 7-2 MCE */ 48#define AD1848_IFACE_CTRL 0x09 /* interface control - bits 7-2 MCE */
49#define AD1848_PIN_CTRL 0x0a /* pin control */ 49#define AD1848_PIN_CTRL 0x0a /* pin control */
50#define AD1848_TEST_INIT 0x0b /* test and initialization */ 50#define AD1848_TEST_INIT 0x0b /* test and initialization */
51#define AD1848_MISC_INFO 0x0c /* miscellaneaous information */ 51#define AD1848_MISC_INFO 0x0c /* miscellaneous information */
52#define AD1848_LOOPBACK 0x0d /* loopback control */ 52#define AD1848_LOOPBACK 0x0d /* loopback control */
53#define AD1848_DATA_UPR_CNT 0x0e /* playback/capture upper base count */ 53#define AD1848_DATA_UPR_CNT 0x0e /* playback/capture upper base count */
54#define AD1848_DATA_LWR_CNT 0x0f /* playback/capture lower base count */ 54#define AD1848_DATA_LWR_CNT 0x0f /* playback/capture lower base count */
diff --git a/include/sound/ainstr_fm.h b/include/sound/ainstr_fm.h
deleted file mode 100644
index c4afb1f121fe..000000000000
--- a/include/sound/ainstr_fm.h
+++ /dev/null
@@ -1,134 +0,0 @@
1/*
2 * Advanced Linux Sound Architecture
3 *
4 * FM (OPL2/3) Instrument Format
5 * Copyright (c) 2000 Uros Bizjak <uros@kss-loka.si>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifndef __SOUND_AINSTR_FM_H
25#define __SOUND_AINSTR_FM_H
26
27#ifndef __KERNEL__
28#include <asm/types.h>
29#include <asm/byteorder.h>
30#endif
31
32/*
33 * share types (share ID 1)
34 */
35
36#define FM_SHARE_FILE 0
37
38/*
39 * FM operator
40 */
41
42struct fm_operator {
43 unsigned char am_vib;
44 unsigned char ksl_level;
45 unsigned char attack_decay;
46 unsigned char sustain_release;
47 unsigned char wave_select;
48};
49
50/*
51 * Instrument
52 */
53
54#define FM_PATCH_OPL2 0x01 /* OPL2 2 operators FM instrument */
55#define FM_PATCH_OPL3 0x02 /* OPL3 4 operators FM instrument */
56
57struct fm_instrument {
58 unsigned int share_id[4]; /* share id - zero = no sharing */
59 unsigned char type; /* instrument type */
60
61 struct fm_operator op[4];
62 unsigned char feedback_connection[2];
63
64 unsigned char echo_delay;
65 unsigned char echo_atten;
66 unsigned char chorus_spread;
67 unsigned char trnsps;
68 unsigned char fix_dur;
69 unsigned char modes;
70 unsigned char fix_key;
71};
72
73/*
74 *
75 * Kernel <-> user space
76 * Hardware (CPU) independent section
77 *
78 * * = zero or more
79 * + = one or more
80 *
81 * fm_xinstrument FM_STRU_INSTR
82 *
83 */
84
85#define FM_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T')
86
87/*
88 * FM operator
89 */
90
91struct fm_xoperator {
92 __u8 am_vib;
93 __u8 ksl_level;
94 __u8 attack_decay;
95 __u8 sustain_release;
96 __u8 wave_select;
97};
98
99/*
100 * Instrument
101 */
102
103struct fm_xinstrument {
104 __u32 stype; /* structure type */
105
106 __u32 share_id[4]; /* share id - zero = no sharing */
107 __u8 type; /* instrument type */
108
109 struct fm_xoperator op[4]; /* fm operators */
110 __u8 feedback_connection[2];
111
112 __u8 echo_delay;
113 __u8 echo_atten;
114 __u8 chorus_spread;
115 __u8 trnsps;
116 __u8 fix_dur;
117 __u8 modes;
118 __u8 fix_key;
119};
120
121#ifdef __KERNEL__
122
123#include "seq_instr.h"
124
125int snd_seq_fm_init(struct snd_seq_kinstr_ops * ops,
126 struct snd_seq_kinstr_ops * next);
127
128#endif
129
130/* typedefs for compatibility to user-space */
131typedef struct fm_xoperator fm_xoperator_t;
132typedef struct fm_xinstrument fm_xinstrument_t;
133
134#endif /* __SOUND_AINSTR_FM_H */
diff --git a/include/sound/ainstr_gf1.h b/include/sound/ainstr_gf1.h
deleted file mode 100644
index b62b665c69c6..000000000000
--- a/include/sound/ainstr_gf1.h
+++ /dev/null
@@ -1,229 +0,0 @@
1/*
2 * Advanced Linux Sound Architecture
3 *
4 * GF1 (GUS) Patch Instrument Format
5 * Copyright (c) 1994-99 by Jaroslav Kysela <perex@perex.cz>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifndef __SOUND_AINSTR_GF1_H
25#define __SOUND_AINSTR_GF1_H
26
27#ifndef __KERNEL__
28#include <asm/types.h>
29#include <asm/byteorder.h>
30#endif
31
32/*
33 * share types (share ID 1)
34 */
35
36#define GF1_SHARE_FILE 0
37
38/*
39 * wave formats
40 */
41
42#define GF1_WAVE_16BIT 0x0001 /* 16-bit wave */
43#define GF1_WAVE_UNSIGNED 0x0002 /* unsigned wave */
44#define GF1_WAVE_INVERT 0x0002 /* same as unsigned wave */
45#define GF1_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */
46#define GF1_WAVE_LOOP 0x0008 /* loop mode */
47#define GF1_WAVE_BIDIR 0x0010 /* bidirectional mode */
48#define GF1_WAVE_STEREO 0x0100 /* stereo mode */
49#define GF1_WAVE_ULAW 0x0200 /* uLaw compression mode */
50
51/*
52 * Wavetable definitions
53 */
54
55struct gf1_wave {
56 unsigned int share_id[4]; /* share id - zero = no sharing */
57 unsigned int format; /* wave format */
58
59 struct {
60 unsigned int number; /* some other ID for this instrument */
61 unsigned int memory; /* begin of waveform in onboard memory */
62 unsigned char *ptr; /* pointer to waveform in system memory */
63 } address;
64
65 unsigned int size; /* size of waveform in samples */
66 unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
67 unsigned int loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
68 unsigned int loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
69 unsigned short loop_repeat; /* loop repeat - 0 = forever */
70
71 unsigned char flags; /* GF1 patch flags */
72 unsigned char pad;
73 unsigned int sample_rate; /* sample rate in Hz */
74 unsigned int low_frequency; /* low frequency range */
75 unsigned int high_frequency; /* high frequency range */
76 unsigned int root_frequency; /* root frequency range */
77 signed short tune;
78 unsigned char balance;
79 unsigned char envelope_rate[6];
80 unsigned char envelope_offset[6];
81 unsigned char tremolo_sweep;
82 unsigned char tremolo_rate;
83 unsigned char tremolo_depth;
84 unsigned char vibrato_sweep;
85 unsigned char vibrato_rate;
86 unsigned char vibrato_depth;
87 unsigned short scale_frequency;
88 unsigned short scale_factor; /* 0-2048 or 0-2 */
89
90 struct gf1_wave *next;
91};
92
93/*
94 * Instrument
95 */
96
97#define IWFFFF_EXCLUDE_NONE 0x0000 /* exclusion mode - none */
98#define IWFFFF_EXCLUDE_SINGLE 0x0001 /* exclude single - single note from the instrument group */
99#define IWFFFF_EXCLUDE_MULTIPLE 0x0002 /* exclude multiple - stop only same note from this instrument */
100
101#define IWFFFF_EFFECT_NONE 0
102#define IWFFFF_EFFECT_REVERB 1
103#define IWFFFF_EFFECT_CHORUS 2
104#define IWFFFF_EFFECT_ECHO 3
105
106struct gf1_instrument {
107 unsigned short exclusion;
108 unsigned short exclusion_group; /* 0 - none, 1-65535 */
109
110 unsigned char effect1; /* effect 1 */
111 unsigned char effect1_depth; /* 0-127 */
112 unsigned char effect2; /* effect 2 */
113 unsigned char effect2_depth; /* 0-127 */
114
115 struct gf1_wave *wave; /* first waveform */
116};
117
118/*
119 *
120 * Kernel <-> user space
121 * Hardware (CPU) independent section
122 *
123 * * = zero or more
124 * + = one or more
125 *
126 * gf1_xinstrument IWFFFF_STRU_INSTR
127 * +gf1_xwave IWFFFF_STRU_WAVE
128 *
129 */
130
131#define GF1_STRU_WAVE __cpu_to_be32(('W'<<24)|('A'<<16)|('V'<<8)|'E')
132#define GF1_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T')
133
134/*
135 * Wavetable definitions
136 */
137
138struct gf1_xwave {
139 __u32 stype; /* structure type */
140
141 __u32 share_id[4]; /* share id - zero = no sharing */
142 __u32 format; /* wave format */
143
144 __u32 size; /* size of waveform in samples */
145 __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
146 __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
147 __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
148 __u16 loop_repeat; /* loop repeat - 0 = forever */
149
150 __u8 flags; /* GF1 patch flags */
151 __u8 pad;
152 __u32 sample_rate; /* sample rate in Hz */
153 __u32 low_frequency; /* low frequency range */
154 __u32 high_frequency; /* high frequency range */
155 __u32 root_frequency; /* root frequency range */
156 __s16 tune;
157 __u8 balance;
158 __u8 envelope_rate[6];
159 __u8 envelope_offset[6];
160 __u8 tremolo_sweep;
161 __u8 tremolo_rate;
162 __u8 tremolo_depth;
163 __u8 vibrato_sweep;
164 __u8 vibrato_rate;
165 __u8 vibrato_depth;
166 __u16 scale_frequency;
167 __u16 scale_factor; /* 0-2048 or 0-2 */
168};
169
170/*
171 * Instrument
172 */
173
174struct gf1_xinstrument {
175 __u32 stype;
176
177 __u16 exclusion;
178 __u16 exclusion_group; /* 0 - none, 1-65535 */
179
180 __u8 effect1; /* effect 1 */
181 __u8 effect1_depth; /* 0-127 */
182 __u8 effect2; /* effect 2 */
183 __u8 effect2_depth; /* 0-127 */
184};
185
186/*
187 * Instrument info
188 */
189
190#define GF1_INFO_ENVELOPE (1<<0)
191#define GF1_INFO_TREMOLO (1<<1)
192#define GF1_INFO_VIBRATO (1<<2)
193
194struct gf1_info {
195 unsigned char flags; /* supported wave flags */
196 unsigned char pad[3];
197 unsigned int features; /* supported features */
198 unsigned int max8_len; /* maximum 8-bit wave length */
199 unsigned int max16_len; /* maximum 16-bit wave length */
200};
201
202#ifdef __KERNEL__
203
204#include "seq_instr.h"
205
206struct snd_gf1_ops {
207 void *private_data;
208 int (*info)(void *private_data, struct gf1_info *info);
209 int (*put_sample)(void *private_data, struct gf1_wave *wave,
210 char __user *data, long len, int atomic);
211 int (*get_sample)(void *private_data, struct gf1_wave *wave,
212 char __user *data, long len, int atomic);
213 int (*remove_sample)(void *private_data, struct gf1_wave *wave,
214 int atomic);
215 void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what);
216 struct snd_seq_kinstr_ops kops;
217};
218
219int snd_seq_gf1_init(struct snd_gf1_ops *ops,
220 void *private_data,
221 struct snd_seq_kinstr_ops *next);
222
223#endif
224
225/* typedefs for compatibility to user-space */
226typedef struct gf1_xwave gf1_xwave_t;
227typedef struct gf1_xinstrument gf1_xinstrument_t;
228
229#endif /* __SOUND_AINSTR_GF1_H */
diff --git a/include/sound/ainstr_iw.h b/include/sound/ainstr_iw.h
deleted file mode 100644
index 11bd25082600..000000000000
--- a/include/sound/ainstr_iw.h
+++ /dev/null
@@ -1,384 +0,0 @@
1/*
2 * Advanced Linux Sound Architecture
3 *
4 * InterWave FFFF Instrument Format
5 * Copyright (c) 1994-99 by Jaroslav Kysela <perex@perex.cz>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifndef __SOUND_AINSTR_IW_H
25#define __SOUND_AINSTR_IW_H
26
27#ifndef __KERNEL__
28#include <asm/types.h>
29#include <asm/byteorder.h>
30#endif
31
32/*
33 * share types (share ID 1)
34 */
35
36#define IWFFFF_SHARE_FILE 0
37
38/*
39 * wave formats
40 */
41
42#define IWFFFF_WAVE_16BIT 0x0001 /* 16-bit wave */
43#define IWFFFF_WAVE_UNSIGNED 0x0002 /* unsigned wave */
44#define IWFFFF_WAVE_INVERT 0x0002 /* same as unsigned wave */
45#define IWFFFF_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */
46#define IWFFFF_WAVE_LOOP 0x0008 /* loop mode */
47#define IWFFFF_WAVE_BIDIR 0x0010 /* bidirectional mode */
48#define IWFFFF_WAVE_ULAW 0x0020 /* uLaw compressed wave */
49#define IWFFFF_WAVE_RAM 0x0040 /* wave is _preloaded_ in RAM (it is used for ROM simulation) */
50#define IWFFFF_WAVE_ROM 0x0080 /* wave is in ROM */
51#define IWFFFF_WAVE_STEREO 0x0100 /* wave is stereo */
52
53/*
54 * Wavetable definitions
55 */
56
57struct iwffff_wave {
58 unsigned int share_id[4]; /* share id - zero = no sharing */
59 unsigned int format; /* wave format */
60
61 struct {
62 unsigned int number; /* some other ID for this wave */
63 unsigned int memory; /* begin of waveform in onboard memory */
64 unsigned char *ptr; /* pointer to waveform in system memory */
65 } address;
66
67 unsigned int size; /* size of waveform in samples */
68 unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
69 unsigned int loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
70 unsigned int loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
71 unsigned short loop_repeat; /* loop repeat - 0 = forever */
72 unsigned int sample_ratio; /* sample ratio (44100 * 1024 / rate) */
73 unsigned char attenuation; /* 0 - 127 (no corresponding midi controller) */
74 unsigned char low_note; /* lower frequency range for this waveform */
75 unsigned char high_note; /* higher frequency range for this waveform */
76 unsigned char pad;
77
78 struct iwffff_wave *next;
79};
80
81/*
82 * Layer
83 */
84
85#define IWFFFF_LFO_SHAPE_TRIANGLE 0
86#define IWFFFF_LFO_SHAPE_POSTRIANGLE 1
87
88struct iwffff_lfo {
89 unsigned short freq; /* (0-2047) 0.01Hz - 21.5Hz */
90 signed short depth; /* volume +- (0-255) 0.48675dB/step */
91 signed short sweep; /* 0 - 950 deciseconds */
92 unsigned char shape; /* see to IWFFFF_LFO_SHAPE_XXXX */
93 unsigned char delay; /* 0 - 255 deciseconds */
94};
95
96#define IWFFFF_ENV_FLAG_RETRIGGER 0x0001 /* flag - retrigger */
97
98#define IWFFFF_ENV_MODE_ONE_SHOT 0x0001 /* mode - one shot */
99#define IWFFFF_ENV_MODE_SUSTAIN 0x0002 /* mode - sustain */
100#define IWFFFF_ENV_MODE_NO_SUSTAIN 0x0003 /* mode - no sustain */
101
102#define IWFFFF_ENV_INDEX_VELOCITY 0x0001 /* index - velocity */
103#define IWFFFF_ENV_INDEX_FREQUENCY 0x0002 /* index - frequency */
104
105struct iwffff_env_point {
106 unsigned short offset;
107 unsigned short rate;
108};
109
110struct iwffff_env_record {
111 unsigned short nattack;
112 unsigned short nrelease;
113 unsigned short sustain_offset;
114 unsigned short sustain_rate;
115 unsigned short release_rate;
116 unsigned char hirange;
117 unsigned char pad;
118 struct iwffff_env_record *next;
119 /* points are stored here */
120 /* count of points = nattack + nrelease */
121};
122
123struct iwffff_env {
124 unsigned char flags;
125 unsigned char mode;
126 unsigned char index;
127 unsigned char pad;
128 struct iwffff_env_record *record;
129};
130
131#define IWFFFF_LAYER_FLAG_RETRIGGER 0x0001 /* retrigger */
132
133#define IWFFFF_LAYER_VELOCITY_TIME 0x0000 /* velocity mode = time */
134#define IWFFFF_LAYER_VELOCITY_RATE 0x0001 /* velocity mode = rate */
135
136#define IWFFFF_LAYER_EVENT_KUP 0x0000 /* layer event - key up */
137#define IWFFFF_LAYER_EVENT_KDOWN 0x0001 /* layer event - key down */
138#define IWFFFF_LAYER_EVENT_RETRIG 0x0002 /* layer event - retrigger */
139#define IWFFFF_LAYER_EVENT_LEGATO 0x0003 /* layer event - legato */
140
141struct iwffff_layer {
142 unsigned char flags;
143 unsigned char velocity_mode;
144 unsigned char layer_event;
145 unsigned char low_range; /* range for layer based */
146 unsigned char high_range; /* on either velocity or frequency */
147 unsigned char pan; /* pan offset from CC1 (0 left - 127 right) */
148 unsigned char pan_freq_scale; /* position based on frequency (0-127) */
149 unsigned char attenuation; /* 0-127 (no corresponding midi controller) */
150 struct iwffff_lfo tremolo; /* tremolo effect */
151 struct iwffff_lfo vibrato; /* vibrato effect */
152 unsigned short freq_scale; /* 0-2048, 1024 is equal to semitone scaling */
153 unsigned char freq_center; /* center for keyboard frequency scaling */
154 unsigned char pad;
155 struct iwffff_env penv; /* pitch envelope */
156 struct iwffff_env venv; /* volume envelope */
157
158 struct iwffff_wave *wave;
159 struct iwffff_layer *next;
160};
161
162/*
163 * Instrument
164 */
165
166#define IWFFFF_EXCLUDE_NONE 0x0000 /* exclusion mode - none */
167#define IWFFFF_EXCLUDE_SINGLE 0x0001 /* exclude single - single note from the instrument group */
168#define IWFFFF_EXCLUDE_MULTIPLE 0x0002 /* exclude multiple - stop only same note from this instrument */
169
170#define IWFFFF_LAYER_NONE 0x0000 /* not layered */
171#define IWFFFF_LAYER_ON 0x0001 /* layered */
172#define IWFFFF_LAYER_VELOCITY 0x0002 /* layered by velocity */
173#define IWFFFF_LAYER_FREQUENCY 0x0003 /* layered by frequency */
174
175#define IWFFFF_EFFECT_NONE 0
176#define IWFFFF_EFFECT_REVERB 1
177#define IWFFFF_EFFECT_CHORUS 2
178#define IWFFFF_EFFECT_ECHO 3
179
180struct iwffff_instrument {
181 unsigned short exclusion;
182 unsigned short layer_type;
183 unsigned short exclusion_group; /* 0 - none, 1-65535 */
184
185 unsigned char effect1; /* effect 1 */
186 unsigned char effect1_depth; /* 0-127 */
187 unsigned char effect2; /* effect 2 */
188 unsigned char effect2_depth; /* 0-127 */
189
190 struct iwffff_layer *layer; /* first layer */
191};
192
193/*
194 *
195 * Kernel <-> user space
196 * Hardware (CPU) independent section
197 *
198 * * = zero or more
199 * + = one or more
200 *
201 * iwffff_xinstrument IWFFFF_STRU_INSTR
202 * +iwffff_xlayer IWFFFF_STRU_LAYER
203 * *iwffff_xenv_record IWFFFF_STRU_ENV_RECT (tremolo)
204 * *iwffff_xenv_record IWFFFF_STRU_EVN_RECT (vibrato)
205 * +iwffff_xwave IWFFFF_STRU_WAVE
206 *
207 */
208
209#define IWFFFF_STRU_WAVE __cpu_to_be32(('W'<<24)|('A'<<16)|('V'<<8)|'E')
210#define IWFFFF_STRU_ENV_RECP __cpu_to_be32(('E'<<24)|('N'<<16)|('R'<<8)|'P')
211#define IWFFFF_STRU_ENV_RECV __cpu_to_be32(('E'<<24)|('N'<<16)|('R'<<8)|'V')
212#define IWFFFF_STRU_LAYER __cpu_to_be32(('L'<<24)|('A'<<16)|('Y'<<8)|'R')
213#define IWFFFF_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T')
214
215/*
216 * Wavetable definitions
217 */
218
219struct iwffff_xwave {
220 __u32 stype; /* structure type */
221
222 __u32 share_id[4]; /* share id - zero = no sharing */
223
224 __u32 format; /* wave format */
225 __u32 offset; /* offset to ROM (address) */
226
227 __u32 size; /* size of waveform in samples */
228 __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
229 __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
230 __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
231 __u16 loop_repeat; /* loop repeat - 0 = forever */
232 __u32 sample_ratio; /* sample ratio (44100 * 1024 / rate) */
233 __u8 attenuation; /* 0 - 127 (no corresponding midi controller) */
234 __u8 low_note; /* lower frequency range for this waveform */
235 __u8 high_note; /* higher frequency range for this waveform */
236 __u8 pad;
237};
238
239/*
240 * Layer
241 */
242
243struct iwffff_xlfo {
244 __u16 freq; /* (0-2047) 0.01Hz - 21.5Hz */
245 __s16 depth; /* volume +- (0-255) 0.48675dB/step */
246 __s16 sweep; /* 0 - 950 deciseconds */
247 __u8 shape; /* see to ULTRA_IW_LFO_SHAPE_XXXX */
248 __u8 delay; /* 0 - 255 deciseconds */
249};
250
251struct iwffff_xenv_point {
252 __u16 offset;
253 __u16 rate;
254};
255
256struct iwffff_xenv_record {
257 __u32 stype;
258 __u16 nattack;
259 __u16 nrelease;
260 __u16 sustain_offset;
261 __u16 sustain_rate;
262 __u16 release_rate;
263 __u8 hirange;
264 __u8 pad;
265 /* points are stored here.. */
266 /* count of points = nattack + nrelease */
267};
268
269struct iwffff_xenv {
270 __u8 flags;
271 __u8 mode;
272 __u8 index;
273 __u8 pad;
274};
275
276struct iwffff_xlayer {
277 __u32 stype;
278 __u8 flags;
279 __u8 velocity_mode;
280 __u8 layer_event;
281 __u8 low_range; /* range for layer based */
282 __u8 high_range; /* on either velocity or frequency */
283 __u8 pan; /* pan offset from CC1 (0 left - 127 right) */
284 __u8 pan_freq_scale; /* position based on frequency (0-127) */
285 __u8 attenuation; /* 0-127 (no corresponding midi controller) */
286 struct iwffff_xlfo tremolo; /* tremolo effect */
287 struct iwffff_xlfo vibrato; /* vibrato effect */
288 __u16 freq_scale; /* 0-2048, 1024 is equal to semitone scaling */
289 __u8 freq_center; /* center for keyboard frequency scaling */
290 __u8 pad;
291 struct iwffff_xenv penv; /* pitch envelope */
292 struct iwffff_xenv venv; /* volume envelope */
293};
294
295/*
296 * Instrument
297 */
298
299struct iwffff_xinstrument {
300 __u32 stype;
301
302 __u16 exclusion;
303 __u16 layer_type;
304 __u16 exclusion_group; /* 0 - none, 1-65535 */
305
306 __u8 effect1; /* effect 1 */
307 __u8 effect1_depth; /* 0-127 */
308 __u8 effect2; /* effect 2 */
309 __u8 effect2_depth; /* 0-127 */
310};
311
312/*
313 * ROM support
314 * InterWave ROMs are Little-Endian (x86)
315 */
316
317#define IWFFFF_ROM_HDR_SIZE 512
318
319struct iwffff_rom_header {
320 __u8 iwave[8];
321 __u8 revision;
322 __u8 series_number;
323 __u8 series_name[16];
324 __u8 date[10];
325 __u16 vendor_revision_major;
326 __u16 vendor_revision_minor;
327 __u32 rom_size;
328 __u8 copyright[128];
329 __u8 vendor_name[64];
330 __u8 description[128];
331};
332
333/*
334 * Instrument info
335 */
336
337#define IWFFFF_INFO_LFO_VIBRATO (1<<0)
338#define IWFFFF_INFO_LFO_VIBRATO_SHAPE (1<<1)
339#define IWFFFF_INFO_LFO_TREMOLO (1<<2)
340#define IWFFFF_INFO_LFO_TREMOLO_SHAPE (1<<3)
341
342struct iwffff_info {
343 unsigned int format; /* supported format bits */
344 unsigned int effects; /* supported effects (1 << IWFFFF_EFFECT*) */
345 unsigned int lfos; /* LFO effects */
346 unsigned int max8_len; /* maximum 8-bit wave length */
347 unsigned int max16_len; /* maximum 16-bit wave length */
348};
349
350#ifdef __KERNEL__
351
352#include "seq_instr.h"
353
354struct snd_iwffff_ops {
355 void *private_data;
356 int (*info)(void *private_data, struct iwffff_info *info);
357 int (*put_sample)(void *private_data, struct iwffff_wave *wave,
358 char __user *data, long len, int atomic);
359 int (*get_sample)(void *private_data, struct iwffff_wave *wave,
360 char __user *data, long len, int atomic);
361 int (*remove_sample)(void *private_data, struct iwffff_wave *wave,
362 int atomic);
363 void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what);
364 struct snd_seq_kinstr_ops kops;
365};
366
367int snd_seq_iwffff_init(struct snd_iwffff_ops *ops,
368 void *private_data,
369 struct snd_seq_kinstr_ops *next);
370
371#endif
372
373/* typedefs for compatibility to user-space */
374typedef struct iwffff_xwave iwffff_xwave_t;
375typedef struct iwffff_xlfo iwffff_xlfo_t;
376typedef struct iwffff_xenv_point iwffff_xenv_point_t;
377typedef struct iwffff_xenv_record iwffff_xenv_record_t;
378typedef struct iwffff_xenv iwffff_xenv_t;
379typedef struct iwffff_xlayer iwffff_xlayer_t;
380typedef struct iwffff_xinstrument iwffff_xinstrument_t;
381typedef struct iwffff_rom_header iwffff_rom_header_t;
382typedef struct iwffff_info iwffff_info_t;
383
384#endif /* __SOUND_AINSTR_IW_H */
diff --git a/include/sound/ainstr_simple.h b/include/sound/ainstr_simple.h
deleted file mode 100644
index da08e7287557..000000000000
--- a/include/sound/ainstr_simple.h
+++ /dev/null
@@ -1,159 +0,0 @@
1/*
2 * Advanced Linux Sound Architecture
3 *
4 * Simple (MOD player) Instrument Format
5 * Copyright (c) 1994-99 by Jaroslav Kysela <perex@perex.cz>
6 *
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23
24#ifndef __SOUND_AINSTR_SIMPLE_H
25#define __SOUND_AINSTR_SIMPLE_H
26
27#ifndef __KERNEL__
28#include <asm/types.h>
29#include <asm/byteorder.h>
30#endif
31
32/*
33 * share types (share ID 1)
34 */
35
36#define SIMPLE_SHARE_FILE 0
37
38/*
39 * wave formats
40 */
41
42#define SIMPLE_WAVE_16BIT 0x0001 /* 16-bit wave */
43#define SIMPLE_WAVE_UNSIGNED 0x0002 /* unsigned wave */
44#define SIMPLE_WAVE_INVERT 0x0002 /* same as unsigned wave */
45#define SIMPLE_WAVE_BACKWARD 0x0004 /* backward mode (maybe used for reverb or ping-ping loop) */
46#define SIMPLE_WAVE_LOOP 0x0008 /* loop mode */
47#define SIMPLE_WAVE_BIDIR 0x0010 /* bidirectional mode */
48#define SIMPLE_WAVE_STEREO 0x0100 /* stereo wave */
49#define SIMPLE_WAVE_ULAW 0x0200 /* uLaw compression mode */
50
51/*
52 * instrument effects
53 */
54
55#define SIMPLE_EFFECT_NONE 0
56#define SIMPLE_EFFECT_REVERB 1
57#define SIMPLE_EFFECT_CHORUS 2
58#define SIMPLE_EFFECT_ECHO 3
59
60/*
61 * instrument info
62 */
63
64struct simple_instrument_info {
65 unsigned int format; /* supported format bits */
66 unsigned int effects; /* supported effects (1 << SIMPLE_EFFECT_*) */
67 unsigned int max8_len; /* maximum 8-bit wave length */
68 unsigned int max16_len; /* maximum 16-bit wave length */
69};
70
71/*
72 * Instrument
73 */
74
75struct simple_instrument {
76 unsigned int share_id[4]; /* share id - zero = no sharing */
77 unsigned int format; /* wave format */
78
79 struct {
80 unsigned int number; /* some other ID for this instrument */
81 unsigned int memory; /* begin of waveform in onboard memory */
82 unsigned char *ptr; /* pointer to waveform in system memory */
83 } address;
84
85 unsigned int size; /* size of waveform in samples */
86 unsigned int start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
87 unsigned int loop_start; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
88 unsigned int loop_end; /* loop end offset in samples * 16 (lowest 4 bits - fraction) */
89 unsigned short loop_repeat; /* loop repeat - 0 = forever */
90
91 unsigned char effect1; /* effect 1 */
92 unsigned char effect1_depth; /* 0-127 */
93 unsigned char effect2; /* effect 2 */
94 unsigned char effect2_depth; /* 0-127 */
95};
96
97/*
98 *
99 * Kernel <-> user space
100 * Hardware (CPU) independent section
101 *
102 * * = zero or more
103 * + = one or more
104 *
105 * simple_xinstrument SIMPLE_STRU_INSTR
106 *
107 */
108
109#define SIMPLE_STRU_INSTR __cpu_to_be32(('I'<<24)|('N'<<16)|('S'<<8)|'T')
110
111/*
112 * Instrument
113 */
114
115struct simple_xinstrument {
116 __u32 stype;
117
118 __u32 share_id[4]; /* share id - zero = no sharing */
119 __u32 format; /* wave format */
120
121 __u32 size; /* size of waveform in samples */
122 __u32 start; /* start offset in samples * 16 (lowest 4 bits - fraction) */
123 __u32 loop_start; /* bits loop start offset in samples * 16 (lowest 4 bits - fraction) */
124 __u32 loop_end; /* loop start offset in samples * 16 (lowest 4 bits - fraction) */
125 __u16 loop_repeat; /* loop repeat - 0 = forever */
126
127 __u8 effect1; /* effect 1 */
128 __u8 effect1_depth; /* 0-127 */
129 __u8 effect2; /* effect 2 */
130 __u8 effect2_depth; /* 0-127 */
131};
132
133#ifdef __KERNEL__
134
135#include "seq_instr.h"
136
137struct snd_simple_ops {
138 void *private_data;
139 int (*info)(void *private_data, struct simple_instrument_info *info);
140 int (*put_sample)(void *private_data, struct simple_instrument *instr,
141 char __user *data, long len, int atomic);
142 int (*get_sample)(void *private_data, struct simple_instrument *instr,
143 char __user *data, long len, int atomic);
144 int (*remove_sample)(void *private_data, struct simple_instrument *instr,
145 int atomic);
146 void (*notify)(void *private_data, struct snd_seq_kinstr *instr, int what);
147 struct snd_seq_kinstr_ops kops;
148};
149
150int snd_seq_simple_init(struct snd_simple_ops *ops,
151 void *private_data,
152 struct snd_seq_kinstr_ops *next);
153
154#endif
155
156/* typedefs for compatibility to user-space */
157typedef struct simple_xinstrument simple_xinstrument_t;
158
159#endif /* __SOUND_AINSTR_SIMPLE_H */
diff --git a/include/sound/ak4xxx-adda.h b/include/sound/ak4xxx-adda.h
index 891cf1aea8b1..6153b91cdc3e 100644
--- a/include/sound/ak4xxx-adda.h
+++ b/include/sound/ak4xxx-adda.h
@@ -68,7 +68,7 @@ struct snd_akm4xxx {
68 enum { 68 enum {
69 SND_AK4524, SND_AK4528, SND_AK4529, 69 SND_AK4524, SND_AK4528, SND_AK4529,
70 SND_AK4355, SND_AK4358, SND_AK4381, 70 SND_AK4355, SND_AK4358, SND_AK4381,
71 SND_AK5365 71 SND_AK5365, NON_AKM
72 } type; 72 } type;
73 73
74 /* (array) information of combined codecs */ 74 /* (array) information of combined codecs */
diff --git a/include/sound/asequencer.h b/include/sound/asequencer.h
index 64daccbe8b29..1505e6d5ef82 100644
--- a/include/sound/asequencer.h
+++ b/include/sound/asequencer.h
@@ -110,18 +110,7 @@
110#define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66 /* ports connected */ 110#define SNDRV_SEQ_EVENT_PORT_SUBSCRIBED 66 /* ports connected */
111#define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67 /* ports disconnected */ 111#define SNDRV_SEQ_EVENT_PORT_UNSUBSCRIBED 67 /* ports disconnected */
112 112
113/** synthesizer events 113/* 70-89: synthesizer events - obsoleted */
114 * event data type = snd_seq_eve_sample_control
115 */
116#define SNDRV_SEQ_EVENT_SAMPLE 70 /* sample select */
117#define SNDRV_SEQ_EVENT_SAMPLE_CLUSTER 71 /* sample cluster select */
118#define SNDRV_SEQ_EVENT_SAMPLE_START 72 /* voice start */
119#define SNDRV_SEQ_EVENT_SAMPLE_STOP 73 /* voice stop */
120#define SNDRV_SEQ_EVENT_SAMPLE_FREQ 74 /* playback frequency */
121#define SNDRV_SEQ_EVENT_SAMPLE_VOLUME 75 /* volume and balance */
122#define SNDRV_SEQ_EVENT_SAMPLE_LOOP 76 /* sample loop */
123#define SNDRV_SEQ_EVENT_SAMPLE_POSITION 77 /* sample position */
124#define SNDRV_SEQ_EVENT_SAMPLE_PRIVATE1 78 /* private (hardware dependent) event */
125 114
126/** user-defined events with fixed length 115/** user-defined events with fixed length
127 * event data type = any 116 * event data type = any
@@ -137,28 +126,7 @@
137#define SNDRV_SEQ_EVENT_USR8 98 126#define SNDRV_SEQ_EVENT_USR8 98
138#define SNDRV_SEQ_EVENT_USR9 99 127#define SNDRV_SEQ_EVENT_USR9 99
139 128
140/** instrument layer 129/* 100-118: instrument layer - obsoleted */
141 * variable length data can be passed directly to the driver
142 */
143#define SNDRV_SEQ_EVENT_INSTR_BEGIN 100 /* begin of instrument management */
144#define SNDRV_SEQ_EVENT_INSTR_END 101 /* end of instrument management */
145#define SNDRV_SEQ_EVENT_INSTR_INFO 102 /* instrument interface info */
146#define SNDRV_SEQ_EVENT_INSTR_INFO_RESULT 103 /* result */
147#define SNDRV_SEQ_EVENT_INSTR_FINFO 104 /* get format info */
148#define SNDRV_SEQ_EVENT_INSTR_FINFO_RESULT 105 /* get format info */
149#define SNDRV_SEQ_EVENT_INSTR_RESET 106 /* reset instrument memory */
150#define SNDRV_SEQ_EVENT_INSTR_STATUS 107 /* instrument interface status */
151#define SNDRV_SEQ_EVENT_INSTR_STATUS_RESULT 108 /* result */
152#define SNDRV_SEQ_EVENT_INSTR_PUT 109 /* put instrument to port */
153#define SNDRV_SEQ_EVENT_INSTR_GET 110 /* get instrument from port */
154#define SNDRV_SEQ_EVENT_INSTR_GET_RESULT 111 /* result */
155#define SNDRV_SEQ_EVENT_INSTR_FREE 112 /* free instrument(s) */
156#define SNDRV_SEQ_EVENT_INSTR_LIST 113 /* instrument list */
157#define SNDRV_SEQ_EVENT_INSTR_LIST_RESULT 114 /* result */
158#define SNDRV_SEQ_EVENT_INSTR_CLUSTER 115 /* cluster parameters */
159#define SNDRV_SEQ_EVENT_INSTR_CLUSTER_GET 116 /* get cluster parameters */
160#define SNDRV_SEQ_EVENT_INSTR_CLUSTER_RESULT 117 /* result */
161#define SNDRV_SEQ_EVENT_INSTR_CHANGE 118 /* instrument change */
162/* 119-129: reserved */ 130/* 119-129: reserved */
163 131
164/* 130-139: variable length events 132/* 130-139: variable length events
@@ -258,78 +226,6 @@ struct snd_seq_ev_ext {
258 void *ptr; /* pointer to data (note: maybe 64-bit) */ 226 void *ptr; /* pointer to data (note: maybe 64-bit) */
259} __attribute__((packed)); 227} __attribute__((packed));
260 228
261/* Instrument cluster type */
262typedef unsigned int snd_seq_instr_cluster_t;
263
264/* Instrument type */
265struct snd_seq_instr {
266 snd_seq_instr_cluster_t cluster;
267 unsigned int std; /* the upper byte means a private instrument (owner - client #) */
268 unsigned short bank;
269 unsigned short prg;
270};
271
272 /* sample number */
273struct snd_seq_ev_sample {
274 unsigned int std;
275 unsigned short bank;
276 unsigned short prg;
277};
278
279 /* sample cluster */
280struct snd_seq_ev_cluster {
281 snd_seq_instr_cluster_t cluster;
282};
283
284 /* sample position */
285typedef unsigned int snd_seq_position_t; /* playback position (in samples) * 16 */
286
287 /* sample stop mode */
288enum {
289 SAMPLE_STOP_IMMEDIATELY = 0, /* terminate playing immediately */
290 SAMPLE_STOP_VENVELOPE = 1, /* finish volume envelope */
291 SAMPLE_STOP_LOOP = 2 /* terminate loop and finish wave */
292};
293
294 /* sample frequency */
295typedef int snd_seq_frequency_t; /* playback frequency in HZ * 16 */
296
297 /* sample volume control; if any value is set to -1 == do not change */
298struct snd_seq_ev_volume {
299 signed short volume; /* range: 0-16383 */
300 signed short lr; /* left-right balance; range: 0-16383 */
301 signed short fr; /* front-rear balance; range: 0-16383 */
302 signed short du; /* down-up balance; range: 0-16383 */
303};
304
305 /* simple loop redefinition */
306struct snd_seq_ev_loop {
307 unsigned int start; /* loop start (in samples) * 16 */
308 unsigned int end; /* loop end (in samples) * 16 */
309};
310
311struct snd_seq_ev_sample_control {
312 unsigned char channel;
313 unsigned char unused1, unused2, unused3; /* pad */
314 union {
315 struct snd_seq_ev_sample sample;
316 struct snd_seq_ev_cluster cluster;
317 snd_seq_position_t position;
318 int stop_mode;
319 snd_seq_frequency_t frequency;
320 struct snd_seq_ev_volume volume;
321 struct snd_seq_ev_loop loop;
322 unsigned char raw8[8];
323 } param;
324};
325
326
327
328/* INSTR_BEGIN event */
329struct snd_seq_ev_instr_begin {
330 int timeout; /* zero = forever, otherwise timeout in ms */
331};
332
333struct snd_seq_result { 229struct snd_seq_result {
334 int event; /* processed event type */ 230 int event; /* processed event type */
335 int result; 231 int result;
@@ -399,8 +295,6 @@ struct snd_seq_event {
399 struct snd_seq_addr addr; 295 struct snd_seq_addr addr;
400 struct snd_seq_connect connect; 296 struct snd_seq_connect connect;
401 struct snd_seq_result result; 297 struct snd_seq_result result;
402 struct snd_seq_ev_instr_begin instr_begin;
403 struct snd_seq_ev_sample_control sample;
404 struct snd_seq_ev_quote quote; 298 struct snd_seq_ev_quote quote;
405 } data; 299 } data;
406}; 300};
@@ -441,8 +335,6 @@ struct snd_seq_event_bounce {
441#define snd_seq_ev_is_user_type(ev) ((ev)->type >= 90 && (ev)->type < 99) 335#define snd_seq_ev_is_user_type(ev) ((ev)->type >= 90 && (ev)->type < 99)
442/* fixed length events: 0-99 */ 336/* fixed length events: 0-99 */
443#define snd_seq_ev_is_fixed_type(ev) ((ev)->type < 100) 337#define snd_seq_ev_is_fixed_type(ev) ((ev)->type < 100)
444/* instrument layer events: 100-129 */
445#define snd_seq_ev_is_instr_type(ev) ((ev)->type >= 100 && (ev)->type < 130)
446/* variable length events: 130-139 */ 338/* variable length events: 130-139 */
447#define snd_seq_ev_is_variable_type(ev) ((ev)->type >= 130 && (ev)->type < 140) 339#define snd_seq_ev_is_variable_type(ev) ((ev)->type >= 130 && (ev)->type < 140)
448/* reserved for kernel */ 340/* reserved for kernel */
@@ -738,136 +630,6 @@ struct snd_seq_query_subs {
738 630
739 631
740/* 632/*
741 * Instrument abstraction layer
742 * - based on events
743 */
744
745/* instrument types */
746#define SNDRV_SEQ_INSTR_ATYPE_DATA 0 /* instrument data */
747#define SNDRV_SEQ_INSTR_ATYPE_ALIAS 1 /* instrument alias */
748
749/* instrument ASCII identifiers */
750#define SNDRV_SEQ_INSTR_ID_DLS1 "DLS1"
751#define SNDRV_SEQ_INSTR_ID_DLS2 "DLS2"
752#define SNDRV_SEQ_INSTR_ID_SIMPLE "Simple Wave"
753#define SNDRV_SEQ_INSTR_ID_SOUNDFONT "SoundFont"
754#define SNDRV_SEQ_INSTR_ID_GUS_PATCH "GUS Patch"
755#define SNDRV_SEQ_INSTR_ID_INTERWAVE "InterWave FFFF"
756#define SNDRV_SEQ_INSTR_ID_OPL2_3 "OPL2/3 FM"
757#define SNDRV_SEQ_INSTR_ID_OPL4 "OPL4"
758
759/* instrument types */
760#define SNDRV_SEQ_INSTR_TYPE0_DLS1 (1<<0) /* MIDI DLS v1 */
761#define SNDRV_SEQ_INSTR_TYPE0_DLS2 (1<<1) /* MIDI DLS v2 */
762#define SNDRV_SEQ_INSTR_TYPE1_SIMPLE (1<<0) /* Simple Wave */
763#define SNDRV_SEQ_INSTR_TYPE1_SOUNDFONT (1<<1) /* EMU SoundFont */
764#define SNDRV_SEQ_INSTR_TYPE1_GUS_PATCH (1<<2) /* Gravis UltraSound Patch */
765#define SNDRV_SEQ_INSTR_TYPE1_INTERWAVE (1<<3) /* InterWave FFFF */
766#define SNDRV_SEQ_INSTR_TYPE2_OPL2_3 (1<<0) /* Yamaha OPL2/3 FM */
767#define SNDRV_SEQ_INSTR_TYPE2_OPL4 (1<<1) /* Yamaha OPL4 */
768
769/* put commands */
770#define SNDRV_SEQ_INSTR_PUT_CMD_CREATE 0
771#define SNDRV_SEQ_INSTR_PUT_CMD_REPLACE 1
772#define SNDRV_SEQ_INSTR_PUT_CMD_MODIFY 2
773#define SNDRV_SEQ_INSTR_PUT_CMD_ADD 3
774#define SNDRV_SEQ_INSTR_PUT_CMD_REMOVE 4
775
776/* get commands */
777#define SNDRV_SEQ_INSTR_GET_CMD_FULL 0
778#define SNDRV_SEQ_INSTR_GET_CMD_PARTIAL 1
779
780/* query flags */
781#define SNDRV_SEQ_INSTR_QUERY_FOLLOW_ALIAS (1<<0)
782
783/* free commands */
784#define SNDRV_SEQ_INSTR_FREE_CMD_ALL 0
785#define SNDRV_SEQ_INSTR_FREE_CMD_PRIVATE 1
786#define SNDRV_SEQ_INSTR_FREE_CMD_CLUSTER 2
787#define SNDRV_SEQ_INSTR_FREE_CMD_SINGLE 3
788
789/* size of ROM/RAM */
790typedef unsigned int snd_seq_instr_size_t;
791
792/* INSTR_INFO */
793
794struct snd_seq_instr_info {
795 int result; /* operation result */
796 unsigned int formats[8]; /* bitmap of supported formats */
797 int ram_count; /* count of RAM banks */
798 snd_seq_instr_size_t ram_sizes[16]; /* size of RAM banks */
799 int rom_count; /* count of ROM banks */
800 snd_seq_instr_size_t rom_sizes[8]; /* size of ROM banks */
801 char reserved[128];
802};
803
804/* INSTR_STATUS */
805
806struct snd_seq_instr_status {
807 int result; /* operation result */
808 snd_seq_instr_size_t free_ram[16]; /* free RAM in banks */
809 int instrument_count; /* count of downloaded instruments */
810 char reserved[128];
811};
812
813/* INSTR_FORMAT_INFO */
814
815struct snd_seq_instr_format_info {
816 char format[16]; /* format identifier - SNDRV_SEQ_INSTR_ID_* */
817 unsigned int len; /* max data length (without this structure) */
818};
819
820struct snd_seq_instr_format_info_result {
821 int result; /* operation result */
822 char format[16]; /* format identifier */
823 unsigned int len; /* filled data length (without this structure) */
824};
825
826/* instrument data */
827struct snd_seq_instr_data {
828 char name[32]; /* instrument name */
829 char reserved[16]; /* for the future use */
830 int type; /* instrument type */
831 union {
832 char format[16]; /* format identifier */
833 struct snd_seq_instr alias;
834 } data;
835};
836
837/* INSTR_PUT/GET, data are stored in one block (extended), header + data */
838
839struct snd_seq_instr_header {
840 union {
841 struct snd_seq_instr instr;
842 snd_seq_instr_cluster_t cluster;
843 } id; /* instrument identifier */
844 unsigned int cmd; /* get/put/free command */
845 unsigned int flags; /* query flags (only for get) */
846 unsigned int len; /* real instrument data length (without header) */
847 int result; /* operation result */
848 char reserved[16]; /* for the future */
849 struct snd_seq_instr_data data; /* instrument data (for put/get result) */
850};
851
852/* INSTR_CLUSTER_SET */
853
854struct snd_seq_instr_cluster_set {
855 snd_seq_instr_cluster_t cluster; /* cluster identifier */
856 char name[32]; /* cluster name */
857 int priority; /* cluster priority */
858 char reserved[64]; /* for the future use */
859};
860
861/* INSTR_CLUSTER_GET */
862
863struct snd_seq_instr_cluster_get {
864 snd_seq_instr_cluster_t cluster; /* cluster identifier */
865 char name[32]; /* cluster name */
866 int priority; /* cluster priority */
867 char reserved[64]; /* for the future use */
868};
869
870/*
871 * IOCTL commands 633 * IOCTL commands
872 */ 634 */
873 635
diff --git a/include/sound/asound.h b/include/sound/asound.h
index af9d11d315e9..3eaf155b850d 100644
--- a/include/sound/asound.h
+++ b/include/sound/asound.h
@@ -95,7 +95,7 @@ enum {
95 SNDRV_HWDEP_IFACE_HDA, /* HD-audio */ 95 SNDRV_HWDEP_IFACE_HDA, /* HD-audio */
96 96
97 /* Don't forget to change the following: */ 97 /* Don't forget to change the following: */
98 SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_SB_RC 98 SNDRV_HWDEP_IFACE_LAST = SNDRV_HWDEP_IFACE_HDA
99}; 99};
100 100
101struct snd_hwdep_info { 101struct snd_hwdep_info {
@@ -138,7 +138,7 @@ enum {
138 * * 138 * *
139 *****************************************************************************/ 139 *****************************************************************************/
140 140
141#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 8) 141#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 9)
142 142
143typedef unsigned long snd_pcm_uframes_t; 143typedef unsigned long snd_pcm_uframes_t;
144typedef signed long snd_pcm_sframes_t; 144typedef signed long snd_pcm_sframes_t;
@@ -354,8 +354,8 @@ struct snd_pcm_hw_params {
354 354
355enum { 355enum {
356 SNDRV_PCM_TSTAMP_NONE = 0, 356 SNDRV_PCM_TSTAMP_NONE = 0,
357 SNDRV_PCM_TSTAMP_MMAP, 357 SNDRV_PCM_TSTAMP_ENABLE,
358 SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_MMAP, 358 SNDRV_PCM_TSTAMP_LAST = SNDRV_PCM_TSTAMP_ENABLE,
359}; 359};
360 360
361struct snd_pcm_sw_params { 361struct snd_pcm_sw_params {
@@ -363,7 +363,7 @@ struct snd_pcm_sw_params {
363 unsigned int period_step; 363 unsigned int period_step;
364 unsigned int sleep_min; /* min ticks to sleep */ 364 unsigned int sleep_min; /* min ticks to sleep */
365 snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */ 365 snd_pcm_uframes_t avail_min; /* min avail frames for wakeup */
366 snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */ 366 snd_pcm_uframes_t xfer_align; /* obsolete: xfer size need to be a multiple */
367 snd_pcm_uframes_t start_threshold; /* min hw_avail frames for automatic start */ 367 snd_pcm_uframes_t start_threshold; /* min hw_avail frames for automatic start */
368 snd_pcm_uframes_t stop_threshold; /* min avail frames for automatic stop */ 368 snd_pcm_uframes_t stop_threshold; /* min avail frames for automatic stop */
369 snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */ 369 snd_pcm_uframes_t silence_threshold; /* min distance from noise for silence filling */
@@ -435,9 +435,16 @@ struct snd_xfern {
435}; 435};
436 436
437enum { 437enum {
438 SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY = 0, /* gettimeofday equivalent */
439 SNDRV_PCM_TSTAMP_TYPE_MONOTONIC, /* posix_clock_monotonic equivalent */
440 SNDRV_PCM_TSTAMP_TYPE_LAST = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC,
441};
442
443enum {
438 SNDRV_PCM_IOCTL_PVERSION = _IOR('A', 0x00, int), 444 SNDRV_PCM_IOCTL_PVERSION = _IOR('A', 0x00, int),
439 SNDRV_PCM_IOCTL_INFO = _IOR('A', 0x01, struct snd_pcm_info), 445 SNDRV_PCM_IOCTL_INFO = _IOR('A', 0x01, struct snd_pcm_info),
440 SNDRV_PCM_IOCTL_TSTAMP = _IOW('A', 0x02, int), 446 SNDRV_PCM_IOCTL_TSTAMP = _IOW('A', 0x02, int),
447 SNDRV_PCM_IOCTL_TTSTAMP = _IOW('A', 0x03, int),
441 SNDRV_PCM_IOCTL_HW_REFINE = _IOWR('A', 0x10, struct snd_pcm_hw_params), 448 SNDRV_PCM_IOCTL_HW_REFINE = _IOWR('A', 0x10, struct snd_pcm_hw_params),
442 SNDRV_PCM_IOCTL_HW_PARAMS = _IOWR('A', 0x11, struct snd_pcm_hw_params), 449 SNDRV_PCM_IOCTL_HW_PARAMS = _IOWR('A', 0x11, struct snd_pcm_hw_params),
443 SNDRV_PCM_IOCTL_HW_FREE = _IO('A', 0x12), 450 SNDRV_PCM_IOCTL_HW_FREE = _IO('A', 0x12),
@@ -689,7 +696,7 @@ struct snd_timer_tread {
689 * * 696 * *
690 ****************************************************************************/ 697 ****************************************************************************/
691 698
692#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 4) 699#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 5)
693 700
694struct snd_ctl_card_info { 701struct snd_ctl_card_info {
695 int card; /* card number */ 702 int card; /* card number */
@@ -738,8 +745,7 @@ typedef int __bitwise snd_ctl_elem_iface_t;
738#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */ 745#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */
739#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */ 746#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */
740#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */ 747#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */
741#define SNDRV_CTL_ELEM_ACCESS_DINDIRECT (1<<30) /* indirect access for matrix dimensions in the info structure */ 748/* bits 30 and 31 are obsoleted (for indirect access) */
742#define SNDRV_CTL_ELEM_ACCESS_INDIRECT (1<<31) /* indirect access for element value in the value structure */
743 749
744/* for further details see the ACPI and PCI power management specification */ 750/* for further details see the ACPI and PCI power management specification */
745#define SNDRV_CTL_POWER_D0 0x0000 /* full On */ 751#define SNDRV_CTL_POWER_D0 0x0000 /* full On */
@@ -793,30 +799,30 @@ struct snd_ctl_elem_info {
793 } value; 799 } value;
794 union { 800 union {
795 unsigned short d[4]; /* dimensions */ 801 unsigned short d[4]; /* dimensions */
796 unsigned short *d_ptr; /* indirect */ 802 unsigned short *d_ptr; /* indirect - obsoleted */
797 } dimen; 803 } dimen;
798 unsigned char reserved[64-4*sizeof(unsigned short)]; 804 unsigned char reserved[64-4*sizeof(unsigned short)];
799}; 805};
800 806
801struct snd_ctl_elem_value { 807struct snd_ctl_elem_value {
802 struct snd_ctl_elem_id id; /* W: element ID */ 808 struct snd_ctl_elem_id id; /* W: element ID */
803 unsigned int indirect: 1; /* W: use indirect pointer (xxx_ptr member) */ 809 unsigned int indirect: 1; /* W: indirect access - obsoleted */
804 union { 810 union {
805 union { 811 union {
806 long value[128]; 812 long value[128];
807 long *value_ptr; 813 long *value_ptr; /* obsoleted */
808 } integer; 814 } integer;
809 union { 815 union {
810 long long value[64]; 816 long long value[64];
811 long long *value_ptr; 817 long long *value_ptr; /* obsoleted */
812 } integer64; 818 } integer64;
813 union { 819 union {
814 unsigned int item[128]; 820 unsigned int item[128];
815 unsigned int *item_ptr; 821 unsigned int *item_ptr; /* obsoleted */
816 } enumerated; 822 } enumerated;
817 union { 823 union {
818 unsigned char data[512]; 824 unsigned char data[512];
819 unsigned char *data_ptr; 825 unsigned char *data_ptr; /* obsoleted */
820 } bytes; 826 } bytes;
821 struct snd_aes_iec958 iec958; 827 struct snd_aes_iec958 iec958;
822 } value; /* RO */ 828 } value; /* RO */
diff --git a/include/sound/asound_fm.h b/include/sound/asound_fm.h
index 8fbcab7cc73b..c2a4b967d5be 100644
--- a/include/sound/asound_fm.h
+++ b/include/sound/asound_fm.h
@@ -104,6 +104,8 @@ struct snd_dm_fm_params {
104#define SNDRV_DM_FM_IOCTL_SET_MODE _IOW('H', 0x25, int) 104#define SNDRV_DM_FM_IOCTL_SET_MODE _IOW('H', 0x25, int)
105/* for OPL3 only */ 105/* for OPL3 only */
106#define SNDRV_DM_FM_IOCTL_SET_CONNECTION _IOW('H', 0x26, int) 106#define SNDRV_DM_FM_IOCTL_SET_CONNECTION _IOW('H', 0x26, int)
107/* SBI patch management */
108#define SNDRV_DM_FM_IOCTL_CLEAR_PATCHES _IO ('H', 0x40)
107 109
108#define SNDRV_DM_FM_OSS_IOCTL_RESET 0x20 110#define SNDRV_DM_FM_OSS_IOCTL_RESET 0x20
109#define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE 0x21 111#define SNDRV_DM_FM_OSS_IOCTL_PLAY_NOTE 0x21
@@ -112,4 +114,21 @@ struct snd_dm_fm_params {
112#define SNDRV_DM_FM_OSS_IOCTL_SET_MODE 0x24 114#define SNDRV_DM_FM_OSS_IOCTL_SET_MODE 0x24
113#define SNDRV_DM_FM_OSS_IOCTL_SET_OPL 0x25 115#define SNDRV_DM_FM_OSS_IOCTL_SET_OPL 0x25
114 116
117/*
118 * Patch Record - fixed size for write
119 */
120
121#define FM_KEY_SBI "SBI\032"
122#define FM_KEY_2OP "2OP\032"
123#define FM_KEY_4OP "4OP\032"
124
125struct sbi_patch {
126 unsigned char prog;
127 unsigned char bank;
128 char key[4];
129 char name[25];
130 char extension[7];
131 unsigned char data[32];
132};
133
115#endif /* __SOUND_ASOUND_FM_H */ 134#endif /* __SOUND_ASOUND_FM_H */
diff --git a/include/sound/core.h b/include/sound/core.h
index 6954836487ed..4fc0235ad784 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -22,12 +22,22 @@
22 * 22 *
23 */ 23 */
24 24
25#include <linux/module.h>
25#include <linux/sched.h> /* wake_up() */ 26#include <linux/sched.h> /* wake_up() */
26#include <linux/mutex.h> /* struct mutex */ 27#include <linux/mutex.h> /* struct mutex */
27#include <linux/rwsem.h> /* struct rw_semaphore */ 28#include <linux/rwsem.h> /* struct rw_semaphore */
28#include <linux/pm.h> /* pm_message_t */ 29#include <linux/pm.h> /* pm_message_t */
29#include <linux/device.h> 30#include <linux/device.h>
30 31
32/* number of supported soundcards */
33#ifdef CONFIG_SND_DYNAMIC_MINORS
34#define SNDRV_CARDS 32
35#else
36#define SNDRV_CARDS 8 /* don't change - minor numbers */
37#endif
38
39#define CONFIG_SND_MAJOR 116 /* standard configuration */
40
31/* forward declarations */ 41/* forward declarations */
32#ifdef CONFIG_PCI 42#ifdef CONFIG_PCI
33struct pci_dev; 43struct pci_dev;
diff --git a/include/sound/cs4231-regs.h b/include/sound/cs4231-regs.h
index f1490265c9b8..e8d1f3e31f9e 100644
--- a/include/sound/cs4231-regs.h
+++ b/include/sound/cs4231-regs.h
@@ -45,7 +45,7 @@
45#define CS4231_IFACE_CTRL 0x09 /* interface control - bits 7-2 MCE */ 45#define CS4231_IFACE_CTRL 0x09 /* interface control - bits 7-2 MCE */
46#define CS4231_PIN_CTRL 0x0a /* pin control */ 46#define CS4231_PIN_CTRL 0x0a /* pin control */
47#define CS4231_TEST_INIT 0x0b /* test and initialization */ 47#define CS4231_TEST_INIT 0x0b /* test and initialization */
48#define CS4231_MISC_INFO 0x0c /* miscellaneaous information */ 48#define CS4231_MISC_INFO 0x0c /* miscellaneous information */
49#define CS4231_LOOPBACK 0x0d /* loopback control */ 49#define CS4231_LOOPBACK 0x0d /* loopback control */
50#define CS4231_PLY_UPR_CNT 0x0e /* playback upper base count */ 50#define CS4231_PLY_UPR_CNT 0x0e /* playback upper base count */
51#define CS4231_PLY_LWR_CNT 0x0f /* playback lower base count */ 51#define CS4231_PLY_LWR_CNT 0x0f /* playback lower base count */
diff --git a/include/sound/cs46xx.h b/include/sound/cs46xx.h
index 6b40ee60f4c5..e3005a674a24 100644
--- a/include/sound/cs46xx.h
+++ b/include/sound/cs46xx.h
@@ -1708,9 +1708,6 @@ struct snd_cs46xx {
1708 1708
1709 struct gameport *gameport; 1709 struct gameport *gameport;
1710 1710
1711#ifdef CONFIG_SND_CS46XX_DEBUG_GPIO
1712 int current_gpio;
1713#endif
1714#ifdef CONFIG_SND_CS46XX_NEW_DSP 1711#ifdef CONFIG_SND_CS46XX_NEW_DSP
1715 struct mutex spos_mutex; 1712 struct mutex spos_mutex;
1716 1713
diff --git a/include/sound/driver.h b/include/sound/driver.h
index 5ccb6c5feecb..f0359437d01a 100644
--- a/include/sound/driver.h
+++ b/include/sound/driver.h
@@ -1,51 +1 @@
1#ifndef __SOUND_DRIVER_H #warning "This file is deprecated"
2#define __SOUND_DRIVER_H
3
4/*
5 * Main header file for the ALSA driver
6 * Copyright (c) 1994-2000 by Jaroslav Kysela <perex@perex.cz>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifdef ALSA_BUILD
26#include "config.h"
27#endif
28
29
30/* number of supported soundcards */
31#ifdef CONFIG_SND_DYNAMIC_MINORS
32#define SNDRV_CARDS 32
33#else
34#define SNDRV_CARDS 8 /* don't change - minor numbers */
35#endif
36
37#ifndef CONFIG_SND_MAJOR /* standard configuration */
38#define CONFIG_SND_MAJOR 116
39#endif
40
41#ifndef CONFIG_SND_DEBUG
42#undef CONFIG_SND_DEBUG_MEMORY
43#endif
44
45#ifdef ALSA_BUILD
46#include "adriver.h"
47#endif
48
49#include <linux/module.h>
50
51#endif /* __SOUND_DRIVER_H */
diff --git a/include/sound/emu10k1.h b/include/sound/emu10k1.h
index 441aa06dcd6f..7b7b9b13b4dd 100644
--- a/include/sound/emu10k1.h
+++ b/include/sound/emu10k1.h
@@ -1120,6 +1120,99 @@
1120/************************************************************************************************/ 1120/************************************************************************************************/
1121/* EMU1010m HANA Destinations */ 1121/* EMU1010m HANA Destinations */
1122/************************************************************************************************/ 1122/************************************************************************************************/
1123/* Hana, original 1010,1212,1820 using Alice2
1124 * Destiniations for SRATEX = 1X rates: 44.1 kHz or 48 kHz
1125 * 0x00, 0x00-0x0f: 16 EMU32 channels to Alice2
1126 * 0x01, 0x10-0x1f: 32 Elink channels to Audio Dock
1127 * 0x01, 0x00: Dock DAC 1 Left
1128 * 0x01, 0x04: Dock DAC 1 Right
1129 * 0x01, 0x08: Dock DAC 2 Left
1130 * 0x01, 0x0c: Dock DAC 2 Right
1131 * 0x01, 0x10: Dock DAC 3 Left
1132 * 0x01, 0x12: PHONES Left
1133 * 0x01, 0x14: Dock DAC 3 Right
1134 * 0x01, 0x16: PHONES Right
1135 * 0x01, 0x18: Dock DAC 4 Left
1136 * 0x01, 0x1a: S/PDIF Left
1137 * 0x01, 0x1c: Dock DAC 4 Right
1138 * 0x01, 0x1e: S/PDIF Right
1139 * 0x02, 0x00: Hana S/PDIF Left
1140 * 0x02, 0x01: Hana S/PDIF Right
1141 * 0x03, 0x00: Hanoa DAC Left
1142 * 0x03, 0x01: Hanoa DAC Right
1143 * 0x04, 0x00-0x07: Hana ADAT
1144 * 0x05, 0x00: I2S0 Left to Alice2
1145 * 0x05, 0x01: I2S0 Right to Alice2
1146 * 0x06, 0x00: I2S0 Left to Alice2
1147 * 0x06, 0x01: I2S0 Right to Alice2
1148 * 0x07, 0x00: I2S0 Left to Alice2
1149 * 0x07, 0x01: I2S0 Right to Alice2
1150 *
1151 * Hana2 never released, but used Tina
1152 * Not needed.
1153 *
1154 * Hana3, rev2 1010,1212,1616 using Tina
1155 * Destinations for SRATEX = 1X rates: 44.1 kHz or 48 kHz
1156 * 0x00, 0x00-0x0f: 16 EMU32A channels to Tina
1157 * 0x01, 0x10-0x1f: 32 EDI channels to Micro Dock
1158 * 0x01, 0x00: Dock DAC 1 Left
1159 * 0x01, 0x04: Dock DAC 1 Right
1160 * 0x01, 0x08: Dock DAC 2 Left
1161 * 0x01, 0x0c: Dock DAC 2 Right
1162 * 0x01, 0x10: Dock DAC 3 Left
1163 * 0x01, 0x12: Dock S/PDIF Left
1164 * 0x01, 0x14: Dock DAC 3 Right
1165 * 0x01, 0x16: Dock S/PDIF Right
1166 * 0x01, 0x18-0x1f: Dock ADAT 0-7
1167 * 0x02, 0x00: Hana3 S/PDIF Left
1168 * 0x02, 0x01: Hana3 S/PDIF Right
1169 * 0x03, 0x00: Hanoa DAC Left
1170 * 0x03, 0x01: Hanoa DAC Right
1171 * 0x04, 0x00-0x07: Hana3 ADAT 0-7
1172 * 0x05, 0x00-0x0f: 16 EMU32B channels to Tina
1173 * 0x06-0x07: Not used
1174 *
1175 * HanaLite, rev1 0404 using Alice2
1176 * Destiniations for SRATEX = 1X rates: 44.1 kHz or 48 kHz
1177 * 0x00, 0x00-0x0f: 16 EMU32 channels to Alice2
1178 * 0x01: Not used
1179 * 0x02, 0x00: S/PDIF Left
1180 * 0x02, 0x01: S/PDIF Right
1181 * 0x03, 0x00: DAC Left
1182 * 0x03, 0x01: DAC Right
1183 * 0x04-0x07: Not used
1184 *
1185 * HanaLiteLite, rev2 0404 using Alice2
1186 * Destiniations for SRATEX = 1X rates: 44.1 kHz or 48 kHz
1187 * 0x00, 0x00-0x0f: 16 EMU32 channels to Alice2
1188 * 0x01: Not used
1189 * 0x02, 0x00: S/PDIF Left
1190 * 0x02, 0x01: S/PDIF Right
1191 * 0x03, 0x00: DAC Left
1192 * 0x03, 0x01: DAC Right
1193 * 0x04-0x07: Not used
1194 *
1195 * Mana, Cardbus 1616 using Tina2
1196 * Destinations for SRATEX = 1X rates: 44.1 kHz or 48 kHz
1197 * 0x00, 0x00-0x0f: 16 EMU32A channels to Tina2
1198 * 0x01, 0x10-0x1f: 32 EDI channels to Micro Dock
1199 * 0x01, 0x00: Dock DAC 1 Left
1200 * 0x01, 0x04: Dock DAC 1 Right
1201 * 0x01, 0x08: Dock DAC 2 Left
1202 * 0x01, 0x0c: Dock DAC 2 Right
1203 * 0x01, 0x10: Dock DAC 3 Left
1204 * 0x01, 0x12: Dock S/PDIF Left
1205 * 0x01, 0x14: Dock DAC 3 Right
1206 * 0x01, 0x16: Dock S/PDIF Right
1207 * 0x01, 0x18-0x1f: Dock ADAT 0-7
1208 * 0x02: Not used
1209 * 0x03, 0x00: Mana DAC Left
1210 * 0x03, 0x01: Mana DAC Right
1211 * 0x04, 0x00-0x0f: 16 EMU32B channels to Tina2
1212 * 0x05-0x07: Not used
1213 *
1214 *
1215 */
1123/* 32-bit destinations of signal in the Hana FPGA. Destinations are either 1216/* 32-bit destinations of signal in the Hana FPGA. Destinations are either
1124 * physical outputs of Hana, or outputs going to Alice2 (audigy) for capture 1217 * physical outputs of Hana, or outputs going to Alice2 (audigy) for capture
1125 * - 16 x EMU_DST_ALICE2_EMU32_X. 1218 * - 16 x EMU_DST_ALICE2_EMU32_X.
@@ -1206,9 +1299,122 @@
1206#define EMU_DST_ALICE_I2S2_LEFT 0x0700 /* Alice2 I2S2 Left */ 1299#define EMU_DST_ALICE_I2S2_LEFT 0x0700 /* Alice2 I2S2 Left */
1207#define EMU_DST_ALICE_I2S2_RIGHT 0x0701 /* Alice2 I2S2 Right */ 1300#define EMU_DST_ALICE_I2S2_RIGHT 0x0701 /* Alice2 I2S2 Right */
1208 1301
1302/* Additional destinations for 1616(M)/Microdock */
1303/* Microdock S/PDIF OUT Left, 1st or 48kHz only */
1304#define EMU_DST_MDOCK_SPDIF_LEFT1 0x0112
1305/* Microdock S/PDIF OUT Left, 2nd or 96kHz */
1306#define EMU_DST_MDOCK_SPDIF_LEFT2 0x0113
1307/* Microdock S/PDIF OUT Right, 1st or 48kHz only */
1308#define EMU_DST_MDOCK_SPDIF_RIGHT1 0x0116
1309/* Microdock S/PDIF OUT Right, 2nd or 96kHz */
1310#define EMU_DST_MDOCK_SPDIF_RIGHT2 0x0117
1311/* Microdock S/PDIF ADAT 8 channel out +8 to +f */
1312#define EMU_DST_MDOCK_ADAT 0x0118
1313
1314/* Headphone jack on 1010 cardbus? 44.1/48kHz only? */
1315#define EMU_DST_MANA_DAC_LEFT 0x0300
1316/* Headphone jack on 1010 cardbus? 44.1/48kHz only? */
1317#define EMU_DST_MANA_DAC_RIGHT 0x0301
1318
1209/************************************************************************************************/ 1319/************************************************************************************************/
1210/* EMU1010m HANA Sources */ 1320/* EMU1010m HANA Sources */
1211/************************************************************************************************/ 1321/************************************************************************************************/
1322/* Hana, original 1010,1212,1820 using Alice2
1323 * Sources SRATEX = 1X rates: 44.1 kHz or 48 kHz
1324 * 0x00,0x00-0x1f: Silence
1325 * 0x01, 0x10-0x1f: 32 Elink channels from Audio Dock
1326 * 0x01, 0x00: Dock Mic A
1327 * 0x01, 0x04: Dock Mic B
1328 * 0x01, 0x08: Dock ADC 1 Left
1329 * 0x01, 0x0c: Dock ADC 1 Right
1330 * 0x01, 0x10: Dock ADC 2 Left
1331 * 0x01, 0x14: Dock ADC 2 Right
1332 * 0x01, 0x18: Dock ADC 3 Left
1333 * 0x01, 0x1c: Dock ADC 3 Right
1334 * 0x02, 0x00: Hana ADC Left
1335 * 0x02, 0x01: Hana ADC Right
1336 * 0x03, 0x00-0x0f: 16 inputs from Alice2 Emu32A output
1337 * 0x03, 0x10-0x1f: 16 inputs from Alice2 Emu32B output
1338 * 0x04, 0x00-0x07: Hana ADAT
1339 * 0x05, 0x00: Hana S/PDIF Left
1340 * 0x05, 0x01: Hana S/PDIF Right
1341 * 0x06-0x07: Not used
1342 *
1343 * Hana2 never released, but used Tina
1344 * Not needed.
1345 *
1346 * Hana3, rev2 1010,1212,1616 using Tina
1347 * Sources SRATEX = 1X rates: 44.1 kHz or 48 kHz
1348 * 0x00,0x00-0x1f: Silence
1349 * 0x01, 0x10-0x1f: 32 Elink channels from Audio Dock
1350 * 0x01, 0x00: Dock Mic A
1351 * 0x01, 0x04: Dock Mic B
1352 * 0x01, 0x08: Dock ADC 1 Left
1353 * 0x01, 0x0c: Dock ADC 1 Right
1354 * 0x01, 0x10: Dock ADC 2 Left
1355 * 0x01, 0x12: Dock S/PDIF Left
1356 * 0x01, 0x14: Dock ADC 2 Right
1357 * 0x01, 0x16: Dock S/PDIF Right
1358 * 0x01, 0x18-0x1f: Dock ADAT 0-7
1359 * 0x01, 0x18: Dock ADC 3 Left
1360 * 0x01, 0x1c: Dock ADC 3 Right
1361 * 0x02, 0x00: Hanoa ADC Left
1362 * 0x02, 0x01: Hanoa ADC Right
1363 * 0x03, 0x00-0x0f: 16 inputs from Tina Emu32A output
1364 * 0x03, 0x10-0x1f: 16 inputs from Tina Emu32B output
1365 * 0x04, 0x00-0x07: Hana3 ADAT
1366 * 0x05, 0x00: Hana3 S/PDIF Left
1367 * 0x05, 0x01: Hana3 S/PDIF Right
1368 * 0x06-0x07: Not used
1369 *
1370 * HanaLite, rev1 0404 using Alice2
1371 * Sources SRATEX = 1X rates: 44.1 kHz or 48 kHz
1372 * 0x00,0x00-0x1f: Silence
1373 * 0x01: Not used
1374 * 0x02, 0x00: ADC Left
1375 * 0x02, 0x01: ADC Right
1376 * 0x03, 0x00-0x0f: 16 inputs from Alice2 Emu32A output
1377 * 0x03, 0x10-0x1f: 16 inputs from Alice2 Emu32B output
1378 * 0x04: Not used
1379 * 0x05, 0x00: S/PDIF Left
1380 * 0x05, 0x01: S/PDIF Right
1381 * 0x06-0x07: Not used
1382 *
1383 * HanaLiteLite, rev2 0404 using Alice2
1384 * Sources SRATEX = 1X rates: 44.1 kHz or 48 kHz
1385 * 0x00,0x00-0x1f: Silence
1386 * 0x01: Not used
1387 * 0x02, 0x00: ADC Left
1388 * 0x02, 0x01: ADC Right
1389 * 0x03, 0x00-0x0f: 16 inputs from Alice2 Emu32A output
1390 * 0x03, 0x10-0x1f: 16 inputs from Alice2 Emu32B output
1391 * 0x04: Not used
1392 * 0x05, 0x00: S/PDIF Left
1393 * 0x05, 0x01: S/PDIF Right
1394 * 0x06-0x07: Not used
1395 *
1396 * Mana, Cardbus 1616 using Tina2
1397 * Sources SRATEX = 1X rates: 44.1 kHz or 48 kHz
1398 * 0x00,0x00-0x1f: Silence
1399 * 0x01, 0x10-0x1f: 32 Elink channels from Audio Dock
1400 * 0x01, 0x00: Dock Mic A
1401 * 0x01, 0x04: Dock Mic B
1402 * 0x01, 0x08: Dock ADC 1 Left
1403 * 0x01, 0x0c: Dock ADC 1 Right
1404 * 0x01, 0x10: Dock ADC 2 Left
1405 * 0x01, 0x12: Dock S/PDIF Left
1406 * 0x01, 0x14: Dock ADC 2 Right
1407 * 0x01, 0x16: Dock S/PDIF Right
1408 * 0x01, 0x18-0x1f: Dock ADAT 0-7
1409 * 0x01, 0x18: Dock ADC 3 Left
1410 * 0x01, 0x1c: Dock ADC 3 Right
1411 * 0x02: Not used
1412 * 0x03, 0x00-0x0f: 16 inputs from Tina Emu32A output
1413 * 0x03, 0x10-0x1f: 16 inputs from Tina Emu32B output
1414 * 0x04-0x07: Not used
1415 *
1416 */
1417
1212/* 32-bit sources of signal in the Hana FPGA. The sources are routed to 1418/* 32-bit sources of signal in the Hana FPGA. The sources are routed to
1213 * destinations using mixer control for each destination - see emumixer.c 1419 * destinations using mixer control for each destination - see emumixer.c
1214 * Sources are either physical inputs of FPGA, 1420 * Sources are either physical inputs of FPGA,
@@ -1263,6 +1469,19 @@
1263#define EMU_SRC_HANA_SPDIF_LEFT2 0x0502 /* Hana SPDIF Left, 2nd or 96kHz */ 1469#define EMU_SRC_HANA_SPDIF_LEFT2 0x0502 /* Hana SPDIF Left, 2nd or 96kHz */
1264#define EMU_SRC_HANA_SPDIF_RIGHT1 0x0501 /* Hana SPDIF Right, 1st or 48kHz only */ 1470#define EMU_SRC_HANA_SPDIF_RIGHT1 0x0501 /* Hana SPDIF Right, 1st or 48kHz only */
1265#define EMU_SRC_HANA_SPDIF_RIGHT2 0x0503 /* Hana SPDIF Right, 2nd or 96kHz */ 1471#define EMU_SRC_HANA_SPDIF_RIGHT2 0x0503 /* Hana SPDIF Right, 2nd or 96kHz */
1472
1473/* Additional inputs for 1616(M)/Microdock */
1474/* Microdock S/PDIF Left, 1st or 48kHz only */
1475#define EMU_SRC_MDOCK_SPDIF_LEFT1 0x0112
1476/* Microdock S/PDIF Left, 2nd or 96kHz */
1477#define EMU_SRC_MDOCK_SPDIF_LEFT2 0x0113
1478/* Microdock S/PDIF Right, 1st or 48kHz only */
1479#define EMU_SRC_MDOCK_SPDIF_RIGHT1 0x0116
1480/* Microdock S/PDIF Right, 2nd or 96kHz */
1481#define EMU_SRC_MDOCK_SPDIF_RIGHT2 0x0117
1482/* Microdock ADAT 8 channel in +8 to +f */
1483#define EMU_SRC_MDOCK_ADAT 0x0118
1484
1266/* 0x600 and 0x700 no used */ 1485/* 0x600 and 0x700 no used */
1267 1486
1268/* ------------------- STRUCTURES -------------------- */ 1487/* ------------------- STRUCTURES -------------------- */
@@ -1423,6 +1642,14 @@ struct snd_emu10k1_midi {
1423 void (*interrupt)(struct snd_emu10k1 *emu, unsigned int status); 1642 void (*interrupt)(struct snd_emu10k1 *emu, unsigned int status);
1424}; 1643};
1425 1644
1645enum {
1646 EMU_MODEL_SB,
1647 EMU_MODEL_EMU1010,
1648 EMU_MODEL_EMU1010B,
1649 EMU_MODEL_EMU1616,
1650 EMU_MODEL_EMU0404,
1651};
1652
1426struct snd_emu_chip_details { 1653struct snd_emu_chip_details {
1427 u32 vendor; 1654 u32 vendor;
1428 u32 device; 1655 u32 device;
@@ -1439,7 +1666,7 @@ struct snd_emu_chip_details {
1439 unsigned char spdif_bug; /* Has Spdif phasing bug */ 1666 unsigned char spdif_bug; /* Has Spdif phasing bug */
1440 unsigned char ac97_chip; /* Has an AC97 chip: 1 = mandatory, 2 = optional */ 1667 unsigned char ac97_chip; /* Has an AC97 chip: 1 = mandatory, 2 = optional */
1441 unsigned char ecard; /* APS EEPROM */ 1668 unsigned char ecard; /* APS EEPROM */
1442 unsigned char emu1010; /* EMU 1010m card */ 1669 unsigned char emu_model; /* EMU model type */
1443 unsigned char spi_dac; /* SPI interface for DAC */ 1670 unsigned char spi_dac; /* SPI interface for DAC */
1444 unsigned char i2c_adc; /* I2C interface for ADC */ 1671 unsigned char i2c_adc; /* I2C interface for ADC */
1445 unsigned char adc_1361t; /* Use Philips 1361T ADC */ 1672 unsigned char adc_1361t; /* Use Philips 1361T ADC */
@@ -1515,6 +1742,8 @@ struct snd_emu10k1 {
1515 spinlock_t reg_lock; 1742 spinlock_t reg_lock;
1516 spinlock_t emu_lock; 1743 spinlock_t emu_lock;
1517 spinlock_t voice_lock; 1744 spinlock_t voice_lock;
1745 spinlock_t spi_lock; /* serialises access to spi port */
1746 spinlock_t i2c_lock; /* serialises access to i2c port */
1518 1747
1519 struct snd_emu10k1_voice voices[NUM_G]; 1748 struct snd_emu10k1_voice voices[NUM_G];
1520 struct snd_emu10k1_voice p16v_voices[4]; 1749 struct snd_emu10k1_voice p16v_voices[4];
diff --git a/include/sound/gus.h b/include/sound/gus.h
index e5433d8b78bc..841bb8df38c1 100644
--- a/include/sound/gus.h
+++ b/include/sound/gus.h
@@ -27,13 +27,8 @@
27#include "timer.h" 27#include "timer.h"
28#include "seq_midi_emul.h" 28#include "seq_midi_emul.h"
29#include "seq_device.h" 29#include "seq_device.h"
30#include "ainstr_iw.h"
31#include "ainstr_gf1.h"
32#include "ainstr_simple.h"
33#include <asm/io.h> 30#include <asm/io.h>
34 31
35#define SNDRV_SEQ_DEV_ID_GUS "gus-synth"
36
37/* IO ports */ 32/* IO ports */
38 33
39#define GUSP(gus, x) ((gus)->gf1.port + SNDRV_g_u_s_##x) 34#define GUSP(gus, x) ((gus)->gf1.port + SNDRV_g_u_s_##x)
@@ -234,16 +229,6 @@ struct snd_gus_port {
234 229
235struct snd_gus_voice; 230struct snd_gus_voice;
236 231
237struct snd_gus_sample_ops {
238 void (*sample_start)(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_position_t position);
239 void (*sample_stop)(struct snd_gus_card *gus, struct snd_gus_voice *voice, int mode);
240 void (*sample_freq)(struct snd_gus_card *gus, struct snd_gus_voice *voice, snd_seq_frequency_t freq);
241 void (*sample_volume)(struct snd_gus_card *gus, struct snd_gus_voice *voice, struct snd_seq_ev_volume *volume);
242 void (*sample_loop)(struct snd_gus_card *card, struct snd_gus_voice *voice, struct snd_seq_ev_loop *loop);
243 void (*sample_pos)(struct snd_gus_card *card, struct snd_gus_voice *voice, snd_seq_position_t position);
244 void (*sample_private1)(struct snd_gus_card *card, struct snd_gus_voice *voice, unsigned char *data);
245};
246
247#define SNDRV_GF1_VOICE_TYPE_PCM 0 232#define SNDRV_GF1_VOICE_TYPE_PCM 0
248#define SNDRV_GF1_VOICE_TYPE_SYNTH 1 233#define SNDRV_GF1_VOICE_TYPE_SYNTH 1
249#define SNDRV_GF1_VOICE_TYPE_MIDI 2 234#define SNDRV_GF1_VOICE_TYPE_MIDI 2
@@ -284,12 +269,8 @@ struct snd_gus_voice {
284 269
285 struct snd_gus_sample_ops *sample_ops; 270 struct snd_gus_sample_ops *sample_ops;
286 271
287 struct snd_seq_instr instr;
288
289 /* running status / registers */ 272 /* running status / registers */
290 273
291 struct snd_seq_ev_volume sample_volume;
292
293 unsigned short fc_register; 274 unsigned short fc_register;
294 unsigned short fc_lfo; 275 unsigned short fc_lfo;
295 unsigned short gf1_volume; 276 unsigned short gf1_volume;
@@ -382,10 +363,6 @@ struct snd_gf1 {
382 363
383 int seq_client; 364 int seq_client;
384 struct snd_gus_port seq_ports[4]; 365 struct snd_gus_port seq_ports[4];
385 struct snd_seq_kinstr_list *ilist;
386 struct snd_iwffff_ops iwffff_ops;
387 struct snd_gf1_ops gf1_ops;
388 struct snd_simple_ops simple_ops;
389 366
390 /* timer */ 367 /* timer */
391 368
@@ -458,8 +435,6 @@ struct snd_gus_card {
458 struct snd_rawmidi_substream *midi_substream_output; 435 struct snd_rawmidi_substream *midi_substream_output;
459 struct snd_rawmidi_substream *midi_substream_input; 436 struct snd_rawmidi_substream *midi_substream_input;
460 437
461 struct snd_seq_device *seq_dev;
462
463 spinlock_t reg_lock; 438 spinlock_t reg_lock;
464 spinlock_t voice_alloc; 439 spinlock_t voice_alloc;
465 spinlock_t active_voice_lock; 440 spinlock_t active_voice_lock;
@@ -647,48 +622,10 @@ void snd_gus_irq_profile_init(struct snd_gus_card *gus);
647 622
648int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi **rrawmidi); 623int snd_gf1_rawmidi_new(struct snd_gus_card * gus, int device, struct snd_rawmidi **rrawmidi);
649 624
650#if 0
651extern void snd_engine_instrument_register(unsigned short mode,
652 struct _SND_INSTRUMENT_VOICE_COMMANDS *voice_cmds,
653 struct _SND_INSTRUMENT_NOTE_COMMANDS *note_cmds,
654 struct _SND_INSTRUMENT_CHANNEL_COMMANDS *channel_cmds);
655extern int snd_engine_instrument_register_ask(unsigned short mode);
656#endif
657
658/* gus_dram.c */ 625/* gus_dram.c */
659int snd_gus_dram_write(struct snd_gus_card *gus, char __user *ptr, 626int snd_gus_dram_write(struct snd_gus_card *gus, char __user *ptr,
660 unsigned int addr, unsigned int size); 627 unsigned int addr, unsigned int size);
661int snd_gus_dram_read(struct snd_gus_card *gus, char __user *ptr, 628int snd_gus_dram_read(struct snd_gus_card *gus, char __user *ptr,
662 unsigned int addr, unsigned int size, int rom); 629 unsigned int addr, unsigned int size, int rom);
663 630
664#if defined(CONFIG_SND_SEQUENCER) || defined(CONFIG_SND_SEQUENCER_MODULE)
665
666/* gus_sample.c */
667void snd_gus_sample_event(struct snd_seq_event *ev, struct snd_gus_port *p);
668
669/* gus_simple.c */
670void snd_gf1_simple_init(struct snd_gus_voice *voice);
671
672/* gus_instr.c */
673int snd_gus_iwffff_put_sample(void *private_data, struct iwffff_wave *wave,
674 char __user *data, long len, int atomic);
675int snd_gus_iwffff_get_sample(void *private_data, struct iwffff_wave *wave,
676 char __user *data, long len, int atomic);
677int snd_gus_iwffff_remove_sample(void *private_data, struct iwffff_wave *wave,
678 int atomic);
679int snd_gus_gf1_put_sample(void *private_data, struct gf1_wave *wave,
680 char __user *data, long len, int atomic);
681int snd_gus_gf1_get_sample(void *private_data, struct gf1_wave *wave,
682 char __user *data, long len, int atomic);
683int snd_gus_gf1_remove_sample(void *private_data, struct gf1_wave *wave,
684 int atomic);
685int snd_gus_simple_put_sample(void *private_data, struct simple_instrument *instr,
686 char __user *data, long len, int atomic);
687int snd_gus_simple_get_sample(void *private_data, struct simple_instrument *instr,
688 char __user *data, long len, int atomic);
689int snd_gus_simple_remove_sample(void *private_data, struct simple_instrument *instr,
690 int atomic);
691
692#endif /* CONFIG_SND_SEQUENCER */
693
694#endif /* __SOUND_GUS_H */ 631#endif /* __SOUND_GUS_H */
diff --git a/include/sound/info.h b/include/sound/info.h
index fecbb1ffd540..8ae72e74f898 100644
--- a/include/sound/info.h
+++ b/include/sound/info.h
@@ -100,8 +100,10 @@ int snd_info_minor_unregister(void);
100extern struct snd_info_entry *snd_seq_root; 100extern struct snd_info_entry *snd_seq_root;
101#ifdef CONFIG_SND_OSSEMUL 101#ifdef CONFIG_SND_OSSEMUL
102extern struct snd_info_entry *snd_oss_root; 102extern struct snd_info_entry *snd_oss_root;
103void snd_card_info_read_oss(struct snd_info_buffer *buffer);
103#else 104#else
104#define snd_oss_root NULL 105#define snd_oss_root NULL
106static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {}
105#endif 107#endif
106 108
107int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3))); 109int snd_iprintf(struct snd_info_buffer * buffer, char *fmt,...) __attribute__ ((format (printf, 2, 3)));
diff --git a/include/sound/opl3.h b/include/sound/opl3.h
index 1d14b3f82393..a0c5febdc4ea 100644
--- a/include/sound/opl3.h
+++ b/include/sound/opl3.h
@@ -51,19 +51,16 @@
51 * 51 *
52 */ 52 */
53 53
54#include "driver.h" 54#include <sound/core.h>
55#include <linux/time.h> 55#include <sound/hwdep.h>
56#include <linux/mutex.h> 56#include <sound/timer.h>
57#include "core.h" 57#include <sound/seq_midi_emul.h>
58#include "hwdep.h"
59#include "timer.h"
60#include "seq_midi_emul.h"
61#ifdef CONFIG_SND_SEQUENCER_OSS 58#ifdef CONFIG_SND_SEQUENCER_OSS
62#include "seq_oss.h" 59#include <sound/seq_oss.h>
63#include "seq_oss_legacy.h" 60#include <sound/seq_oss_legacy.h>
64#endif 61#endif
65#include "seq_device.h" 62#include <sound/seq_device.h>
66#include "ainstr_fm.h" 63#include <sound/asound_fm.h>
67 64
68/* 65/*
69 * Register numbers for the global registers 66 * Register numbers for the global registers
@@ -240,6 +237,47 @@
240struct snd_opl3; 237struct snd_opl3;
241 238
242/* 239/*
240 * Instrument record, aka "Patch"
241 */
242
243/* FM operator */
244struct fm_operator {
245 unsigned char am_vib;
246 unsigned char ksl_level;
247 unsigned char attack_decay;
248 unsigned char sustain_release;
249 unsigned char wave_select;
250} __attribute__((packed));
251
252/* Instrument data */
253struct fm_instrument {
254 struct fm_operator op[4];
255 unsigned char feedback_connection[2];
256 unsigned char echo_delay;
257 unsigned char echo_atten;
258 unsigned char chorus_spread;
259 unsigned char trnsps;
260 unsigned char fix_dur;
261 unsigned char modes;
262 unsigned char fix_key;
263};
264
265/* type */
266#define FM_PATCH_OPL2 0x01 /* OPL2 2 operators FM instrument */
267#define FM_PATCH_OPL3 0x02 /* OPL3 4 operators FM instrument */
268
269/* Instrument record */
270struct fm_patch {
271 unsigned char prog;
272 unsigned char bank;
273 unsigned char type;
274 struct fm_instrument inst;
275 char name[24];
276 struct fm_patch *next;
277};
278
279
280/*
243 * A structure to keep track of each hardware voice 281 * A structure to keep track of each hardware voice
244 */ 282 */
245struct snd_opl3_voice { 283struct snd_opl3_voice {
@@ -277,9 +315,9 @@ struct snd_opl3 {
277 void *private_data; 315 void *private_data;
278 void (*private_free)(struct snd_opl3 *); 316 void (*private_free)(struct snd_opl3 *);
279 317
318 struct snd_hwdep *hwdep;
280 spinlock_t reg_lock; 319 spinlock_t reg_lock;
281 struct snd_card *card; /* The card that this belongs to */ 320 struct snd_card *card; /* The card that this belongs to */
282 int used; /* usage flag - exclusive */
283 unsigned char fm_mode; /* OPL mode, see SNDRV_DM_FM_MODE_XXX */ 321 unsigned char fm_mode; /* OPL mode, see SNDRV_DM_FM_MODE_XXX */
284 unsigned char rhythm; /* percussion mode flag */ 322 unsigned char rhythm; /* percussion mode flag */
285 unsigned char max_voices; /* max number of voices */ 323 unsigned char max_voices; /* max number of voices */
@@ -297,8 +335,8 @@ struct snd_opl3 {
297 struct snd_midi_channel_set * oss_chset; 335 struct snd_midi_channel_set * oss_chset;
298#endif 336#endif
299 337
300 struct snd_seq_kinstr_ops fm_ops; 338#define OPL3_PATCH_HASH_SIZE 32
301 struct snd_seq_kinstr_list *ilist; 339 struct fm_patch *patch_table[OPL3_PATCH_HASH_SIZE];
302 340
303 struct snd_opl3_voice voices[MAX_OPL3_VOICES]; /* Voices (OPL3 'channel') */ 341 struct snd_opl3_voice voices[MAX_OPL3_VOICES]; /* Voices (OPL3 'channel') */
304 int use_time; /* allocation counter */ 342 int use_time; /* allocation counter */
@@ -312,7 +350,6 @@ struct snd_opl3 {
312 int sys_timer_status; /* system timer run status */ 350 int sys_timer_status; /* system timer run status */
313 spinlock_t sys_timer_lock; /* Lock for system timer access */ 351 spinlock_t sys_timer_lock; /* Lock for system timer access */
314#endif 352#endif
315 struct mutex access_mutex; /* locking */
316}; 353};
317 354
318/* opl3.c */ 355/* opl3.c */
@@ -333,8 +370,19 @@ int snd_opl3_hwdep_new(struct snd_opl3 * opl3, int device, int seq_device,
333int snd_opl3_open(struct snd_hwdep * hw, struct file *file); 370int snd_opl3_open(struct snd_hwdep * hw, struct file *file);
334int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file, 371int snd_opl3_ioctl(struct snd_hwdep * hw, struct file *file,
335 unsigned int cmd, unsigned long arg); 372 unsigned int cmd, unsigned long arg);
373long snd_opl3_write(struct snd_hwdep *hw, const char __user *buf, long count,
374 loff_t *offset);
336int snd_opl3_release(struct snd_hwdep * hw, struct file *file); 375int snd_opl3_release(struct snd_hwdep * hw, struct file *file);
337 376
338void snd_opl3_reset(struct snd_opl3 * opl3); 377void snd_opl3_reset(struct snd_opl3 * opl3);
339 378
379int snd_opl3_load_patch(struct snd_opl3 *opl3,
380 int prog, int bank, int type,
381 const char *name,
382 const unsigned char *ext,
383 const unsigned char *data);
384struct fm_patch *snd_opl3_find_patch(struct snd_opl3 *opl3, int prog, int bank,
385 int create_patch);
386void snd_opl3_clear_patches(struct snd_opl3 *opl3);
387
340#endif /* __SOUND_OPL3_H */ 388#endif /* __SOUND_OPL3_H */
diff --git a/include/sound/pcm.h b/include/sound/pcm.h
index 5e9cc460075e..51d58ccda2d8 100644
--- a/include/sound/pcm.h
+++ b/include/sound/pcm.h
@@ -274,7 +274,6 @@ struct snd_pcm_runtime {
274 snd_pcm_uframes_t period_size; /* period size */ 274 snd_pcm_uframes_t period_size; /* period size */
275 unsigned int periods; /* periods */ 275 unsigned int periods; /* periods */
276 snd_pcm_uframes_t buffer_size; /* buffer size */ 276 snd_pcm_uframes_t buffer_size; /* buffer size */
277 unsigned int tick_time; /* tick time */
278 snd_pcm_uframes_t min_align; /* Min alignment for the format */ 277 snd_pcm_uframes_t min_align; /* Min alignment for the format */
279 size_t byte_align; 278 size_t byte_align;
280 unsigned int frame_bits; 279 unsigned int frame_bits;
@@ -286,8 +285,6 @@ struct snd_pcm_runtime {
286 /* -- SW params -- */ 285 /* -- SW params -- */
287 int tstamp_mode; /* mmap timestamp is updated */ 286 int tstamp_mode; /* mmap timestamp is updated */
288 unsigned int period_step; 287 unsigned int period_step;
289 unsigned int sleep_min; /* min ticks to sleep */
290 snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */
291 snd_pcm_uframes_t start_threshold; 288 snd_pcm_uframes_t start_threshold;
292 snd_pcm_uframes_t stop_threshold; 289 snd_pcm_uframes_t stop_threshold;
293 snd_pcm_uframes_t silence_threshold; /* Silence filling happens when 290 snd_pcm_uframes_t silence_threshold; /* Silence filling happens when
@@ -306,7 +303,6 @@ struct snd_pcm_runtime {
306 303
307 /* -- locking / scheduling -- */ 304 /* -- locking / scheduling -- */
308 wait_queue_head_t sleep; 305 wait_queue_head_t sleep;
309 struct timer_list tick_timer;
310 struct fasync_struct *fasync; 306 struct fasync_struct *fasync;
311 307
312 /* -- private section -- */ 308 /* -- private section -- */
@@ -323,6 +319,7 @@ struct snd_pcm_runtime {
323 319
324 /* -- timer -- */ 320 /* -- timer -- */
325 unsigned int timer_resolution; /* timer resolution */ 321 unsigned int timer_resolution; /* timer resolution */
322 int tstamp_type; /* timestamp type */
326 323
327 /* -- DMA -- */ 324 /* -- DMA -- */
328 unsigned char *dma_area; /* DMA area */ 325 unsigned char *dma_area; /* DMA area */
@@ -810,7 +807,6 @@ static inline const struct snd_interval *hw_param_interval_c(const struct snd_pc
810#define params_periods(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIODS)->min 807#define params_periods(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_PERIODS)->min
811#define params_buffer_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min 808#define params_buffer_size(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_SIZE)->min
812#define params_buffer_bytes(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min 809#define params_buffer_bytes(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_BUFFER_BYTES)->min
813#define params_tick_time(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_TICK_TIME)->min
814 810
815 811
816int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v); 812int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v);
@@ -908,9 +904,6 @@ int snd_pcm_capture_xrun_check(struct snd_pcm_substream *substream);
908int snd_pcm_playback_xrun_asap(struct snd_pcm_substream *substream); 904int snd_pcm_playback_xrun_asap(struct snd_pcm_substream *substream);
909int snd_pcm_capture_xrun_asap(struct snd_pcm_substream *substream); 905int snd_pcm_capture_xrun_asap(struct snd_pcm_substream *substream);
910void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr); 906void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr);
911void snd_pcm_tick_prepare(struct snd_pcm_substream *substream);
912void snd_pcm_tick_set(struct snd_pcm_substream *substream, unsigned long ticks);
913void snd_pcm_tick_elapsed(struct snd_pcm_substream *substream);
914void snd_pcm_period_elapsed(struct snd_pcm_substream *substream); 907void snd_pcm_period_elapsed(struct snd_pcm_substream *substream);
915snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, 908snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream,
916 const void __user *buf, 909 const void __user *buf,
@@ -952,6 +945,15 @@ void snd_pcm_timer_resolution_change(struct snd_pcm_substream *substream);
952void snd_pcm_timer_init(struct snd_pcm_substream *substream); 945void snd_pcm_timer_init(struct snd_pcm_substream *substream);
953void snd_pcm_timer_done(struct snd_pcm_substream *substream); 946void snd_pcm_timer_done(struct snd_pcm_substream *substream);
954 947
948static inline void snd_pcm_gettime(struct snd_pcm_runtime *runtime,
949 struct timespec *tv)
950{
951 if (runtime->tstamp_type == SNDRV_PCM_TSTAMP_TYPE_MONOTONIC)
952 do_posix_clock_monotonic_gettime(tv);
953 else
954 getnstimeofday(tv);
955}
956
955/* 957/*
956 * Memory 958 * Memory
957 */ 959 */
diff --git a/include/sound/seq_instr.h b/include/sound/seq_instr.h
deleted file mode 100644
index 93b0c51df5b0..000000000000
--- a/include/sound/seq_instr.h
+++ /dev/null
@@ -1,110 +0,0 @@
1#ifndef __SOUND_SEQ_INSTR_H
2#define __SOUND_SEQ_INSTR_H
3
4/*
5 * Main kernel header file for the ALSA sequencer
6 * Copyright (c) 1999 by Jaroslav Kysela <perex@perex.cz>
7 *
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24#include "seq_kernel.h"
25
26/* Instrument cluster */
27struct snd_seq_kcluster {
28 snd_seq_instr_cluster_t cluster;
29 char name[32];
30 int priority;
31 struct snd_seq_kcluster *next;
32};
33
34/* return pointer to private data */
35#define KINSTR_DATA(kinstr) (void *)(((char *)kinstr) + sizeof(struct snd_seq_kinstr))
36
37/* Instrument structure */
38struct snd_seq_kinstr {
39 struct snd_seq_instr instr;
40 char name[32];
41 int type; /* instrument type */
42 int use; /* use count */
43 int busy; /* not useable */
44 int add_len; /* additional length */
45 struct snd_seq_kinstr_ops *ops; /* operations */
46 struct snd_seq_kinstr *next;
47};
48
49#define SNDRV_SEQ_INSTR_HASH_SIZE 32
50
51/* Instrument flags */
52#define SNDRV_SEQ_INSTR_FLG_DIRECT (1<<0) /* accept only direct events */
53
54/* List of all instruments */
55struct snd_seq_kinstr_list {
56 struct snd_seq_kinstr *hash[SNDRV_SEQ_INSTR_HASH_SIZE];
57 int count; /* count of all instruments */
58
59 struct snd_seq_kcluster *chash[SNDRV_SEQ_INSTR_HASH_SIZE];
60 int ccount; /* count of all clusters */
61
62 int owner; /* current owner of the instrument list */
63 unsigned int flags;
64
65 spinlock_t lock;
66 spinlock_t ops_lock;
67 struct mutex ops_mutex;
68 unsigned long ops_flags;
69};
70
71#define SNDRV_SEQ_INSTR_NOTIFY_REMOVE 0
72#define SNDRV_SEQ_INSTR_NOTIFY_CHANGE 1
73
74struct snd_seq_kinstr_ops {
75 void *private_data;
76 long add_len; /* additional length */
77 char *instr_type;
78 int (*info)(void *private_data, char *info_data, long len);
79 int (*put)(void *private_data, struct snd_seq_kinstr *kinstr,
80 char __user *instr_data, long len, int atomic, int cmd);
81 int (*get)(void *private_data, struct snd_seq_kinstr *kinstr,
82 char __user *instr_data, long len, int atomic, int cmd);
83 int (*get_size)(void *private_data, struct snd_seq_kinstr *kinstr, long *size);
84 int (*remove)(void *private_data, struct snd_seq_kinstr *kinstr, int atomic);
85 void (*notify)(void *private_data, struct snd_seq_kinstr *kinstr, int what);
86 struct snd_seq_kinstr_ops *next;
87};
88
89
90/* instrument operations */
91struct snd_seq_kinstr_list *snd_seq_instr_list_new(void);
92void snd_seq_instr_list_free(struct snd_seq_kinstr_list **list);
93int snd_seq_instr_list_free_cond(struct snd_seq_kinstr_list *list,
94 struct snd_seq_instr_header *ifree,
95 int client,
96 int atomic);
97struct snd_seq_kinstr *snd_seq_instr_find(struct snd_seq_kinstr_list *list,
98 struct snd_seq_instr *instr,
99 int exact,
100 int follow_alias);
101void snd_seq_instr_free_use(struct snd_seq_kinstr_list *list,
102 struct snd_seq_kinstr *instr);
103int snd_seq_instr_event(struct snd_seq_kinstr_ops *ops,
104 struct snd_seq_kinstr_list *list,
105 struct snd_seq_event *ev,
106 int client,
107 int atomic,
108 int hop);
109
110#endif /* __SOUND_SEQ_INSTR_H */
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 2b1ae8edc43c..a105b01e06d5 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -22,7 +22,7 @@
22#define SND_SOC_NOPM -1 22#define SND_SOC_NOPM -1
23 23
24/* 24/*
25 * SoC dynamic audio power managment 25 * SoC dynamic audio power management
26 * 26 *
27 * We can have upto 4 power domains 27 * We can have upto 4 power domains
28 * 1. Codec domain - VREF, VMID 28 * 1. Codec domain - VREF, VMID
@@ -131,18 +131,34 @@
131 .shift = wshift, .invert = winvert} 131 .shift = wshift, .invert = winvert}
132 132
133/* dapm kcontrol types */ 133/* dapm kcontrol types */
134#define SOC_DAPM_SINGLE(xname, reg, shift, mask, invert) \ 134#define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \
135{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 135{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
136 .info = snd_soc_info_volsw, \ 136 .info = snd_soc_info_volsw, \
137 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ 137 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
138 .private_value = SOC_SINGLE_VALUE(reg, shift, mask, invert) } 138 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
139#define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, mask, invert, \ 139#define SOC_DAPM_DOUBLE(xname, reg, shift_left, shift_right, max, invert, \
140 power) \ 140 power) \
141{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 141{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
142 .info = snd_soc_info_volsw, \ 142 .info = snd_soc_info_volsw, \
143 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ 143 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
144 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\ 144 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
145 ((mask) << 16) | ((invert) << 24) } 145 ((max) << 16) | ((invert) << 24) }
146#define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
147{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
148 .info = snd_soc_info_volsw, \
149 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
150 .tlv.p = (tlv_array), \
151 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
152 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
153#define SOC_DAPM_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, \
154 power, tlv_array) \
155{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
156 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
157 .tlv.p = (tlv_array), \
158 .info = snd_soc_info_volsw, \
159 .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
160 .private_value = (reg) | ((shift_left) << 8) | ((shift_right) << 12) |\
161 ((max) << 16) | ((invert) << 24) }
146#define SOC_DAPM_ENUM(xname, xenum) \ 162#define SOC_DAPM_ENUM(xname, xenum) \
147{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 163{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
148 .info = snd_soc_info_enum_double, \ 164 .info = snd_soc_info_enum_double, \
@@ -199,6 +215,7 @@ void snd_soc_dapm_free(struct snd_soc_device *socdev);
199/* dapm events */ 215/* dapm events */
200int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream, 216int snd_soc_dapm_stream_event(struct snd_soc_codec *codec, char *stream,
201 int event); 217 int event);
218int snd_soc_dapm_device_event(struct snd_soc_device *socdev, int event);
202 219
203/* dapm sys fs - used by the core */ 220/* dapm sys fs - used by the core */
204int snd_soc_dapm_sys_add(struct device *dev); 221int snd_soc_dapm_sys_add(struct device *dev);
@@ -272,7 +289,7 @@ struct snd_soc_dapm_widget {
272 289
273 /* external events */ 290 /* external events */
274 unsigned short event_flags; /* flags to specify event types */ 291 unsigned short event_flags; /* flags to specify event types */
275 int (*event)(struct snd_soc_dapm_widget*, int); 292 int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int);
276 293
277 /* kcontrols that relate to this widget */ 294 /* kcontrols that relate to this widget */
278 int num_kcontrols; 295 int num_kcontrols;
diff --git a/include/sound/soc.h b/include/sound/soc.h
index f47ef1f75f18..e6ea6f750941 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -16,38 +16,63 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/workqueue.h> 18#include <linux/workqueue.h>
19#include <sound/driver.h>
20#include <sound/core.h> 19#include <sound/core.h>
21#include <sound/pcm.h> 20#include <sound/pcm.h>
22#include <sound/control.h> 21#include <sound/control.h>
23#include <sound/ac97_codec.h> 22#include <sound/ac97_codec.h>
24 23
25#define SND_SOC_VERSION "0.13.1" 24#define SND_SOC_VERSION "0.13.2"
26 25
27/* 26/*
28 * Convenience kcontrol builders 27 * Convenience kcontrol builders
29 */ 28 */
30#define SOC_SINGLE_VALUE(reg,shift,mask,invert) ((reg) | ((shift) << 8) |\ 29#define SOC_SINGLE_VALUE(reg, shift, max, invert) ((reg) | ((shift) << 8) |\
31 ((shift) << 12) | ((mask) << 16) | ((invert) << 24)) 30 ((shift) << 12) | ((max) << 16) | ((invert) << 24))
32#define SOC_SINGLE_VALUE_EXT(reg,mask,invert) ((reg) | ((mask) << 16) |\ 31#define SOC_SINGLE_VALUE_EXT(reg, max, invert) ((reg) | ((max) << 16) |\
33 ((invert) << 31)) 32 ((invert) << 31))
34#define SOC_SINGLE(xname, reg, shift, mask, invert) \ 33#define SOC_SINGLE(xname, reg, shift, max, invert) \
35{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 34{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
36 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\ 35 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
37 .put = snd_soc_put_volsw, \ 36 .put = snd_soc_put_volsw, \
38 .private_value = SOC_SINGLE_VALUE(reg, shift, mask, invert) } 37 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
39#define SOC_DOUBLE(xname, reg, shift_left, shift_right, mask, invert) \ 38#define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
39{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
40 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
41 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
42 .tlv.p = (tlv_array), \
43 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
44 .put = snd_soc_put_volsw, \
45 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
46#define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
40{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\ 47{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
41 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \ 48 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
42 .put = snd_soc_put_volsw, \ 49 .put = snd_soc_put_volsw, \
43 .private_value = (reg) | ((shift_left) << 8) | \ 50 .private_value = (reg) | ((shift_left) << 8) | \
44 ((shift_right) << 12) | ((mask) << 16) | ((invert) << 24) } 51 ((shift_right) << 12) | ((max) << 16) | ((invert) << 24) }
45#define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, mask, invert) \ 52#define SOC_DOUBLE_R(xname, reg_left, reg_right, shift, max, invert) \
46{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ 53{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
47 .info = snd_soc_info_volsw_2r, \ 54 .info = snd_soc_info_volsw_2r, \
48 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \ 55 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
49 .private_value = (reg_left) | ((shift) << 8) | \ 56 .private_value = (reg_left) | ((shift) << 8) | \
50 ((mask) << 12) | ((invert) << 20) | ((reg_right) << 24) } 57 ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
58#define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
59{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
60 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
61 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
62 .tlv.p = (tlv_array), \
63 .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
64 .put = snd_soc_put_volsw, \
65 .private_value = (reg) | ((shift_left) << 8) | \
66 ((shift_right) << 12) | ((max) << 16) | ((invert) << 24) }
67#define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, shift, max, invert, tlv_array) \
68{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
69 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
70 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
71 .tlv.p = (tlv_array), \
72 .info = snd_soc_info_volsw_2r, \
73 .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
74 .private_value = (reg_left) | ((shift) << 8) | \
75 ((max) << 12) | ((invert) << 20) | ((reg_right) << 24) }
51#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \ 76#define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xtexts) \
52{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \ 77{ .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
53 .mask = xmask, .texts = xtexts } 78 .mask = xmask, .texts = xtexts }
@@ -105,9 +130,21 @@
105#define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */ 130#define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */
106 131
107/* 132/*
133 * DAI Sync
134 * Synchronous LR (Left Right) clocks and Frame signals.
135 */
136#define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */
137#define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */
138
139/*
140 * TDM
141 */
142#define SND_SOC_DAIFMT_TDM (1 << 6)
143
144/*
108 * DAI hardware signal inversions 145 * DAI hardware signal inversions
109 */ 146 */
110#define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bit clock + frame */ 147#define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */
111#define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */ 148#define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
112#define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */ 149#define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
113#define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */ 150#define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
@@ -410,6 +447,9 @@ struct snd_soc_dai_link {
410 447
411 /* codec/machine specific init - e.g. add machine controls */ 448 /* codec/machine specific init - e.g. add machine controls */
412 int (*init)(struct snd_soc_codec *codec); 449 int (*init)(struct snd_soc_codec *codec);
450
451 /* DAI pcm */
452 struct snd_pcm *pcm;
413}; 453};
414 454
415/* SoC machine */ 455/* SoC machine */
@@ -426,6 +466,9 @@ struct snd_soc_machine {
426 int (*resume_pre)(struct platform_device *pdev); 466 int (*resume_pre)(struct platform_device *pdev);
427 int (*resume_post)(struct platform_device *pdev); 467 int (*resume_post)(struct platform_device *pdev);
428 468
469 /* callbacks */
470 int (*dapm_event)(struct snd_soc_machine *, int event);
471
429 /* CPU <--> Codec DAI links */ 472 /* CPU <--> Codec DAI links */
430 struct snd_soc_dai_link *dai_link; 473 struct snd_soc_dai_link *dai_link;
431 int num_links; 474 int num_links;
diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h
index e8eeb3a1ed29..b62ce3e077f9 100644
--- a/include/sound/tea575x-tuner.h
+++ b/include/sound/tea575x-tuner.h
@@ -30,6 +30,7 @@ struct snd_tea575x;
30struct snd_tea575x_ops { 30struct snd_tea575x_ops {
31 void (*write)(struct snd_tea575x *tea, unsigned int val); 31 void (*write)(struct snd_tea575x *tea, unsigned int val);
32 unsigned int (*read)(struct snd_tea575x *tea); 32 unsigned int (*read)(struct snd_tea575x *tea);
33 void (*mute)(struct snd_tea575x *tea, unsigned int mute);
33}; 34};
34 35
35struct snd_tea575x { 36struct snd_tea575x {
diff --git a/include/sound/trident.h b/include/sound/trident.h
index 9752243241e5..9f191a0a1e19 100644
--- a/include/sound/trident.h
+++ b/include/sound/trident.h
@@ -26,19 +26,12 @@
26#include "pcm.h" 26#include "pcm.h"
27#include "mpu401.h" 27#include "mpu401.h"
28#include "ac97_codec.h" 28#include "ac97_codec.h"
29#include "seq_midi_emul.h"
30#include "seq_device.h"
31#include "util_mem.h" 29#include "util_mem.h"
32//#include "ainstr_iw.h"
33//#include "ainstr_gf1.h"
34#include "ainstr_simple.h"
35 30
36#define TRIDENT_DEVICE_ID_DX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_DX) 31#define TRIDENT_DEVICE_ID_DX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_DX)
37#define TRIDENT_DEVICE_ID_NX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_NX) 32#define TRIDENT_DEVICE_ID_NX ((PCI_VENDOR_ID_TRIDENT<<16)|PCI_DEVICE_ID_TRIDENT_4DWAVE_NX)
38#define TRIDENT_DEVICE_ID_SI7018 ((PCI_VENDOR_ID_SI<<16)|PCI_DEVICE_ID_SI_7018) 33#define TRIDENT_DEVICE_ID_SI7018 ((PCI_VENDOR_ID_SI<<16)|PCI_DEVICE_ID_SI_7018)
39 34
40#define SNDRV_SEQ_DEV_ID_TRIDENT "trident-synth"
41
42#define SNDRV_TRIDENT_VOICE_TYPE_PCM 0 35#define SNDRV_TRIDENT_VOICE_TYPE_PCM 0
43#define SNDRV_TRIDENT_VOICE_TYPE_SYNTH 1 36#define SNDRV_TRIDENT_VOICE_TYPE_SYNTH 1
44#define SNDRV_TRIDENT_VOICE_TYPE_MIDI 2 37#define SNDRV_TRIDENT_VOICE_TYPE_MIDI 2
@@ -257,16 +250,6 @@ struct snd_trident;
257struct snd_trident_voice; 250struct snd_trident_voice;
258struct snd_trident_pcm_mixer; 251struct snd_trident_pcm_mixer;
259 252
260struct snd_trident_sample_ops {
261 void (*sample_start)(struct snd_trident *gus, struct snd_trident_voice *voice, snd_seq_position_t position);
262 void (*sample_stop)(struct snd_trident *gus, struct snd_trident_voice *voice, int mode);
263 void (*sample_freq)(struct snd_trident *gus, struct snd_trident_voice *voice, snd_seq_frequency_t freq);
264 void (*sample_volume)(struct snd_trident *gus, struct snd_trident_voice *voice, struct snd_seq_ev_volume *volume);
265 void (*sample_loop)(struct snd_trident *card, struct snd_trident_voice *voice, struct snd_seq_ev_loop *loop);
266 void (*sample_pos)(struct snd_trident *card, struct snd_trident_voice *voice, snd_seq_position_t position);
267 void (*sample_private1)(struct snd_trident *card, struct snd_trident_voice *voice, unsigned char *data);
268};
269
270struct snd_trident_port { 253struct snd_trident_port {
271 struct snd_midi_channel_set * chset; 254 struct snd_midi_channel_set * chset;
272 struct snd_trident * trident; 255 struct snd_trident * trident;
@@ -300,7 +283,6 @@ struct snd_trident_voice {
300 unsigned char port; 283 unsigned char port;
301 unsigned char index; 284 unsigned char index;
302 285
303 struct snd_seq_instr instr;
304 struct snd_trident_sample_ops *sample_ops; 286 struct snd_trident_sample_ops *sample_ops;
305 287
306 /* channel parameters */ 288 /* channel parameters */
@@ -354,9 +336,6 @@ struct snd_4dwave {
354 int seq_client; 336 int seq_client;
355 337
356 struct snd_trident_port seq_ports[4]; 338 struct snd_trident_port seq_ports[4];
357 struct snd_simple_ops simple_ops;
358 struct snd_seq_kinstr_list *ilist;
359
360 struct snd_trident_voice voices[64]; 339 struct snd_trident_voice voices[64];
361 340
362 int ChanSynthCount; /* number of allocated synth channels */ 341 int ChanSynthCount; /* number of allocated synth channels */
@@ -416,7 +395,6 @@ struct snd_trident {
416 struct snd_pcm *foldback; /* Foldback PCM */ 395 struct snd_pcm *foldback; /* Foldback PCM */
417 struct snd_pcm *spdif; /* SPDIF PCM */ 396 struct snd_pcm *spdif; /* SPDIF PCM */
418 struct snd_rawmidi *rmidi; 397 struct snd_rawmidi *rmidi;
419 struct snd_seq_device *seq_dev;
420 398
421 struct snd_ac97_bus *ac97_bus; 399 struct snd_ac97_bus *ac97_bus;
422 struct snd_ac97 *ac97; 400 struct snd_ac97 *ac97;
diff --git a/include/sound/version.h b/include/sound/version.h
index a2be8ad8894b..fac66c49445a 100644
--- a/include/sound/version.h
+++ b/include/sound/version.h
@@ -1,3 +1,3 @@
1/* include/version.h. Generated by alsa/ksync script. */ 1/* include/version.h. Generated by alsa/ksync script. */
2#define CONFIG_SND_VERSION "1.0.15" 2#define CONFIG_SND_VERSION "1.0.16rc2"
3#define CONFIG_SND_DATE " (Tue Oct 23 06:09:18 2007 UTC)" 3#define CONFIG_SND_DATE " (Thu Jan 31 16:40:16 2008 UTC)"
diff --git a/include/xen/page.h b/include/xen/page.h
index c0c8fcb27899..031ef22a971e 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -156,16 +156,16 @@ static inline pte_t mfn_pte(unsigned long page_nr, pgprot_t pgprot)
156 156
157static inline unsigned long long pte_val_ma(pte_t x) 157static inline unsigned long long pte_val_ma(pte_t x)
158{ 158{
159 return ((unsigned long long)x.pte_high << 32) | x.pte_low; 159 return x.pte;
160} 160}
161#define pmd_val_ma(v) ((v).pmd) 161#define pmd_val_ma(v) ((v).pmd)
162#define pud_val_ma(v) ((v).pgd.pgd) 162#define pud_val_ma(v) ((v).pgd.pgd)
163#define __pte_ma(x) ((pte_t) { .pte_low = (x), .pte_high = (x)>>32 } ) 163#define __pte_ma(x) ((pte_t) { .pte = (x) })
164#define __pmd_ma(x) ((pmd_t) { (x) } ) 164#define __pmd_ma(x) ((pmd_t) { (x) } )
165#else /* !X86_PAE */ 165#else /* !X86_PAE */
166#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT) 166#define pte_mfn(_pte) ((_pte).pte_low >> PAGE_SHIFT)
167#define mfn_pte(pfn, prot) __pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot)) 167#define mfn_pte(pfn, prot) __pte_ma(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
168#define pte_val_ma(x) ((x).pte_low) 168#define pte_val_ma(x) ((x).pte)
169#define pmd_val_ma(v) ((v).pud.pgd.pgd) 169#define pmd_val_ma(v) ((v).pud.pgd.pgd)
170#define __pte_ma(x) ((pte_t) { (x) } ) 170#define __pte_ma(x) ((pte_t) { (x) } )
171#endif /* CONFIG_X86_PAE */ 171#endif /* CONFIG_X86_PAE */